View | Details | Raw Unified | Return to bug 179 | Differences between
and this patch

Collapse All | Expand All

(-)channels.c (-1 / +18 lines)
Lines 711-717 Link Here
711
	}
711
	}
712
	/** XXX check close conditions, too */
712
	/** XXX check close conditions, too */
713
	if (compat20 && c->efd != -1) {
713
	if (compat20 && c->efd != -1) {
714
		if (c->extended_usage == CHAN_EXTENDED_WRITE &&
714
		if (c->ostate != CHAN_OUTPUT_CLOSED &&
715
		    c->extended_usage == CHAN_EXTENDED_WRITE &&
715
		    buffer_len(&c->extended) > 0)
716
		    buffer_len(&c->extended) > 0)
716
			FD_SET(c->efd, writeset);
717
			FD_SET(c->efd, writeset);
717
		else if (c->extended_usage == CHAN_EXTENDED_READ &&
718
		else if (c->extended_usage == CHAN_EXTENDED_READ &&
Lines 1562-1567 Link Here
1562
	channel_handler(channel_post, readset, writeset);
1563
	channel_handler(channel_post, readset, writeset);
1563
}
1564
}
1564
1565
1566
#define CHANNEL_EFD_ALIVE(c) \
1567
	(compat20 && c->extended_usage == CHAN_EXTENDED_READ && \
1568
	(c->efd != -1 || buffer_len(&c->extended) > 0))
1569
1565
1570
1566
/* If there is data to send to the connection, enqueue some of it now. */
1571
/* If there is data to send to the connection, enqueue some of it now. */
1567
1572
Lines 1634-1639 Link Here
1634
			 * input-buffer is empty and read-socket shutdown:
1639
			 * input-buffer is empty and read-socket shutdown:
1635
			 * tell peer, that we will not send more data: send IEOF
1640
			 * tell peer, that we will not send more data: send IEOF
1636
			 */
1641
			 */
1642
			if (CHANNEL_EFD_ALIVE(c))
1643
                               debug2("channel %d: ibuf_empty delayed efd %d/(%d)",
1644
                                   c->self, c->efd, buffer_len(&c->extended));
1645
			else
1637
			chan_ibuf_empty(c);
1646
			chan_ibuf_empty(c);
1638
		}
1647
		}
1639
		/* Send extended data, i.e. stderr */
1648
		/* Send extended data, i.e. stderr */
Lines 1725-1730 Link Here
1725
	if (c->type != SSH_CHANNEL_OPEN) {
1734
	if (c->type != SSH_CHANNEL_OPEN) {
1726
		log("channel %d: ext data for non open", id);
1735
		log("channel %d: ext data for non open", id);
1727
		return;
1736
		return;
1737
	}
1738
	if (c->ostate == CHAN_OUTPUT_CLOSED) {
1739
                if (c->flags & CHAN_WRITE_FAILED) {
1740
			debug3("channel %d: ignoring ext data", c->self);
1741
			return;
1742
		}
1743
		packet_disconnect(
1744
		    "Received extended_data after EOF on channel %d.", id);
1728
	}
1745
	}
1729
	tcode = packet_get_int();
1746
	tcode = packet_get_int();
1730
	if (c->efd == -1 ||
1747
	if (c->efd == -1 ||
(-)channels.h (+1 lines)
Lines 135-140 Link Here
135
135
136
#define CHAN_CLOSE_SENT			0x01
136
#define CHAN_CLOSE_SENT			0x01
137
#define CHAN_CLOSE_RCVD			0x02
137
#define CHAN_CLOSE_RCVD			0x02
138
#define CHAN_WRITE_FAILED		0x04
138
139
139
/* channel management */
140
/* channel management */
140
141
(-)nchan.c (-17 / +1 lines)
Lines 312-317 Link Here
312
	switch (c->ostate) {
312
	switch (c->ostate) {
313
	case CHAN_OUTPUT_OPEN:
313
	case CHAN_OUTPUT_OPEN:
314
	case CHAN_OUTPUT_WAIT_DRAIN:
314
	case CHAN_OUTPUT_WAIT_DRAIN:
315
		c->flags |= CHAN_WRITE_FAILED;
315
		chan_shutdown_write(c);
316
		chan_shutdown_write(c);
316
		chan_set_ostate(c, CHAN_OUTPUT_CLOSED);
317
		chan_set_ostate(c, CHAN_OUTPUT_CLOSED);
317
		break;
318
		break;
Lines 404-425 Link Here
404
		debug("channel %d: is dead", c->self);
405
		debug("channel %d: is dead", c->self);
405
		return 1;
406
		return 1;
406
	}
407
	}
407
	/*
408
	 * we have to delay the close message if the efd (for stderr) is
409
	 * still active
410
	 */
411
	if (((c->extended_usage != CHAN_EXTENDED_IGNORE) &&
412
	    buffer_len(&c->extended) > 0)
413
#if 0
414
	    || ((c->extended_usage == CHAN_EXTENDED_READ) &&
415
	    c->efd != -1)
416
#endif
417
	    ) {
418
		debug2("channel %d: active efd: %d len %d type %s",
419
		    c->self, c->efd, buffer_len(&c->extended),
420
		    c->extended_usage==CHAN_EXTENDED_READ ?
421
		    "read": "write");
422
	} else {
423
		if (!(c->flags & CHAN_CLOSE_SENT)) {
408
		if (!(c->flags & CHAN_CLOSE_SENT)) {
424
			if (send) {
409
			if (send) {
425
				chan_send_close2(c);
410
				chan_send_close2(c);
Lines 436-442 Link Here
436
		    (c->flags & CHAN_CLOSE_RCVD)) {
421
		    (c->flags & CHAN_CLOSE_RCVD)) {
437
			debug("channel %d: is dead", c->self);
422
			debug("channel %d: is dead", c->self);
438
			return 1;
423
			return 1;
439
		}
440
	}
424
	}
441
	return 0;
425
	return 0;
442
}
426
}

Return to bug 179