This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch

[PATCH] fix avoid process deadlock

Message ID
DKIM signature
Download raw message
Patch: +2 -2
When I start up my linux machine, the himalaya watch commands aren't
able to start up until I've unlocked my password manager. For some
reason, between systemd and KeePassXC, two instances of my watch command
are started at the same time. My watch command is `himalaya
accounts sync`. Two copies of `himalaya accounts sync` start to run at
the same time. This nearly always results in deadlock, as both copies
try to acquire a process lock, but cannot completely sieze the whole

This patch would mitigate the problem. It causes the sync commmand to
fail if the lock cannot be acquired, instead of hanging. This allows for
one of the commands to move forward and avoids deadlock.

 src/backend/backend.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/backend/backend.rs b/src/backend/backend.rs
index b056fa9..e98327b 100644
--- a/src/backend/backend.rs
+++ b/src/backend/backend.rs
@@ -4,7 +4,7 @@
//! custom backend implementations.

use log::info;
use proc_lock::{lock, LockPath};
use proc_lock::{try_lock, LockPath};
use std::{any::Any, borrow::Cow, fmt, io, result};
use thiserror::Error;

@@ -260,7 +260,7 @@ pub fn sync(&self, remote: &dyn Backend) -> Result<BackendSyncReport> {
        let sync_dir = self.account_config.sync_dir()?;
        let lock_path = LockPath::Tmp(format!("himalaya-sync-{}.lock", account));
        let guard =
            lock(&lock_path).map_err(|err| Error::SyncAccountLockError(err, account.to_owned()))?;
            try_lock(&lock_path).map_err(|err| Error::SyncAccountLockError(err, account.to_owned()))?;

        // init SQLite cache

Message ID
<20230222210610.9169-1-me@djha.skin> (view parent)
DKIM signature
Download raw message
Patch applied [3d71e33], thank you!

[3d71e33]: https://git.sr.ht/~soywod/himalaya-lib/commit/3d71e3304eb529604f1059c54f8a2a214ab357dc
Reply to thread Export thread (mbox)