in reply to flock error...?

"Get a REAL OS," so goes the chant of the rabble.

Problem is this. If you've got multiple processes with a file open for writing and reading at the same time, trouble results. So you need locking. The flock() call is one method of locking a resource in Perl.

In Win98/95, only one user is expected to be using the system at a time. Thus, file locking (at least on this level) shouldn't really be a concern, right?. The OS won't allow more than one process in Win98/95 to have a file open for writing at the same time. That solves the locking problem and makes flock() unnecessary for the OS... The problem is that Perl wants to use this locking mechanism, but it simply doesn't exist in Win98/95.

So what do you do? Well, if this were a long-term thing I'd agree with the rabble. If you're just working out the bugs, noodling around with the system before it goes into production, try this:

# Change this flock(FH, LOCK_EX) || die "Error in flock: $!"; # Into this (untested, no Win98 machine handy) eval { flock(FH, LOCK_EX) || die "Error in flock: $!"; }; die unless ($@ =~ /unimplemented/);
This will essentially ignore the flock()'s on Win95/98, but they really shouldn't be a concern of yours anyway if you're just testing, right?

Replies are listed 'Best First'.
Re^2: flock error...?
by diotalevi (Canon) on Nov 30, 2002 at 23:49 UTC

    I get the distinct impression from the question that the intention is to leave the web server on the Windows 98 machine hence my recommendation to either start using Win32 locking or get a better operating system. A basic assumption of server-side programming is that locking is of paramount importance so this isn't a problem firebird34 can dodge.

    __SIG__ use B; printf "You are here %08x\n", unpack "L!", unpack "P4", pack "L!", B::svref_2object(sub{})->OUTSIDE;
      The server will be hosted on a Redhat flavour, but I am running on the Win98 atm, just working out any bugs that I might find and/or put in some new features. I'll try that snippit change tomorrow aswell, thanks.

      I do have access to Mandrake 8.2 on my other OS, but bad e-card atm, so it's hard to transfer over.

      Thanks for the help all! Didn't know that Win32 had trouble with flocking, having never used it before.