in reply to Re: Strange IO + concurrency issue
in thread [SOLVED] Strange IO + concurrency issue
1. You are opening a lock to a semaphore file (lock.tmp).I knew that if lock extended to other steps it works, but I could not understand why.
2. Once that lock is obtained you are opening an output file (somefile$_.tmp).
3. You unlock/close your semaphore file.
4. You write to somefile$_.tmp
5. You close somefile$_.tmp.
6. You copy from your tmp file to a new file.
Steps 4, 5, and 6 are unprotected.
Problem was that step (6) unprotected. And this assertion was wrong:if ($f) { print ($f "x") for (1..40_000_000); close $f; }
die if -s $filename != -s $newfilename;Correct assertion would be:
die if 40_000_000 != -s $newfilename;i.e. when data copied, file could be in the middle of creation by another process. so in the end I see:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Strange IO + concurrency issue
by ig (Vicar) on Sep 30, 2013 at 05:50 UTC | |
by vsespb (Chaplain) on Sep 30, 2013 at 08:28 UTC |