int cleanup_delay;
int spawn_flag;
+#ifdef WNOHANG
pthread_mutex_t wait_mutex;
fr_hash_table_t *waiters;
+#endif
/*
* All threads wait on this semaphore, for requests
}
#endif
-
+#ifdef WNOHANG
/*
* We don't want to catch SIGCHLD for a host of reasons.
*
pthread_mutex_unlock(&thread_pool.wait_mutex);
}
+#else
+#define reap_children()
+#endif /* WNOHANG */
/*
* Add a request to the list of waiting requests.
}
+#ifdef WNOHANG
static uint32_t pid_hash(const void *data)
{
const thread_fork_t *tf = data;
return (a->pid - b->pid);
}
+#endif
/*
* Allocate the thread pool, and seed it with an initial number
thread_pool.cleanup_delay = 5;
thread_pool.spawn_flag = spawn_flag;
+#ifdef WNOHANG
if ((pthread_mutex_init(&thread_pool.wait_mutex,NULL) != 0)) {
radlog(L_ERR, "FATAL: Failed to initialize wait mutex: %s",
strerror(errno));
radlog(L_ERR, "FATAL: Failed to set up wait hash");
return -1;
}
+#endif
}
pool_cf = cf_subsection_find_next(cs, NULL, "thread");
if (!thread_pool.spawn_flag) {
radius_handle_request(request, fun);
+#ifdef WNOHANG
/*
* Requests that care about child process exit
* codes have already either called
* rad_waitpid(), or they've given up.
*/
wait(NULL);
+#endif
return 1;
}
}
+#ifdef WNOHANG
/*
* Thread wrapper for fork().
*/
return 0;
}
+#else
+/*
+ * No rad_fork or rad_waitpid
+ */
+#endif
void thread_pool_lock(void)
{