Skip to content

Commit

Permalink
Avoid running the atfork handler during fork fixup
Browse files Browse the repository at this point in the history
fixes OpenSC#16
  • Loading branch information
frankmorgner committed Oct 17, 2018
1 parent 0e2ae10 commit 40d2a2a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/pkcs11h-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,7 @@ __pkcs11h_forkFixup (

if (_g_pkcs11h_data != NULL && _g_pkcs11h_data->initialized) {
_pkcs11h_provider_t current;
const PKCS11H_BOOL safe = _g_pkcs11h_data->safefork;

#if defined(ENABLE_PKCS11H_THREADING)
if (_pkcs11h_threading_mutexLock (&_g_pkcs11h_data->mutexes.global) != CKR_OK) {
Expand All @@ -1318,6 +1319,10 @@ __pkcs11h_forkFixup (
mutex_locked = TRUE;
#endif

/* We are already running, so on fork() every possible new child will
* safely finalize the fixup */
pkcs11h_setForkMode (FALSE);

for (
current = _g_pkcs11h_data->providers;
current != NULL;
Expand Down Expand Up @@ -1350,6 +1355,8 @@ __pkcs11h_forkFixup (
mutex_locked = FALSE;
}
#endif

pkcs11h_setForkMode (safe);
}

_PKCS11H_DEBUG (
Expand Down

0 comments on commit 40d2a2a

Please sign in to comment.