Hi Jason,
thanks for the reply.
the last 2 statements in presence module mod_init close the connection and set pa_db to NULL. when my module main process forks the extra processes the pa_db in presence is NULL, so when it calls pres_refresh_watchers it fails because pa_db is NULL. i commented these last statements in presence mod_init and i got it to work.
// pa_dbf.close(pa_db); // pa_db = NULL;
does this have any implications on how the module works ? is it ok to merge this change ?
Thank you
Hello,
the database connection should not be shared beween processes, because it can bring unexpected results in may places.
Right now, the rule is to have one connection per process, shared by all modules in that process.
To achieve that, at mod_init each module opens database connection and closes it before ending the function. Then in child_init() the connection is opened again. Another module that will have to open in child_init() will get the same connection now.
When you create a new process, you tell the type of child and based on that child_init() from the other modules are executed.
What is the function do you use for creating a new process? Maybe you can paste it here exactly how you do it and I can see if something can be done.
Cheers, Daniel
On 03/09/14 12:09, Luis Azedo wrote:
Hi Daniel,
this is the way we are creating the child processes (1 manager and n workers) the problem is with the workers. the worker will call a event-route and in the script config we try to call pres_refresh_watchers and that's where we get the pa_db = NULL.
as i understand from your email, if we change PROC_NOCHLDINIT and let the child_init execute for the forked process then it will also execute child_init in other modules ? it makes sense.
going to try this.
static int mod_child_init(int rank) { int pid; int i;
fire_init_event(rank);
if (rank==PROC_MAIN) { pid=fork_process(PROC_NOCHLDINIT, "AMQP Manager", 1); if (pid<0) return -1; /* error */ if(pid==0){ kz_amqp_manager_loop(0); } else { for(i=0; i < dbk_consumer_processes; i++) { pid=fork_process(PROC_NOCHLDINIT, "AMQP Consumer", 1); if (pid<0) return -1; /* error */ if(pid==0){ mod_consumer_proc(i+1); } } } }
return 0; }
On Mon, Sep 8, 2014 at 1:11 PM, Daniel-Constantin Mierla miconda@gmail.com wrote: