Remove fr_connection_delete
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 23 Jun 2014 15:17:42 +0000 (16:17 +0100)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 23 Jun 2014 15:19:54 +0000 (16:19 +0100)
src/include/connection.h
src/main/connection.c
src/modules/rlm_couchbase/rlm_couchbase.c
src/modules/rlm_krb5/rlm_krb5.c
src/modules/rlm_ldap/rlm_ldap.c
src/modules/rlm_redis/rlm_redis.c
src/modules/rlm_rest/rlm_rest.c
src/modules/rlm_smsotp/rlm_smsotp.c
src/modules/rlm_sql/sql.c
src/modules/rlm_yubikey/validate.c

index 8b7473a..0e68f42 100644 (file)
@@ -70,22 +70,10 @@ typedef void *(*fr_connection_create_t)(TALLOC_CTX *ctx, void *opaque);
  */
 typedef int (*fr_connection_alive_t)(void *opaque, void *connection);
 
-/** Delete a connection and free allocated memory
- *
- * Should close any sockets associated with the passed connection handle,
- * and free any memory allocated to it.
- *
- * @param[in] opaque pointer passed to fr_connection_pool_init.
- * @param[in,out] connection handle returned by fr_connection_create_t.
- * @return < 0 on error else 0 if connection was closed successfully.
- */
-typedef int (*fr_connection_delete_t)(void *opaque, void *connection);
-
 fr_connection_pool_t *fr_connection_pool_init(CONF_SECTION *cs,
                                              void *opaque,
                                              fr_connection_create_t c,
                                              fr_connection_alive_t a,
-                                             fr_connection_delete_t d,
                                              char const *prefix);
 void fr_connection_pool_delete(fr_connection_pool_t *pool);
 
index ff0db71..8cd5e0f 100644 (file)
@@ -162,8 +162,6 @@ struct fr_connection_pool_t {
                                        //!< connections.
        fr_connection_alive_t   alive;  //!< Function used to check status
                                        //!< of connections.
-       fr_connection_delete_t  delete; //!< Function used to close existing
-                                       //!< connections.
 };
 
 #define LOG_PREFIX "rlm_%s (%s)"
