diff options
author | Guido van Rossum <guido@python.org> | 1997-09-30 22:03:16 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-09-30 22:03:16 (GMT) |
commit | b74eca93496e7abcf5fc10b15aef55739e6074d5 (patch) | |
tree | ad1fe06512c3133351d00d7bac9f69118d351342 | |
parent | b4102bf5f8bb429788e317312c353dd2965cdf4f (diff) | |
download | cpython-b74eca93496e7abcf5fc10b15aef55739e6074d5.zip cpython-b74eca93496e7abcf5fc10b15aef55739e6074d5.tar.gz cpython-b74eca93496e7abcf5fc10b15aef55739e6074d5.tar.bz2 |
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)'').
-rw-r--r-- | Python/ceval.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index d8c9a05..dd7faf9 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -171,33 +171,30 @@ PyEval_ReleaseThread(tstate) PyThreadState * PyEval_SaveThread() { + PyThreadState *tstate = PyThreadState_Swap(NULL); + if (tstate == NULL) + Py_FatalError("PyEval_SaveThread: NULL tstate"); #ifdef WITH_THREAD - if (interpreter_lock) { - PyThreadState *tstate = PyThreadState_Swap(NULL); - if (tstate == NULL) - Py_FatalError("PyEval_SaveThread: NULL tstate"); + if (interpreter_lock) release_lock(interpreter_lock); - return tstate; - } #endif - return NULL; + return tstate; } void PyEval_RestoreThread(tstate) PyThreadState *tstate; { + if (tstate == NULL) + Py_FatalError("PyEval_RestoreThread: NULL tstate"); #ifdef WITH_THREAD if (interpreter_lock) { - int err; - err = errno; - if (tstate == NULL) - Py_FatalError("PyEval_RestoreThread: NULL tstate"); + int err = errno; acquire_lock(interpreter_lock, 1); - PyThreadState_Swap(tstate); errno = err; } #endif + PyThreadState_Swap(tstate); } |