Module: kamailio
Branch: master
Commit: 19e5bf3d4cfc2b7d47623e307fff7e60e73e8a18
URL:
https://github.com/kamailio/kamailio/commit/19e5bf3d4cfc2b7d47623e307fff7e6…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2024-02-26T14:06:38+01:00
ndb_redis: init enabled for tcp-main and postchildinit callbacks
- GH #3768
---
Modified: src/modules/ndb_redis/ndb_redis_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/19e5bf3d4cfc2b7d47623e307fff7e6…
Patch:
https://github.com/kamailio/kamailio/commit/19e5bf3d4cfc2b7d47623e307fff7e6…
---
diff --git a/src/modules/ndb_redis/ndb_redis_mod.c
b/src/modules/ndb_redis/ndb_redis_mod.c
index d082bd82ae8..8256c0a619a 100644
--- a/src/modules/ndb_redis/ndb_redis_mod.c
+++ b/src/modules/ndb_redis/ndb_redis_mod.c
@@ -79,8 +79,9 @@ static int w_redis_execute(struct sip_msg *msg, char *ssrv);
static int w_redis_free_reply(struct sip_msg *msg, char *res);
-static void mod_destroy(void);
+static int mod_init(void);
static int child_init(int rank);
+static void mod_destroy(void);
int bind_ndb_redis(ndb_redis_api_t *api);
@@ -146,23 +147,37 @@ static param_export_t params[] = {
};
struct module_exports exports = {
- "ndb_redis",
+ "ndb_redis", /* module name */
DEFAULT_DLFLAGS, /* dlopen flags */
- cmds, params, 0, /* exported RPC methods */
+ cmds, /* exported functions */
+ params, /* exported parameters */
+ 0, /* exported RPC methods */
mod_pvs, /* exported pseudo-variables */
0, /* response function */
- 0, /* module initialization function */
+ mod_init, /* module initialization function */
child_init, /* per child init function */
mod_destroy /* destroy function */
};
/* clang-format on */
+/**
+ *
+ */
+static int mod_init(void)
+{
+ /*
+ * register the need to be called post-fork of all children
+ * with the special rank PROC_POSTCHILDINIT by main attendant
+ */
+ ksr_module_set_flag(KSRMOD_FLAG_POSTCHILDINIT);
+ return 0;
+}
/* each child get a new connection to the database */
static int child_init(int rank)
{
- /* skip child init for non-worker process ranks */
- if(rank == PROC_INIT || rank == PROC_MAIN || rank == PROC_TCP_MAIN)
+ /* skip child init for special process ranks */
+ if(rank == PROC_INIT || rank == PROC_MAIN)
return 0;
if(redisc_init() < 0) {