summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvery Pennarun <apenwarr@gmail.com>2011-05-29 22:04:39 -0400
committerAvery Pennarun <apenwarr@gmail.com>2011-05-29 22:42:16 -0400
commit8ab5ef283df66ef99aa0c826d941e414407bf773 (patch)
tree15e627fc38d7710f259902e0e9c8b6a78611afad
parente67208a294b6e4bed75dec1e39d4b716d28a559c (diff)
ssnet.py: deal with a possible connect/getsockopt(SO_ERROR) race.
Seems to affect Linux servers. Ed Maste says the patch fixes it for him.
-rw-r--r--ssnet.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/ssnet.py b/ssnet.py
index b6d73c2..a636ce1 100644
--- a/ssnet.py
+++ b/ssnet.py
@@ -152,6 +152,17 @@ class SockWrapper:
debug3('%r: fixed connect result: %s\n' % (self, e))
if e.args[0] in [errno.EINPROGRESS, errno.EALREADY]:
pass # not connected yet
+ elif e.args[0] == 0:
+ # connected successfully (weird Linux bug?)
+ # Sometimes Linux seems to return EINVAL when it isn't
+ # invalid. This *may* be caused by a race condition
+ # between connect() and getsockopt(SO_ERROR) (ie. it
+ # finishes connecting in between the two, so there is no
+ # longer an error). However, I'm not sure of that.
+ #
+ # I did get at least one report that the problem went away
+ # when we added this, however.
+ self.connect_to = None
elif e.args[0] == errno.EISCONN:
# connected successfully (BSD)
self.connect_to = None