<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    Hello,<br>
    <br>
    the issue is that the sqlops connections are opened in child_init
    callback which is executed after the event_route[htable:mod-init].<br>
    <br>
    I kind of need same feature for some config, the plan is to add
    another event_route executed by the sqlops after initialization of
    its connections.<br>
    <br>
    One workaround for now is to use a shared variable in order to
    execute that piece of config only once:<br>
    <br>
    if($sht(once)==0) {<br>
        $sht(once) = 1;<br>
        # ... your one time config actions here<br>
    }<br>
    <br>
    To be fully safe, if that matters for you at the expense of
    synchronized execution of that config part, you should wrap the test
    and update of the $sht(once) inside locks -- see cfgutils module for
    that.<br>
    <br>
    Cheers,<br>
    Daniel<br>
    <br>
    On 4/7/11 9:32 PM, Camila Troncoso wrote:
    <blockquote
      cite="mid:14123d7a6fc4c43490addc6a60bc8703@mail.gmail.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <meta name="Generator" content="Microsoft Word 12 (filtered
        medium)">
      <style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Trebuchet MS";
        panose-1:2 11 6 3 2 2 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-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-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 3.0cm 70.85pt 3.0cm;}
div.WordSection1
        {page:WordSection1;}
--></style>
      <div class="WordSection1">
        <p class="MsoNormal"><span lang="EN-US">Hello, </span></p>
        <p class="MsoNormal"><span lang="EN-US"> </span></p>
        <p class="MsoNormal">
          <span lang="EN-US">I´m using Kamalio 3.1.0 and want to alter
            some databases (mysql) tables at kamailio starts. I read
            that the route event_route[htable:mod-init] allows me to do
            that, but i´m having some problems. </span></p>
        <p class="MsoNormal"><span lang="EN-US">I load htable.so module
            and insert the event_route[] in mi kamailio.conf script but
            when I start kamailio it returns an error: </span></p>
        <p class="MsoNormal"><span lang="EN-US"> </span></p>
        <p class="MsoNormal"><span lang="EN-US"> </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
            &lt;core&gt; [sr_module.c:828]: DEBUG: init_mod_child
            (-127): usrloc </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
            &lt;core&gt; [sr_module.c:828]: DEBUG: init_mod_child
            (-127): registrar </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
            &lt;core&gt; [sr_module.c:828]: DEBUG: init_mod_child
            (-127): uri_db </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
            &lt;core&gt; [sr_module.c:828]: DEBUG: init_mod_child
            (-127): domain </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
            &lt;core&gt; [sr_module.c:828]: DEBUG: init_mod_child
            (-127): permissions </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
            &lt;core&gt; [sr_module.c:828]: DEBUG: init_mod_child
            (-127): group </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
            &lt;core&gt; [sr_module.c:828]: DEBUG: init_mod_child
            (-127): mi_fifo </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
            &lt;core&gt; [sr_module.c:828]: DEBUG: init_mod_child
            (-127): avpops </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
            &lt;core&gt; [sr_module.c:828]: DEBUG: init_mod_child
            (-127): dialog </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
            &lt;core&gt; [sr_module.c:828]: DEBUG: init_mod_child
            (-127): lcr </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
            &lt;core&gt; [sr_module.c:828]: DEBUG: init_mod_child
            (-127): sqlops </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
            &lt;core&gt; [sr_module.c:828]: DEBUG: init_mod_child
            (-127): rtimer </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
            &lt;core&gt; [sr_module.c:828]: DEBUG: init_mod_child
            (-127): htable </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
            htable [htable.c:185]: rank is (-127) </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
            htable [htable.c:191]: executing
            event_route[htable:mod-init] (1) </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
            &lt;core&gt; [parser/msg_parser.c:630]: SIP Request: </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
            &lt;core&gt; [parser/msg_parser.c:632]:  method: 
            &lt;OPTIONS&gt; </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
            &lt;core&gt; [parser/msg_parser.c:634]:  uri:     &lt;<a
              moz-do-not-send="true"
              href="mailto:sip%3Ayou@kamailio.org">sip:you@kamailio.org</a>&gt;
          </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
            &lt;core&gt; [parser/msg_parser.c:636]:  version:
            &lt;SIP/2.0&gt; </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 /usr/local/sbin/kamailio[31610]:
            &lt;core&gt; [mem/q_malloc.c:366]: qm_malloc(0x82bbfa0, 32)
            called from &lt;core&gt;: parser/msg_parser.c:
            parse_headers(341) </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 /usr/local/sbin/kamailio[31610]:
            &lt;core&gt; [mem/q_malloc.c:406]: qm_malloc(0x82bbfa0, 32)
            returns address 0x834f780 frag. 0x834f768 (size=32) on 1 -th
            hit </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 /usr/local/sbin/kamailio[31610]:
            &lt;core&gt; [mem/q_malloc.c:366]: qm_malloc(0x82bbfa0, 116)
            called from &lt;core&gt;: parser/msg_parser.c:
            get_hdr_field(130) </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 /usr/local/sbin/kamailio[31610]:
            &lt;core&gt; [mem/q_malloc.c:406]: qm_malloc(0x82bbfa0, 116)
            returns address 0x834f7d0 frag. 0x834f7b8 (size=116) on 1
            -th hit </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
            &lt;core&gt; [parser/parse_via.c:2300]: end of header
            reached, state=2 </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
            &lt;core&gt; [parser/msg_parser.c:515]: parse_headers: Via
            found, flags=2 </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
            &lt;core&gt; [parser/msg_parser.c:517]: parse_headers: this
            is the first via </span></p>
        <p class="MsoNormal" style=""><span style="font-size: 9pt;
            font-family: &quot;Courier New&quot;;" lang="EN-US">Apr  7
            15:30:22 server4967 kamailio: ERROR: &lt;core&gt;
            [daemonize.c:307]: Main process exited before writing to
            pipe </span></p>
        <p class="MsoNormal"><b><span style="font-size: 9pt;
              font-family: &quot;Courier New&quot;;" lang="EN-US"> </span></b></p>
        <p class="MsoNormal"><b><span style="font-size: 9pt;
              font-family: &quot;Courier New&quot;;" lang="EN-US"> </span></b></p>
        <p class="MsoNormal"><span lang="EN-US">My event_rout[] is as
            fallows:</span></p>
        <p class="MsoNormal"><span style="font-size: 9pt; font-family:
            &quot;Courier New&quot;;" lang="EN-US"> </span></p>
        <p class="MsoNormal"><span style="font-size: 9pt; font-family:
            &quot;Courier New&quot;;" lang="EN-US">event_route[htable:mod-init]{</span></p>
        <p class="MsoNormal"><span style="font-size: 9pt; font-family:
            &quot;Courier New&quot;;" lang="EN-US">       </span></p>
        <p class="MsoNormal" style="text-indent: 35.4pt;"><span
            style="font-size: 9pt; font-family: &quot;Courier
            New&quot;;" lang="EN-US">sql_query("cd", "select prefix from
            lcr_rule", "rc");</span></p>
        <p class="MsoNormal"><span style="font-size: 9pt; font-family:
            &quot;Courier New&quot;;" lang="EN-US">       xlog("L_INFO",
            "dbr = $dbr(rc=&gt;rows)");</span></p>
        <p class="MsoNormal"><span style="font-size: 9pt; font-family:
            &quot;Courier New&quot;;" lang="EN-US">      
            if($dbr(rc=&gt;rows)&gt;0){</span></p>
        <p class="MsoNormal"><span style="font-size: 9pt; font-family:
            &quot;Courier New&quot;;" lang="EN-US">             $var(i)
            = 0;</span></p>
        <p class="MsoNormal"><span style="font-size: 9pt; font-family:
            &quot;Courier New&quot;;" lang="EN-US">            
            while($var(i)&lt;$dbr(rc=&gt;rows)){</span></p>
        <p class="MsoNormal"><span style="font-size: 9pt; font-family:
            &quot;Courier New&quot;;" lang="EN-US">                    </span><span
            style="font-size: 9pt; font-family: &quot;Courier
            New&quot;;">$var(prefijo)=$dbr(rc=&gt;[$var(i),0]);</span></p>
        <p class="MsoNormal"><span style="font-size: 9pt; font-family:
            &quot;Courier New&quot;;">                    </span><span
            style="font-size: 9pt; font-family: &quot;Courier
            New&quot;;" lang="EN-US">xlog("L_INFO",
            "$dbr(rc=&gt;[$var(i),0])");</span></p>
        <p class="MsoNormal"><span style="font-size: 9pt; font-family:
            &quot;Courier New&quot;;" lang="EN-US">                   
            sql_query("cd", "ALTER TABLE rebalse ADD COLUMN
            Prefijo_$var(prefijo) INT","rr");</span></p>
        <p class="MsoNormal"><span style="font-size: 9pt; font-family:
            &quot;Courier New&quot;;" lang="EN-US">                   
            $var(i) = $var(i) + 1;</span></p>
        <p class="MsoNormal"><span style="font-size: 9pt; font-family:
            &quot;Courier New&quot;;" lang="EN-US">             }</span></p>
        <p class="MsoNormal"><span style="font-size: 9pt; font-family:
            &quot;Courier New&quot;;" lang="EN-US">       }</span></p>
        <p class="MsoNormal"><span style="font-size: 9pt; font-family:
            &quot;Courier New&quot;;" lang="EN-US">      
            sql_result_free("rc");</span></p>
        <p class="MsoNormal"><span style="font-size: 9pt; font-family:
            &quot;Courier New&quot;;" lang="EN-US">}</span></p>
        <p class="MsoNormal"><span lang="EN-US"> </span></p>
        <p class="MsoNormal"><span lang="EN-US"> </span></p>
        <p class="MsoNormal">
          <span lang="EN-US">I tested the commands inside the
            event_route[] and they work fine…</span></p>
        <p class="MsoNormal"><span lang="EN-US"> </span></p>
        <p class="MsoNormal"><span lang="EN-US">Can someone help me?</span></p>
        <p class="MsoNormal">
          <span lang="EN-US"> </span></p>
        <p class="MsoNormal"><span lang="EN-US">Regards,</span></p>
        <p class="MsoNormal"><span lang="EN-US"> </span></p>
        <p class="MsoNormal"><b><span style="font-size: 10pt;
              font-family: &quot;Arial&quot;,&quot;sans-serif&quot;;
              color: black;">Camila Troncoso </span></b><b><span
              style="font-size: 10pt; font-family: &quot;Trebuchet
              MS&quot;,&quot;sans-serif&quot;; color: rgb(255, 192, 0);">|</span></b><span
            style="font-size: 10pt; font-family: &quot;Trebuchet
            MS&quot;,&quot;sans-serif&quot;; color: gray;"> Ingeniero de
            Desarrollo</span></p>
        <p class="MsoNormal"><span style="font-size: 10pt; font-family:
            &quot;Trebuchet MS&quot;,&quot;sans-serif&quot;; color:
            black;">RedVoiss </span><b><span style="font-size: 10pt;
              font-family: &quot;Trebuchet
              MS&quot;,&quot;sans-serif&quot;; color: rgb(255, 192, 0);">|</span></b><span
            style="font-size: 9pt; font-family: &quot;Trebuchet
            MS&quot;,&quot;sans-serif&quot;; color: rgb(127, 127, 127);"><a
              moz-do-not-send="true"
              href="mailto:ctroncoso@redvoiss.net">ctroncoso@redvoiss.net</a></span><span
            style="font-size: 8pt; font-family: &quot;Trebuchet
            MS&quot;,&quot;sans-serif&quot;; color: black;"></span></p>
        <p class="MsoNormal" style="margin-top: 3pt;"><span
            style="font-size: 9pt; font-family: &quot;Trebuchet
            MS&quot;,&quot;sans-serif&quot;; color: rgb(89, 89, 89);"
            lang="EN-US">Santiago</span><span style="font-size: 9pt;
            font-family: &quot;Trebuchet
            MS&quot;,&quot;sans-serif&quot;; color: gray;" lang="EN-US">
            - Chile </span><b><span style="font-size: 9pt; font-family:
              &quot;Trebuchet MS&quot;,&quot;sans-serif&quot;; color:
              rgb(255, 192, 0);" lang="EN-US">|</span></b><span
            style="font-size: 9pt; font-family: &quot;Trebuchet
            MS&quot;,&quot;sans-serif&quot;; color: gray;" lang="EN-US">
            +56 2 2408535 </span></p>
        <p class="MsoNormal" style="margin-top: 3pt;"><span
            style="font-size: 9pt; font-family: &quot;Trebuchet
            MS&quot;,&quot;sans-serif&quot;; color: rgb(127, 127, 127);"
            lang="EN-US"><a moz-do-not-send="true"
              href="http://www.redvoiss.net">www.redvoiss.net</a>     </span><span
            style="font-size: 9pt; font-family: &quot;Trebuchet
            MS&quot;,&quot;sans-serif&quot;; color: black;" lang="EN-US"></span></p>
        <p class="MsoNormal"> </p>
      </div>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
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></pre>
  </body>
</html>