|
Lines 155-160
static int connection_out; /* Connection
Link Here
|
| 155 |
static int need_rekeying; /* Set to non-zero if rekeying is requested. */ |
155 |
static int need_rekeying; /* Set to non-zero if rekeying is requested. */ |
| 156 |
static int session_closed; /* In SSH2: login session closed. */ |
156 |
static int session_closed; /* In SSH2: login session closed. */ |
| 157 |
static u_int x11_refuse_time; /* If >0, refuse x11 opens after this time. */ |
157 |
static u_int x11_refuse_time; /* If >0, refuse x11 opens after this time. */ |
|
|
158 |
static time_t server_alive_time; /* Time to do server_alive_check */ |
| 158 |
|
159 |
|
| 159 |
static void client_init_dispatch(struct ssh *ssh); |
160 |
static void client_init_dispatch(struct ssh *ssh); |
| 160 |
int session_ident = -1; |
161 |
int session_ident = -1; |
|
Lines 488-494
client_wait_until_can_do_something(struc
Link Here
|
| 488 |
{ |
489 |
{ |
| 489 |
struct timeval tv, *tvp; |
490 |
struct timeval tv, *tvp; |
| 490 |
int timeout_secs; |
491 |
int timeout_secs; |
| 491 |
time_t minwait_secs = 0, server_alive_time = 0, now = monotime(); |
492 |
time_t minwait_secs = 0, now = monotime(); |
| 492 |
int r, ret; |
493 |
int r, ret; |
| 493 |
|
494 |
|
| 494 |
/* Add any selections by the channel mechanism. */ |
495 |
/* Add any selections by the channel mechanism. */ |
|
Lines 517-526
client_wait_until_can_do_something(struc
Link Here
|
| 517 |
*/ |
518 |
*/ |
| 518 |
|
519 |
|
| 519 |
timeout_secs = INT_MAX; /* we use INT_MAX to mean no timeout */ |
520 |
timeout_secs = INT_MAX; /* we use INT_MAX to mean no timeout */ |
| 520 |
if (options.server_alive_interval > 0) { |
521 |
if (options.server_alive_interval > 0) |
| 521 |
timeout_secs = options.server_alive_interval; |
522 |
timeout_secs = MAXIMUM(server_alive_time - now, 0); |
| 522 |
server_alive_time = now + options.server_alive_interval; |
|
|
| 523 |
} |
| 524 |
if (options.rekey_interval > 0 && !rekeying) |
523 |
if (options.rekey_interval > 0 && !rekeying) |
| 525 |
timeout_secs = MINIMUM(timeout_secs, |
524 |
timeout_secs = MINIMUM(timeout_secs, |
| 526 |
ssh_packet_get_rekey_timeout(ssh)); |
525 |
ssh_packet_get_rekey_timeout(ssh)); |
|
Lines 558-570
client_wait_until_can_do_something(struc
Link Here
|
| 558 |
"select: %s\r\n", strerror(errno))) != 0) |
557 |
"select: %s\r\n", strerror(errno))) != 0) |
| 559 |
fatal("%s: buffer error: %s", __func__, ssh_err(r)); |
558 |
fatal("%s: buffer error: %s", __func__, ssh_err(r)); |
| 560 |
quit_pending = 1; |
559 |
quit_pending = 1; |
| 561 |
} else if (ret == 0) { |
560 |
} else { |
| 562 |
/* |
561 |
/* |
| 563 |
* Timeout. Could have been either keepalive or rekeying. |
562 |
* See if ServerAlive check is needed. We can't rely on the |
| 564 |
* Keepalive we check here, rekeying is checked in clientloop. |
563 |
* select timing out since traffic on the client side such |
|
|
564 |
* as port forwards can keep waking it up. |
| 565 |
*/ |
565 |
*/ |
| 566 |
if (server_alive_time != 0 && server_alive_time <= monotime()) |
566 |
if (options.server_alive_interval > 0 && |
|
|
567 |
!FD_ISSET(connection_in, *readsetp) && |
| 568 |
(now = monotime()) >= server_alive_time) { |
| 569 |
server_alive_time = now + options.server_alive_interval; |
| 567 |
server_alive_check(ssh); |
570 |
server_alive_check(ssh); |
|
|
571 |
} |
| 568 |
} |
572 |
} |
| 569 |
|
573 |
|
| 570 |
} |
574 |
} |
|
Lines 606-611
client_process_net_input(struct ssh *ssh
Link Here
|
| 606 |
* the packet subsystem. |
610 |
* the packet subsystem. |
| 607 |
*/ |
611 |
*/ |
| 608 |
if (FD_ISSET(connection_in, readset)) { |
612 |
if (FD_ISSET(connection_in, readset)) { |
|
|
613 |
if (options.server_alive_interval > 0) |
| 614 |
server_alive_time = monotime() + |
| 615 |
options.server_alive_interval; |
| 609 |
/* Read as much as possible. */ |
616 |
/* Read as much as possible. */ |
| 610 |
len = read(connection_in, buf, sizeof(buf)); |
617 |
len = read(connection_in, buf, sizeof(buf)); |
| 611 |
if (len == 0) { |
618 |
if (len == 0) { |
|
Lines 1305-1310
client_loop(struct ssh *ssh, int have_pt
Link Here
|
| 1305 |
channel_register_cleanup(ssh, session_ident, |
1312 |
channel_register_cleanup(ssh, session_ident, |
| 1306 |
client_channel_closed, 0); |
1313 |
client_channel_closed, 0); |
| 1307 |
} |
1314 |
} |
|
|
1315 |
|
| 1316 |
if (options.server_alive_interval > 0) |
| 1317 |
server_alive_time = monotime() + options.server_alive_interval; |
| 1308 |
|
1318 |
|
| 1309 |
/* Main loop of the client for the interactive session mode. */ |
1319 |
/* Main loop of the client for the interactive session mode. */ |
| 1310 |
while (!quit_pending) { |
1320 |
while (!quit_pending) { |