[Python-checkins] bpo-36333, bpo-36356: Fix _PyEval_FiniThreads() (GH-12432)

Victor Stinner webhook-mailer at python.org
Tue Mar 19 09:19:44 EDT 2019


https://github.com/python/cpython/commit/a712679a2bffffefaacdc05f788d6ea50f72a561
commit: a712679a2bffffefaacdc05f788d6ea50f72a561
branch: master
author: Victor Stinner <vstinner at redhat.com>
committer: GitHub <noreply at github.com>
date: 2019-03-19T14:19:38+01:00
summary:

bpo-36333, bpo-36356: Fix _PyEval_FiniThreads() (GH-12432)

_PyEval_FiniThreads() now free the pending lock.

files:
M Python/ceval.c

diff --git a/Python/ceval.c b/Python/ceval.c
index d6a0b335955e..40320bf35703 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -169,8 +169,10 @@ PyEval_ThreadsInitialized(void)
 void
 PyEval_InitThreads(void)
 {
-    if (gil_created())
+    if (gil_created()) {
         return;
+    }
+
     PyThread_init_thread();
     create_gil();
     take_gil(_PyThreadState_GET());
@@ -184,10 +186,17 @@ PyEval_InitThreads(void)
 void
 _PyEval_FiniThreads(void)
 {
-    if (!gil_created())
+    if (!gil_created()) {
         return;
+    }
+
     destroy_gil();
     assert(!gil_created());
+
+    if (_PyRuntime.ceval.pending.lock != NULL) {
+        PyThread_free_lock(_PyRuntime.ceval.pending.lock);
+        _PyRuntime.ceval.pending.lock = NULL;
+    }
 }
 
 void



More information about the Python-checkins mailing list