diff options
author | Victor Stinner <vstinner@python.org> | 2021-10-01 11:29:25 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-01 11:29:25 (GMT) |
commit | 833fdf126c8fe77fd17e8a8ffbc5c571b3bf64bd (patch) | |
tree | 7e4ed574b7cfb30c0ebb7585061134fee1b1f8ae /Modules/signalmodule.c | |
parent | 54957f16a63ecb6b15f77b01fa7c55ada892604a (diff) | |
download | cpython-833fdf126c8fe77fd17e8a8ffbc5c571b3bf64bd.zip cpython-833fdf126c8fe77fd17e8a8ffbc5c571b3bf64bd.tar.gz cpython-833fdf126c8fe77fd17e8a8ffbc5c571b3bf64bd.tar.bz2 |
bpo-41710: Add private _PyDeadline_Get() function (GH-28674)
Add a private C API for deadlines: add _PyDeadline_Init() and
_PyDeadline_Get() functions.
* Add _PyTime_Add() and _PyTime_Mul() functions which compute t1+t2
and t1*t2 and clamp the result on overflow.
* _PyTime_MulDiv() now uses _PyTime_Add() and _PyTime_Mul().
Diffstat (limited to 'Modules/signalmodule.c')
-rw-r--r-- | Modules/signalmodule.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index fc58cfd..8b7ef2c 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -1221,11 +1221,7 @@ signal_sigtimedwait_impl(PyObject *module, sigset_t sigset, PyObject *timeout_obj) /*[clinic end generated code: output=59c8971e8ae18a64 input=87fd39237cf0b7ba]*/ { - struct timespec ts; - siginfo_t si; - int res; - _PyTime_t timeout, deadline, monotonic; - + _PyTime_t timeout; if (_PyTime_FromSecondsObject(&timeout, timeout_obj, _PyTime_ROUND_CEILING) < 0) return NULL; @@ -1235,12 +1231,16 @@ signal_sigtimedwait_impl(PyObject *module, sigset_t sigset, return NULL; } - deadline = _PyTime_GetMonotonicClock() + timeout; + _PyTime_t deadline = _PyDeadline_Init(timeout); + siginfo_t si; do { - if (_PyTime_AsTimespec(timeout, &ts) < 0) + struct timespec ts; + if (_PyTime_AsTimespec(timeout, &ts) < 0) { return NULL; + } + int res; Py_BEGIN_ALLOW_THREADS res = sigtimedwait(&sigset, &si, &ts); Py_END_ALLOW_THREADS @@ -1259,10 +1259,10 @@ signal_sigtimedwait_impl(PyObject *module, sigset_t sigset, if (PyErr_CheckSignals()) return NULL; - monotonic = _PyTime_GetMonotonicClock(); - timeout = deadline - monotonic; - if (timeout < 0) + timeout = _PyDeadline_Get(deadline); + if (timeout < 0) { break; + } } while (1); return fill_siginfo(&si); |