@@ -445,7 +443,6 @@ static void fr_connection_close(fr_connection_pool_t *pool,
        if (pool->trigger) exec_trigger(NULL, pool->cs, "close", true);
 
        fr_connection_unlink(pool, this);
-       if (pool->delete) pool->delete(pool->opaque, this->connection);
        rad_assert(pool->num > 0);
        pool->num--;
        talloc_free(this);
@@ -572,7 +569,6 @@ void fr_connection_pool_delete(fr_connection_pool_t *pool)
  * @param[in] opaque data pointer to pass to callbacks.
  * @param[in] c Callback to create new connections.
  * @param[in] a Callback to check the status of connections.
- * @param[in] d Callback to delete connections.
  * @param[in] prefix to prepend to all log message, if NULL will create prefix
  *     from parent conf section names.
  * @return A new connection pool or NULL on error.
@@ -581,7 +577,6 @@ fr_connection_pool_t *fr_connection_pool_init(CONF_SECTION *parent,
                                              void *opaque,
                                              fr_connection_create_t c,
                                              fr_connection_alive_t a,
-                                             fr_connection_delete_t d,
                                              char const *prefix)
 {
        uint32_t i;
@@ -618,7 +613,6 @@ fr_connection_pool_t *fr_connection_pool_init(CONF_SECTION *parent,
        pool->opaque = opaque;
        pool->create = c;
        pool->alive = a;
-       pool->delete = d;
 
        pool->head = pool->tail = NULL;
 
@@ -1155,8 +1149,8 @@ void *fr_connection_reconnect(fr_connection_pool_t *pool, void *conn)
        }
 
        if (pool->trigger) exec_trigger(NULL, pool->cs, "close", true);
-       pool->delete(pool->opaque, conn);
        this->connection = new_conn;
        pthread_mutex_unlock(&pool->mutex);
+
        return new_conn;
 }
index 854ecf4..ffab0ed 100644 (file)
@@ -100,7 +100,7 @@ static int mod_instantiate(CONF_SECTION *conf, void *instance) {
        }
 
        /* initiate connection pool */
-       inst->pool = fr_connection_pool_init(conf, inst, mod_conn_create, mod_conn_alive, NULL, NULL);
+       inst->pool = fr_connection_pool_init(conf, inst, mod_conn_create, mod_conn_alive, NULL);
 
        /* check connection pool */
        if (!inst->pool) {
index 14743d5..c248021 100644 (file)
@@ -222,7 +222,7 @@ static int mod_instantiate(CONF_SECTION *conf, void *instance)
        /*
         *      Initialize the socket pool.
         */
-       inst->pool = fr_connection_pool_init(conf, inst, mod_conn_create, NULL, NULL, NULL);
+       inst->pool = fr_connection_pool_init(conf, inst, mod_conn_create, NULL, NULL);
        if (!inst->pool) {
                return -1;
        }
index e4697fd..6593303 100644 (file)
@@ -769,7 +769,7 @@ static int mod_instantiate(CONF_SECTION *conf, void *instance)
        /*
         *      Initialize the socket pool.
         */
-       inst->pool = fr_connection_pool_init(inst->cs, inst, mod_conn_create, NULL, NULL, NULL);
+       inst->pool = fr_connection_pool_init(inst->cs, inst, mod_conn_create, NULL, NULL);
        if (!inst->pool) {
                return -1;
        }
index f07d494..4ae3b09 100644 (file)
@@ -276,7 +276,7 @@ static int mod_instantiate(CONF_SECTION *conf, void *instance)
 
        xlat_register(inst->xlat_name, redis_xlat, NULL, inst); /* FIXME! */
 
-       inst->pool = fr_connection_pool_init(conf, inst, mod_conn_create, NULL, NULL, NULL);
+       inst->pool = fr_connection_pool_init(conf, inst, mod_conn_create, NULL, NULL);
        if (!inst->pool) {
                return -1;
        }
index b8a4df8..512de7a 100644 (file)
@@ -670,7 +670,7 @@ static int mod_instantiate(CONF_SECTION *conf, void *instance)
                return -1;
        }
 
-       inst->conn_pool = fr_connection_pool_init(conf, inst, mod_conn_create, mod_conn_alive, NULL, NULL);
+       inst->conn_pool = fr_connection_pool_init(conf, inst, mod_conn_create, mod_conn_alive, NULL);
        if (!inst->conn_pool) {
                return -1;
        }
index 4aecd19..3f1954e 100644 (file)
@@ -172,7 +172,7 @@ static int mod_instantiate(CONF_SECTION *conf, void *instance)
        /*
         *      Initialize the socket pool.
         */
-       inst->pool = fr_connection_pool_init(conf, inst, mod_conn_create, NULL, NULL, NULL);
+       inst->pool = fr_connection_pool_init(conf, inst, mod_conn_create, NULL, NULL);
        if (!inst->pool) {
                return -1;
        }
index 962f49d..bdb97fe 100644 (file)
@@ -109,7 +109,7 @@ static void *mod_conn_create(TALLOC_CTX *ctx, void *instance)
  *************************************************************************/
 int sql_socket_pool_init(rlm_sql_t * inst)
 {
-       inst->pool = fr_connection_pool_init(inst->cs, inst, mod_conn_create, NULL, NULL, NULL);
+       inst->pool = fr_connection_pool_init(inst->cs, inst, mod_conn_create, NULL, NULL);
        if (!inst->pool) return -1;
 
        return 1;
index b6fd613..2d2d648 100644 (file)
@@ -138,7 +138,7 @@ init:
        }
 
        snprintf(prefix, sizeof(prefix), "rlm_yubikey (%s)", inst->name);
-       inst->conn_pool = fr_connection_pool_init(conf, inst, mod_conn_create, NULL, NULL, prefix);
+       inst->conn_pool = fr_connection_pool_init(conf, inst, mod_conn_create, NULL, prefix);
        if (!inst->conn_pool) {
                ykclient_done(&inst->ykc);