4.6p1 chan_read_failed error

Damien Miller
2007-04-08T22:46:56Z

On Wed, 4 Apr 2007, Damien Miller wrote:

> Well, it also undoes the fix for bug #52. I think it is safe to simply hush
> the error message:

ugh, the logic in that patch was almost, but not completely, wrong. Please
try this one instead:

Index: channels.c
==================================================================RCS file:
/var/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	8 Apr 2007 22:43:25 -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);
@@ -1472,14 +1472,15 @@ 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, (errno == EAGAIN &&
+				    !(c->isatty && c->detach_close)));
 			}
 			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:
/var/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	8 Apr 2007 22:43:41 -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:
/var/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	8 Apr 2007 22:41:36 -0000
@@ -133,17 +133,19 @@ chan_rcvd_oclose1(Channel *c)
 	}
 }
 void
-chan_read_failed(Channel *c)
+chan_read_failed(Channel *c, int simulated)
 {
-	debug2("channel %d: read failed", c->self);
+	debug2("channel %d: read failed%s, istate %d", c->self,
+	    simulated ? " (simulated)" : "", 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 (!simulated)
+			error("channel %d: chan_read_failed for istate %d",
+			    c->self, c->istate);
 		break;
 	}
 }