Skip to content

Commit 8ab5ef2

Browse files
committed
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.
1 parent e67208a commit 8ab5ef2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ssnet.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,17 @@ def try_connect(self):
152152
debug3('%r: fixed connect result: %s\n' % (self, e))
153153
if e.args[0] in [errno.EINPROGRESS, errno.EALREADY]:
154154
pass # not connected yet
155+
elif e.args[0] == 0:
156+
# connected successfully (weird Linux bug?)
157+
# Sometimes Linux seems to return EINVAL when it isn't
158+
# invalid. This *may* be caused by a race condition
159+
# between connect() and getsockopt(SO_ERROR) (ie. it
160+
# finishes connecting in between the two, so there is no
161+
# longer an error). However, I'm not sure of that.
162+
#
163+
# I did get at least one report that the problem went away
164+
# when we added this, however.
165+
self.connect_to = None
155166
elif e.args[0] == errno.EISCONN:
156167
# connected successfully (BSD)
157168
self.connect_to = None

0 commit comments

Comments
 (0)