-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Use database locking (flock) for zsh #199
base: master
Are you sure you want to change the base?
Conversation
@rupa ping. Could you please review and merge this? I've been using it for two months and so far had no races and DB corruptions. |
@rupa ping |
1 similar comment
@rupa ping |
Yes please! Would love to see this get merged. |
@rupa gentle ping |
This would be very useful.. |
As this PR is coming up on two years, I'm closing it. If there's anything I can do to make it land, I'd be happy to fix. For example, if the use of |
sorry my friend, I haven't have a lot of bandwidth, I don't use zsh, and I am definitely slow on changes with this project for a variety of reasons. This is an issue though, and i'd prefer it stay open. Thanks, and apologies |
This commit ensures the database is locked before reading and updating when used in zsh. We load the zsh/system module which provides the zsystem flock command to perform advisory file locking. A separate code path is needed when updating the database entry because replacing the file (via mv) would cause any process waiting for a lock to fail. Here we simply clobber the database with the contents of the tempfile.
@rupa that's quite alright, I understand 😄. Rebased on master to get rid of the conflicts. |
This PR adds support for locking the database (via advisory file locking) during update when
zsh
is used as shell. This is done viazsystem flock
that is available in thezsh/system
module. The lock is acquired before the database is read and kept until the (new) database has been written and the command has exited.A separate code path is needed when updating the database entry because replacing the file (via mv) would cause any process waiting for a lock to fail. Here we simply clobber the database with the contents of the tempfile.
This is a partial fix for #198, more specifically, this only fixes the problem on
zsh
.// ping @balta2ar