mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Bail out early from internal_select() when socket file descriptor
closed. Prevents core dump.
This commit is contained in:
parent
330f9e9581
commit
ad65490628
1 changed files with 5 additions and 0 deletions
|
@ -505,9 +505,14 @@ internal_select(PySocketSockObject *s, int writing)
|
|||
fd_set fds;
|
||||
struct timeval tv;
|
||||
|
||||
/* Nothing to do unless we're in timeout mode (not non-blocking) */
|
||||
if (s->sock_timeout <= 0.0)
|
||||
return;
|
||||
|
||||
/* Guard against closed socket */
|
||||
if (s->sock_fd < 0)
|
||||
return;
|
||||
|
||||
/* Construct the arguments to select */
|
||||
tv.tv_sec = (int)s->sock_timeout;
|
||||
tv.tv_usec = (int)((s->sock_timeout - tv.tv_sec) * 1e6);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue