Fixing the race condition in shlock.c

Julien ÉLIE julien at trigofacile.com
Tue Nov 18 15:14:37 UTC 2008


Hi Berend,

> In one case I did use shlock in combination with minicom IIRC, which
> 'automagically' detects a binary lock if the file is sized 4 bytes.
> Meaning pids 100 to 999 did not work very well...

I have added that in the comment (with "%10ld\n", (long) pid).


> Actually I think this comment was added in response to my initial bug
> report. So yes this should fix that race condition.
> See:
>   http://marc.info/?l=inn-workers&m=103217171006618&w=2
>   http://marc.info/?l=inn-workers&m=103285788122354&w=2

Thanks for the pointer.


> One additional test you might want to do is adding a sleep() call
> before the unlink to verify if the algorithm is really correct. I have
> been using this for the last 6 years and never heard of this problem
> happening again.

The algorithm works fine with sleep(1) and sleep(3).
I have just committed your patch.  Thanks again.  You're also mentioned in
the CONTRIBUTORS file and the shlock man page:
    http://www.eyrie.org/~eagle/software/inn/docs/shlock.html

-- 
Julien ÉLIE

« Celui qui sait qu'il ne sait pas, éduque-le.
  Celui qui sait qu'il sait, écoute-le.
  Celui qui ne sait pas qu'il sait, éveille-le.
  Celui qui ne sait pas qu'il ne sait pas, fuis-le. » (proverbe chinois)




More information about the inn-workers mailing list