summaryrefslogtreecommitdiff
path: root/Modules/selectmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/selectmodule.c')
-rw-r--r--Modules/selectmodule.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c
index b71b2c4f6c..ff1c028d0d 100644
--- a/Modules/selectmodule.c
+++ b/Modules/selectmodule.c
@@ -318,8 +318,9 @@ select_select_impl(PyObject *module, PyObject *rlist, PyObject *wlist,
if (omax > max) max = omax;
if (emax > max) max = emax;
- if (tvp)
- deadline = _PyTime_GetMonotonicClock() + timeout;
+ if (tvp) {
+ deadline = _PyDeadline_Init(timeout);
+ }
do {
Py_BEGIN_ALLOW_THREADS
@@ -335,7 +336,7 @@ select_select_impl(PyObject *module, PyObject *rlist, PyObject *wlist,
goto finally;
if (tvp) {
- timeout = deadline - _PyTime_GetMonotonicClock();
+ timeout = _PyDeadline_Get(deadline);
if (timeout < 0) {
/* bpo-35310: lists were unmodified -- clear them explicitly */
FD_ZERO(&ifdset);
@@ -599,7 +600,7 @@ select_poll_poll_impl(pollObject *self, PyObject *timeout_obj)
}
if (timeout >= 0) {
- deadline = _PyTime_GetMonotonicClock() + timeout;
+ deadline = _PyDeadline_Init(timeout);
}
}
@@ -646,7 +647,7 @@ select_poll_poll_impl(pollObject *self, PyObject *timeout_obj)
}
if (timeout >= 0) {
- timeout = deadline - _PyTime_GetMonotonicClock();
+ timeout = _PyDeadline_Get(deadline);
if (timeout < 0) {
poll_result = 0;
break;
@@ -938,8 +939,9 @@ select_devpoll_poll_impl(devpollObject *self, PyObject *timeout_obj)
dvp.dp_nfds = self->max_n_fds;
dvp.dp_timeout = (int)ms;
- if (timeout >= 0)
- deadline = _PyTime_GetMonotonicClock() + timeout;
+ if (timeout >= 0) {
+ deadline = _PyDeadline_Init(timeout);
+ }
do {
/* call devpoll() */
@@ -956,7 +958,7 @@ select_devpoll_poll_impl(devpollObject *self, PyObject *timeout_obj)
return NULL;
if (timeout >= 0) {
- timeout = deadline - _PyTime_GetMonotonicClock();
+ timeout = _PyDeadline_Get(deadline);
if (timeout < 0) {
poll_result = 0;
break;
@@ -1550,7 +1552,7 @@ select_epoll_poll_impl(pyEpoll_Object *self, PyObject *timeout_obj,
}
if (timeout >= 0) {
- deadline = _PyTime_GetMonotonicClock() + timeout;
+ deadline = _PyDeadline_Init(timeout);
}
}
@@ -1584,7 +1586,7 @@ select_epoll_poll_impl(pyEpoll_Object *self, PyObject *timeout_obj,
goto error;
if (timeout >= 0) {
- timeout = deadline - _PyTime_GetMonotonicClock();
+ timeout = _PyDeadline_Get(deadline);
if (timeout < 0) {
nfds = 0;
break;
@@ -2172,8 +2174,9 @@ select_kqueue_control_impl(kqueue_queue_Object *self, PyObject *changelist,
}
}
- if (ptimeoutspec)
- deadline = _PyTime_GetMonotonicClock() + timeout;
+ if (ptimeoutspec) {
+ deadline = _PyDeadline_Init(timeout);
+ }
do {
Py_BEGIN_ALLOW_THREADS
@@ -2190,7 +2193,7 @@ select_kqueue_control_impl(kqueue_queue_Object *self, PyObject *changelist,
goto error;
if (ptimeoutspec) {
- timeout = deadline - _PyTime_GetMonotonicClock();
+ timeout = _PyDeadline_Get(deadline);
if (timeout < 0) {
gotevents = 0;
break;