diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | channels.c | 28 | ||||
-rw-r--r-- | channels.h | 5 | ||||
-rw-r--r-- | nchan.c | 10 |
4 files changed, 35 insertions, 14 deletions
@@ -65,6 +65,10 @@ | |||
65 | - markus@cvs.openbsd.org 2001/05/28 22:51:11 | 65 | - markus@cvs.openbsd.org 2001/05/28 22:51:11 |
66 | [cipher.c cipher.h] | 66 | [cipher.c cipher.h] |
67 | simpler 3des for ssh1 | 67 | simpler 3des for ssh1 |
68 | - markus@cvs.openbsd.org 2001/05/28 23:14:49 | ||
69 | [channels.c channels.h nchan.c] | ||
70 | undo broken channel fix and try a different one. there | ||
71 | should be still some select errors... | ||
68 | 72 | ||
69 | 20010528 | 73 | 20010528 |
70 | - (tim) [conifgure.in] add setvbuf test needed for sftp-int.c | 74 | - (tim) [conifgure.in] add setvbuf test needed for sftp-int.c |
@@ -5495,4 +5499,4 @@ | |||
5495 | - Wrote replacements for strlcpy and mkdtemp | 5499 | - Wrote replacements for strlcpy and mkdtemp |
5496 | - Released 1.0pre1 | 5500 | - Released 1.0pre1 |
5497 | 5501 | ||
5498 | $Id: ChangeLog,v 1.1242 2001/06/05 20:50:16 mouring Exp $ | 5502 | $Id: ChangeLog,v 1.1243 2001/06/05 20:52:50 mouring Exp $ |
diff --git a/channels.c b/channels.c index d6540560a..3eccb849e 100644 --- a/channels.c +++ b/channels.c | |||
@@ -40,7 +40,7 @@ | |||
40 | */ | 40 | */ |
41 | 41 | ||
42 | #include "includes.h" | 42 | #include "includes.h" |
43 | RCSID("$OpenBSD: channels.c,v 1.117 2001/05/19 19:57:09 stevesk Exp $"); | 43 | RCSID("$OpenBSD: channels.c,v 1.118 2001/05/28 23:14:49 markus Exp $"); |
44 | 44 | ||
45 | #include <openssl/rsa.h> | 45 | #include <openssl/rsa.h> |
46 | #include <openssl/dsa.h> | 46 | #include <openssl/dsa.h> |
@@ -280,6 +280,9 @@ channel_new(char *ctype, int type, int rfd, int wfd, int efd, | |||
280 | void | 280 | void |
281 | channel_close_fds(Channel *c) | 281 | channel_close_fds(Channel *c) |
282 | { | 282 | { |
283 | debug3("channel_close_fds: channel %d: r %d w %d e %d", | ||
284 | c->self, c->rfd, c->wfd, c->efd); | ||
285 | |||
283 | if (c->sock != -1) { | 286 | if (c->sock != -1) { |
284 | close(c->sock); | 287 | close(c->sock); |
285 | c->sock = -1; | 288 | c->sock = -1; |
@@ -304,9 +307,17 @@ void | |||
304 | channel_free(Channel *c) | 307 | channel_free(Channel *c) |
305 | { | 308 | { |
306 | char *s; | 309 | char *s; |
310 | int i, n; | ||
311 | |||
312 | for (n = 0, i = 0; i < channels_alloc; i++) | ||
313 | if (channels[i]) | ||
314 | n++; | ||
315 | |||
316 | debug("channel_free: channel %d: (%s) nchannels: %d", c->self, | ||
317 | c->remote_name ? c->remote_name : "???", n); | ||
307 | 318 | ||
308 | s = channel_open_message(); | 319 | s = channel_open_message(); |
309 | debug("channel_free: channel %d: status: %s", c->self, s); | 320 | debug3("channel_free: status: %s", c->self, s); |
310 | xfree(s); | 321 | xfree(s); |
311 | 322 | ||
312 | if (c->dettach_user != NULL) { | 323 | if (c->dettach_user != NULL) { |
@@ -893,7 +904,7 @@ channel_handle_rfd(Channel *c, fd_set * readset, fd_set * writeset) | |||
893 | char buf[16*1024]; | 904 | char buf[16*1024]; |
894 | int len; | 905 | int len; |
895 | 906 | ||
896 | if (c->istate == CHAN_INPUT_OPEN && | 907 | if (c->rfd != -1 && |
897 | FD_ISSET(c->rfd, readset)) { | 908 | FD_ISSET(c->rfd, readset)) { |
898 | len = read(c->rfd, buf, sizeof(buf)); | 909 | len = read(c->rfd, buf, sizeof(buf)); |
899 | if (len < 0 && (errno == EINTR || errno == EAGAIN)) | 910 | if (len < 0 && (errno == EINTR || errno == EAGAIN)) |
@@ -932,8 +943,7 @@ channel_handle_wfd(Channel *c, fd_set * readset, fd_set * writeset) | |||
932 | int len; | 943 | int len; |
933 | 944 | ||
934 | /* Send buffered output data to the socket. */ | 945 | /* Send buffered output data to the socket. */ |
935 | if ((c->ostate == CHAN_OUTPUT_OPEN || | 946 | if (c->wfd != -1 && |
936 | c->ostate == CHAN_OUTPUT_WAIT_DRAIN) && | ||
937 | FD_ISSET(c->wfd, writeset) && | 947 | FD_ISSET(c->wfd, writeset) && |
938 | buffer_len(&c->output) > 0) { | 948 | buffer_len(&c->output) > 0) { |
939 | len = write(c->wfd, buffer_ptr(&c->output), | 949 | len = write(c->wfd, buffer_ptr(&c->output), |
@@ -1164,9 +1174,8 @@ channel_handler(chan_fn *ftab[], fd_set * readset, fd_set * writeset) | |||
1164 | c = channels[i]; | 1174 | c = channels[i]; |
1165 | if (c == NULL) | 1175 | if (c == NULL) |
1166 | continue; | 1176 | continue; |
1167 | if (ftab[c->type] == NULL) | 1177 | if (ftab[c->type] != NULL) |
1168 | continue; | 1178 | (*ftab[c->type])(c, readset, writeset); |
1169 | (*ftab[c->type])(c, readset, writeset); | ||
1170 | if (chan_is_dead(c)) { | 1179 | if (chan_is_dead(c)) { |
1171 | /* | 1180 | /* |
1172 | * we have to remove the fd's from the select mask | 1181 | * we have to remove the fd's from the select mask |
@@ -1715,6 +1724,7 @@ channel_still_open() | |||
1715 | case SSH_CHANNEL_AUTH_SOCKET: | 1724 | case SSH_CHANNEL_AUTH_SOCKET: |
1716 | case SSH_CHANNEL_DYNAMIC: | 1725 | case SSH_CHANNEL_DYNAMIC: |
1717 | case SSH_CHANNEL_CONNECTING: | 1726 | case SSH_CHANNEL_CONNECTING: |
1727 | case SSH_CHANNEL_ZOMBIE: | ||
1718 | continue; | 1728 | continue; |
1719 | case SSH_CHANNEL_LARVAL: | 1729 | case SSH_CHANNEL_LARVAL: |
1720 | if (!compat20) | 1730 | if (!compat20) |
@@ -1757,6 +1767,7 @@ channel_find_open() | |||
1757 | case SSH_CHANNEL_RPORT_LISTENER: | 1767 | case SSH_CHANNEL_RPORT_LISTENER: |
1758 | case SSH_CHANNEL_OPENING: | 1768 | case SSH_CHANNEL_OPENING: |
1759 | case SSH_CHANNEL_CONNECTING: | 1769 | case SSH_CHANNEL_CONNECTING: |
1770 | case SSH_CHANNEL_ZOMBIE: | ||
1760 | continue; | 1771 | continue; |
1761 | case SSH_CHANNEL_LARVAL: | 1772 | case SSH_CHANNEL_LARVAL: |
1762 | case SSH_CHANNEL_AUTH_SOCKET: | 1773 | case SSH_CHANNEL_AUTH_SOCKET: |
@@ -1804,6 +1815,7 @@ channel_open_message() | |||
1804 | case SSH_CHANNEL_RPORT_LISTENER: | 1815 | case SSH_CHANNEL_RPORT_LISTENER: |
1805 | case SSH_CHANNEL_CLOSED: | 1816 | case SSH_CHANNEL_CLOSED: |
1806 | case SSH_CHANNEL_AUTH_SOCKET: | 1817 | case SSH_CHANNEL_AUTH_SOCKET: |
1818 | case SSH_CHANNEL_ZOMBIE: | ||
1807 | continue; | 1819 | continue; |
1808 | case SSH_CHANNEL_LARVAL: | 1820 | case SSH_CHANNEL_LARVAL: |
1809 | case SSH_CHANNEL_OPENING: | 1821 | case SSH_CHANNEL_OPENING: |
diff --git a/channels.h b/channels.h index 6739b2214..55d31854e 100644 --- a/channels.h +++ b/channels.h | |||
@@ -32,7 +32,7 @@ | |||
32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
33 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 33 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
34 | */ | 34 | */ |
35 | /* RCSID("$OpenBSD: channels.h,v 1.32 2001/05/04 23:47:33 markus Exp $"); */ | 35 | /* RCSID("$OpenBSD: channels.h,v 1.33 2001/05/28 23:14:49 markus Exp $"); */ |
36 | 36 | ||
37 | #ifndef CHANNELS_H | 37 | #ifndef CHANNELS_H |
38 | #define CHANNELS_H | 38 | #define CHANNELS_H |
@@ -53,7 +53,8 @@ | |||
53 | #define SSH_CHANNEL_RPORT_LISTENER 11 /* Listening to a R-style port */ | 53 | #define SSH_CHANNEL_RPORT_LISTENER 11 /* Listening to a R-style port */ |
54 | #define SSH_CHANNEL_CONNECTING 12 | 54 | #define SSH_CHANNEL_CONNECTING 12 |
55 | #define SSH_CHANNEL_DYNAMIC 13 | 55 | #define SSH_CHANNEL_DYNAMIC 13 |
56 | #define SSH_CHANNEL_MAX_TYPE 14 | 56 | #define SSH_CHANNEL_ZOMBIE 14 /* Almost dead. */ |
57 | #define SSH_CHANNEL_MAX_TYPE 15 | ||
57 | 58 | ||
58 | #define SSH_CHANNEL_PATH_LEN 30 | 59 | #define SSH_CHANNEL_PATH_LEN 30 |
59 | 60 | ||
@@ -23,7 +23,7 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include "includes.h" | 25 | #include "includes.h" |
26 | RCSID("$OpenBSD: nchan.c,v 1.25 2001/05/16 22:09:21 markus Exp $"); | 26 | RCSID("$OpenBSD: nchan.c,v 1.26 2001/05/28 23:14:49 markus Exp $"); |
27 | 27 | ||
28 | #include "ssh1.h" | 28 | #include "ssh1.h" |
29 | #include "ssh2.h" | 29 | #include "ssh2.h" |
@@ -394,14 +394,16 @@ chan_send_close2(Channel *c) | |||
394 | void | 394 | void |
395 | chan_mark_dead(Channel *c) | 395 | chan_mark_dead(Channel *c) |
396 | { | 396 | { |
397 | c->flags |= CHAN_DEAD; | 397 | c->type = SSH_CHANNEL_ZOMBIE; |
398 | } | 398 | } |
399 | 399 | ||
400 | int | 400 | int |
401 | chan_is_dead(Channel *c) | 401 | chan_is_dead(Channel *c) |
402 | { | 402 | { |
403 | if (c->flags & CHAN_DEAD) | 403 | if (c->type == SSH_CHANNEL_ZOMBIE) { |
404 | debug("channel %d: zombie", c->self); | ||
404 | return 1; | 405 | return 1; |
406 | } | ||
405 | if (c->istate != CHAN_INPUT_CLOSED || c->ostate != CHAN_OUTPUT_CLOSED) | 407 | if (c->istate != CHAN_INPUT_CLOSED || c->ostate != CHAN_OUTPUT_CLOSED) |
406 | return 0; | 408 | return 0; |
407 | if (!compat20) { | 409 | if (!compat20) { |
@@ -484,6 +486,7 @@ chan_shutdown_write(Channel *c) | |||
484 | if (close(c->wfd) < 0) | 486 | if (close(c->wfd) < 0) |
485 | log("channel %d: chan_shutdown_write: close() failed for fd%d: %.100s", | 487 | log("channel %d: chan_shutdown_write: close() failed for fd%d: %.100s", |
486 | c->self, c->wfd, strerror(errno)); | 488 | c->self, c->wfd, strerror(errno)); |
489 | c->wfd = -1; | ||
487 | } | 490 | } |
488 | } | 491 | } |
489 | static void | 492 | static void |
@@ -506,5 +509,6 @@ chan_shutdown_read(Channel *c) | |||
506 | if (close(c->rfd) < 0) | 509 | if (close(c->rfd) < 0) |
507 | log("channel %d: chan_shutdown_read: close() failed for fd%d: %.100s", | 510 | log("channel %d: chan_shutdown_read: close() failed for fd%d: %.100s", |
508 | c->self, c->rfd, strerror(errno)); | 511 | c->self, c->rfd, strerror(errno)); |
512 | c->rfd = -1; | ||
509 | } | 513 | } |
510 | } | 514 | } |