Bugzilla – Attachment 3518 Details for
Bug 3304
SSH client MUX to multiple hosts causes select: Bad file descriptor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
debug select failures
debug-select.diff (text/plain), 2.96 KB, created by
Damien Miller
on 2021-05-13 07:45:54 AEST
(
hide
)
Description:
debug select failures
Filename:
MIME Type:
Creator:
Damien Miller
Created:
2021-05-13 07:45:54 AEST
Size:
2.96 KB
patch
obsolete
>diff --git a/channels.c b/channels.c >index 32d1f6178..6834bc56d 100644 >--- a/channels.c >+++ b/channels.c >@@ -2438,6 +2438,7 @@ channel_prepare_select(struct ssh *ssh, fd_set **readsetp, fd_set **writesetp, > { > u_int n, sz, nfdset; > >+ debug_f("entering, maxfd = %d", *maxfdp); > channel_before_prepare_select(ssh); /* might update channel_max_fd */ > > n = MAXIMUM(*maxfdp, ssh->chanctxt->channel_max_fd); >@@ -2458,9 +2459,11 @@ channel_prepare_select(struct ssh *ssh, fd_set **readsetp, fd_set **writesetp, > memset(*readsetp, 0, sz); > memset(*writesetp, 0, sz); > >+ debug_f("before handler, maxfd = %d", *maxfdp); > if (!ssh_packet_is_rekeying(ssh)) > channel_handler(ssh, CHAN_PRE, *readsetp, *writesetp, > minwait_secs); >+ debug_f("done, maxfd = %d", *maxfdp); > } > > /* >diff --git a/clientloop.c b/clientloop.c >index 219f0e904..2a52425ed 100644 >--- a/clientloop.c >+++ b/clientloop.c >@@ -85,6 +85,7 @@ > #include <pwd.h> > #include <unistd.h> > #include <limits.h> >+#include <fcntl.h> > > #include "openbsd-compat/sys-queue.h" > #include "xmalloc.h" >@@ -492,6 +493,25 @@ server_alive_check(struct ssh *ssh) > schedule_server_alive_check(); > } > >+static void >+debug_bad_fdset(const char *what, fd_set *set, int maxfd) >+{ >+ int i; >+ >+ for (i = 0; i < maxfd; i++) { >+ if (!FD_ISSET(i, set) || fcntl(i, F_GETFL) != -1) >+ continue; >+ debug_f("select: %s bad fd %i", what, i); >+ } >+} >+ >+static void >+debug_bad_select(fd_set *readset, fd_set *writeset, int maxfd) >+{ >+ debug_bad_fdset("readset", readset, maxfd); >+ debug_bad_fdset("writeset", writeset, maxfd); >+} >+ > /* > * Waits until the client can do something (some data becomes available on > * one of the file descriptors). >@@ -504,7 +524,7 @@ client_wait_until_can_do_something(struct ssh *ssh, > struct timeval tv, *tvp; > int timeout_secs; > time_t minwait_secs = 0, now = monotime(); >- int r, ret; >+ int oerrno, r, ret; > > /* Add any selections by the channel mechanism. */ > channel_prepare_select(ssh, readsetp, writesetp, maxfdp, >@@ -553,9 +573,14 @@ client_wait_until_can_do_something(struct ssh *ssh, > tv.tv_usec = 0; > tvp = &tv; > } >- > ret = select((*maxfdp)+1, *readsetp, *writesetp, NULL, tvp); > if (ret == -1) { >+ if (errno != EINTR) { >+ oerrno = errno; >+ debug_f("select: %s", strerror(errno)); >+ debug_bad_select(*readsetp, *writesetp, *maxfdp); >+ errno = oerrno; >+ } > /* > * We have to clear the select masks, because we return. > * We have to return, because the mainloop checks for the flags >@@ -571,13 +596,14 @@ client_wait_until_can_do_something(struct ssh *ssh, > fatal_fr(r, "sshbuf_putf"); > quit_pending = 1; > } else if (options.server_alive_interval > 0 && !FD_ISSET(connection_in, >- *readsetp) && monotime() >= server_alive_time) >+ *readsetp) && monotime() >= server_alive_time) { > /* > * ServerAlive check is needed. We can't rely on the select > * timing out since traffic on the client side such as port > * forwards can keep waking it up. > */ > server_alive_check(ssh); >+ } > } > > static void
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 3304
:
3499
|
3500
|
3501
|
3502
|
3515
|
3516
|
3517
| 3518