summaryrefslogtreecommitdiff
path: root/serverloop.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2001-10-10 15:01:40 +1000
committerDamien Miller <djm@mindrot.org>2001-10-10 15:01:40 +1000
commit8c3902afde376c2efbd587ea63043e7abceabaff (patch)
tree4f2cb45e30a51b269af2c803fee7f6d33d9d3202 /serverloop.c
parentaf5f2e641c2a204943df3895a612ce334195def5 (diff)
- markus@cvs.openbsd.org 2001/10/04 15:12:37
[serverloop.c] client_alive_check cleanup
Diffstat (limited to 'serverloop.c')
-rw-r--r--serverloop.c51
1 files changed, 24 insertions, 27 deletions
diff --git a/serverloop.c b/serverloop.c
index 049ea4e46..4577cc804 100644
--- a/serverloop.c
+++ b/serverloop.c
@@ -35,7 +35,7 @@
35 */ 35 */
36 36
37#include "includes.h" 37#include "includes.h"
38RCSID("$OpenBSD: serverloop.c,v 1.78 2001/10/04 15:05:40 markus Exp $"); 38RCSID("$OpenBSD: serverloop.c,v 1.79 2001/10/04 15:12:37 markus Exp $");
39 39
40#include "xmalloc.h" 40#include "xmalloc.h"
41#include "packet.h" 41#include "packet.h"
@@ -80,6 +80,7 @@ static int connection_in; /* Connection to client (input). */
80static int connection_out; /* Connection to client (output). */ 80static int connection_out; /* Connection to client (output). */
81static int connection_closed = 0; /* Connection to client closed. */ 81static int connection_closed = 0; /* Connection to client closed. */
82static u_int buffer_high; /* "Soft" max buffer size. */ 82static u_int buffer_high; /* "Soft" max buffer size. */
83static int client_alive_timeouts = 0;
83 84
84/* 85/*
85 * This SIGCHLD kludge is used to detect when the child exits. The server 86 * This SIGCHLD kludge is used to detect when the child exits. The server
@@ -91,8 +92,6 @@ static volatile int child_terminated; /* The child has terminated. */
91/* prototypes */ 92/* prototypes */
92static void server_init_dispatch(void); 93static void server_init_dispatch(void);
93 94
94int client_alive_timeouts = 0;
95
96static void 95static void
97sigchld_handler(int sig) 96sigchld_handler(int sig)
98{ 97{
@@ -161,6 +160,26 @@ make_packets_from_stdout_data(void)
161 } 160 }
162} 161}
163 162
163static void
164client_alive_check(void)
165{
166 int id;
167
168 /* timeout, check to see how many we have had */
169 if (++client_alive_timeouts > options.client_alive_count_max)
170 packet_disconnect("Timeout, your session not responding.");
171
172 id = channel_find_open();
173 if (id == -1)
174 packet_disconnect("No open channels after timeout!");
175 /*
176 * send a bogus channel request with "wantreply",
177 * we should get back a failure
178 */
179 channel_request_start(id, "keepalive@openssh.com", 1);
180 packet_send();
181}
182
164/* 183/*
165 * Sleep in select() until we can do something. This will initialize the 184 * Sleep in select() until we can do something. This will initialize the
166 * select masks. Upon return, the masks will indicate which descriptors 185 * select masks. Upon return, the masks will indicate which descriptors
@@ -261,30 +280,8 @@ retry_select:
261 else 280 else
262 goto retry_select; 281 goto retry_select;
263 } 282 }
264 if (ret == 0 && client_alive_scheduled) { 283 if (ret == 0 && client_alive_scheduled)
265 /* timeout, check to see how many we have had */ 284 client_alive_check();
266 client_alive_timeouts++;
267
268 if (client_alive_timeouts > options.client_alive_count_max ) {
269 packet_disconnect(
270 "Timeout, your session not responding.");
271 } else {
272 /*
273 * send a bogus channel request with "wantreply"
274 * we should get back a failure
275 */
276 int id;
277
278 id = channel_find_open();
279 if (id != -1) {
280 channel_request_start(id,
281 "keepalive@openssh.com", 1);
282 packet_send();
283 } else
284 packet_disconnect(
285 "No open channels after timeout!");
286 }
287 }
288} 285}
289 286
290/* 287/*