summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/socketmodule.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 8c5c36c..fd20b17 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -614,7 +614,7 @@ internal_select(PySocketSockObject *s, int writing, _PyTime_t interval,
_PyTime_t ms;
#else
fd_set fds, efds;
- struct timeval tv;
+ struct timeval tv, *tvp;
#endif
#ifdef WITH_THREAD
@@ -650,7 +650,12 @@ internal_select(PySocketSockObject *s, int writing, _PyTime_t interval,
n = poll(&pollfd, 1, (int)ms);
Py_END_ALLOW_THREADS;
#else
- _PyTime_AsTimeval_noraise(interval, &tv, _PyTime_ROUND_CEILING);
+ if (interval >= 0) {
+ _PyTime_AsTimeval_noraise(interval, &tv, _PyTime_ROUND_CEILING);
+ tvp = &tv;
+ }
+ else
+ tvp = NULL;
FD_ZERO(&fds);
FD_SET(s->sock_fd, &fds);
@@ -667,10 +672,10 @@ internal_select(PySocketSockObject *s, int writing, _PyTime_t interval,
Py_BEGIN_ALLOW_THREADS;
if (writing)
n = select(Py_SAFE_DOWNCAST(s->sock_fd+1, SOCKET_T, int),
- NULL, &fds, &efds, &tv);
+ NULL, &fds, &efds, tvp);
else
n = select(Py_SAFE_DOWNCAST(s->sock_fd+1, SOCKET_T, int),
- &fds, NULL, &efds, &tv);
+ &fds, NULL, &efds, tvp);
Py_END_ALLOW_THREADS;
#endif