Commit 4bf4f70c authored by Avery Pennarun's avatar Avery Pennarun

ssnet: recover slightly more gracefully from an infinite forwarding loop.

If you 'telnet localhost 12300' weird things happen; someday we should
probably auto-detect and avoid that altogether.  But meanwhile, catch EPIPE
if it happens (it's irrelevant) and don't barf with a %d data type for a
value that can apparently sometimes be None.
parent 410b9d42
...@@ -35,7 +35,7 @@ def _nb_clean(func, *args): ...@@ -35,7 +35,7 @@ def _nb_clean(func, *args):
try: try:
return func(*args) return func(*args)
except OSError, e: except OSError, e:
if e.errno not in (errno.EWOULDBLOCK, errno.EAGAIN): if e.errno not in (errno.EWOULDBLOCK, errno.EAGAIN, errno.EPIPE):
raise raise
else: else:
return None return None
...@@ -308,7 +308,7 @@ class Mux(Handler): ...@@ -308,7 +308,7 @@ class Mux(Handler):
self.wsock.setblocking(False) self.wsock.setblocking(False)
if self.outbuf and self.outbuf[0]: if self.outbuf and self.outbuf[0]:
wrote = _nb_clean(os.write, self.wsock.fileno(), self.outbuf[0]) wrote = _nb_clean(os.write, self.wsock.fileno(), self.outbuf[0])
debug2('mux wrote: %d/%d\n' % (wrote, len(self.outbuf[0]))) debug2('mux wrote: %r/%d\n' % (wrote, len(self.outbuf[0])))
if wrote: if wrote:
self.outbuf[0] = self.outbuf[0][wrote:] self.outbuf[0] = self.outbuf[0][wrote:]
while self.outbuf and not self.outbuf[0]: while self.outbuf and not self.outbuf[0]:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment