diff options
author | rofl0r <rofl0r@users.noreply.github.com> | 2018-12-15 17:09:04 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-15 17:09:04 +0000 |
commit | b131f45cbb4b829d7e520392a2dcfc9b41044351 (patch) | |
tree | a3af65b9d42d1aa4de4b7e50c4b6689a3be03f6d | |
parent | dc41b3533326d745c65afaea4cb34c229a31d0c3 (diff) |
child.c: properly initialize fdset for each select() call (#216)
it was reported that because the fdset was only initialized once,
tinyproxy would fail to properly listen on more than one interface.
closes #214
closes #127
-rw-r--r-- | src/child.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/child.c b/src/child.c index effb2ae..60f8ead 100644 --- a/src/child.c +++ b/src/child.c @@ -206,26 +206,26 @@ static void child_main (struct child_s *ptr) * We have to wait for connections on multiple fds, * so use select. */ + while (!config.quit) { - FD_ZERO(&rfds); + int listenfd = -1; - for (i = 0; i < vector_length(listen_fds); i++) { - int *fd = (int *) vector_getentry(listen_fds, i, NULL); + FD_ZERO(&rfds); - ret = socket_nonblocking(*fd); - if (ret != 0) { - log_message(LOG_ERR, "Failed to set the listening " - "socket %d to non-blocking: %s", - fd, strerror(errno)); - exit(1); - } + for (i = 0; i < vector_length(listen_fds); i++) { + int *fd = (int *) vector_getentry(listen_fds, i, NULL); - FD_SET(*fd, &rfds); - maxfd = max(maxfd, *fd); - } + ret = socket_nonblocking(*fd); + if (ret != 0) { + log_message(LOG_ERR, "Failed to set the listening " + "socket %d to non-blocking: %s", + fd, strerror(errno)); + exit(1); + } - while (!config.quit) { - int listenfd = -1; + FD_SET(*fd, &rfds); + maxfd = max(maxfd, *fd); + } ptr->status = T_WAITING; |