mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00: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:
parent
974847be44
commit
628f6eb003
18 changed files with 91 additions and 251 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue