Module: kamailio Branch: master Commit: 4780d46976a7a392f23af0d89f05855d473bcb30 URL: https://github.com/kamailio/kamailio/commit/4780d46976a7a392f23af0d89f05855d...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2022-05-09T09:05:18+02:00
usrloc: connect to db for main process in PROC_POSTCHILDINIT child init
---
Modified: src/modules/usrloc/usrloc_mod.c
---
Diff: https://github.com/kamailio/kamailio/commit/4780d46976a7a392f23af0d89f05855d... Patch: https://github.com/kamailio/kamailio/commit/4780d46976a7a392f23af0d89f05855d...
---
diff --git a/src/modules/usrloc/usrloc_mod.c b/src/modules/usrloc/usrloc_mod.c index d60162ed3e..797c252b85 100644 --- a/src/modules/usrloc/usrloc_mod.c +++ b/src/modules/usrloc/usrloc_mod.c @@ -358,6 +358,16 @@ static int mod_init(void) }
/* Shall we use database ? */ + switch (ul_db_mode) { + case DB_ONLY: + case WRITE_THROUGH: + case WRITE_BACK: + /* + * register the need to be called post-fork of all children + * with the special rank PROC_POSTCHILDINIT + */ + ksr_module_set_flag(KSRMOD_FLAG_POSTCHILDINIT); + } if (ul_db_mode != NO_DB) { /* Yes */ if (db_bind_mod(&ul_db_url, &ul_dbf) < 0) { /* Find database module */ LM_ERR("failed to bind database module\n"); @@ -452,14 +462,14 @@ static int child_init(int _rank) case WRITE_THROUGH: /* connect to db only from SIP workers, TIMER and MAIN processes, * and RPC processes */ - if (_rank<=0 && _rank!=PROC_TIMER && _rank!=PROC_MAIN + if (_rank<=0 && _rank!=PROC_TIMER && _rank!=PROC_POSTCHILDINIT && _rank!=PROC_RPC) return 0; break; case WRITE_BACK: /* connect to db only from TIMER (for flush), from MAIN (for * final flush() and from child 1 for preload */ - if (_rank!=PROC_TIMER && _rank!=PROC_MAIN && _rank!=PROC_SIPINIT) + if (_rank!=PROC_TIMER && _rank!=PROC_POSTCHILDINIT && _rank!=PROC_SIPINIT) return 0; break; case DB_READONLY: