summaryrefslogtreecommitdiffstats
path: root/nchan.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2000-08-07 15:47:48 +1000
committerDamien Miller <djm@mindrot.org>2000-08-07 15:47:48 +1000
commit0f091bd1fc9724eb7c2f8df8ad333b5390b2e639 (patch)
tree12f5dfc28f70a1c4d786c1ea6c08d15ccc01446f /nchan.c
parent729e1f15d8ce40d67e94bf8bd142fa67acce9a96 (diff)
- (djm) Suppress error messages on channel close shutdown() failurs
works around Linux bug. Patch from Zack Weinberg <zack@wolery.cumb.org>
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 cef56497..51c5a4ca 100644
--- a/nchan.c
+++ b/nchan.c
@@ -483,7 +483,14 @@ chan_shutdown_read(Channel *c)
return;
debug("channel %d: close_read", c->self);
if (c->sock != -1) {
- if (shutdown(c->sock, SHUT_RD) < 0)
+ /*
+ * shutdown(sock, SHUT_READ) may return ENOTCONN if the
+ * write side has been closed already. (bug on Linux)
+ */
+ if (shutdown(c->sock, SHUT_RD) < 0
+ && (errno != ENOTCONN
+ || c->ostate == CHAN_OUTPUT_OPEN
+ || c->ostate == CHAN_OUTPUT_WAIT_DRAIN))
error("channel %d: chan_shutdown_read: shutdown() failed for fd%d [i%d o%d]: %.100s",
c->self, c->sock, c->istate, c->ostate, strerror(errno));
} else {