mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #10350: Read and save errno before calling a function which might overwrite it.
Original patch by Hallvard B Furuseth.
This commit is contained in:
parent
87448819ab
commit
c345ce1a69
7 changed files with 33 additions and 12 deletions
|
@ -267,7 +267,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};
|
||||
|
@ -313,11 +313,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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue