You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Andrew Alakozow <aa...@mail.ru> on 2003/07/07 13:29:01 UTC

Apache::Session::Lock::File hangs under Windows

Hello,

This may be OT, but may be not though Apache::Session is widely used under
mod_perl.

Apache::Session::Lock::File hangs under Windows if you try to remove
session or add data to existing session. This happenes because you cannot
"flock($self->{fh},
LOCK_EX)" if you already has "flock($self->{fh}, LOCK_SH)" in Windows.

I wrote to Jeffrey Baker a while ago but has no answer.

Possible patch is:

*** File.old Fri Sep 01 21:21:18 2000
--- File.pm Tue Apr 01 16:40:52 2003
***************
*** 65,70 ****
--- 65,72 ----
          $self->{opened} = 1;
      }

+     if ($^O eq 'MSWin32' && $self->{read}){flock($self->{fh}, LOCK_UN)}
+
      flock($self->{fh}, LOCK_EX);
      $self->{write} = 1;
  }

aa29


Re: Apache::Session::Lock::File hangs under Windows

Posted by Enrico Sorcinelli <e....@pisa.iol.it>.
On Tue, 8 Jul 2003 10:26:54 +0400
"Andrew Alakozow" <aa...@mail.ru> wrote:

Hi Andrew

> 
> BTW, 'clean' method of this model hangs as well.
> 

Also Apache::Session::Lock::File (1.54) 'clean' method has a little bug in 
checking lockfiles last access time.

See my post at:

	http://mathforum.org/epigone/modperl/plinfrargoo

Since I've mailed this to the author with no response, I'll include the 
patch into my next release of Apache::SessionManager (A::S wrapper).

by

	- Enrico

Re: Apache::Session::Lock::File hangs under Windows

Posted by Andrew Alakozow <aa...@mail.ru>.
 PH> On Mon, 2003-07-07 at 07:29, Andrew Alakozow wrote:
>> Apache::Session::Lock::File hangs under Windows if you try to remove
>> session or add data to existing session. This happenes because you
>> cannot "flock($self->{fh}, LOCK_EX)" if you already has
>> "flock($self->{fh}, LOCK_SH)" in Windows.

PH> Under mod_perl 1, there is no need to use locking on Win32 since
PH> mod_perl runs single-threaded there.
I write code that should work on both Unix and Win. More compatible libs I
use, less branching I need in my code. Now it's mod_perl 1, but I'll have to
move it to mod_perl 2 someday.

PH> This patch might be useful for mod_perl 2 on Win32, but LOCK_UN is
PH> tricky.  Have you seen this?
http://perl.plover.com/yak/flock/samples/slide004.html
Apache::Session::Lock::File doesn't put any data in lock files.

IMHO, this lib should be patched or contain alarm about Windows, but it
shouldn't just hang. It was first time I've run perl -d on purpose. %)

BTW, 'clean' method of this model hangs as well.

aa29


Re: Apache::Session::Lock::File hangs under Windows

Posted by Perrin Harkins <pe...@elem.com>.
On Mon, 2003-07-07 at 07:29, Andrew Alakozow wrote:
> Apache::Session::Lock::File hangs under Windows if you try to remove
> session or add data to existing session. This happenes because you cannot
> "flock($self->{fh},
> LOCK_EX)" if you already has "flock($self->{fh}, LOCK_SH)" in Windows.

Under mod_perl 1, there is no need to use locking on Win32 since
mod_perl runs single-threaded there.  This patch might be useful for
mod_perl 2 on Win32, but LOCK_UN is tricky.  Have you seen this?
http://perl.plover.com/yak/flock/samples/slide004.html

- Perrin