From: Alan T. DeKok Date: Sun, 6 Nov 2011 10:17:41 +0000 (+0100) Subject: Added support for triggers X-Git-Tag: release_3_0_0_beta0~522 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=304299b1ca7a8c5f5daca48d15ed2d0cd5d1472b;p=thirdparty%2Ffreeradius-server.git Added support for triggers start/stop connection pool open/close individual connection --- diff --git a/src/main/connection.c b/src/main/connection.c index af51d51426c..9b22359f76f 100644 --- a/src/main/connection.c +++ b/src/main/connection.c @@ -66,6 +66,7 @@ struct fr_connection_pool_t { int idle_timeout; int lazy_init; int spawning; + int trigger; /* do triggering */ fr_connection_t *head, *tail; @@ -223,12 +224,16 @@ static fr_connection_t *fr_connection_spawn(fr_connection_pool_t *fc, pthread_mutex_unlock(&fc->mutex); + if (fc->trigger) exec_trigger(NULL, fc->cs, "open"); + return this; } static void fr_connection_close(fr_connection_pool_t *fc, fr_connection_t *this) { + if (fc->trigger) exec_trigger(NULL, fc->cs, "close"); + rad_assert(this->used == FALSE); fr_connection_unlink(fc, this); @@ -254,6 +259,8 @@ void fr_connection_pool_delete(fr_connection_pool_t *fc) fr_connection_close(fc, this); } + if (fc->trigger) exec_trigger(NULL, fc->cs, "stop"); + rad_assert(fc->head == NULL); rad_assert(fc->tail == NULL); rad_assert(fc->num == 0); @@ -316,6 +323,8 @@ fr_connection_pool_t *fr_connection_pool_init(CONF_SECTION *parent, goto error; } + if (cf_section_sub_find(cs, "trigger")) fc->trigger = TRUE; + /* * Some simple limits */ @@ -341,6 +350,8 @@ fr_connection_pool_t *fr_connection_pool_init(CONF_SECTION *parent, } } + if (fc->trigger) exec_trigger(NULL, fc->cs, "start"); + return fc; }