anyone else seeing funny behavior wrt flock()?
or...any thoughts about how i might be mis-using it?
Tx
- rich
--
rac...@sockeye.com
Sockeye Networks
275 Grove St.
Newton, MA
617.559.4051
> Has anyone experienced difficulty using flock(2) on linux. In
> particular, I am running RH 7.1.
> The symptom is that using flock() with LOCK_SH (shared lock), threads
> seem to be colliding when writing to the associated (presumably
> flock-ed) file. that is, the lock is not honored and two threads can
> overwrite each other. ouch!
>
> anyone else seeing funny behavior wrt flock()?
>
> or...any thoughts about how i might be mis-using it?
>
> Tx
>
> - rich
>
flock() applies an *advisory* lock. Each thread would need to lock and
unlock the
filehandle at the begining and end of the critical section.
Alternately, a per process
lock could be used if a means, such as semiphores, keeps the threads out
of each
others way.