Skip to content

Commit cfb2592

Browse files
committed
server.py: handle (throw away) ECONNREFUSED from the DNS server.
This might happen occasionally on a flakey network. Reported by Ed Maste.
1 parent 2e8381e commit cfb2592

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

server.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,14 @@ def __init__(self, mux, chan, request):
119119
self.sock.send(request)
120120

121121
def callback(self):
122-
data = self.sock.recv(4096)
122+
try:
123+
data = self.sock.recv(4096)
124+
except socket.error, e:
125+
if e.args[0] == errno.ECONNREFUSED:
126+
debug2('DNS response: ignoring ECONNREFUSED.\n')
127+
return # might have been spurious; wait for a real answer
128+
else:
129+
raise
123130
debug2('DNS response: %d bytes\n' % len(data))
124131
self.mux.send(self.chan, ssnet.CMD_DNS_RESPONSE, data)
125132
self.ok = False

0 commit comments

Comments
 (0)