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.

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
Branch
tusooa/stacked
Lint
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 169
Build 327: GitLab CI for kazv
Build 326: arc lint + arc unit