gh-74953: _PyThread_cond_after() uses _PyTime_t (#94056)

pthread _PyThread_cond_after() implementation now uses the _PyTime_t
type to handle properly overflow: clamp to the maximum value.

Remove MICROSECONDS_TO_TIMESPEC() function.
This commit is contained in:
Victor Stinner 2022-06-21 15:45:49 +02:00 committed by GitHub
parent 616fa3465d
commit c7a79bb036
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 29 deletions

View file

@ -68,9 +68,9 @@ void _PyThread_cond_after(long long us, struct timespec *abs);
Py_LOCAL_INLINE(int)
PyCOND_TIMEDWAIT(PyCOND_T *cond, PyMUTEX_T *mut, long long us)
{
struct timespec abs;
_PyThread_cond_after(us, &abs);
int ret = pthread_cond_timedwait(cond, mut, &abs);
struct timespec abs_timeout;
_PyThread_cond_after(us, &abs_timeout);
int ret = pthread_cond_timedwait(cond, mut, &abs_timeout);
if (ret == ETIMEDOUT) {
return 1;
}