mirror of
https://github.com/python/cpython.git
synced 2026-05-08 05:32:01 -04:00
gh-111924: Use PyMutex for runtime global locks.
This replaces some usages of PyThread_type_lock with PyMutex, which does not require memory allocation to initialize.
This commit is contained in:
+3
-9
@@ -451,15 +451,9 @@ PySys_AddAuditHook(Py_AuditHookFunction hook, void *userData)
|
||||
e->hookCFunction = (Py_AuditHookFunction)hook;
|
||||
e->userData = userData;
|
||||
|
||||
if (runtime->audit_hooks.mutex == NULL) {
|
||||
/* The runtime must not be initialized yet. */
|
||||
add_audit_hook_entry_unlocked(runtime, e);
|
||||
}
|
||||
else {
|
||||
PyThread_acquire_lock(runtime->audit_hooks.mutex, WAIT_LOCK);
|
||||
add_audit_hook_entry_unlocked(runtime, e);
|
||||
PyThread_release_lock(runtime->audit_hooks.mutex);
|
||||
}
|
||||
PyMutex_Lock(&runtime->audit_hooks.mutex);
|
||||
add_audit_hook_entry_unlocked(runtime, e);
|
||||
PyMutex_Unlock(&runtime->audit_hooks.mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user