X-Git-Url: http://andersk.mit.edu/gitweb/openssh.git/blobdiff_plain/f49df8e9edfff7a6a0a3b8eb6275d93e834c11e5..27c47c0ad07c3e63270ef33b5f3f7226d4d58582:/nchan.c diff --git a/nchan.c b/nchan.c index 5c18487f..2680f0a6 100644 --- a/nchan.c +++ b/nchan.c @@ -23,7 +23,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: nchan.c,v 1.31 2001/07/17 21:04:57 markus Exp $"); +RCSID("$OpenBSD: nchan.c,v 1.32 2001/10/10 22:18:47 markus Exp $"); #include "ssh1.h" #include "ssh2.h" @@ -58,7 +58,7 @@ RCSID("$OpenBSD: nchan.c,v 1.31 2001/07/17 21:04:57 markus Exp $"); * ssh-1.2.27 as an example. * */ - + /* functions manipulating channel states */ /* * EVENTS update channel input/output states execute ACTIONS @@ -432,7 +432,7 @@ chan_mark_dead(Channel *c) } int -chan_is_dead(Channel *c) +chan_is_dead(Channel *c, int send) { if (c->type == SSH_CHANNEL_ZOMBIE) { debug("channel %d: zombie", c->self); @@ -461,7 +461,16 @@ chan_is_dead(Channel *c) "read": "write"); } else { if (!(c->flags & CHAN_CLOSE_SENT)) { - chan_send_close2(c); + if (send) { + chan_send_close2(c); + } else { + /* channel would be dead if we sent a close */ + if (c->flags & CHAN_CLOSE_RCVD) { + debug("channel %d: almost dead", + c->self); + return 1; + } + } } if ((c->flags & CHAN_CLOSE_SENT) && (c->flags & CHAN_CLOSE_RCVD)) { @@ -541,7 +550,7 @@ chan_shutdown_read(Channel *c) 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)); + strerror(errno)); } else { if (channel_close_fd(&c->rfd) < 0) log("channel %d: chan_shutdown_read: "