[jcifs] Curious "race" condition

André Warnier aw at ice-sa.com
Thu Oct 21 03:45:06 MDT 2010


Hi.
I don't know if this is the right list for this, but I figure that there are enough Samba 
experts here to maybe give me some pointers (or tell me I'm wrong and need to look 
somewhere else).

Here is the issue :

Program A runs on a Windows system.  It creates new files on a network drive, which is 
actually situated on a Solaris machine and shared via Samba.
The creation sequence is as follows :
- open the new file for output, with a name "//servername/sharename/xxxx.dat.tmp" (where 
"xxxxx" is guaranteed to be unique each time)
- write data to the file
- close the file
- only if no errors occurred, rename the output file from "xxxxx.dat.tmp" to "xxxxx.dat"

At the same time, program B runs on the Solaris machine.
It regularly scans the same (for him, local) directory, for files ending in ".dat".
When it finds one, it opens it and reads it.

This happens thousands of times per month without problems.

But once in a great while (2-3 times per year, no more), program B reports an error and 
crashes.  The reported error leads me to believe that it finds a "xxxxx.dat" file that is 
either empty or only partially written.
If we restart program B, it processes that same file properly.

Considering the sequence of operations above, my understanding is that program B should 
never be able to find a "xxxxxx.dat" file that is empty of partially written.

But my question is : considering that this happens on a network share shared via Samba, is 
it possible due to some race condition or configuration issue, that the above may 
nevertheless "sometimes" occur ?



More information about the jCIFS mailing list