Hi, according to kamailio-devel-guide child_init function is just called for kamailio workers:
16.10.6. Module Child Init Function This is the function called just after KAMAILIO (OPENSER) forks its worker processes.
but later it says:
The function gets as parameter the rank of the child process. The rank is a positive number if it is a worker process and negative for special processes like timer processes or TCP attendant.
So my question is: should I check the rank parameter in child_init function just to run the code for real workers?
For example, in modules_k/alias_db module I see:
----------------------------------------------- static int child_init(int rank) { if (rank==PROC_INIT || rank==PROC_MAIN || rank==PROC_TCP_MAIN) return 0; /* do nothing for the main process */
db_handle = adbf.init(&db_url); if (!db_handle) { LM_ERR("unable to connect database\n"); return -1; } return 0; } ---------------------------------------------
But in modules/db_flatstore I see:
--------------------------------------------- /* * FIXME: We should check whether just calling km_child_init would really work * here. This function comes from kamailio and since the core of sip-router is * based on SER 2.0, the way how child_init is called and values of the rank * variable could be incompatible with km_child_init function. A solution here * would be to rewrite km_child_init with ser 2.0 init stuff in mind. */ static int child_init(int rank) { char* tmp; unsigned int v;
km_child_init(rank);
if (rank <= 0) { v = -rank; } else { v = rank - PROC_MIN; } [...] ---------------------------------------------
I just want child_init to be run for workers, and no por other special processes. Also I'm writting the module under modules/ so, what should I do to achieve it?
Thanks a lot.