This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients neologix, pitrou, vstinner
Date 2017-06-26.13:50:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1498485001.71.0.115721395457.issue30768@psf.upfronthosting.co.za>
In-reply-to
Content
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);
History
Date User Action Args
2017-06-26 13:50:01vstinnersetrecipients: + vstinner, pitrou, neologix
2017-06-26 13:50:01vstinnersetmessageid: <1498485001.71.0.115721395457.issue30768@psf.upfronthosting.co.za>
2017-06-26 13:50:01vstinnerlinkissue30768 messages
2017-06-26 13:50:01vstinnercreate