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
This commit is contained in:
parent
dc41b35333
commit
b131f45cbb
36
src/child.c
36
src/child.c
@ -206,27 +206,27 @@ static void child_main (struct child_s *ptr)
|
|||||||
* We have to wait for connections on multiple fds,
|
* We have to wait for connections on multiple fds,
|
||||||
* so use select.
|
* so use select.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
FD_ZERO(&rfds);
|
|
||||||
|
|
||||||
for (i = 0; i < vector_length(listen_fds); i++) {
|
|
||||||
int *fd = (int *) vector_getentry(listen_fds, i, NULL);
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
FD_SET(*fd, &rfds);
|
|
||||||
maxfd = max(maxfd, *fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (!config.quit) {
|
while (!config.quit) {
|
||||||
|
|
||||||
int listenfd = -1;
|
int listenfd = -1;
|
||||||
|
|
||||||
|
FD_ZERO(&rfds);
|
||||||
|
|
||||||
|
for (i = 0; i < vector_length(listen_fds); i++) {
|
||||||
|
int *fd = (int *) vector_getentry(listen_fds, i, NULL);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
FD_SET(*fd, &rfds);
|
||||||
|
maxfd = max(maxfd, *fd);
|
||||||
|
}
|
||||||
|
|
||||||
ptr->status = T_WAITING;
|
ptr->status = T_WAITING;
|
||||||
|
|
||||||
clilen = sizeof(struct sockaddr_storage);
|
clilen = sizeof(struct sockaddr_storage);
|
||||||
|
Loading…
Reference in New Issue
Block a user