good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: flock() ..I really need a hand .. please :)by a (Friar) |
on Mar 20, 2001 at 09:59 UTC ( [id://65633]=note: print w/replies, xml ) | Need Help?? |
Well, this probably won't be helpful, but ... flock is not going to save you if the 'other' apps won't play nice. Likewise, unless all your apps respect the SEMAPHORE flag (e.g.: flocking it won't do much. Of course, this implies that $SEMAPHORE is a well known name (/tmp/myapp.lck), not /tmp/mlock$$.lck - unless other versions can predict the name and check if it exists, (I'm guessing $file is the useful name and the file that gets 'wiped' now and then) your lock/semaphore isn't going to help. It seems your code would allow 2 instances to mess w/ $file if they each had different $tempfile instances. It should be that they have one $SEMAPHORE to work w/, check the existence of, etc. Sorry, I don't recall your other posts, but you might also do your self some good by having the 'rename' preceeded by a debug "about to rename $tempfile to $file (I'm $this instance)" so you can see who is doing the wiping in hopes of pinpointing where your lock/semaphore goes a stray. As I read it, though your flocking isn't really giving you exclusive access for multiple instances of that code, or for anybody else, unless they're using the same $tempfile. a
In Section
Seekers of Perl Wisdom
|
|