nbd-server: Add locking around transaction log writes
authorManfred Spraul <manfred.spraul@de.bosch.com>
Fri, 21 Jan 2022 17:57:05 +0000 (18:57 +0100)
committerWouter Verhelst <w@uter.be>
Thu, 3 Mar 2022 09:53:01 +0000 (11:53 +0200)
commit49c593db059a66d4a8a848f373f95a6fa4bba37c
tree59c58ed5494125e7895532e6f012032415261bee
parent2fbcb596ed253da6260a53ba95b0fa0c332f787d
nbd-server: Add locking around transaction log writes

Bugfix for the previous patch:
nbd-server uses multiple processes and within each process multiple threads.
Thus: Locking is needed, to ensure that the data in the transaction log
is not corrupted.

Solution: Use sem_open(), the simplest solution.

Alternatives:
- shm_open() + a shared pthread_mutex

- fcntl() for cross process locking, and a ptrace_mutex for intra-process
  locking.

Signed-off-by: Manfred Spraul <manfred.spraul@de.bosch.com>
Signed-off-by: Wouter Verhelst <w@uter.be>
nbd-server.c
nbdsrv.h