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

Storing lock in /tmp folder might be a bad idea. #1

Closed
knopp opened this issue Feb 21, 2022 · 9 comments · Fixed by #4
Closed

Storing lock in /tmp folder might be a bad idea. #1

knopp opened this issue Feb 21, 2022 · 9 comments · Fixed by #4

Comments

@knopp
Copy link

knopp commented Feb 21, 2022

/tmp gets cleaned on macOS periodically which breaks long running applications holding locks. I assume other unix platforms might have similar problem.

@knopp
Copy link
Author

knopp commented Feb 21, 2022

Better location to store this would be XDG_RUNTIME_DIR on Linux and _CS_DARWIN_USER_CACHE_DIR (obtained through confstr on macOS.

@oblique
Copy link
Owner

oblique commented Feb 22, 2022

Other UNIX platforms do not have this issue, but I'm thinking to make this configurable.

XDG_RUNTIME_DIR/_CS_DARWIN_USER_CACHE_DIR are also bad choices because are not system-wide directories.

@knopp
Copy link
Author

knopp commented Feb 22, 2022

Not sure what you mean. Do other UNIX platforms not have cron jobs that clean temp folder? If you need the lock to be accessible by multiple users then indeed, XDG_RUNTIME_DIR/_CS_DARWIN_USER_CACHE_DIR are not good choices. I'd say that different people have different usecases so making this configurable would probably be best.

@oblique
Copy link
Owner

oblique commented Feb 22, 2022

Do other UNIX platforms not have cron jobs that clean temp folder?

No they don't. I'm actually surprised that MacOS has.

@knopp
Copy link
Author

knopp commented Feb 22, 2022

It does, but only for the /tmp folder. $TMPDIR (/var/folders...) is cleaned differently (though Apple doesn't document this anywhere).

@lpil
Copy link

lpil commented Apr 16, 2022

I stumbled across a way to create a lock outside of /tmp which may be useful to you here.

Some info: #2

@oblique
Copy link
Owner

oblique commented Apr 20, 2022

I decided to keep NamedLock::create as it was before, and introduce NamedLock::with_path. With the new function you will be able to give the exact path of the lock file.

@oblique
Copy link
Owner

oblique commented Apr 21, 2022

After some reading about TMPDIR, I decided to use it if it is set, otherwise /tmp will be used.

@oblique
Copy link
Owner

oblique commented Apr 21, 2022

Version 0.2.0 is published

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

Successfully merging a pull request may close this issue.

3 participants