When we a get a SIGTERM or SIGQUIT, mark "exiting", and stop
returning new connections. Also, don't allow reconnection of
existing connections. This should help with CTRL-C.
bool write_pid; //!< write the PID file
+ bool exiting; //!< are we exiting?
+
#ifdef ENABLE_OPENSSL_VERSION_CHECK
char const *allow_vulnerable_openssl; //!< The CVE number of the last security issue acknowledged.
if (!pool) return NULL;
+ /*
+ * Allow CTRL-C to kill the server in debugging mode.
+ */
+ if (main_config.exiting) return NULL;
+
#ifdef HAVE_PTHREAD_H
if (spawn) pthread_mutex_lock(&pool->mutex);
#endif
if (!pool || !conn) return NULL;
/*
+ * Don't allow opening of new connections if we're trying
+ * to exit.
+ */
+ if (main_config.exiting) {
+ fr_connection_release(pool, conn);
+ return NULL;
+ }
+
+ /*
* If fr_connection_find is successful the pool is now locked
*/
this = fr_connection_find(pool, conn);
#ifndef HAVE_PTHREAD_H
void radius_signal_self(int flag)
{
+ if (flag == RADIUS_SIGNAL_SELF_TERM) {
+ main_config.exiting = true;
+ }
+
return handle_signal_self(flag);
}
ssize_t rcode;
uint8_t buffer[16];
+ if (flag == RADIUS_SIGNAL_SELF_TERM) {
+ main_config.exiting = true;
+ }
+
/*
* The read MUST be non-blocking for this to work.
*/