summaryrefslogtreecommitdiff
path: root/channels.c
diff options
context:
space:
mode:
Diffstat (limited to 'channels.c')
-rw-r--r--channels.c28
1 files changed, 20 insertions, 8 deletions
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"
43RCSID("$OpenBSD: channels.c,v 1.117 2001/05/19 19:57:09 stevesk Exp $"); 43RCSID("$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,
280void 280void
281channel_close_fds(Channel *c) 281channel_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
304channel_free(Channel *c) 307channel_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: