<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body 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<br>
<br>
<div class="moz-cite-prefix">On 03/09/14 12:09, Luis Azedo wrote:<br>
</div>
<blockquote
cite="mid:CAEvFzR87po7eJkonNHREEDgeyyrcGy26330sAR=o+7KztZMu6A@mail.gmail.com"
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">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">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">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">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">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">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 class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
sr-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a>
</pre>
</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>