extern pid_t rad_fork(void);
extern pid_t rad_waitpid(pid_t pid, int *status);
extern int total_active_threads(void);
+extern void thread_pool_lock(void);
+extern void thread_pool_unlock(void);
#ifndef HAVE_PTHREAD_H
#define rad_fork(n) fork()
# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
#endif
+#ifndef HAVE_PTHREAD_H
+#define thread_pool_lock(_x)
+#define thread_pool_unlock(_x)
+#endif
+
/*
* Global variables.
*/
}
/*
- * Loop while doing stuff.
+ * Process requests until HUP or exit.
*/
while ((rcode = radius_event_process()) == 0x80) {
+ thread_pool_lock();
/*
- * HUP handler.
+ * Reload anything that can safely be reloaded.
*/
+ DEBUG("HUP support not available.");
+
+ thread_pool_unlock();
}
DEBUG("Exiting...");
reset_signal(SIGHUP, sig_hup);
- write(STDOUT_FILENO, "STUFF\n", 6);
-
radius_signal_self(RADIUS_SIGNAL_SELF_HUP);
}
return 0;
}
-#else /* HAVE_PTHREAD_H */
-/*
- * "thread" code when we don't have threads.
- */
-int thread_pool_init(int spawn_flag)
+void thread_pool_lock(void)
{
- return 0;
+ pthread_mutex_lock(&thread_pool.queue_mutex);
}
-/*
- * call "radrespond".
- */
-int thread_pool_addrequest(REQUEST *request, RAD_REQUEST_FUNP fun)
+void thread_pool_unlock(void)
{
- radius_handle_request(request, fun);
- return 1;
+ pthread_mutex_unlock(&thread_pool.queue_mutex);
}
-
#endif /* HAVE_PTHREAD_H */