Skip to content

Commit

Permalink
Just acquire a read lock on for preparation.
Browse files Browse the repository at this point in the history
A read lock will prevent modification of the slots, which is probably
all we really need. Any other thread simply does not survive the fork,
and the current thread can't have a wrtie lock, because we never call
callback or return to the applciation with a write lock held.

Signed-off-by: Simo Sorce <simo@redhat.com>
  • Loading branch information
simo5 committed Mar 7, 2024
1 parent 58040b4 commit ef4b55e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/slot.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ void p11prov_slot_fork_prepare(P11PROV_SLOTS_CTX *sctx)
{
int err;

err = pthread_rwlock_wrlock(&sctx->rwlock);
err = pthread_rwlock_rdlock(&sctx->rwlock);
if (err != 0) {
err = errno;
P11PROV_debug("Failed to get slots lock (errno:%d)", err);
Expand Down

0 comments on commit ef4b55e

Please sign in to comment.