Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
bpo-36333, bpo-36356: Fix _PyEval_FiniThreads()
_PyEval_FiniThreads() now free the pending lock.
  • Loading branch information
vstinner committed Mar 19, 2019
commit 3ce82f55454e97ce6d3d426da40b54f9cfaacaf4
13 changes: 11 additions & 2 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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
Expand Down