diff options
author | Avery Pennarun <apenwarr@gmail.com> | 2010-09-30 23:25:08 -0700 |
---|---|---|
committer | Avery Pennarun <apenwarr@gmail.com> | 2010-10-01 00:05:49 -0700 |
commit | 4bf4f70c670b929f5018091bb5ef2e5fbcf71ff3 (patch) | |
tree | 48a872543b5043cd2f6be430126528edb71aceaa | |
parent | 410b9d4229b36e60e64f101c1105b90d844e8006 (diff) |
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.
-rw-r--r-- | ssnet.py | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -35,7 +35,7 @@ def _nb_clean(func, *args): try: return func(*args) except OSError, e: - if e.errno not in (errno.EWOULDBLOCK, errno.EAGAIN): + if e.errno not in (errno.EWOULDBLOCK, errno.EAGAIN, errno.EPIPE): raise else: return None @@ -308,7 +308,7 @@ class Mux(Handler): self.wsock.setblocking(False) if self.outbuf and 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: self.outbuf[0] = self.outbuf[0][wrote:] while self.outbuf and not self.outbuf[0]: |