changeset: 95495:bff88c866886 user: Victor Stinner date: Thu Apr 09 10:27:25 2015 +0200 files: Modules/socketmodule.c description: Issue #23618: Fix internal_select() for negative timeout (blocking socket) when poll() is not available. select() doesn't accept negative timeout, the timeout parameter must be NULL to block on select(). diff -r 462680f4e8af -r bff88c866886 Modules/socketmodule.c --- a/Modules/socketmodule.c Thu Apr 09 10:23:12 2015 +0200 +++ b/Modules/socketmodule.c Thu Apr 09 10:27:25 2015 +0200 @@ -614,7 +614,7 @@ _PyTime_t ms; #else fd_set fds, efds; - struct timeval tv; + struct timeval tv, *tvp; #endif #ifdef WITH_THREAD @@ -650,7 +650,12 @@ 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 @@ 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