[SR-Users] raw_query is crashing....

Krishna Kurapati kkurapat at gmail.com
Tue Jan 8 02:40:32 CET 2013


Hi,

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.

Here is the code That I added:

query_len = snprintf(query, 2048, "SELECT *  FROM %.*s  WHERE %.*s='%.*s'
AND %.*s='%.*s' AND %.*s!=%i AND %.*s<%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);
        if (query_len < 0) {
                LM_ERR("error in sql snprintf");
                goto error;
        }

        LM_DBG("m_dump_msg: Query=%s\n", query);

        query_str.s = query;
        query_str.len = query_len;
        if (msilo_dbf.raw_query(db_con, &query_str, &db_res) < 0) {
                LM_ERR("Failed to query database. Query = %s\n", query);
                goto error;
        }

The Debug Log at Level 4 shows following:

11(7520) DEBUG: msilo [msilo.c:1120]: m_dump_msg: Query=SELECT *  FROM silo
 WHERE tousername='968257197' AND todomain='50.62.1.7' AND status!=200 AND
status<1000 LIMIT 1;
11(7520) DEBUG: <core> [db_res.c:118]: allocate 48 bytes for result set at
0x7fdd4b605540
11(7520) DEBUG: db_mysql [km_res.c:68]: 16 columns returned from the query
11(7520) DEBUG: <core> [db_res.c:155]: allocate 128 bytes for result names
at 0x7fdd4b5d8dc0
11(7520) DEBUG: <core> [db_res.c:165]: allocate 64 bytes for result types
at 0x7fdd4b5d8e60
11(7520) DEBUG: db_mysql [km_res.c:85]: allocate 16 bytes for RES_NAMES[0]
at 0x7fdd4b5d8d90
11(7520) DEBUG: db_mysql [km_res.c:92]: RES_NAMES(0x7fdd4b5d8d90)[0]=[id]
11(7520) DEBUG: db_mysql [km_res.c:100]: use DB1_INT result type
11(7520) DEBUG: db_mysql [km_res.c:85]: allocate 16 bytes for RES_NAMES[1]
at 0x7fdd4b5d8d60
11(7520) DEBUG: db_mysql [km_res.c:92]:
RES_NAMES(0x7fdd4b5d8d60)[1]=[src_addr]
11(7520) DEBUG: db_mysql [km_res.c:136]: use DB1_STRING result type
11(7520) DEBUG: db_mysql [km_res.c:85]: allocate 16 bytes for RES_NAMES[2]
at 0x7fdd4b5d8d30
11(7520) DEBUG: db_mysql [km_res.c:92]:
RES_NAMES(0x7fdd4b5d8d30)[2]=[dst_addr]
11(7520) DEBUG: db_mysql [km_res.c:136]: use DB1_STRING result type

<skip>

11(7520) DEBUG: <core> [db_val.c:117]: converting STRING
[ac3aeddd9b6f45e6822c824aa2c133b2]
11(7520) DEBUG: <core> [db_val.c:73]: converting INT [0]
11(7520) DEBUG: <core> [db_val.c:73]: converting INT [1]
26(7552) : <core> [pass_fd.c:293]: ERROR: receive_fd: EOF on 22
26(7552) DEBUG: <core> [tcp_main.c:3592]: DBG: handle_ser_child: dead child
11, pid 7520 (shutting down?)
26(7552) DEBUG: <core> [io_wait.h:617]: DBG: io_watch_del (0x842d20, 22,
-1, 0x0) fd_no=44 called
26(7552) DEBUG: <core> [tcp_main.c:3353]: DBG: handle_tcp_child: dead tcp
child 1 (pid 7520, no 11) (shutting down?)
26(7552) DEBUG: <core> [io_wait.h:617]: DBG: io_watch_del (0x842d20, 25,
-1, 0x0) fd_no=43 called
 0(7509) ALERT: <core> [main.c:787]: child process 7520 exited by a signal
11
 0(7509) ALERT: <core> [main.c:790]: core was not generated
 0(7509) INFO: <core> [main.c:802]: INFO: terminating due to SIGCHLD


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.

What am I doing wrong to make it crash?

Thanks
Krish Kura
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20130107/baf60a43/attachment-0001.htm>


More information about the sr-users mailing list