问题
I have a .NET system where I need to allow files to be locked and unlocked across process boundaries. The model I plan to use is this:
- User generate a lock token
- Uses Locks a file with token and refreshes token
- repeat at #2 as needed
- Uses unlocks all files by releasing token
- If uses fails to refresh token in some time-frame, #4 happens automatically
Each step can be done from a different process.
The question is two fold: is this a reasonable model and are there any readily available tools for implementing it? If this can't be directly done in the OS, I'm thinking of some sort of advisory locking with .file
s or the like.
Edit: this mode gets non-exclusive read locks, but other modes could get exclusive write locks but they would always be released by the same process that got them.
来源:https://stackoverflow.com/questions/804356/extra-process-file-locks