[Python-modules-commits] [python-tornado] 05/10: Ignore ENOPROTOOPT errors from SO_REUSEADDR or SO_ERROR on AF_UNIX sockets, for

Ondřej Nový onovy at moszumanska.debian.org
Sat Jul 16 20:52:51 UTC 2016


This is an automated email from the git hooks/post-receive script.

onovy pushed a commit to branch master
in repository python-tornado.

commit d345ec29447f22b86a06a45fdb71597533fed4f8
Author: SVN-Git Migration <python-modules-team at lists.alioth.debian.org>
Date:   Thu Oct 8 13:13:33 2015 -0700

    Ignore ENOPROTOOPT errors from SO_REUSEADDR or SO_ERROR on AF_UNIX sockets, for
    
    systems which do not implement them there.
    Patch-Name: sockopt.patch
---
 tornado/iostream.py |  7 ++++++-
 tornado/netutil.py  | 12 ++++++++++--
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/tornado/iostream.py b/tornado/iostream.py
index bcf4441..b5f49fa 100644
--- a/tornado/iostream.py
+++ b/tornado/iostream.py
@@ -1174,7 +1174,12 @@ class IOStream(BaseIOStream):
         return future
 
     def _handle_connect(self):
-        err = self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
+        try:
+            err = self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
+        except socket.error as e:
+            err = e.args[0]
+            if err == errno.ENOPROTOOPT:
+                err = 0
         if err != 0:
             self.error = socket.error(err, os.strerror(err))
             # IOLoop implementations may vary: some of them return
diff --git a/tornado/netutil.py b/tornado/netutil.py
index 5cbcdb9..b7113d6 100644
--- a/tornado/netutil.py
+++ b/tornado/netutil.py
@@ -169,9 +169,17 @@ def bind_sockets(port, address=None, family=socket.AF_UNSPEC,
             raise
         set_close_exec(sock.fileno())
         if os.name != 'nt':
-            sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+            try:
+                sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+            except socket.error as e:
+                if e.args[0] != errno.ENOPROTOOPT:
+                    raise
         if reuse_port:
-            sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
+            try:
+                sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
+            except socket.error as e:
+                if e.args[0] != errno.ENOPROTOOPT:
+                    raise
         if af == socket.AF_INET6:
             # On linux, ipv6 sockets accept ipv4 too by default,
             # but this makes it impossible to bind to both

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-tornado.git



More information about the Python-modules-commits mailing list