Page MenuHomePhorge

Use POSIX file lock to prevent two kazvs running on the same session
ClosedPublic

Authored by tusooa on Jul 12 2024, 10:30 PM.
Tags
None
Referenced Files
F39744: D120.1728623379.diff
Wed, Oct 9, 10:09 PM
Unknown Object (File)
Sat, Oct 5, 7:36 AM
Unknown Object (File)
Sat, Oct 5, 7:36 AM
Unknown Object (File)
Sat, Oct 5, 7:36 AM
Unknown Object (File)
Sat, Oct 5, 2:06 AM
Unknown Object (File)
Thu, Oct 3, 12:38 PM
Unknown Object (File)
Wed, Oct 2, 6:19 PM
Unknown Object (File)
Tue, Oct 1, 2:21 AM
Subscribers
None

Details

Summary

This commit implements a locking mechanism. It operates on the file located at <sessionDir>/lock. When a session is loaded or first saved, the lock file is opened (created if it does not yet exist), then lockf is used to lock the file. If the lock cannot be grabbed, kazv will refuse to load the session from the store file.

We do not use locking on the store file itself, because in the future for each save the store file's inode might change (i.e. moved from another file). In this case the lock, which is on the old file, cannot guard against operations on the new file with the same name.

Type: add

BUG: https://iron.lily-is.land/T93

Test Plan

Verify unit tests pass. Open kazv with some session. Open another kazv. Try to load that session. Verify it fails.

Diff Detail

Repository
rK kazv
Lint
Lint Not Applicable
Unit
Tests Not Applicable