i.e. call radius_exec_program() 4 times for each packet, each
with "nowait". The "reap_children" function is called ONCE per packet,
and was calling waitpid() ONCE if there were no threads waiting
for a child.
This change makes it KEEP waiting until there are no more children
to wait for.
pthread_mutex_lock(&thread_pool.wait_mutex);
do {
+ retry:
pid = waitpid(0, &status, WNOHANG);
if (pid <= 0) break;
mytf.pid = pid;
tf = fr_hash_table_finddata(thread_pool.waiters, &mytf);
- if (!tf) continue;
+ if (!tf) goto retry;
tf->status = status;
tf->exited = 1;
if (!rcode) {
radlog(L_ERR, "Failed to store PID, creating what will be a zombie process %d",
(int) child_pid);
+ free(tf);
}
}