Two connection pools in one module.
Ленченко Илья Анатольевич
ilya.lenchenko at altarix.ru
Wed Jul 6 17:21:00 CEST 2016
Hello,
I am writing module for freeradius 3.0.11. Module needs to work with mysql and rabbitMQ both. So i tried to declare two variables of type fr_connection_pool_t in one instance struct:
typedef struct rlm_smt_t {
const char *mysqlHost;
const char *mysqlPort;
const char *mysqlUser;
const char *mysqlPassword;
const char *mysqlSchema;
const char *mysqlTable;
const char *mysqlRequestPartner;
const char *mysqlRequestSession;
const char *mysqlRequestSessionTimeout;
char const *journalName;
const char *rmqHost;
const char *rmqUser;
const char *rmqPassword;
uint32_t rmqPort;
const char *rmqVhost;
uint32_t rmqTimeout;
uint32_t rmqChannel;
uint32_t rmqChannelMax;
uint32_t rmqFrameMax;
uint32_t rmqHeartbeat;
int auth_type;
fr_connection_pool_t *poolMYSQL;
fr_connection_pool_t *poolRabbitMQ;
} rlm_smt_t;
Then:
static int mod_instantiate(CONF_SECTION *conf, void *instance)
{
rlm_smt_t *inst = instance;
inst->poolMYSQL = fr_connection_pool_module_init(conf, inst, mod_conn_create_mysql, NULL, NULL);
if (!inst->poolMYSQL) {
return -1;
}
inst->poolRabbitMQ = fr_connection_pool_module_init(conf, inst, mod_conn_create_rmq, NULL, NULL);
if (!inst->poolRabbitMQ) {
return -1;
}
return 0;
}
And:
static int mod_detach(void *instance)
{
rlm_smt_t *inst = instance;
fr_connection_pool_free(inst->poolMYSQL);
fr_connection_pool_free(inst->poolRabbitMQ);
return 0;
}
It seems to me that module ignores line inst->poolRabbitMQ = fr_connection_pool_module_init(conf, inst, mod_conn_create_rmq, NULL, NULL);
And then i get segmentation fault in mod_detach.
Is it possible to keep two connection pools in one module? How can i achieve that?
Also module reads only one pool from config file, but i need to read two pools.
Thanks.
Ilya Lenchenko
More information about the Freeradius-Devel
mailing list