mirror of
https://github.com/python/cpython.git
synced 2025-09-10 02:36:56 +00:00
Change PyEval_SaveThread() and PyEval_RestoreThread() to always do the
tstate swapping. Only the acquiring and releasing of the lock is conditional (twice, under ``#ifdef WITH_THREAD'' and inside ``if (interpreter_lock)'').
This commit is contained in:
parent
b4102bf5f8
commit
b74eca9349
1 changed files with 9 additions and 12 deletions
|
@ -171,33 +171,30 @@ PyEval_ReleaseThread(tstate)
|
||||||
PyThreadState *
|
PyThreadState *
|
||||||
PyEval_SaveThread()
|
PyEval_SaveThread()
|
||||||
{
|
{
|
||||||
|
PyThreadState *tstate = PyThreadState_Swap(NULL);
|
||||||
|
if (tstate == NULL)
|
||||||
|
Py_FatalError("PyEval_SaveThread: NULL tstate");
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
if (interpreter_lock) {
|
if (interpreter_lock)
|
||||||
PyThreadState *tstate = PyThreadState_Swap(NULL);
|
|
||||||
if (tstate == NULL)
|
|
||||||
Py_FatalError("PyEval_SaveThread: NULL tstate");
|
|
||||||
release_lock(interpreter_lock);
|
release_lock(interpreter_lock);
|
||||||
return tstate;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
return NULL;
|
return tstate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PyEval_RestoreThread(tstate)
|
PyEval_RestoreThread(tstate)
|
||||||
PyThreadState *tstate;
|
PyThreadState *tstate;
|
||||||
{
|
{
|
||||||
|
if (tstate == NULL)
|
||||||
|
Py_FatalError("PyEval_RestoreThread: NULL tstate");
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
if (interpreter_lock) {
|
if (interpreter_lock) {
|
||||||
int err;
|
int err = errno;
|
||||||
err = errno;
|
|
||||||
if (tstate == NULL)
|
|
||||||
Py_FatalError("PyEval_RestoreThread: NULL tstate");
|
|
||||||
acquire_lock(interpreter_lock, 1);
|
acquire_lock(interpreter_lock, 1);
|
||||||
PyThreadState_Swap(tstate);
|
|
||||||
errno = err;
|
errno = err;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
PyThreadState_Swap(tstate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue