summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles-François Natali <neologix@free.fr>2011-11-22 18:51:14 (GMT)
committerCharles-François Natali <neologix@free.fr>2011-11-22 18:51:14 (GMT)
commit23b0b9252e91f2a1262cf83c51d4f4621d655095 (patch)
treebfffcba5a4207342d72899eea53fc07f8f9fca70
parent221ef67fd669622f0d2b8c6a4e9c16ea4a0e1488 (diff)
parenta233df885b15ada37bb04e06aa465e8d4554b228 (diff)
downloadcpython-23b0b9252e91f2a1262cf83c51d4f4621d655095.zip
cpython-23b0b9252e91f2a1262cf83c51d4f4621d655095.tar.gz
cpython-23b0b9252e91f2a1262cf83c51d4f4621d655095.tar.bz2
Issue #13156: _PyGILState_Reinit(): Re-associate the auto thread state with the
TLS key only if the thread that called fork() had an associated auto thread state (this might not be the case for example for a thread created outside of Python calling into a subinterpreter).
-rw-r--r--Python/pystate.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/Python/pystate.c b/Python/pystate.c
index 40699af..3b4c6a2 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -592,9 +592,9 @@ _PyGILState_Fini(void)
autoInterpreterState = NULL;
}
-/* Reset the TLS key - called by PyOS_AfterFork.
+/* Reset the TLS key - called by PyOS_AfterFork().
* This should not be necessary, but some - buggy - pthread implementations
- * don't flush TLS on fork, see issue #10517.
+ * don't reset TLS upon fork(), see issue #10517.
*/
void
_PyGILState_Reinit(void)
@@ -604,8 +604,9 @@ _PyGILState_Reinit(void)
if ((autoTLSkey = PyThread_create_key()) == -1)
Py_FatalError("Could not allocate TLS entry");
- /* re-associate the current thread state with the new key */
- if (PyThread_set_key_value(autoTLSkey, (void *)tstate) < 0)
+ /* If the thread had an associated auto thread state, reassociate it with
+ * the new key. */
+ if (tstate && PyThread_set_key_value(autoTLSkey, (void *)tstate) < 0)
Py_FatalError("Couldn't create autoTLSkey mapping");
}