From: Alan T. DeKok Date: Thu, 11 Feb 2010 09:24:57 +0000 (+0100) Subject: Do waitpid() for ALL children, even if there are no threads waiting X-Git-Tag: release_2_1_9~88 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d2b8cf1307aa18a3e04c30dc61dc437afab1cd3;p=thirdparty%2Ffreeradius-server.git Do waitpid() for ALL children, even if there are no threads waiting 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. --- diff --git a/src/main/threads.c b/src/main/threads.c index 51ffaa2760d..988ac7f8357 100644 --- a/src/main/threads.c +++ b/src/main/threads.c @@ -263,12 +263,13 @@ static void reap_children(void) 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; @@ -1064,6 +1065,7 @@ pid_t rad_fork(void) if (!rcode) { radlog(L_ERR, "Failed to store PID, creating what will be a zombie process %d", (int) child_pid); + free(tf); } }