in reply to race condition? - flock and $SIG{ALRM}
Thanks to the recent input I've recieved - much appreciated.
I hope replying directly to my own node isn't considered too horribly faux pas - I'd like to clarify some things...
The transaction gig will not be a possible solution to this particular project however, so I'm stuck with doing the best I can protecting a single file that will be appended to very often by multiple processes - these processes will all be separate instances of the same program. This program, called rtmail, is a mail filter that gets piped to from sendmail.
What rtmail does is route mail to final destinations, depending upon the sender's domain. Thats easy - it's the bit where rtmail also makes a backup of all mail sent to it on the local machine using different spool files, named accordingly to each of the final remote destinations, that is the tricky part... This is mission critical stuff, and so I want to be as certain as possible that it's all being reliably and accurately backed off into these local mail spools.
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 that makes certain absolutely no mail, under any circumstance is ever to simply disappear into the void.
So, what I've learned so far from your replies is that:
Perl signal traps are unreliable I really need the timeout though, so if something goes terribly wrong, I don't have a seething mass of rtmails filling the process table on the mail server, all waiting indefinately for a lock...
The race condition between the successful flock and the alarm unset is possible, but not to be worried about If that's the case, then I could simply bail on the inner eval and not ever bother with the extra checks on $@ . And when/if the race condition ever does occur, so what - it'll just get caught by my exception handler as if the flock timed out, so no actual damage or lost data will take place anyhow. But I would prefer, if possible, to not raise the exception routine if it's not truly an exception situation - perhaps I'm just being too retentive...
Thanks for everyones insight, I really appreciate the help. Beers!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(atl: about exceptions) RE: RE: race condition? - flock and $SIG{ALRM}
by atl (Pilgrim) on Sep 18, 2000 at 14:35 UTC | |
by Zarathustra (Beadle) on Sep 19, 2000 at 21:33 UTC | |
by tilly (Archbishop) on Sep 19, 2000 at 22:05 UTC | |
|
off topic ( RE: RE: race condition? - flock and $SIG{ALRM} )
by Zarathustra (Beadle) on Sep 17, 2000 at 23:27 UTC |