@@ -230,44 +230,44 @@ static int addrcmp(const struct sockaddr_storage *s1,
}
void add_child(struct child_process *cld, struct sockaddr *addr, socklen_t addrlen,
- struct child *firstborn , unsigned int *live_children)
+ struct child *first_child, unsigned int *live_children)
{
- struct child *newborn, **cradle;
+ struct child *new_cld, **current;
- CALLOC_ARRAY(newborn, 1);
+ CALLOC_ARRAY(new_cld, 1);
(*live_children)++;
- memcpy(&newborn->cld, cld, sizeof(*cld));
- memcpy(&newborn->address, addr, addrlen);
- for (cradle = &firstborn; *cradle; cradle = &(*cradle)->next)
- if (!addrcmp(&(*cradle)->address, &newborn->address))
+ memcpy(&new_cld->cld, cld, sizeof(*cld));
+ memcpy(&new_cld->address, addr, addrlen);
+ for (current = &first_child; *current; current = &(*current)->next)
+ if (!addrcmp(&(*current)->address, &new_cld->address))
break;
- newborn->next = *cradle;
- *cradle = newborn;
+ new_cld->next = *current;
+ *current = new_cld;
}
-void kill_some_child(struct child *firstborn)
+void kill_some_child(struct child *first_child)
{
- const struct child *blanket, *next;
+ const struct child *current, *next;
- if (!(blanket = firstborn))
+ if (!(current = first_child))
return;
- for (; (next = blanket->next); blanket = next)
- if (!addrcmp(&blanket->address, &next->address)) {
- kill(blanket->cld.pid, SIGTERM);
+ for (; (next = current->next); current = next)
+ if (!addrcmp(¤t->address, &next->address)) {
+ kill(current->cld.pid, SIGTERM);
break;
}
}
-void check_dead_children(struct child *firstborn, unsigned int *live_children,
+void check_dead_children(struct child *first_child, unsigned int *live_children,
log_fn loginfo)
{
int status;
pid_t pid;
- struct child **cradle, *blanket;
- for (cradle = &firstborn; (blanket = *cradle);)
- if ((pid = waitpid(blanket->cld.pid, &status, WNOHANG)) > 1) {
+ struct child **ptr, *current;
+ for (ptr = &first_child; (current = *ptr);)
+ if ((pid = waitpid(current->cld.pid, &status, WNOHANG)) > 1) {
if (loginfo) {
const char *dead = "";
if (status)
@@ -277,10 +277,10 @@ void check_dead_children(struct child *firstborn, unsigned int *live_children,
}
/* remove the child */
- *cradle = blanket->next;
+ *ptr = current->next;
(*live_children)--;
- child_process_clear(&blanket->cld);
- free(blanket);
+ child_process_clear(¤t->cld);
+ free(current);
} else
- cradle = &blanket->next;
+ ptr = ¤t->next;
}
@@ -32,7 +32,7 @@ struct child {
* live children.
*/
void add_child(struct child_process *cld, struct sockaddr *addr, socklen_t addrlen,
- struct child *firstborn, unsigned int *live_children);
+ struct child *first_child, unsigned int *live_children);
/*
* Kill the newest connection from a duplicate IP.
@@ -40,7 +40,7 @@ void add_child(struct child_process *cld, struct sockaddr *addr, socklen_t addrl
* This function should be called if the number of connections grows
* past the maximum number of allowed connections.
*/
-void kill_some_child(struct child *firstborn);
+void kill_some_child(struct child *first_child);
/*
* Check for children that have disconnected and remove them from the
@@ -49,7 +49,7 @@ void kill_some_child(struct child *firstborn);
* Optionally log the child PID that disconnected by passing a loginfo
* function.
*/
-void check_dead_children(struct child *firstborn, unsigned int *live_children,
+void check_dead_children(struct child *first_child, unsigned int *live_children,
log_fn loginfo);
#endif
@@ -789,7 +789,7 @@ static int max_connections = 32;
static unsigned int live_children;
-static struct child *firstborn;
+static struct child *first_child;
static struct strvec cld_argv = STRVEC_INIT;
static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)
@@ -797,9 +797,9 @@ static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)
struct child_process cld = CHILD_PROCESS_INIT;
if (max_connections && live_children >= max_connections) {
- kill_some_child(firstborn);
+ kill_some_child(first_child);
sleep(1); /* give it some time to die */
- check_dead_children(firstborn, &live_children, loginfo);
+ check_dead_children(first_child, &live_children, loginfo);
if (live_children >= max_connections) {
close(incoming);
logerror("Too many children, dropping connection");
@@ -832,7 +832,7 @@ static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)
if (start_command(&cld))
logerror("unable to fork");
else
- add_child(&cld, addr, addrlen, firstborn, &live_children);
+ add_child(&cld, addr, addrlen, first_child, &live_children);
}
static void child_handler(int signo)
@@ -862,7 +862,7 @@ static int service_loop(struct socketlist *socklist)
for (;;) {
int i;
- check_dead_children(firstborn, &live_children, loginfo);
+ check_dead_children(first_child, &live_children, loginfo);
if (poll(pfd, socklist->nr, -1) < 0) {
if (errno != EINTR) {