Added support for triggers
authorAlan T. DeKok <aland@freeradius.org>
Sun, 6 Nov 2011 10:17:41 +0000 (11:17 +0100)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 6 Nov 2011 10:17:41 +0000 (11:17 +0100)
start/stop connection pool
open/close individual connection

src/main/connection.c

index af51d51..9b22359 100644 (file)
@@ -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;
 }