[pypy-svn] pypy fast-forward: Sendall() should try again when errno=EINTR

amauryfa commits-noreply at bitbucket.org
Tue Jan 11 22:41:28 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: fast-forward
Changeset: r40601:56ce3e8d0e80
Date: 2011-01-11 22:40 +0100
http://bitbucket.org/pypy/pypy/changeset/56ce3e8d0e80/

Log:	Sendall() should try again when errno=EINTR Now test_socket passes
	without error!

diff --git a/pypy/rlib/_rsocket_rffi.py b/pypy/rlib/_rsocket_rffi.py
--- a/pypy/rlib/_rsocket_rffi.py
+++ b/pypy/rlib/_rsocket_rffi.py
@@ -117,6 +117,7 @@
     INVALID_SOCKET = platform.DefinedConstantInteger('INVALID_SOCKET')
     INET_ADDRSTRLEN = platform.DefinedConstantInteger('INET_ADDRSTRLEN')
     INET6_ADDRSTRLEN= platform.DefinedConstantInteger('INET6_ADDRSTRLEN')
+    EINTR = platform.DefinedConstantInteger('EINTR')
     EINPROGRESS = platform.DefinedConstantInteger('EINPROGRESS')
     WSAEINPROGRESS = platform.DefinedConstantInteger('WSAEINPROGRESS')
     EWOULDBLOCK = platform.DefinedConstantInteger('EWOULDBLOCK')
@@ -406,6 +407,7 @@
 FIONBIO = cConfig.FIONBIO
 INET_ADDRSTRLEN = cConfig.INET_ADDRSTRLEN
 INET6_ADDRSTRLEN = cConfig.INET6_ADDRSTRLEN
+EINTR = cConfig.EINTR
 EINPROGRESS = cConfig.EINPROGRESS or cConfig.WSAEINPROGRESS
 EWOULDBLOCK = cConfig.EWOULDBLOCK or cConfig.WSAEWOULDBLOCK
 EAFNOSUPPORT = cConfig.EAFNOSUPPORT or cConfig.WSAEAFNOSUPPORT

diff --git a/pypy/rlib/rsocket.py b/pypy/rlib/rsocket.py
--- a/pypy/rlib/rsocket.py
+++ b/pypy/rlib/rsocket.py
@@ -1011,9 +1011,13 @@
             remaining = len(data)
             p = dataptr
             while remaining > 0:
-                res = self.send_raw(p, remaining, flags)
-                p = rffi.ptradd(p, res)
-                remaining -= res
+                try:
+                    res = self.send_raw(p, remaining, flags)
+                    p = rffi.ptradd(p, res)
+                    remaining -= res
+                except CSocketError, e:
+                    if e.errno != _c.EINTR:
+                        raise
                 if signal_checker:
                     signal_checker.check()
         finally:


More information about the Pypy-commit mailing list