Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

flock error...?

by FireBird34 (Pilgrim)
on Nov 30, 2002 at 19:35 UTC ( [id://216680]=perlquestion: print w/replies, xml ) Need Help??

FireBird34 has asked for the wisdom of the Perl Monks concerning the following question:

flock() unimplemented on this platform at ./Sources/Subs.pl line 862.

I am trying to install the all famous "YaBB forums." A friend is currently creating a web-game, and he wants me as the forum admin. Being like any other good admin, I want to know what I'm doing inside out. I have everything installed with no problems... almost no problems I should say. I am getting that above error.

I am currently on a Win98 OS, running the Abria Merlin server (using Apache software). I know 98 isn't a good server, but we are not using my computer as the host (we will be using redhat 8.0 I believe). Anyway, my question is, why would I be getting that error? I have never used the file lock command before, so was curious if this was a problem on the 98 platform, or am I messed up on my OS?

(if this is a question better suited for some place else, feel free to flame -- it is Perl related, so I would rather try and be told "no" then not try and never know)

Replies are listed 'Best First'.
Re: flock error...?
by dws (Chancellor) on Nov 30, 2002 at 20:18 UTC
    I know 98 isn't a good server ... why would I be getting that error?

    Because flock() depends on operating system services that Win98 doesn't provide. Within the Windows family, you would have to upgrade to WinNT, Win2000, or WinXP to get flock().

    You'll be O.K. once you move to Red Hat.

Re: flock error...?
by diotalevi (Canon) on Nov 30, 2002 at 20:26 UTC

    This just means you need to get a better operating system. You'll do one of a few things: alter YaBB to use native Win32 locking (not that I know how, I'm just suggesting it), move up to a Windows with POSIX capabilities (NT, Windows 2000, XP) or get a better operating operating system. You know the drill, OpenBSD, FreeBSD, NetBSD, Mac OS X, Linux, etc.

    Don't be tempted to just uncomment the locking system. That's critical to preventing data corruption. Keep in mind that as long as you stick with crippled (no POSIX capabilities) operating systems like Windows 95, 98, ME your perl experience will be one frustration after another. I do the majority of my work on a Windows 2000 computer but that's augmented by a local Cygwin install and an OpenBSD server. If I had full choice of operating systems I might be using a FreeBSD desktop with Wine and/or VMWare to go windows-ish at need.

    So go do something sane with your choice of new operating system.

    __SIG__ use B; printf "You are here %08x\n", unpack "L!", unpack "P4", pack "L!", B::svref_2object(sub{})->OUTSIDE;
Re: flock error...?
by PodMaster (Abbot) on Dec 01, 2002 at 11:11 UTC
Re: flock error...?
by clintp (Curate) on Nov 30, 2002 at 23:34 UTC
    "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?

      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.
Re: flock error...?
by BUU (Prior) on Nov 30, 2002 at 21:05 UTC
    Since YaBB is trying to flock() things, it sounds like it's attempting to use flat files as a database system. This is generally bad. Try switching to a database back end and see if it works better.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://216680]
Approved by diotalevi
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (2)
As of 2024-04-19 01:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found