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

Collapse All | Expand All

(-)a/nchan.c (+22 lines)
Lines 78-83 static void chan_send_eow2(struct ssh *, Channel *); Link Here
78
/* helper */
78
/* helper */
79
static void	chan_shutdown_write(struct ssh *, Channel *);
79
static void	chan_shutdown_write(struct ssh *, Channel *);
80
static void	chan_shutdown_read(struct ssh *, Channel *);
80
static void	chan_shutdown_read(struct ssh *, Channel *);
81
static void	chan_shutdown_extended_read(struct ssh *, Channel *);
81
82
82
static const char *ostates[] = { "open", "drain", "wait_ieof", "closed" };
83
static const char *ostates[] = { "open", "drain", "wait_ieof", "closed" };
83
static const char *istates[] = { "open", "drain", "wait_oclose", "closed" };
84
static const char *istates[] = { "open", "drain", "wait_oclose", "closed" };
Lines 287-297 chan_rcvd_oclose(struct ssh *ssh, Channel *c) Link Here
287
	switch (c->istate) {
288
	switch (c->istate) {
288
	case CHAN_INPUT_OPEN:
289
	case CHAN_INPUT_OPEN:
289
		chan_shutdown_read(ssh, c);
290
		chan_shutdown_read(ssh, c);
291
		chan_shutdown_extended_read(ssh, c);
290
		chan_set_istate(c, CHAN_INPUT_CLOSED);
292
		chan_set_istate(c, CHAN_INPUT_CLOSED);
291
		break;
293
		break;
292
	case CHAN_INPUT_WAIT_DRAIN:
294
	case CHAN_INPUT_WAIT_DRAIN:
293
		if (!(c->flags & CHAN_LOCAL))
295
		if (!(c->flags & CHAN_LOCAL))
294
			chan_send_eof2(ssh, c);
296
			chan_send_eof2(ssh, c);
297
		chan_shutdown_extended_read(ssh, c);
295
		chan_set_istate(c, CHAN_INPUT_CLOSED);
298
		chan_set_istate(c, CHAN_INPUT_CLOSED);
296
		break;
299
		break;
297
	}
300
	}
Lines 415-417 chan_shutdown_read(struct ssh *ssh, Channel *c) Link Here
415
		}
418
		}
416
	}
419
	}
417
}
420
}
421
422
static void
423
chan_shutdown_extended_read(struct ssh *ssh, Channel *c)
424
{
425
	if (c->type == SSH_CHANNEL_LARVAL || c->efd == -1)
426
		return;
427
	if (c->extended_usage != CHAN_EXTENDED_READ &&
428
	    c->extended_usage != CHAN_EXTENDED_IGNORE)
429
		return;
430
	debug2("channel %d: %s (i%d o%d sock %d wfd %d efd %d [%s])",
431
	    c->self, __func__, c->istate, c->ostate, c->sock, c->rfd, c->efd,
432
	    channel_format_extended_usage(c));
433
	if (channel_close_fd(ssh, &c->efd) < 0) {
434
		logit("channel %d: %s: close() failed for "
435
		    "extended fd %d [i%d o%d]: %.100s",
436
		    c->self, __func__, c->efd, c->istate, c->ostate,
437
		    strerror(errno));
438
	}
439
}

Return to bug 2863