At 05:54 PM 9/23/00 +0100, Matt Sergeant wrote:
>On Sat, 23 Sep 2000, Gunther Birznieks wrote:
>
> > At 11:46 AM 9/23/00 +0100, Matt Sergeant wrote:
> > >On Sat, 23 Sep 2000, Teijo Aulin wrote:
> > >
> > > > Hi!
> > > >
> > > > I'm running Apache 1.3.12 with mod_perl 1.23 under Win98. I downloaded
> > > > AutoRank from www.cgi-works.net and tried to run it. I got the 
> following
> > > > error message: "flock() unimplemented on this platform at (eval 11)
> > > line 4."
> > > > I see that flock() is not implemented under win 98, so how can i 
> fix this?
> > > > What would be the similar function under win 98? I run many scripts 
> that
> > > > work on my server, so its not a matter of configuration. At least i 
> think
> > > > so. :)
> > >
> > >I tend to just wrap flock in an eval, so that it works on Win9x, that is
> > >when I have to have something that works on that platform (not very
> > >often).
> >
> > Wouldn't that just make sure the preciously locked resource is no longer
> > actually locked? While mod_perl is still 1 thread on apache for windows 
> and
> > so may work on that narrow case, that doesn't seem like the best advice to
> > hand out.
>
>No longer locked? It can't ever be locked under Win9x because it doesn't
>support the notion of file locking. The only thing you can hope to do is
>implement some sort of flock based on writing a temporary file or
>something. I guess there might be something on CPAN to help you do
>this. But don't expect it to be reliable (same can occasionally be said of
>flock() of course...).

The PerlCookbook seemed to indicate that mkdir is an atomic operation (both 
checks if the directory exists and creates it if it does not), so a locking 
mechanism based on mkdir would take care of this issue 
presumably.  Removing the lock is a matter of removing the directory.

However, (maybe this is right ... i dont have it here with me), the 
PerlCookbook was saying this within the context of an NFS locking mechanism 
I think. So, if mkdir is not truly atomic under Perl's implementation for 
Win32 then that would screw that over. Would anyone here know off the top 
of their head?

There is also a module on CPAN called IPCLocker which in theory could work. 
It doesn't actually use any IPC calls ala Unix... It's just a simple Perl 
daemon that accepts connections to set up a lock. I seem to recall that the 
server didn't fork (accepted serialized connections) so it just help a 
shared hash of locks. So that might work too (presuming that the daemon is 
written to work on Win98 which is another story).

Reply via email to