<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Indeed, the db connection is not initialized at the time of
executing event_route[htable:mod-init]. This is executed after all
modules are initialized, but the sqlops connections are initialized
in child init.<br>
<br>
However, it should not cause this crash. What version are you using?
Because latest master and 4.1 have a simple condition at
sql_api.c:257.<br>
<br>
Cheers,<br>
Daniel<br>
<br>
<div class="moz-cite-prefix">On 15/05/14 12:44, Waite, Hugh wrote:<br>
</div>
<blockquote
cite="mid:A125E59206A9104F81AB3874E34FEF792B5298FEA8@cz-nag-mbx01.intinfra.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<meta name="Generator" content="Microsoft Word 14 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I
added this to my config to try and it caused a segfault on
startup in sql_query.<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">It
seems the db connection is not initialised at this point.<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Courier
New";color:#1F497D">(gdb) bt<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Courier
New";color:#1F497D">#0 0x0000000000000000 in ?? ()<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Courier
New";color:#1F497D">#1 0x00007f47450517ef in
sql_do_query (con=0x7f474d573930, query=0x7ffffc18f350,
res=0x7f474d7220a0) at sql_api.c:257<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Courier
New";color:#1F497D">#2 0x00007f4745059a7b in sql_query
(msg=0x7f47484ea540, dbl=0x7f474d573930 "@;WMG\177",
query=0x7f474d6780e8 "\250\016rMG\177", res=0x7f474d7220a0
"j8Wi") at sqlops.c:209<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Courier
New";color:#1F497D">#3 0x0000000000419ca2 in do_action
(h=0x7ffffc18fa50, a=0x7f474d7207b0, msg=0x7f47484ea540) at
action.c:1117<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Courier
New";color:#1F497D">#4 0x0000000000422878 in
run_actions (h=0x7ffffc18fa50, a=0x7f474d720420,
msg=0x7f47484ea540) at action.c:1599<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Courier
New";color:#1F497D">#5 0x0000000000423017 in
run_top_route (a=0x7f474d720420, msg=0x7f47484ea540,
c=0x7ffffc18fa50) at action.c:1685<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Courier
New";color:#1F497D">#6 0x00007f4742d1cbec in
child_init (rank=-127) at htable.c:223<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Courier
New";color:#1F497D">#7 0x00000000004f7ec2 in
init_mod_child (m=0x7f474d56dad8, rank=-127) at
sr_module.c:924<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Courier
New";color:#1F497D">#8 0x00000000004f7d65 in
init_mod_child (m=0x7f474d56e3e0, rank=-127) at
sr_module.c:921<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Courier
New";color:#1F497D">#9 0x00000000004f8048 in
init_child (rank=-127) at sr_module.c:948<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Courier
New";color:#1F497D">#10 0x000000000046ce42 in main_loop
() at main.c:1571<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Courier
New";color:#1F497D">#11 0x000000000047030b in main
(argc=13, argv=0x7ffffc18fec8) at main.c:2533<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Courier
New";color:#1F497D">(gdb) frame 1<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Courier
New";color:#1F497D">#1 0x00007f47450517ef in
sql_do_query (con=0x7f474d573930, query=0x7ffffc18f350,
res=0x7f474d7220a0) at sql_api.c:257<o:p></o:p></span></p>
<p class="MsoNormal"><b><span
style="font-size:10.0pt;font-family:"Courier
New";color:#1F497D">257
if(con->dbf.raw_query(con->dbh, query,
&db_res)!=0)<o:p></o:p></span></b></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Courier
New";color:#1F497D">(gdb) p con<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Courier
New";color:#1F497D">$1 = (sql_con_t *) 0x7f474d573930<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Courier
New";color:#1F497D">(gdb) p con->dbf<o:p></o:p></span></p>
<p class="MsoNormal"><b><span
style="font-size:10.0pt;font-family:"Courier
New";color:#1F497D">$2 = {cap = 0, use_table = 0,
init = 0, init2 = 0, close = 0, query = 0, fetch_result =
0, raw_query = 0, free_result = 0, insert = 0, delete = 0,
update = 0, replace = 0, last_inserted_id = 0,
insert_update = 0, insert_delayed = 0,<o:p></o:p></span></b></p>
<p class="MsoNormal"><b><span
style="font-size:10.0pt;font-family:"Courier
New";color:#1F497D"> affected_rows = 0,
start_transaction = 0, end_transaction = 0,
abort_transaction = 0, query_lock = 0}<o:p></o:p></span></b></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Courier
New";color:#1F497D">(gdb)<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Regards,<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Hugh<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span
style="font-size:10.0pt;font-family:"Tahoma","sans-serif""
lang="EN-US">From:</span></b><span
style="font-size:10.0pt;font-family:"Tahoma","sans-serif""
lang="EN-US"> <a class="moz-txt-link-abbreviated" href="mailto:sr-users-bounces@lists.sip-router.org">sr-users-bounces@lists.sip-router.org</a>
[<a class="moz-txt-link-freetext" href="mailto:sr-users-bounces@lists.sip-router.org">mailto:sr-users-bounces@lists.sip-router.org</a>]
<b>On Behalf Of </b>Sebastian Damm<br>
<b>Sent:</b> 15 May 2014 10:34<br>
<b>To:</b> SIP Router - Kamailio (OpenSER) and SIP Express
Router (SER) - Users Mailing List<br>
<b>Subject:</b> [SR-Users] DB select htable:mod-init doesn't
work<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Hi,<o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt">I'm
trying to fill a hash table on startup in the
htable:mod-init event route. But it doesn't work.
Kamailio doesn't start at all, but doesn't print out an
error in the log.<o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt">This is
what the route looks like:<br>
<br>
event_route[htable:mod-init] {<br>
xlog("L_NOTICE", "Loading Carrier domains into
Hash table.\n");<br>
sql_query("ser", "select domain_name from
carrier_domains", "domains");<br>
xlog("L_NOTICE", "Loaded from database...\n");<br>
while($var(i)<$dbr(domains=>cols)) {<br>
xlog("L_NOTICE", "Entry:
$dbr(domains=>[$var(i),0])\n");<br>
$sht(carrierips=>$var(i)) =
$dbr(domains=>[$var(i),0]);<br>
$var(i) = $var(i) + 1;<br>
}<br>
}<o:p></o:p></p>
</div>
<p class="MsoNormal">Of course, the necessary parameters are
set.<br>
modparam("htable", "htable", "carrierips=>size=6")<br>
modparam("sqlops","sqlcon","ser=>mysql://<a
moz-do-not-send="true"
href="http://user:password@127.0.0.1/ser">user:password@127.0.0.1/ser</a>")<br
clear="all">
<o:p></o:p></p>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">In
the log I see the following:<br>
May 15 11:25:33 linux /usr/sbin/kamailio[20872]:
NOTICE: <script>: Loading Carrier domains into
Hash table.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">As
you can see, there should be a lot more output, but
nothing happens anymore after that. In ngrep I see
other queries going to the same database from other
modules, but my query from the event route is never
executed.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Am I
missing something?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Best Regards,<br>
Sebastian<o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<hr>
<font color="Gray" face="Arial" size="1">This e-mail and any
attachment is for authorised use by the intended recipient(s)
only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not
be copied, disclosed to, retained or used by, any other party.
If you are not an intended recipient then please promptly delete
this e-mail and any attachment and all copies and inform the
sender. Thank you for understanding.<br>
</font>
<br clear="all">
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla - <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a>
<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></pre>
</body>
</html>