{ NULL, -1, 0, NULL, NULL} /* end the list */
};
-static int mod_conn_delete(UNUSED void *instance, void *handle)
+static int _mod_conn_free(REDISSOCK *dissocket)
{
- REDISSOCK *dissocket = handle;
-
redisFree(dissocket->conn);
if (dissocket->reply) {
dissocket->reply = NULL;
}
- talloc_free(dissocket);
- return 1;
+ return 0;
}
-static void *mod_conn_create(void *ctx)
+static void *mod_conn_create(TALLOC_CTX *ctx, void *instance)
{
- REDIS_INST *inst = ctx;
+ REDIS_INST *inst = instance;
REDISSOCK *dissocket = NULL;
redisContext *conn;
redisReply *reply = NULL;
reply = redisCommand(conn, buffer);
if (!reply) {
- ERROR("rlm_redis (%s): Failed to run AUTH",
- inst->xlat_name);
+ ERROR("rlm_redis (%s): Failed to run AUTH", inst->xlat_name);
+
do_close:
if (reply) freeReplyObject(reply);
redisFree(conn);
}
}
- dissocket = talloc_zero(inst, REDISSOCK);
+ dissocket = talloc_zero(ctx, REDISSOCK);
dissocket->conn = conn;
+ talloc_set_destructor(dissocket, _mod_conn_free);
return dissocket;
}
xlat_register(inst->xlat_name, redis_xlat, NULL, inst); /* FIXME! */
- inst->pool = fr_connection_pool_init(conf, inst, mod_conn_create, NULL, mod_conn_delete, NULL);
+ inst->pool = fr_connection_pool_init(conf, inst, mod_conn_create, NULL, NULL, NULL);
if (!inst->pool) {
return -1;
}