You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just a curious question: Why did you chose mkdir for locking and not touch, i.e. why do you lock with a directory and not an empty file? Is there any reason behind it or was it just by chance?
The text was updated successfully, but these errors were encountered:
rugk
changed the title
Why did you chose mkdir for locking and not touch?
Why did you choose mkdir for locking and not touch?
Jul 22, 2017
open(2) with O_CREAT|O_EXCL and mkdir(2) are very similar for this purpose. open(2) without O_EXCL does of course not work.
I believe mkdir became the preferred way due to some bugs in networked FSs (directories and files are handled very differently due to different caching strategies, I think apart from that Linux had some bugs as well).
attic had posix locking, but that is problematic even on UNIX platforms (and does not exist on windows filesystems). there were numerous issues on the attic issue tracker due to it. and "issue" basically meant "game over".
I looked around for locking libraries and checked how they do it.
I found a handful, but nothing looked like we could just use it.
So, reinvented the wheel again (rounder version) and just took the mkdir locking as seen in some others for its cross-platform compatibility and simplicity.
Just a curious question: Why did you chose mkdir for locking and not touch, i.e. why do you lock with a directory and not an empty file? Is there any reason behind it or was it just by chance?
The text was updated successfully, but these errors were encountered: