diff Modules/socketmodule.c @ 24317:29ae8e89153b legacy-trunk

Bail out early from internal_select() when socket file descriptor closed. Prevents core dump.
author Guido van Rossum <guido@python.org>
date Fri, 19 Jul 2002 12:44:59 +0000
parents 428cbbf05639
children 979ff5d0ae07
line wrap: on
line diff
--- a/Modules/socketmodule.c	Fri Jul 19 07:05:44 2002 +0000
+++ b/Modules/socketmodule.c	Fri Jul 19 12:44:59 2002 +0000
@@ -505,9 +505,14 @@
 	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);