From 304299b1ca7a8c5f5daca48d15ed2d0cd5d1472b Mon Sep 17 00:00:00 2001 From: "Alan T. DeKok" Date: Sun, 6 Nov 2011 11:17:41 +0100 Subject: [PATCH] Added support for triggers start/stop connection pool open/close individual connection --- src/main/connection.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/connection.c b/src/main/connection.c index af51d51..9b22359 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; } -- 2.1.4