This implements POSIX locks (fcntl) in client-server IPC architecture. This is a bit hacky and has some drawbacks (locking will always use IPC if you're not in main process, files are identifed by hacks), but I think it should be good enough.
(The sync engine is simply not ready for this: it would require some more features, but first I think it needs to be simplified, I think I've already blown all available complexity budget for this).
See shim_fs_lock.h for an introduction.
Closes #437.
How to test this PR?
I initially added an example for SQLite, but together with @mkow we decided it's probably not worth keeping. Too much maintenance burden, and there are other tests anyway. So I removed it from this PR.
There is a regression test (fcntl_lock). It tests some cases but LTP turns out to be much more thorough. Still, it might be a good sanity check, and it includes some cases we care about (it makes a difference to us whether the waiting process is the main one).
I added a log_debug() that displays locked ranges after each lock operation.
I was able to reenable many LTP tests. The tests for this feature turn out to be really good! After my test started passing, they still found the following:
Various correctness tests for overlapping ranges triggered bugs (typos) in my code
I learned that it's enough to close a FD (even duplicated) to drop locks, not close the whole file handle
I learned that I need to drop all locks for a process immediately after it exits (i.e. beforewait() returns), and not as an asynchronous action
Description of the changes
This implements POSIX locks (fcntl) in client-server IPC architecture. This is a bit hacky and has some drawbacks (locking will always use IPC if you're not in main process, files are identifed by hacks), but I think it should be good enough.
(The sync engine is simply not ready for this: it would require some more features, but first I think it needs to be simplified, I think I've already blown all available complexity budget for this).
See
shim_fs_lock.h
for an introduction.Closes #437.
How to test this PR?
fcntl_lock
). It tests some cases but LTP turns out to be much more thorough. Still, it might be a good sanity check, and it includes some cases we care about (it makes a difference to us whether the waiting process is the main one).log_debug()
that displays locked ranges after each lock operation.wait()
returns), and not as an asynchronous actionThis change is