Comments (2)
Is the following a correct explanation of the semantics?
- Create a file at path dir+"."+name called tmplock. Fail if unable to create. (potential race condition here, I suggest it be dir+"."+name+random_stuff_or_pid_or_something)
- Write the current pid to tmplock, fail if unable to write.
- Hard link tmplock to dir+name. Ignore failure to link.
- Stat tmplock by name (should still be dir+"."+name). It should still exist, error if not.
- Stat the real lock dir+name. Should exist. Error if doesn't.
- Make sure that both the tmplock and the new lock are the same file.
- Get the owner of the lock.
etc
from lockfile.
@matjam Thanks for taking the time to analyse the code deeply.
Is the following a correct explanation of the semantics?
- Create a file at path dir+"."+name called tmplock. Fail if unable to create. (potential race condition here, I suggest it be dir+"."+name+random_stuff_or_pid_or_something)
ioutil.TempFile takes care of the "random_stuff_or_pid_or_something" for me. So consider it done 🙂
- Write the current pid to tmplock, fail if unable to write.
Yes.
- Hard link tmplock to dir+name. Ignore failure to link.
Your observation of the existing code is correct.
Intention here was to only ignore the failure to create a link due to the destination already existing.
Ignoring every error here was the bug that made analysis of golang/dep#913 harder than necessary. This imprecise error handling is fixed by #21 .
- Stat tmplock by name (should still be dir+"."+name). It should still exist, error if not.
- Stat the real lock dir+name. Should exist. Error if doesn't.
- Make sure that both the tmplock and the new lock are the same file.
- Get the owner of the lock.
etc
correct.
from lockfile.
Related Issues (13)
- Failer on windows when pid is from dead process HOT 10
- return better error on Unlock/Trylock race HOT 2
- Automatic retries HOT 1
- License file is MIT but readme says the project is BSD HOT 1
- Locking fails in vboxfs because hard links are not possible. HOT 4
- non-recursive lock
- lock failed when program restart after crash HOT 6
- Stop file from being deleted (win, mac, linux) HOT 1
- Use symlinks instead of hardlinks on unix platforms HOT 7
- circular imports not allowed HOT 4
- Dependency Dashboard
- bug: deadlock caused by pid reusing HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lockfile.