Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why did you choose mkdir for locking and not touch? #2857

Closed
rugk opened this issue Jul 22, 2017 · 3 comments
Closed

Why did you choose mkdir for locking and not touch? #2857

rugk opened this issue Jul 22, 2017 · 3 comments
Labels

Comments

@rugk
Copy link
Contributor

rugk commented Jul 22, 2017

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?

@rugk 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
@enkore
Copy link
Contributor

enkore commented 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).

Note: there is a mailing list as well.

@enkore enkore closed this as completed Jul 22, 2017
@ThomasWaldmann
Copy link
Member

ThomasWaldmann commented Jul 22, 2017

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.

@rugk
Copy link
Contributor Author

rugk commented Jul 22, 2017

Thanks for you reply. I don't like mailing lists, but GitHub issues tagged with "question" are also okay, IMHO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants