Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/child.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "conf.h"

static vector_t listen_fds;
volatile int children; /* referenced from main.c */

/*
* Stores the internal data needed for each child (connection)
Expand Down Expand Up @@ -202,6 +203,11 @@ static void child_main (struct child_s *ptr)
ptr->connects = 0;
srand(time(NULL));

#ifdef FILTER_ENABLE
if (config.filter)
filter_init ();
#endif /* FILTER_ENABLE */

/*
* We have to wait for connections on multiple fds,
* so use select.
Expand All @@ -226,7 +232,6 @@ static void child_main (struct child_s *ptr)
FD_SET(*fd, &rfds);
maxfd = max(maxfd, *fd);
}

ptr->status = T_WAITING;

clilen = sizeof(struct sockaddr_storage);
Expand Down Expand Up @@ -299,7 +304,8 @@ static void child_main (struct child_s *ptr)
* Make sure no error occurred...
*/
if (connfd < 0) {
log_message (LOG_ERR,
if (errno != EAGAIN) /* do not spam the logs */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

under which circumstances do you get an EAGAIN here ?

log_message (LOG_ERR,
"Accept returned an error (%s) ... retrying.",
strerror (errno));
continue;
Expand Down Expand Up @@ -358,8 +364,10 @@ static pid_t child_make (struct child_s *ptr)
{
pid_t pid;

if ((pid = fork ()) > 0)
if ((pid = fork ()) > 0) {
++children;
return pid; /* parent */
}

/*
* Reset the SIGNALS so that the child can be reaped.
Expand Down Expand Up @@ -513,10 +521,7 @@ void child_main_loop (void)
* This should actually be handled somehow...
*/
reload_config ();

#ifdef FILTER_ENABLE
filter_reload ();
#endif /* FILTER_ENABLE */

/* propagate filter reload to all children */
child_kill_children (SIGHUP);
Expand Down
4 changes: 3 additions & 1 deletion src/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ void filter_init (void)

fd = fopen (config.filter, "r");
if (!fd) {
return;
log_message(LOG_ERR, "Can't read the filter from %s: %s",
config.filter, strerror(errno));
exit(3);
}

p = NULL;
Expand Down
6 changes: 1 addition & 5 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
struct config_s config;
struct config_s config_defaults;
unsigned int received_sighup = FALSE; /* boolean */
extern volatile int children; /* defined in child.c */

/*
* Handle a signal
Expand Down Expand Up @@ -374,11 +375,6 @@ main (int argc, char **argv)
exit (EX_OSERR);
}

#ifdef FILTER_ENABLE
if (config.filter)
filter_init ();
#endif /* FILTER_ENABLE */

/* Start listening on the selected port. */
if (child_listening_sockets(config.listen_addrs, config.port) < 0) {
fprintf (stderr, "%s: Could not create listening sockets.\n",
Expand Down