in reply to What the flock!? Concurrency issues in file writing.

I would start with code in the flock documentation and work from there.

I would also try to be sure that nobody else is trying to write to the file. You might be able to ensure that by changing the filename that you write to. That is, instead of writing to "report", change it to "report-locksafe" in the places where you're doing locking. If you see something show up in "report" anyway, there's another writer somewhere.

Also, the "do or die" idiom is good here. Check to see if your flock fails and be sure to output $! if it does.

  • Comment on Re: What the flock!? Concurrency issues in file writing.

Replies are listed 'Best First'.
Re^2: What the flock!? Concurrency issues in file writing.
by suaveant (Parson) on Oct 01, 2008 at 16:09 UTC
    I checked flock, no erroring there... each report generates a unique filename based on various stats and the time, so no worry of other processes adding on. I also did a run where I commented out my file writes to make sure I wasn't doing writes from any non-flocking part of the system.

    Maybe I can make up a test script to recreate the problem...

                    - Ant
                    - Some of my best work - (1 2 3)