#endif
}
+static void
+clear_pending_handling_thread(struct _pending_calls *pending)
+{
+#ifdef Py_GIL_DISABLED
+ PyMutex_Lock(&pending->mutex);
+ pending->handling_thread = NULL;
+ PyMutex_Unlock(&pending->mutex);
+#else
+ pending->handling_thread = NULL;
+#endif
+}
+
static int
make_pending_calls(PyThreadState *tstate)
{
int32_t npending;
if (_make_pending_calls(pending, &npending) != 0) {
- pending->handling_thread = NULL;
+ clear_pending_handling_thread(pending);
/* There might not be more calls to make, but we play it safe. */
signal_pending_calls(tstate, interp);
return -1;
if (_Py_IsMainThread() && _Py_IsMainInterpreter(interp)) {
if (_make_pending_calls(pending_main, &npending) != 0) {
- pending->handling_thread = NULL;
+ clear_pending_handling_thread(pending);
/* There might not be more calls to make, but we play it safe. */
signal_pending_calls(tstate, interp);
return -1;
}
}
- pending->handling_thread = NULL;
+ clear_pending_handling_thread(pending);
return 0;
}