[net.unix-wizards] flock-fsync problems

robin@itcatl.UUCP (Robin Cutshaw) (01/23/86)

The problem:

    open-file
    loop
	flock file exclusive
	write special value to location unique to this process only
	fsync
	flock file unlock
	delay
	flock file exclusive
	read value from unique location
	flock file unlock
    endloop


given several processes running the above algorithm and that no process
writes over the unique location allocated to any other process, the
value read is not always the value previously written (when it is wrong
it is the value written on the pass previous to this one).

The question:

    Does the flock-fsync mechanism work for multiple processes accessing
    the same file?  Is their a better/easier/more reliable mechanism to
    do this?


-robin		(uucp: ..!gatech!itcatl!robin)

robin@itcatl.UUCP (01/27/86)

It seems that there was a "slight" problem with the flock test code that we
were using.  After fixing the problem, no errors could be demonstrated even
without the fsync (which I assumed really wasn't necessary anyway).  Thanks
for those who responded.

-robin