[Zodb-checkins] CVS: ZEO/ZEO/zrpc - client.py:1.1.2.7
Tim Peters
tim.one@home.com
Sat, 26 Jan 2002 13:37:31 -0500
Update of /cvs-repository/ZEO/ZEO/zrpc
In directory cvs.zope.org:/tmp/cvs-serv4531/zrpc
Modified Files:
Tag: Standby-branch
client.py
Log Message:
ConnectThread.connect(): add enough errno smarts so that checkWriteClient
passes on Windows too.
=== ZEO/ZEO/zrpc/client.py 1.1.2.6 => 1.1.2.7 ===
self.sock = sock
+# When trying to do a connect on a non-blocking socket, some outcomes
+# are expected. Set _CONNECT_IN_PROGRESS to the errno value(s) expected
+# when an initial connect can't complete immediately. Set _CONNECT_OK
+# to the errno value(s) expected if the connect succeeds *or* if it's
+# already connected (our code can attempt redundant connects).
+if hasattr(errno, "WSAEWOULDBLOCK"): # Windows
+ _CONNECT_IN_PROGRESS = (errno.WSAEWOULDBLOCK,)
+ _CONNECT_OK = (0, errno.WSAEISCONN)
+else: # Unix
+ _CONNECT_IN_PROGRESS = (errno.EINPROGRESS,)
+ _CONNECT_OK = (0, errno.EISCONN)
+
class ConnectThread(threading.Thread):
"""Thread that tries to connect to server given one or more addresses.
@@ -213,8 +225,6 @@
s.setblocking(0)
self.sockets[s] = addr
# XXX can still block for a while if addr requires DNS
- # YYY What is that XXX comment trying to say? self.connect
- # YYY explicitly tolerates EINPROGRESS.
e = self.connect(s)
# next wait until they actually connect
@@ -254,9 +264,9 @@
"""
addr = self.sockets[s]
e = s.connect_ex(addr)
- if e == errno.EINPROGRESS:
+ if e in _CONNECT_IN_PROGRESS:
return 1
- elif e == 0 or e == errno.EISCONN:
+ elif e in _CONNECT_OK:
c = self.test_connection(s, addr)
log("connected to %s" % repr(addr), level=zLOG.DEBUG)
if c: