[pypy-commit] pypy default: Fix translation when there is no SOCK_CLOEXEC

rlamy pypy.commits at gmail.com
Tue Aug 30 13:26:49 EDT 2016


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: 
Changeset: r86749:24d11640c483
Date: 2016-08-30 18:26 +0100
http://bitbucket.org/pypy/pypy/changeset/24d11640c483/

Log:	Fix translation when there is no SOCK_CLOEXEC

diff --git a/rpython/rlib/rsocket.py b/rpython/rlib/rsocket.py
--- a/rpython/rlib/rsocket.py
+++ b/rpython/rlib/rsocket.py
@@ -526,7 +526,7 @@
                  fd=_c.INVALID_SOCKET, inheritable=True):
         """Create a new socket."""
         if _c.invalid_socket(fd):
-            if not inheritable and SOCK_CLOEXEC is not None:
+            if not inheritable and 'SOCK_CLOEXEC' in constants:
                 # Non-inheritable: we try to call socket() with
                 # SOCK_CLOEXEC, which may fail.  If we get EINVAL,
                 # then we fall back to the SOCK_CLOEXEC-less case.
@@ -655,7 +655,7 @@
         address, addr_p, addrlen_p = self._addrbuf()
         try:
             remove_inheritable = not inheritable
-            if (not inheritable and SOCK_CLOEXEC is not None
+            if (not inheritable and 'SOCK_CLOEXEC' in constants
                     and _c.HAVE_ACCEPT4
                     and _accept4_syscall.attempt_syscall()):
                 newfd = _c.socketaccept4(self.fd, addr_p, addrlen_p,
@@ -1138,7 +1138,7 @@
         try:
             res = -1
             remove_inheritable = not inheritable
-            if not inheritable and SOCK_CLOEXEC is not None:
+            if not inheritable and 'SOCK_CLOEXEC' in constants:
                 # Non-inheritable: we try to call socketpair() with
                 # SOCK_CLOEXEC, which may fail.  If we get EINVAL,
                 # then we fall back to the SOCK_CLOEXEC-less case.


More information about the pypy-commit mailing list