|
Lines 85-90
Link Here
|
| 85 |
#include <pwd.h> |
85 |
#include <pwd.h> |
| 86 |
#include <unistd.h> |
86 |
#include <unistd.h> |
| 87 |
#include <limits.h> |
87 |
#include <limits.h> |
|
|
88 |
#include <fcntl.h> |
| 88 |
|
89 |
|
| 89 |
#include "openbsd-compat/sys-queue.h" |
90 |
#include "openbsd-compat/sys-queue.h" |
| 90 |
#include "xmalloc.h" |
91 |
#include "xmalloc.h" |
|
Lines 492-497
server_alive_check(struct ssh *ssh)
Link Here
|
| 492 |
schedule_server_alive_check(); |
493 |
schedule_server_alive_check(); |
| 493 |
} |
494 |
} |
| 494 |
|
495 |
|
|
|
496 |
static void |
| 497 |
debug_bad_fdset(const char *what, fd_set *set, int maxfd) |
| 498 |
{ |
| 499 |
int i; |
| 500 |
|
| 501 |
for (i = 0; i < maxfd; i++) { |
| 502 |
if (!FD_ISSET(i, set) || fcntl(i, F_GETFL) != -1) |
| 503 |
continue; |
| 504 |
debug_f("select: %s bad fd %i", what, i); |
| 505 |
} |
| 506 |
} |
| 507 |
|
| 508 |
static void |
| 509 |
debug_bad_select(fd_set *readset, fd_set *writeset, int maxfd) |
| 510 |
{ |
| 511 |
debug_bad_fdset("readset", readset, maxfd); |
| 512 |
debug_bad_fdset("writeset", writeset, maxfd); |
| 513 |
} |
| 514 |
|
| 495 |
/* |
515 |
/* |
| 496 |
* Waits until the client can do something (some data becomes available on |
516 |
* Waits until the client can do something (some data becomes available on |
| 497 |
* one of the file descriptors). |
517 |
* one of the file descriptors). |
|
Lines 504-510
client_wait_until_can_do_something(struct ssh *ssh,
Link Here
|
| 504 |
struct timeval tv, *tvp; |
524 |
struct timeval tv, *tvp; |
| 505 |
int timeout_secs; |
525 |
int timeout_secs; |
| 506 |
time_t minwait_secs = 0, now = monotime(); |
526 |
time_t minwait_secs = 0, now = monotime(); |
| 507 |
int r, ret; |
527 |
int oerrno, r, ret; |
| 508 |
|
528 |
|
| 509 |
/* Add any selections by the channel mechanism. */ |
529 |
/* Add any selections by the channel mechanism. */ |
| 510 |
channel_prepare_select(ssh, readsetp, writesetp, maxfdp, |
530 |
channel_prepare_select(ssh, readsetp, writesetp, maxfdp, |
|
Lines 553-561
client_wait_until_can_do_something(struct ssh *ssh,
Link Here
|
| 553 |
tv.tv_usec = 0; |
573 |
tv.tv_usec = 0; |
| 554 |
tvp = &tv; |
574 |
tvp = &tv; |
| 555 |
} |
575 |
} |
| 556 |
|
|
|
| 557 |
ret = select((*maxfdp)+1, *readsetp, *writesetp, NULL, tvp); |
576 |
ret = select((*maxfdp)+1, *readsetp, *writesetp, NULL, tvp); |
| 558 |
if (ret == -1) { |
577 |
if (ret == -1) { |
|
|
578 |
if (errno != EINTR) { |
| 579 |
oerrno = errno; |
| 580 |
debug_f("select: %s", strerror(errno)); |
| 581 |
debug_bad_select(*readsetp, *writesetp, *maxfdp); |
| 582 |
errno = oerrno; |
| 583 |
} |
| 559 |
/* |
584 |
/* |
| 560 |
* We have to clear the select masks, because we return. |
585 |
* We have to clear the select masks, because we return. |
| 561 |
* We have to return, because the mainloop checks for the flags |
586 |
* We have to return, because the mainloop checks for the flags |
|
Lines 571-583
client_wait_until_can_do_something(struct ssh *ssh,
Link Here
|
| 571 |
fatal_fr(r, "sshbuf_putf"); |
596 |
fatal_fr(r, "sshbuf_putf"); |
| 572 |
quit_pending = 1; |
597 |
quit_pending = 1; |
| 573 |
} else if (options.server_alive_interval > 0 && !FD_ISSET(connection_in, |
598 |
} else if (options.server_alive_interval > 0 && !FD_ISSET(connection_in, |
| 574 |
*readsetp) && monotime() >= server_alive_time) |
599 |
*readsetp) && monotime() >= server_alive_time) { |
| 575 |
/* |
600 |
/* |
| 576 |
* ServerAlive check is needed. We can't rely on the select |
601 |
* ServerAlive check is needed. We can't rely on the select |
| 577 |
* timing out since traffic on the client side such as port |
602 |
* timing out since traffic on the client side such as port |
| 578 |
* forwards can keep waking it up. |
603 |
* forwards can keep waking it up. |
| 579 |
*/ |
604 |
*/ |
| 580 |
server_alive_check(ssh); |
605 |
server_alive_check(ssh); |
|
|
606 |
} |
| 581 |
} |
607 |
} |
| 582 |
|
608 |
|
| 583 |
static void |
609 |
static void |