<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello,<br>
    <br>
    use gdb to investigate the core you get. Be sure that query variable
    has enough space, you don't show its declaration.<br>
    <br>
    Cheers,<br>
    Daniel<br>
    <br>
    <div class="moz-cite-prefix">On 1/8/13 2:40 AM, Krishna Kurapati
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAOzCjAegAX1mDh_n2_=mY6wsQ_o8X_y_rD3gAs+81rtC6EMo3Q@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi,
        <div><br>
        </div>
        <div style="">Since there is no way to limit the result set to
          1, I tried to use raw_query inside msilo module. Everytime it
          executes, it is crashing. The same query if I run in mysql
          shell, it is returning successfully.</div>
        <div style=""><br>
        </div>
        <div style="">Here is the code That I added:</div>
        <div style=""><br>
        </div>
        <div style="">
          <div>query_len = snprintf(query, 2048, "SELECT * &nbsp;FROM %.*s
            &nbsp;WHERE %.*s='%.*s' AND %.*s='%.*s' AND %.*s!=%i AND
            %.*s&lt;%i LIMIT 1;", ms_db_table.len, ms_db_table.s,
            sc_uri_touser.len, sc_uri_touser.s, puri.user.len,
            puri.user.s, sc_uri_tohost.len, sc_uri_tohost.s,
            puri.host.len, puri.host.s, sc_status.len, sc_status.s, 200,
            sc_status.len, sc_status.s, MSG_NOTIFY_OFFSET);</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; if (query_len &lt; 0) {</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LM_ERR("error in sql snprintf");</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; goto error;</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
          <div><br>
          </div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; LM_DBG("m_dump_msg: Query=%s\n", query);</div>
          <div><br>
          </div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; query_str.s = query;</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; query_str.len = query_len;</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; if (msilo_dbf.raw_query(db_con, &amp;query_str,
            &amp;db_res) &lt; 0) {</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LM_ERR("Failed to query database. Query =
            %s\n", query);</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; goto error;</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
          <div><br>
          </div>
          <div style="">The Debug Log at Level 4 shows following:</div>
          <div style=""><br>
          </div>
          <div style="">
            <div>11(7520) DEBUG: msilo [msilo.c:1120]: m_dump_msg:
              Query=SELECT * &nbsp;FROM silo &nbsp;WHERE tousername='968257197'
              AND todomain='50.62.1.7' AND status!=200 AND
              status&lt;1000 LIMIT 1;</div>
            <div>
              <div>11(7520) DEBUG: &lt;core&gt; [db_res.c:118]: allocate
                48 bytes for result set at 0x7fdd4b605540</div>
              <div>11(7520) DEBUG: db_mysql [km_res.c:68]: 16 columns
                returned from the query</div>
              <div>11(7520) DEBUG: &lt;core&gt; [db_res.c:155]: allocate
                128 bytes for result names at 0x7fdd4b5d8dc0</div>
              <div>11(7520) DEBUG: &lt;core&gt; [db_res.c:165]: allocate
                64 bytes for result types at 0x7fdd4b5d8e60</div>
              <div>11(7520) DEBUG: db_mysql [km_res.c:85]: allocate 16
                bytes for RES_NAMES[0] at 0x7fdd4b5d8d90</div>
              <div>11(7520) DEBUG: db_mysql [km_res.c:92]:
                RES_NAMES(0x7fdd4b5d8d90)[0]=[id]</div>
              <div>11(7520) DEBUG: db_mysql [km_res.c:100]: use DB1_INT
                result type</div>
              <div>11(7520) DEBUG: db_mysql [km_res.c:85]: allocate 16
                bytes for RES_NAMES[1] at 0x7fdd4b5d8d60</div>
              <div>11(7520) DEBUG: db_mysql [km_res.c:92]:
                RES_NAMES(0x7fdd4b5d8d60)[1]=[src_addr]</div>
              <div>11(7520) DEBUG: db_mysql [km_res.c:136]: use
                DB1_STRING result type</div>
              <div>11(7520) DEBUG: db_mysql [km_res.c:85]: allocate 16
                bytes for RES_NAMES[2] at 0x7fdd4b5d8d30</div>
              <div>11(7520) DEBUG: db_mysql [km_res.c:92]:
                RES_NAMES(0x7fdd4b5d8d30)[2]=[dst_addr]</div>
              <div>11(7520) DEBUG: db_mysql [km_res.c:136]: use
                DB1_STRING result type<br>
              </div>
            </div>
            <div style=""><br>
            </div>
            <div style="">&lt;skip&gt;</div>
            <div style="">
              <div><br>
              </div>
              <div>11(7520) DEBUG: &lt;core&gt; [db_val.c:117]:
                converting STRING [ac3aeddd9b6f45e6822c824aa2c133b2]</div>
              <div>11(7520) DEBUG: &lt;core&gt; [db_val.c:73]:
                converting INT [0]</div>
              <div>11(7520) DEBUG: &lt;core&gt; [db_val.c:73]:
                converting INT [1]</div>
              <div>26(7552) : &lt;core&gt; [pass_fd.c:293]: ERROR:
                receive_fd: EOF on 22</div>
              <div>26(7552) DEBUG: &lt;core&gt; [tcp_main.c:3592]: DBG:
                handle_ser_child: dead child 11, pid 7520 (shutting
                down?)</div>
              <div>26(7552) DEBUG: &lt;core&gt; [io_wait.h:617]: DBG:
                io_watch_del (0x842d20, 22, -1, 0x0) fd_no=44 called</div>
              <div>26(7552) DEBUG: &lt;core&gt; [tcp_main.c:3353]: DBG:
                handle_tcp_child: dead tcp child 1 (pid 7520, no 11)
                (shutting down?)</div>
              <div>26(7552) DEBUG: &lt;core&gt; [io_wait.h:617]: DBG:
                io_watch_del (0x842d20, 25, -1, 0x0) fd_no=43 called</div>
              <div>&nbsp;0(7509) ALERT: &lt;core&gt; [main.c:787]: child
                process 7520 exited by a signal 11</div>
              <div>&nbsp;0(7509) ALERT: &lt;core&gt; [main.c:790]: core was
                not generated</div>
              <div>&nbsp;0(7509) INFO: &lt;core&gt; [main.c:802]: INFO:
                terminating due to SIGCHLD</div>
              <div><br>
              </div>
              <div><br>
              </div>
            </div>
          </div>
          <div style="">As you can see something happening to Database
            connection. Not sure why I am unable to use raw_query.
            Normal API query from msilo works just fine.</div>
          <div style=""><br>
          </div>
          <div style="">What am I doing wrong to make it crash?</div>
          <div style=""><br>
          </div>
          <div style="">Thanks</div>
          <div style="">Krish Kura</div>
        </div>
      </div>
      <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>