If we get EPIPE on uwrite(), don't close, just do nowrite().

EPIPE doesn't mean the whole socket is dead, it just means we can't write to
it.  Maybe there's still data waiting to be read, though.
This commit is contained in:
Avery Pennarun 2011-01-12 09:19:43 -08:00
parent b7f1530aef
commit 38bb7f3c21

View File

@ -163,9 +163,14 @@ class SockWrapper:
try:
return _nb_clean(os.write, self.wsock.fileno(), buf)
except OSError, e:
# unexpected error... stream is dead
self.seterr('uwrite: %s' % e)
return 0
if e.errno == errno.EPIPE:
debug1('%r: uwrite: got EPIPE\n' % self)
self.nowrite()
return 0
else:
# unexpected error... stream is dead
self.seterr('uwrite: %s' % e)
return 0
def write(self, buf):
assert(buf)