Module: kamailio Branch: master Commit: 848d55388dda0c135820d9f24950561946249bbc URL: https://github.com/kamailio/kamailio/commit/848d55388dda0c135820d9f249505619...
Author: Ovidiu Sas osas@voipembedded.com Committer: Ovidiu Sas osas@voipembedded.com Date: 2023-06-12T00:24:15-04:00
mqueue: fix support for db_text - db_operations are safe only after db mod_init() - closes #3474
---
Modified: src/modules/mqueue/mqueue_mod.c
---
Diff: https://github.com/kamailio/kamailio/commit/848d55388dda0c135820d9f249505619... Patch: https://github.com/kamailio/kamailio/commit/848d55388dda0c135820d9f249505619...
---
diff --git a/src/modules/mqueue/mqueue_mod.c b/src/modules/mqueue/mqueue_mod.c index 912a36b33bb..d51b65f5d19 100644 --- a/src/modules/mqueue/mqueue_mod.c +++ b/src/modules/mqueue/mqueue_mod.c @@ -101,6 +101,8 @@ struct module_exports exports = { */ static int mod_init(void) { + mq_head_t *mh = mq_head_get(NULL); + if(!mq_head_defined()) LM_WARN("no mqueue defined\n");
@@ -109,6 +111,17 @@ static int mod_init(void) return 1; }
+ while(mh != NULL) { + if (mh->dbmode == 1 || mh->dbmode == 2) { + if(mqueue_db_load_queue(&(mh->name)) < 0) { + LM_ERR("error loading mqueue: %.*s from DB\n", + mh->name.len, mh->name.s); + return 1; + } + } + mh = mh->next; + } + return 0; }
@@ -245,13 +258,6 @@ int mq_param(modparam_t type, void *val) } LM_INFO("mqueue param: [%.*s|%d|%d]\n", qname.len, qname.s, dbmode, addmode); - if(dbmode == 1 || dbmode == 2) { - if(mqueue_db_load_queue(&qname) < 0) { - LM_ERR("error loading mqueue: %.*s from DB\n", qname.len, qname.s); - free_params(params_list); - return -1; - } - } mq_set_dbmode(&qname, dbmode); free_params(params_list); return 0;