]> granicus.if.org Git - python/commitdiff
Merge the trivial portion of r74426 from trunk.
authorGregory P. Smith <greg@mad-scientist.com>
Mon, 4 Jan 2010 03:29:50 +0000 (03:29 +0000)
committerGregory P. Smith <greg@mad-scientist.com>
Mon, 4 Jan 2010 03:29:50 +0000 (03:29 +0000)
socket.sendall() now handles EINTR properly internally.

Modules/socketmodule.c

index 7b6046dbc6ead548bfd25d7a6d5df69da51af895..fa543cdab9bc01e158403173baa89d117aa6a74e 100644 (file)
@@ -2572,8 +2572,21 @@ sock_sendall(PySocketSockObject *s, PyObject *args)
 #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);