Skip to content

Commit 45f4cc0

Browse files
Re-init other runtime locks.
1 parent b9ada30 commit 45f4cc0

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

Python/pystate.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,20 @@ _PyRuntimeState_ReInitThreads(void)
105105
// This was initially set in _PyRuntimeState_Init().
106106
_PyRuntime.main_thread = PyThread_get_thread_ident();
107107

108-
/* XXX What about the following?
109-
* _PyRuntime.interpreters.mutex
110-
* _PyRuntime.interpreters.main.id_mutex
111-
* _PyRuntime.xidregistry.mutex
112-
*/
108+
_PyRuntime.interpreters.mutex = PyThread_allocate_lock();
109+
if (_PyRuntime.interpreters.mutex == NULL) {
110+
Py_FatalError("Can't initialize lock for runtime interpreters");
111+
}
112+
113+
_PyRuntime.interpreters.main->id_mutex = PyThread_allocate_lock();
114+
if (_PyRuntime.interpreters.main->id_mutex == NULL) {
115+
Py_FatalError("Can't initialize ID lock for main interpreter");
116+
}
117+
118+
_PyRuntime.xidregistry.mutex = PyThread_allocate_lock();
119+
if (_PyRuntime.xidregistry.mutex == NULL) {
120+
Py_FatalError("Can't initialize lock for cross-interpreter data registry");
121+
}
113122
}
114123

115124
#define HEAD_LOCK() PyThread_acquire_lock(_PyRuntime.interpreters.mutex, \

0 commit comments

Comments
 (0)