Hello,
the issue is that the sqlops connections are opened in child_init
callback which is executed after the event_route[htable:mod-init].
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.
One workaround for now is to use a shared variable in order to execute
that piece of config only once:
if($sht(once)==0) {
$sht(once) = 1;
# ... your one time config actions here
}
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.
Cheers,
Daniel
On 4/7/11 9:32 PM, Camila Troncoso wrote:
Hello,
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.
I load htable.so module and insert the event_route[] in mi
kamailio.conf script but when I start kamailio it returns an error:
Apr 7 15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
<core> [sr_module.c:828]: DEBUG: init_mod_child (-127): usrloc
Apr 7 15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
<core> [sr_module.c:828]: DEBUG: init_mod_child (-127): registrar
Apr 7 15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
<core> [sr_module.c:828]: DEBUG: init_mod_child (-127): uri_db
Apr 7 15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
<core> [sr_module.c:828]: DEBUG: init_mod_child (-127): domain
Apr 7 15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
<core> [sr_module.c:828]: DEBUG: init_mod_child (-127): permissions
Apr 7 15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
<core> [sr_module.c:828]: DEBUG: init_mod_child (-127): group
Apr 7 15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
<core> [sr_module.c:828]: DEBUG: init_mod_child (-127): mi_fifo
Apr 7 15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
<core> [sr_module.c:828]: DEBUG: init_mod_child (-127): avpops
Apr 7 15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
<core> [sr_module.c:828]: DEBUG: init_mod_child (-127): dialog
Apr 7 15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
<core> [sr_module.c:828]: DEBUG: init_mod_child (-127): lcr
Apr 7 15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
<core> [sr_module.c:828]: DEBUG: init_mod_child (-127): sqlops
Apr 7 15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
<core> [sr_module.c:828]: DEBUG: init_mod_child (-127): rtimer
Apr 7 15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
<core> [sr_module.c:828]: DEBUG: init_mod_child (-127): htable
Apr 7 15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
htable [htable.c:185]: rank is (-127)
Apr 7 15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
htable [htable.c:191]: executing event_route[htable:mod-init] (1)
Apr 7 15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
<core> [parser/msg_parser.c:630]: SIP Request:
Apr 7 15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
<core> [parser/msg_parser.c:632]: method: <OPTIONS>
Apr 7 15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
<core> [parser/msg_parser.c:634]: uri: <sip:you@kamailio.org
<mailto:sip%3Ayou@kamailio.org>>
Apr 7 15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
<core> [parser/msg_parser.c:636]: version: <SIP/2.0>
Apr 7 15:30:22 server4967 /usr/local/sbin/kamailio[31610]: <core>
[mem/q_malloc.c:366]: qm_malloc(0x82bbfa0, 32) called from <core>:
parser/msg_parser.c: parse_headers(341)
Apr 7 15:30:22 server4967 /usr/local/sbin/kamailio[31610]: <core>
[mem/q_malloc.c:406]: qm_malloc(0x82bbfa0, 32) returns address
0x834f780 frag. 0x834f768 (size=32) on 1 -th hit
Apr 7 15:30:22 server4967 /usr/local/sbin/kamailio[31610]: <core>
[mem/q_malloc.c:366]: qm_malloc(0x82bbfa0, 116) called from <core>:
parser/msg_parser.c: get_hdr_field(130)
Apr 7 15:30:22 server4967 /usr/local/sbin/kamailio[31610]: <core>
[mem/q_malloc.c:406]: qm_malloc(0x82bbfa0, 116) returns address
0x834f7d0 frag. 0x834f7b8 (size=116) on 1 -th hit
Apr 7 15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
<core> [parser/parse_via.c:2300]: end of header reached, state=2
Apr 7 15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
<core> [parser/msg_parser.c:515]: parse_headers: Via found, flags=2
Apr 7 15:30:22 server4967 /usr/local/sbin/kamailio[31610]: DEBUG:
<core> [parser/msg_parser.c:517]: parse_headers: this is the first via
Apr 7 15:30:22 server4967 kamailio: ERROR: <core> [daemonize.c:307]:
Main process exited before writing to pipe
**
**
My event_rout[] is as fallows:
event_route[htable:mod-init]{
sql_query("cd", "select prefix from lcr_rule", "rc");
xlog("L_INFO", "dbr = $dbr(rc=>rows)");
if($dbr(rc=>rows)>0){
$var(i) = 0;
while($var(i)<$dbr(rc=>rows)){
$var(prefijo)=$dbr(rc=>[$var(i),0]);
xlog("L_INFO", "$dbr(rc=>[$var(i),0])");
sql_query("cd", "ALTER TABLE rebalse ADD COLUMN
Prefijo_$var(prefijo) INT","rr");
$var(i) = $var(i) + 1;
}
}
sql_result_free("rc");
}
I tested the commands inside the event_route[] and they work fine…
Can someone help me?
Regards,
*Camila Troncoso **|* Ingeniero de Desarrollo
RedVoiss *|*ctroncoso(a)redvoiss.net <mailto:ctroncoso@redvoiss.net>
Santiago- Chile *|*+56 2 2408535
www.redvoiss.net <http://www.redvoiss.net>
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users(a)lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
--
Daniel-Constantin Mierla
http://www.asipto.com