Greetings!

I am experimenting on file locking using the flock functionality under modperl and apache 2 on a redhat 9 box. Note however that I am quite newbie in apache/modperl configuration. And please tell me what I did wrong in the process (or any flaws in my simple test methodology). I need exclusive nonblocking locking in all three cases:
(1) nonmp-perl to nonmp-perl
(2) nonmp-perl to modperl or vice-versa
(3) modperl-modperl


statement used to open the file:
open my $LEXFH, $filename;

i wrote two (very similar) scripts:
(a) cgi-style script to be executed under Modperl::Registry.
(b) normal perl script

$filename is constant in the two scripts. Both scripts have sleeps for a few seconds (4) to simulate file io.

flock works on case 1 and 2 using exclusive nonblocking lock => flock(FILEHANDLEHERE, LOCK_EX | LOCK_NB). if flock was unable to acquire the lock to the file, it doesn't block or wait.

case 3:
I'm a bit unsure what model (worker or prefork) my apache uses. Anyway, in case it's worker, I tried to configure apache with the following:
---------
ThreadsPerChild=1
MinSpareThreads=0
MaxSpareThreads=0
---------
and restarted httpd.


Now, I tried to open two browser tabs to test the cgi script [script a]. The second request seems to wait (blocking even with LOCK_NB) until the previous request releases the lock. I tried 3 and 4 additional requests one after the other, but still seems to block. The process id of the scripts are all the same (based on $$) so I guess it's the same perl process, same httpd child handling all the requests.

Now, I want non blocking flock.. How do I do this? Anything wrong to what I did? Any tips on configuring apache for this?

Thanks!


Dexter Tad-y dexterbt1 at my.smart.com.ph







--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html



Reply via email to