Skip to content

Commit

Permalink
Remove fr_connection_delete
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed Jun 23, 2014
1 parent 123c066 commit a2965a3
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 27 deletions.
12 changes: 0 additions & 12 deletions src/include/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *prefix);
void fr_connection_pool_delete(fr_connection_pool_t *pool);

Expand Down
8 changes: 1 addition & 7 deletions src/main/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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.
Expand All @@ -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 *prefix)
{
uint32_t i;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion src/modules/rlm_couchbase/rlm_couchbase.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/rlm_krb5/rlm_krb5.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/rlm_ldap/rlm_ldap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/rlm_redis/rlm_redis.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/rlm_rest/rlm_rest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/rlm_smsotp/rlm_smsotp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/rlm_sql/sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/rlm_yubikey/validate.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ int rlm_yubikey_ykclient_init(CONF_SECTION *conf, rlm_yubikey_t *inst)
}

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);

Expand Down

0 comments on commit a2965a3

Please sign in to comment.