Skip to content

Commit

Permalink
ssnet.py: deal with a possible connect/getsockopt(SO_ERROR) race.
Browse files Browse the repository at this point in the history
Seems to affect Linux servers.  Ed Maste says the patch fixes it for him.
  • Loading branch information
apenwarr committed May 30, 2011
1 parent e67208a commit 8ab5ef2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ssnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,17 @@ def try_connect(self):
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
Expand Down

0 comments on commit 8ab5ef2

Please sign in to comment.