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
Unknown Object (File)
Wed, Sep 4, 2:29 AM
Unknown Object (File)
Mon, Sep 2, 2:29 PM
Unknown Object (File)
Fri, Aug 30, 9:35 AM
Unknown Object (File)
Fri, Aug 30, 9:35 AM
Unknown Object (File)
Fri, Aug 30, 9:35 AM
Unknown Object (File)
Fri, Aug 30, 9:35 AM
Unknown Object (File)
Sun, Aug 25, 8:06 PM
Unknown Object (File)
Sun, Aug 25, 10:07 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