mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
gh-100227: Add a Granular Lock for _PyRuntime.imports.extensions.dict (gh-103460)
The lock is unnecessary as long as there's a GIL, but completely necessary with a per-interpreter GIL.
This commit is contained in:
parent
b934f97850
commit
d8627999d8
3 changed files with 16 additions and 4 deletions
|
|
@ -380,7 +380,7 @@ _Py_COMP_DIAG_IGNORE_DEPR_DECLS
|
|||
static const _PyRuntimeState initial = _PyRuntimeState_INIT(_PyRuntime);
|
||||
_Py_COMP_DIAG_POP
|
||||
|
||||
#define NUMLOCKS 4
|
||||
#define NUMLOCKS 5
|
||||
|
||||
static int
|
||||
alloc_for_runtime(PyThread_type_lock locks[NUMLOCKS])
|
||||
|
|
@ -434,6 +434,7 @@ init_runtime(_PyRuntimeState *runtime,
|
|||
&runtime->xidregistry.mutex,
|
||||
&runtime->getargs.mutex,
|
||||
&runtime->unicode_state.ids.lock,
|
||||
&runtime->imports.extensions.mutex,
|
||||
};
|
||||
for (int i = 0; i < NUMLOCKS; i++) {
|
||||
assert(locks[i] != NULL);
|
||||
|
|
@ -518,6 +519,7 @@ _PyRuntimeState_Fini(_PyRuntimeState *runtime)
|
|||
&runtime->xidregistry.mutex,
|
||||
&runtime->getargs.mutex,
|
||||
&runtime->unicode_state.ids.lock,
|
||||
&runtime->imports.extensions.mutex,
|
||||
};
|
||||
for (int i = 0; i < NUMLOCKS; i++) {
|
||||
FREE_LOCK(*lockptrs[i]);
|
||||
|
|
@ -546,6 +548,7 @@ _PyRuntimeState_ReInitThreads(_PyRuntimeState *runtime)
|
|||
&runtime->xidregistry.mutex,
|
||||
&runtime->getargs.mutex,
|
||||
&runtime->unicode_state.ids.lock,
|
||||
&runtime->imports.extensions.mutex,
|
||||
};
|
||||
int reinit_err = 0;
|
||||
for (int i = 0; i < NUMLOCKS; i++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue