Skip to content

Commit

Permalink
fix off-by-one error that would sometime ignore the latest connection
Browse files Browse the repository at this point in the history
  • Loading branch information
yrutschle committed Mar 31, 2024
1 parent 5f1c1b1 commit 1799a81
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sslh-select.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static void watchers_init(watchers** w, struct listen_endpoint* listen_sockets,
void watchers_add_read(watchers* w, int fd)
{
FD_SET(fd, &w->fds_r);
if (fd > w->max_fd)
if (fd + 1 > w->max_fd)
w->max_fd = fd + 1;
}

Expand Down Expand Up @@ -148,7 +148,7 @@ void main_loop(struct listen_endpoint listen_sockets[], int num_addr_listen)

print_message(msg_fd, "selecting... max_fd=%d num_probing=%d\n",
fd_info.watchers->max_fd, fd_info.num_probing);
res = select(fd_info.watchers->max_fd + 1, &readfds, &writefds,
res = select(fd_info.watchers->max_fd, &readfds, &writefds,
NULL, fd_info.num_probing ? &tv : NULL);
if (res < 0)
perror("select");
Expand Down

0 comments on commit 1799a81

Please sign in to comment.