mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.12] gh-100227: Lock Around Adding Global Audit Hooks (gh-105515) (gh-105525)
The risk of a race with this state is relatively low, but we play it safe anyway.
(cherry picked from commit e822a676f1
)
This commit is contained in:
parent
2ad2bd8b14
commit
b08ea9a561
4 changed files with 1334 additions and 1300 deletions
|
@ -380,7 +380,7 @@ _Py_COMP_DIAG_IGNORE_DEPR_DECLS
|
|||
static const _PyRuntimeState initial = _PyRuntimeState_INIT(_PyRuntime);
|
||||
_Py_COMP_DIAG_POP
|
||||
|
||||
#define NUMLOCKS 6
|
||||
#define NUMLOCKS 7
|
||||
#define LOCKS_INIT(runtime) \
|
||||
{ \
|
||||
&(runtime)->interpreters.mutex, \
|
||||
|
@ -389,6 +389,7 @@ _Py_COMP_DIAG_POP
|
|||
&(runtime)->unicode_state.ids.lock, \
|
||||
&(runtime)->imports.extensions.mutex, \
|
||||
&(runtime)->atexit.mutex, \
|
||||
&(runtime)->audit_hooks.mutex, \
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -432,7 +433,7 @@ init_runtime(_PyRuntimeState *runtime,
|
|||
|
||||
runtime->open_code_hook = open_code_hook;
|
||||
runtime->open_code_userdata = open_code_userdata;
|
||||
runtime->audit_hook_head = audit_hook_head;
|
||||
runtime->audit_hooks.head = audit_hook_head;
|
||||
|
||||
PyPreConfig_InitPythonConfig(&runtime->preconfig);
|
||||
|
||||
|
@ -458,7 +459,7 @@ _PyRuntimeState_Init(_PyRuntimeState *runtime)
|
|||
initialization and interpreter initialization. */
|
||||
void *open_code_hook = runtime->open_code_hook;
|
||||
void *open_code_userdata = runtime->open_code_userdata;
|
||||
_Py_AuditHookEntry *audit_hook_head = runtime->audit_hook_head;
|
||||
_Py_AuditHookEntry *audit_hook_head = runtime->audit_hooks.head;
|
||||
// bpo-42882: Preserve next_index value if Py_Initialize()/Py_Finalize()
|
||||
// is called multiple times.
|
||||
Py_ssize_t unicode_next_index = runtime->unicode_state.ids.next_index;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue