rwlock: flush and fsync

It is important that we ensure that rwlocked contents are flushed to
disk, because otherwise other rwlock readers might get outdated state.

Kudos @shcheklein for catching this one.
This commit is contained in:
Ruslan Kuprieiev
2020-01-06 22:37:21 +02:00
parent e2efb7b6e4
commit c1906436c2
+3
View File
@@ -50,6 +50,9 @@ def _edit_rwlock(lock_dir):
yield lock
with open(path, "w+") as fobj:
json.dump(lock, fobj)
# NOTE: flush and fsync to ensure that rwlock contents are saved
fobj.flush()
os.fsync(fobj.fileno())
def _infos_to_str(infos):