You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Teijo Aulin <ta...@pp.htv.fi> on 2000/09/23 12:32:54 UTC

flock under win32

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. :)

Thanks in advance.

Teijo Aulin
taulin@pp.htv.fi


Re: OT: flock under win32

Posted by Gunther Birznieks <gu...@extropia.com>.
At 12:46 AM 9/24/2000 -0400, Jim Winstead wrote:
>On Sep 24, Gunther Birznieks wrote:
> > 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?
>
>be careful, mkdir isn't really atomic under nfs.

OK. In going back to look up Perl Cookbook, it does say it's dependent on 
the client and server implementation of NFS... Although it doesn't name any 
system as having an atomic client or server implementation of mkdir. I 
imagine both are needed.

Of course, then the question is... is mkdir() atomic on Win32 Perl..

Thanks,
     Gunther

PS I've added OT to this thread.


Re: [OT] flock under win32

Posted by "Alexander Farber (EED)" <ee...@eed.ericsson.se>.
http://www.activestate.com/Products/ActivePerl/docs/lib/Pod/perlport.html#item_flock

    flock FILEHANDLE,OPERATION
         Not implemented (Mac OS, VMS, RISC OS, VOS). 
         Available only on Windows NT (not on Windows 95). (Win32)

and there is also this note in the same document:

    Don't open the same file more than once at a time for writing, 
    as some operating systems put mandatory locks on such files.

Re: [OT] flock under win32

Posted by Rodney Broom <rb...@home.com>.
Hi all,

Here's my two cents worth (or less):

Teijo Aulin> I got the following error message: "flock() unimplemented on this
platform...
Teijo Aulin> I see that flock() is not implemented under win 98, so how can I
fix this?


Matt Sergeant> It can't ever be locked under Win9x because it doesn't support
the notion of file locking.

Hmm, that can't be altogether true. Haven't we all seen messages from WinDOS
about "cannot access... resource in use"? Although I'd bet that one would have
to use something from the Windoz API to get this functionality. I don't know of
how to do it myself, but maybe something from Dave Roth (www.roth.net).

Matt Sergeant> The only thing you can hope to do is implement some sort of flock
based on writing a temporary file or something.

That's what I'd do. If you were so inclined, you go crazy and write a common
file that kept interesting locking information. Then have your flock() check
that file. The file could even include fancy (unnecessary) stuff like what
process had the resource locked, the lock time, etc. You could go even more nuts
and implement something that watched for shutdown failures to intelligently
removing the locking data file after reboots.

----
Rodney Broom



Re: flock under win32

Posted by Matthew Byng-Maddick <mb...@colondot.net>.
On Sun, 24 Sep 2000, Jim Winstead wrote:
> On Sep 24, Gunther Birznieks wrote:
> > 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.
> be careful, mkdir isn't really atomic under nfs.

But NFS is Not a File System, so this doesn't matter :)

The other possible atomic operation that things use for locking
(emacs/netsacpe etc) is symlink() but you don't get that on win32, so not
a great suggestion here, but you don't get NFS on win32 either.

MBM (wittering before disappearing off to YAPC)

-- 
I'm not even going to *bother* comparing C to BASIC or FORTRAN.
                                            -- L. Zolman, creator of BDS C


Re: flock under win32

Posted by Jim Winstead <ji...@trainedmonkey.com>.
On Sep 24, Gunther Birznieks wrote:
> 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?

be careful, mkdir isn't really atomic under nfs.

jim

Re: flock under win32

Posted by Gunther Birznieks <gu...@extropia.com>.
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).


Re: flock under win32

Posted by Matt Sergeant <ma...@sergeant.org>.
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...).

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org | AxKit: http://axkit.org


Re: flock under win32

Posted by Gunther Birznieks <gu...@extropia.com>.
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.

Or am I missing something out of the message?



Re: flock under win32

Posted by Matt Sergeant <ma...@sergeant.org>.
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).

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org | AxKit: http://axkit.org