Index: channels.c =================================================================== RCS file: /usr/local/src/security/openssh/cvs/openssh/channels.c,v retrieving revision 1.251 diff -u -p -r1.251 channels.c --- channels.c 28 Jan 2007 23:16:28 -0000 1.251 +++ channels.c 10 Apr 2007 02:35:06 -0000 @@ -932,7 +932,7 @@ channel_pre_x11_open(Channel *c, fd_set } else if (ret == -1) { logit("X11 connection rejected because of wrong authentication."); debug2("X11 rejected %d i%d/o%d", c->self, c->istate, c->ostate); - chan_read_failed(c); + chan_read_failed(c, 0); buffer_clear(&c->input); chan_ibuf_empty(c); buffer_clear(&c->output); @@ -1446,12 +1446,13 @@ static int channel_handle_rfd(Channel *c, fd_set *readset, fd_set *writeset) { char buf[CHAN_RBUF]; - int len; + int len, save_errno; if (c->rfd != -1 && (c->detach_close || FD_ISSET(c->rfd, readset))) { errno = 0; len = read(c->rfd, buf, sizeof(buf)); + save_errno = errno; if (len < 0 && (errno == EINTR || (errno == EAGAIN && !(c->isatty && c->detach_close)))) return 1; @@ -1472,14 +1473,14 @@ channel_handle_rfd(Channel *c, fd_set *r c->type = SSH_CHANNEL_INPUT_DRAINING; debug2("channel %d: input draining.", c->self); } else { - chan_read_failed(c); + chan_read_failed(c, save_errno); } return -1; } if (c->input_filter != NULL) { if (c->input_filter(c, buf, len) == -1) { debug2("channel %d: filter stops", c->self); - chan_read_failed(c); + chan_read_failed(c, 0); } } else if (c->datagram) { buffer_put_string(&c->input, buf, len); @@ -1643,7 +1644,7 @@ channel_handle_ctl(Channel *c, fd_set *r chan_mark_dead(c); return -1; } else { - chan_read_failed(c); + chan_read_failed(c, 0); chan_write_failed(c); } return -1; Index: channels.h =================================================================== RCS file: /usr/local/src/security/openssh/cvs/openssh/channels.h,v retrieving revision 1.81 diff -u -p -r1.81 channels.h --- channels.h 5 Aug 2006 02:39:39 -0000 1.81 +++ channels.h 10 Apr 2007 02:01:21 -0000 @@ -240,7 +240,7 @@ void chan_mark_dead(Channel *); /* channel events */ void chan_rcvd_oclose(Channel *); -void chan_read_failed(Channel *); +void chan_read_failed(Channel *, int); void chan_ibuf_empty(Channel *); void chan_rcvd_ieof(Channel *); Index: nchan.c =================================================================== RCS file: /usr/local/src/security/openssh/cvs/openssh/nchan.c,v retrieving revision 1.56 diff -u -p -r1.56 nchan.c --- nchan.c 5 Aug 2006 02:39:40 -0000 1.56 +++ nchan.c 10 Apr 2007 09:38:51 -0000 @@ -133,17 +133,19 @@ chan_rcvd_oclose1(Channel *c) } } void -chan_read_failed(Channel *c) +chan_read_failed(Channel *c, int err_no) { - debug2("channel %d: read failed", c->self); + debug2("channel %d: read failed%s, istate %d", c->self, + err_no ? "" : " (closed)", c->istate); switch (c->istate) { case CHAN_INPUT_OPEN: chan_shutdown_read(c); chan_set_istate(c, CHAN_INPUT_WAIT_DRAIN); break; default: - error("channel %d: chan_read_failed for istate %d", - c->self, c->istate); + if (err_no != 0) + error("channel %d: chan_read_failed for istate %d: %s", + c->self, c->istate, strerror(err_no)); break; } }