Two connection pools in one module.
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
On Wed, Jul 06, 2016 at 03:21:00PM +0000, Ленченко Илья Анатольевич wrote:
{ 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; }
Using the same 'conf' for each one doesn't look good to me. I would first try with different conf subsection for each of mysql and rabbitmq, and pass those through to fr_connection_pool_module_init. Matthew -- Matthew Newton, Ph.D. <mcn4@leicester.ac.uk> Systems Specialist, Infrastructure Services, I.T. Services, University of Leicester, Leicester LE1 7RH, United Kingdom For IT help contact helpdesk extn. 2253, <ithelp@le.ac.uk>
On 6 Jul 2016, at 11:56, Matthew Newton <mcn4@leicester.ac.uk> wrote:
On Wed, Jul 06, 2016 at 03:21:00PM +0000, Ленченко Илья Анатольевич wrote:
{ 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; }
Using the same 'conf' for each one doesn't look good to me.
Yeah that code will assume you're doing connection pool sharing, and just pass back the same pointer. ... and no, we're not going to change that, it's a valid assumption. No other module uses multiple connection pools that draw their configuration from the same subsection, because why would you, when you have a policy language to allow interactions between modules... -Arran Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS Development Team FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2
participants (3)
-
Arran Cudbard-Bell -
Matthew Newton -
Ленченко Илья Анатольевич