<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hello,<br>
<br>
<div class="moz-cite-prefix">On 08/09/14 15:29, Luis Azedo wrote:<br>
</div>
<blockquote
cite="mid:CAEvFzR8oyM4pt7MBzTHk35iySArcDySA41Aihvsy4B8ZnXR1-Q@mail.gmail.com"
type="cite">
<div dir="ltr">Hi Daniel,
<div><br>
</div>
<div>all problems solved with presence! i was not running
child_init and now there is no need for the proposed patch to
presence.</div>
</div>
</blockquote>
ok. Given this, would the db_text patch still be required, as there
should be no database connection sharing?<br>
<br>
Cheers,<br>
Daniel<br>
<blockquote
cite="mid:CAEvFzR8oyM4pt7MBzTHk35iySArcDySA41Aihvsy4B8ZnXR1-Q@mail.gmail.com"
type="cite">
<div dir="ltr">
<div><br>
</div>
<div>Thank you</div>
<div><br>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Mon, Sep 8, 2014 at 2:13 PM, Luis
Azedo <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:luis.azedo@factorlusitano.com"
target="_blank">luis.azedo@factorlusitano.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hi Daniel,
<div><br>
</div>
<div>this is the way we are creating the child processes
(1 manager and n workers)</div>
<div>the problem is with the workers.</div>
<div>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.</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>going to try this.</div>
<div><br>
<div><br>
</div>
<div>
<div>static int mod_child_init(int rank)</div>
<div>{</div>
<div><span style="white-space:pre-wrap"> </span>int
pid;</div>
<div><span style="white-space:pre-wrap"> </span>int
i;</div>
<div><br>
</div>
<div><span style="white-space:pre-wrap"> </span>fire_init_event(rank);</div>
<div><br>
</div>
<div><span style="white-space:pre-wrap"> </span>if
(rank==PROC_MAIN) {</div>
<div><span style="white-space:pre-wrap"> </span>pid=fork_process(PROC_NOCHLDINIT,
"AMQP Manager", 1);</div>
<div><span style="white-space:pre-wrap"> </span>if
(pid<0)</div>
<div><span style="white-space:pre-wrap"> </span>return
-1; /* error */</div>
<div><span style="white-space:pre-wrap"> </span>if(pid==0){</div>
<div><span style="white-space:pre-wrap"> </span>kz_amqp_manager_loop(0);</div>
<div><span style="white-space:pre-wrap"> </span>}</div>
<div><span style="white-space:pre-wrap"> </span>else
{</div>
<div><span style="white-space:pre-wrap"> </span>for(i=0;
i < dbk_consumer_processes; i++) {</div>
<div><span style="white-space:pre-wrap"> </span>pid=fork_process(PROC_NOCHLDINIT,
"AMQP Consumer", 1);</div>
<div><span style="white-space:pre-wrap"> </span>if
(pid<0)</div>
<div><span style="white-space:pre-wrap"> </span>return
-1; /* error */</div>
<div><span style="white-space:pre-wrap"> </span>if(pid==0){</div>
<div><span style="white-space:pre-wrap"> </span>mod_consumer_proc(i+1);</div>
<div><span style="white-space:pre-wrap"> </span>}</div>
<div><span style="white-space:pre-wrap"> </span>}</div>
<div><span style="white-space:pre-wrap"> </span>}</div>
<div><span style="white-space:pre-wrap"> </span>}</div>
<div><br>
</div>
<div><span style="white-space:pre-wrap"> </span>return
0;</div>
<div>}</div>
</div>
<div><br>
</div>
</div>
<div>
<div class="h5">
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Mon, Sep 8, 2014 at
1:11 PM, Daniel-Constantin Mierla <span
dir="ltr"><<a moz-do-not-send="true"
href="mailto:miconda@gmail.com"
target="_blank">miconda@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote"
style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"> Hello,<br>
<br>
the database connection should not be shared
beween processes, because it can bring
unexpected results in may places.<br>
<br>
Right now, the rule is to have one
connection per process, shared by all
modules in that process.<br>
<br>
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.<br>
<br>
When you create a new process, you tell the
type of child and based on that child_init()
from the other modules are executed.<br>
<br>
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.<br>
<br>
Cheers,<br>
Daniel
<div>
<div><br>
<br>
<div>On 03/09/14 12:09, Luis Azedo
wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">Hi Jason,
<div><br>
</div>
<div>thanks for the reply.</div>
<div><br>
</div>
<div>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.</div>
<div>i commented these last
statements in presence mod_init
and i got it to work.</div>
<div><br>
</div>
<div>// pa_dbf.close(pa_db);</div>
<div>// pa_db = NULL;</div>
<div><br>
</div>
<div>does this have any implications
on how the module works ? is it ok
to merge this change ?</div>
<div><br>
</div>
<div>Thank you</div>
<div><br>
<div class="gmail_extra">
<div class="gmail_quote">
<blockquote
class="gmail_quote"
style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Sun, 31 Aug 2014
09:40:49 +0200<br>
From: Jason Penton <<a
moz-do-not-send="true"
href="mailto:jason.penton@gmail.com"
target="_blank">jason.penton@gmail.com</a>><br>
To: "Kamailio (SER) -
Development Mailing List"<br>
<<a
moz-do-not-send="true"
href="mailto:sr-dev@lists.sip-router.org"
target="_blank">sr-dev@lists.sip-router.org</a>><br>
Subject: Re: [sr-dev]
accessing database from a
child forked process<br>
Message-ID:<br>
<<a
moz-do-not-send="true"
href="mailto:CALoGXNWvHhCAO91Tfa0w8W3eYQRvfV7Qkgte7dBnD%2BciNr_Kpg@mail.gmail.com"
target="_blank">CALoGXNWvHhCAO91Tfa0w8W3eYQRvfV7Qkgte7dBnD+ciNr_Kpg@mail.gmail.com</a>><br>
Content-Type: text/plain;
charset="utf-8"<br>
<br>
To confirm exactly what
processes are being used,
maybe check the log file<br>
and take note of process id
at each log event. For
example you could check<br>
the process id of the
messages showing you the
connection is null. Then run<br>
kamcmd ps to show the
process list with a
description of each Kamailio<br>
process. That will probably
point you in the correct
direction.<br>
<br>
Cheers<br>
Jason<br>
<br>
<br>
On Fri, Aug 29, 2014 at 3:53
PM, Luis Azedo <<a
moz-do-not-send="true"
href="mailto:luis.azedo@factorlusitano.com"
target="_blank">luis.azedo@factorlusitano.com</a>><br>
wrote:<br>
<br>
> Hi,<br>
><br>
> i have a module that
creates 1 extra process
where it processes stuff in
a<br>
> loop.<br>
> on some condition i
fire a route_event with a
fakemsg and its up to the<br>
> user of the module to
take action, it tries to
work like dispatcher module<br>
> or htable (mod-init)
events.<br>
><br>
> the problem that i have
is that, if i call some
function on some module<br>
> that performs a
database action, the
connection is null when it
calls<br>
> use_table.<br>
><br>
> in this case i'm making
this call<br>
>
event_route[my_module:my_event]<br>
> {<br>
> $var(my_uri) =
<<result of some
operations>>;<br>
>
pres_refresh_watchers("$var(my_uri)",
"dialog", 1);<br>
> }<br>
> presence module makes
the call to use_table but
this call fails because<br>
> the connection is null.
presence module is working
fine besides this.<br>
><br>
> if i make this call
inside
event_route[dispatcher:dst-up]
it works.<br>
><br>
> i think that dispatcher
fires the event inside a
callback from a<br>
> registered timer, so, i
think (may be wrong) that it
comes from a different<br>
> process ?<br>
><br>
> i wonder if i'm missing
something from child_init ?
need to register<br>
> something ?<br>
><br>
> thanks for your help.<br>
><br>
><br>
><br>
><br>
><br>
><br>
>
_______________________________________________<br>
> sr-dev mailing list<br>
> <a
moz-do-not-send="true"
href="mailto:sr-dev@lists.sip-router.org"
target="_blank">sr-dev@lists.sip-router.org</a><br>
> <a
moz-do-not-send="true"
href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev"
target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a><br>
><br>
><br>
-------------- next part
--------------<br>
An HTML attachment was
scrubbed...<br>
URL: <<a
moz-do-not-send="true"
href="http://lists.sip-router.org/pipermail/sr-dev/attachments/20140831/9fba51e4/attachment-0001.html"
target="_blank">http://lists.sip-router.org/pipermail/sr-dev/attachments/20140831/9fba51e4/attachment-0001.html</a>><br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
sr-dev mailing list<br>
<a moz-do-not-send="true"
href="mailto:sr-dev@lists.sip-router.org"
target="_blank">sr-dev@lists.sip-router.org</a><br>
<a moz-do-not-send="true"
href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev"
target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a><br>
<br>
<br>
End of sr-dev Digest, Vol
70, Issue 71<br>
**************************************<br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
<br>
<fieldset></fieldset>
<br>
<pre>_______________________________________________
sr-dev mailing list
<a moz-do-not-send="true" href="mailto:sr-dev@lists.sip-router.org" target="_blank">sr-dev@lists.sip-router.org</a>
<a moz-do-not-send="true" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a>
</pre>
</blockquote>
<br>
</div>
</div>
<span><font color="#888888">
<pre cols="72">--
Daniel-Constantin Mierla
<a moz-do-not-send="true" href="http://twitter.com/#%21/miconda" target="_blank">http://twitter.com/#!/miconda</a> - <a moz-do-not-send="true" href="http://www.linkedin.com/in/miconda" target="_blank">http://www.linkedin.com/in/miconda</a>
Next Kamailio Advanced Trainings 2014 - <a moz-do-not-send="true" href="http://www.asipto.com" target="_blank">http://www.asipto.com</a>
Sep 22-25, Berlin, Germany</pre>
</font></span></div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a>
Next Kamailio Advanced Trainings 2014 - <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a>
Sep 22-25, Berlin, Germany</pre>
</body>
</html>