summaryrefslogtreecommitdiff
path: root/nchan.c
diff options
context:
space:
mode:
Diffstat (limited to 'nchan.c')
-rw-r--r--nchan.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/nchan.c b/nchan.c
index cef56497b..51c5a4cad 100644
--- a/nchan.c
+++ b/nchan.c
@@ -483,7 +483,14 @@ chan_shutdown_read(Channel *c)
483 return; 483 return;
484 debug("channel %d: close_read", c->self); 484 debug("channel %d: close_read", c->self);
485 if (c->sock != -1) { 485 if (c->sock != -1) {
486 if (shutdown(c->sock, SHUT_RD) < 0) 486 /*
487 * shutdown(sock, SHUT_READ) may return ENOTCONN if the
488 * write side has been closed already. (bug on Linux)
489 */
490 if (shutdown(c->sock, SHUT_RD) < 0
491 && (errno != ENOTCONN
492 || c->ostate == CHAN_OUTPUT_OPEN
493 || c->ostate == CHAN_OUTPUT_WAIT_DRAIN))
487 error("channel %d: chan_shutdown_read: shutdown() failed for fd%d [i%d o%d]: %.100s", 494 error("channel %d: chan_shutdown_read: shutdown() failed for fd%d [i%d o%d]: %.100s",
488 c->self, c->sock, c->istate, c->ostate, strerror(errno)); 495 c->self, c->sock, c->istate, c->ostate, strerror(errno));
489 } else { 496 } else {