Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

(atl: about exceptions) RE: RE: race condition? - flock and $SIG{ALRM}

by atl (Pilgrim)
on Sep 18, 2000 at 14:35 UTC ( [id://32936]=note: print w/replies, xml ) Need Help??


in reply to RE: race condition? - flock and $SIG{ALRM}
in thread race condition? - flock and $SIG{ALRM}

Thus spoke Zarathustra:
One thing I didn't mention in my post, is that most of those die()'s are actually replaced with a call to an exception handler I wrote ...

Just a short note: if you catch the exception instead of letting the process die, youŽll have to close the file yourself to get rid of the lock. Otherwise you might block other processes in the (rather rare) case the race condition occurs.

As for using an exception or not ... if you need this file lock to continue normally, not getting it (including timeout) should be considered an exceptional condition. But thatŽs a matter of programming style, certainly no "rigth" or "wrong" way ...

Beers! Yup! :-))

Andreas

  • Comment on (atl: about exceptions) RE: RE: race condition? - flock and $SIG{ALRM}

Replies are listed 'Best First'.
RE: (atl: about exceptions) RE: RE: race condition? - flock and $SIG{ALRM}
by Zarathustra (Beadle) on Sep 19, 2000 at 21:33 UTC

    if you catch the exception instead of letting the process die, youŽll have to close the file yourself to get rid of the lock. Otherwise you might block other processes in the (rather rare) case the race condition occurs.

    Hey, thanks - you're absolutely right. That's one bit I had completely over looked...

    Good eye!

      Just have the filehandle be localized or in a lexical scope. Then it will close on its own when it notices that you exited the scope it was opened in. :-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-25 13:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found