]> git.tuebingen.mpg.de Git - dss.git/commitdiff
Use semaphore locking to avoid starting dss multiple times.
authorAndre Noll <maan@systemlinux.org>
Sat, 13 Nov 2010 19:31:10 +0000 (20:31 +0100)
committerAndre Noll <maan@systemlinux.org>
Fri, 1 Jun 2012 15:31:36 +0000 (17:31 +0200)
It's trickier than one might expect but it is hopefully also much
better than any pidfile-based approach.

This patch adds ipc.c and ipc.h containing the public lock_dss()
function which acquires a semaphore-based lock whose key is based
on the hash of the resolved path name of the dss config file. This
allows different instances of dss to coexist.

All semaphore operations are called with both the SEM_UNDO and the
IPC_NOWAIT flag. SEM_UNDO guarantees that no stale lock remains after
dss was killed by SIGKIlL while IPC_NOWAIT makes the call to lock_dss()
fail if another process is already holding the lock.

The prune/create/run commands simply take the lock at startup and
exit if it could not be acquired.

The underlying semaphore set contains two semaphores. This is necessary
to implement the --kill subcommand which is done in a subsequent patch.


No differences found