diff Modules/socketmodule.c @ 58144:d399f6dc9ee4

Merge the trivial portion of r74426 from trunk. socket.sendall() now handles EINTR properly internally.
author Gregory P. Smith <greg@mad-scientist.com>
date Mon, 04 Jan 2010 03:29:50 +0000
parents 41bb5e2dc947
children 37f6264d1aa3
line wrap: on
line diff
--- a/Modules/socketmodule.c	Mon Jan 04 01:10:28 2010 +0000
+++ b/Modules/socketmodule.c	Mon Jan 04 03:29:50 2010 +0000
@@ -2572,8 +2572,21 @@
 #else
 		n = send(s->sock_fd, buf, len, flags);
 #endif
-		if (n < 0)
+		if (n < 0) {
+#ifdef EINTR
+			/* We must handle EINTR here as there is no way for
+			 * the caller to know how much was sent otherwise.  */
+			if (errno == EINTR) {
+				/* Run signal handlers.  If an exception was
+				 * raised, abort and leave this socket in
+				 * an unknown state. */
+				if (PyErr_CheckSignals())
+					return NULL;
+				continue;
+			}
+#endif
 			break;
+		}
 		buf += n;
 		len -= n;
 	} while (len > 0);