diff options
author | Ben Lindstrom <mouring@eviladmin.org> | 2001-03-05 06:16:11 +0000 |
---|---|---|
committer | Ben Lindstrom <mouring@eviladmin.org> | 2001-03-05 06:16:11 +0000 |
commit | 7fbd455c780e96065dc2bd8d96d21f0c017c0f99 (patch) | |
tree | 5e8bf350a8beaec98596e5f680b140006b123a8f /nchan.c | |
parent | e9613cf16d72fd78bda7ece0abd7f36c0fb266b6 (diff) |
- markus@cvs.openbsd.org 2001/02/28 08:54:55
[channels.c nchan.c nchan.h]
make sure remote stderr does not get truncated.
remove closed fd's from the select mask.
Diffstat (limited to 'nchan.c')
-rw-r--r-- | nchan.c | 57 |
1 files changed, 31 insertions, 26 deletions
@@ -23,7 +23,7 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include "includes.h" | 25 | #include "includes.h" |
26 | RCSID("$OpenBSD: nchan.c,v 1.22 2001/01/21 19:05:52 markus Exp $"); | 26 | RCSID("$OpenBSD: nchan.c,v 1.23 2001/02/28 08:54:55 markus Exp $"); |
27 | 27 | ||
28 | #include "ssh1.h" | 28 | #include "ssh1.h" |
29 | #include "ssh2.h" | 29 | #include "ssh2.h" |
@@ -54,9 +54,6 @@ static void chan_send_oclose1(Channel *c); | |||
54 | static void chan_send_close2(Channel *c); | 54 | static void chan_send_close2(Channel *c); |
55 | static void chan_send_eof2(Channel *c); | 55 | static void chan_send_eof2(Channel *c); |
56 | 56 | ||
57 | /* channel cleanup */ | ||
58 | chan_event_fn *chan_delete_if_full_closed = NULL; | ||
59 | |||
60 | /* helper */ | 57 | /* helper */ |
61 | static void chan_shutdown_write(Channel *c); | 58 | static void chan_shutdown_write(Channel *c); |
62 | static void chan_shutdown_read(Channel *c); | 59 | static void chan_shutdown_read(Channel *c); |
@@ -249,16 +246,6 @@ chan_send_oclose1(Channel *c) | |||
249 | break; | 246 | break; |
250 | } | 247 | } |
251 | } | 248 | } |
252 | static void | ||
253 | chan_delete_if_full_closed1(Channel *c) | ||
254 | { | ||
255 | debug3("channel %d: chan_delete_if_full_closed1: istate %d ostate %d", | ||
256 | c->self, c->istate, c->ostate); | ||
257 | if (c->istate == CHAN_INPUT_CLOSED && c->ostate == CHAN_OUTPUT_CLOSED) { | ||
258 | debug("channel %d: full closed", c->self); | ||
259 | channel_free(c->self); | ||
260 | } | ||
261 | } | ||
262 | 249 | ||
263 | /* | 250 | /* |
264 | * the same for SSH2 | 251 | * the same for SSH2 |
@@ -401,24 +388,46 @@ chan_send_close2(Channel *c) | |||
401 | c->flags |= CHAN_CLOSE_SENT; | 388 | c->flags |= CHAN_CLOSE_SENT; |
402 | } | 389 | } |
403 | } | 390 | } |
404 | static void | 391 | |
405 | chan_delete_if_full_closed2(Channel *c) | 392 | /* shared */ |
393 | |||
394 | int | ||
395 | chan_is_dead(Channel *c) | ||
406 | { | 396 | { |
407 | debug3("channel %d: chan_delete_if_full_closed2: istate %d ostate %d", | 397 | if (c->istate != CHAN_INPUT_CLOSED || c->ostate != CHAN_OUTPUT_CLOSED) |
408 | c->self, c->istate, c->ostate); | 398 | return 0; |
409 | if (c->istate == CHAN_INPUT_CLOSED && c->ostate == CHAN_OUTPUT_CLOSED) { | 399 | if (!compat20) { |
400 | debug("channel %d: is dead", c->self); | ||
401 | return 1; | ||
402 | } | ||
403 | /* | ||
404 | * we have to delay the close message if the efd (for stderr) is | ||
405 | * still active | ||
406 | */ | ||
407 | if (((c->extended_usage != CHAN_EXTENDED_IGNORE) && | ||
408 | buffer_len(&c->extended) > 0) | ||
409 | #if 0 | ||
410 | || ((c->extended_usage == CHAN_EXTENDED_READ) && | ||
411 | c->efd != -1) | ||
412 | #endif | ||
413 | ) { | ||
414 | debug2("channel %d: active efd: %d len %d type %s", | ||
415 | c->self, c->efd, buffer_len(&c->extended), | ||
416 | c->extended_usage==CHAN_EXTENDED_READ ? | ||
417 | "read": "write"); | ||
418 | } else { | ||
410 | if (!(c->flags & CHAN_CLOSE_SENT)) { | 419 | if (!(c->flags & CHAN_CLOSE_SENT)) { |
411 | chan_send_close2(c); | 420 | chan_send_close2(c); |
412 | } | 421 | } |
413 | if ((c->flags & CHAN_CLOSE_SENT) && | 422 | if ((c->flags & CHAN_CLOSE_SENT) && |
414 | (c->flags & CHAN_CLOSE_RCVD)) { | 423 | (c->flags & CHAN_CLOSE_RCVD)) { |
415 | debug("channel %d: full closed2", c->self); | 424 | debug("channel %d: is dead", c->self); |
416 | channel_free(c->self); | 425 | return 1; |
417 | } | 426 | } |
418 | } | 427 | } |
428 | return 0; | ||
419 | } | 429 | } |
420 | 430 | ||
421 | /* shared */ | ||
422 | void | 431 | void |
423 | chan_init_iostates(Channel *c) | 432 | chan_init_iostates(Channel *c) |
424 | { | 433 | { |
@@ -439,8 +448,6 @@ chan_init(void) | |||
439 | chan_rcvd_ieof = chan_rcvd_ieof2; | 448 | chan_rcvd_ieof = chan_rcvd_ieof2; |
440 | chan_write_failed = chan_write_failed2; | 449 | chan_write_failed = chan_write_failed2; |
441 | chan_obuf_empty = chan_obuf_empty2; | 450 | chan_obuf_empty = chan_obuf_empty2; |
442 | |||
443 | chan_delete_if_full_closed = chan_delete_if_full_closed2; | ||
444 | } else { | 451 | } else { |
445 | chan_rcvd_oclose = chan_rcvd_oclose1; | 452 | chan_rcvd_oclose = chan_rcvd_oclose1; |
446 | chan_read_failed = chan_read_failed_12; | 453 | chan_read_failed = chan_read_failed_12; |
@@ -449,8 +456,6 @@ chan_init(void) | |||
449 | chan_rcvd_ieof = chan_rcvd_ieof1; | 456 | chan_rcvd_ieof = chan_rcvd_ieof1; |
450 | chan_write_failed = chan_write_failed1; | 457 | chan_write_failed = chan_write_failed1; |
451 | chan_obuf_empty = chan_obuf_empty1; | 458 | chan_obuf_empty = chan_obuf_empty1; |
452 | |||
453 | chan_delete_if_full_closed = chan_delete_if_full_closed1; | ||
454 | } | 459 | } |
455 | } | 460 | } |
456 | 461 | ||