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

Function lfs.mkdir() is not idempotent and hence not thread safe #156

Open
alerque opened this issue Mar 7, 2022 · 0 comments
Open

Function lfs.mkdir() is not idempotent and hence not thread safe #156

alerque opened this issue Mar 7, 2022 · 0 comments

Comments

@alerque
Copy link
Member

alerque commented Mar 7, 2022

Related to #55, but not quite the same ... using lfs.mkdir() is not thread safe. Because it is not idempotent it is quite common to wrap it in a check such as:

if not lfs.attributes(path, "mode") == "directory" then
   lfs.mkdir(path)
end

Unfortunately in a multi-threaded environment is is possible for the directory check to return false but another thread to create the directory in the intervening milliseconds.

A new flag needs to be added so that ERROR_FILE_EXISTS is considered a success because no operation was needed. It's likely the existing syscalls can be leveraged by passing the right flags so the success is properly reported.

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

No branches or pull requests

1 participant