Hi Ander,

thanks for the quick correction.

I pushed both patches after testing flock() / close() behavior.
The docs indeed are not 100% clear.

Regards

        Tim

On Thursday 08 October 2015 20:22:46 Ander Juaristi wrote:
> Hi Tim,
> 
> Thanks for your comments. I re-send the first patch. No changes on the
> second.
> On 10/08/2015 10:37 AM, Tim Ruehsen wrote:
> > +          flock (fd, LOCK_UN);
> > +          fclose (f);
> > You are using buffered I/O, fclose() is effectively a write() + close().
> > That opens a hole here if you unlock the file before write().
> > IMO, to avoid that hole you could just drop the explicit unlock. It will
> > be
> > performed automatically when the file is closed by fclose().
> 
> You were right, the lock is released by fclose(). Obvious, isn't it? I mean,
> that's what one would expect.
> 
> I thought about this but I wasn't really sure. The docs are not 100% clear
> IMO:
> 
>      "Furthermore, the lock is released either by an explicit LOCK_UN
> operation on any of these  duplicate  descriptors, or when all such
> descriptors have been closed."
> 
> Regards,
> - AJ

Reply via email to