[New-bugs-announce] [issue30768] PyThread_acquire_lock_timed() should recompute the timeout when interrupted by a signal

STINNER Victor report at bugs.python.org
Mon Jun 26 09:50:01 EDT 2017


New submission from STINNER Victor:

The current code of PyThread_acquire_lock_timed() (the implementation not using semaphore) doesn't compute correctly the timeout when pthread_cond_timedwait() is interrupted by a signal. We should recompute the timeout using a deadline.

Something like select.select():

if (tvp)
    deadline = _PyTime_GetMonotonicClock() + timeout;

do {
    ... use tvp
    if (errno != EINTR)
        break;

    /* select() was interrupted by a signal */
    if (PyErr_CheckSignals())
        goto finally;

    if (tvp) {
        timeout = deadline - _PyTime_GetMonotonicClock();
        if (timeout < 0) {
            n = 0;
            break;
        }
        _PyTime_AsTimeval_noraise(timeout, &tv, _PyTime_ROUND_CEILING);
        /* retry select() with the recomputed timeout */
    }
} while (1);

----------
messages: 296896
nosy: haypo, neologix, pitrou
priority: normal
severity: normal
status: open
title: PyThread_acquire_lock_timed() should recompute the timeout when interrupted by a signal
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30768>
_______________________________________


More information about the New-bugs-announce mailing list