Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Mysterious Disapperance of file contents

by dws (Chancellor)
on Aug 29, 2003 at 02:51 UTC ( #287578=note: print w/replies, xml ) Need Help??


in reply to Mysterious Disapperance of file contents

My problem is that sometimes the counter mysteriously loses count and starts from the beginning again, as if the contents were erased somehow.

Consider the following sequence of events:

open(SEM, ">$semaphore_file") -- succeeds flock(SEM, LOCK_EX) -- succeeds open(MFILE, ">>$completeadd") -- fails die(...)
During the source of the die(), files are closed, and locks are released. Because you opened the semaphore file for writing, but haven't yet written to it, it's just been erased.

This may or may not be what's happening, but it's one possible explanation.

Are you seeing any errors in your error logs?

Update: Ignore everything above "Are you seeing any errors in your error logs?".

Replies are listed 'Best First'.
Re2: Mysterious Disapperance of file contents
by bbfu (Curate) on Aug 29, 2003 at 05:02 UTC

    Because you opened the semaphore file for writing, but haven't yet written to it, it's just been erased.

    Except that he's never (in the shown code, anyway) writing to the semaphore file. He's using a separate, presumably always-empty, file as the semaphore and is always opening the counter file in read or append... except possibly in writedata.

    bbfu
    Black flowers blossom
    Fearless on my breath

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2020-06-02 12:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (17 votes). Check out past polls.

    Notices?