diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-12-16 11:29:37 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-12-16 11:29:37 (GMT) |
commit | ab0e9f7089c04df546af6cacbc8751247cf4020a (patch) | |
tree | 3494351a976a17a62146a3ddd365fe2b5936fca4 /Modules/_multiprocessing/semaphore.c | |
parent | e2b2bf55b30299e310b246b5b4b6f5a5f66e75b2 (diff) | |
parent | c345ce1a69b3c4a46d87ef56d859bc70abfc74b4 (diff) | |
download | cpython-ab0e9f7089c04df546af6cacbc8751247cf4020a.zip cpython-ab0e9f7089c04df546af6cacbc8751247cf4020a.tar.gz cpython-ab0e9f7089c04df546af6cacbc8751247cf4020a.tar.bz2 |
Issue #10350: Read and save errno before calling a function which might overwrite it.
Original patch by Hallvard B Furuseth.
Diffstat (limited to 'Modules/_multiprocessing/semaphore.c')
-rw-r--r-- | Modules/_multiprocessing/semaphore.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/_multiprocessing/semaphore.c b/Modules/_multiprocessing/semaphore.c index e48936e..0c9b04c 100644 --- a/Modules/_multiprocessing/semaphore.c +++ b/Modules/_multiprocessing/semaphore.c @@ -255,7 +255,7 @@ sem_timedwait_save(sem_t *sem, struct timespec *deadline, PyThreadState *_save) static PyObject * semlock_acquire(SemLockObject *self, PyObject *args, PyObject *kwds) { - int blocking = 1, res; + int blocking = 1, res, err = 0; double timeout; PyObject *timeout_obj = Py_None; struct timespec deadline = {0}; @@ -301,11 +301,13 @@ semlock_acquire(SemLockObject *self, PyObject *args, PyObject *kwds) else res = sem_timedwait(self->handle, &deadline); Py_END_ALLOW_THREADS + err = errno; if (res == MP_EXCEPTION_HAS_BEEN_SET) break; } while (res < 0 && errno == EINTR && !PyErr_CheckSignals()); if (res < 0) { + errno = err; if (errno == EAGAIN || errno == ETIMEDOUT) Py_RETURN_FALSE; else if (errno == EINTR) |