Hi Friends,<br><br>i'm using mod_nibblebill for billing on FS, i bundled event processing<br>fucntions when status change,<br>e.g. /* on_routing */ check_billing_before_routing,<br>and * on_hangup */ process_hangup, as below,<br>
however, i found if i make a call containing two-legs e.g. user 1001 call user 1002, then the FS core dump. but if i only make one leg call, e.g. call 888 for IVR, then no problem occure, i found the problem within function "check_billing_before_routing" (because once i comment all of lines within this func, the core did not dump). below is the func "check_billing_before_routing", can anyone help advise what's wrong? how should i correct it, thanks.<br>
<br>static switch_status_t check_billing_before_routing(switch_core_session_t *session)<br>{<br> //charles, check billing before routing the call<br> <br> char buf[128];<br> char cmd[100] = "check_billing_before_answer";<br>
FILE *pp = NULL;<br><br> const char* in_username = NULL;<br> const char* in_calledstation = NULL;<br> const char* in_uniqueid = NULL;<br> const char* in_network_addr = NULL;<br> const char* in_type = "9";<br>
int is_b;<br> <br> //const char* full_cmd;<br> int i_continue = 1;<br> switch_channel_t *channel = NULL;<br><br><br> in_uniqueid = switch_core_session_get_uuid(session);<br> <br> channel = switch_core_session_get_channel(session);<br>
<br> /*only billing on a leg*/<br> is_b = channel && switch_channel_get_originator_caller_profile(channel);<br> printf("is_b is: %d\n", is_b);<br> if(is_b)<br> {<br> return SWITCH_STATUS_SUCCESS;<br>
}<br><br> /* Lock this session's data for this module while we tinker with it */<br> if (globals.mutex) {<br> switch_mutex_lock(globals.mutex);<br> }<br> <br> <br> in_username = switch_channel_get_variable(channel, "caller_id_number");<br>
in_calledstation = switch_channel_get_variable(channel, "destination_number");<br> in_network_addr = switch_channel_get_variable(channel, "network_addr");<br><br> <br> /* Done checking - release lock */<br>
if (globals.mutex) {<br> switch_mutex_unlock(globals.mutex);<br> }<br> <br><br> switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "check_billing_before_routing, in_username: %s, in_calledstation: %s, in_uniqueid: %s in_type: %s, in_network_addr: %s \n", in_username, in_calledstation, in_uniqueid, in_type, in_network_addr);<br>
<br><br> strcat(cmd, " ");<br> strcat(cmd, in_username);<br> strcat(cmd, " ");<br> strcat(cmd, in_calledstation);<br> strcat(cmd, " ");<br> strcat(cmd, in_uniqueid);<br>
strcat(cmd, " ");<br> strcat(cmd, in_type);<br> strcat(cmd, " ");<br> strcat(cmd, in_network_addr);<br><br> printf("excute external cmd: ");<br> printf(cmd);<br> printf("\n");<br>
<br> if( (pp = popen(cmd, "r")) == NULL )<br> {<br> printf("popen() error!\n");<br> exit(1);<br> }<br><br> while(fgets(buf, sizeof buf, pp))<br> {<br> printf("the result of excuting external cmd: %s", buf);<br>
}<br><br> if(pp)<br> {<br> pclose(pp); <br> }<br><br> i_continue = atoi(buf);<br><br> printf("i_continue: %d", i_continue);<br><br><br> if (!i_continue) {<br> <br> switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "call was not authorized to continue \n");<br>
<br> transfer_call(session, globals.nobal_action);<br> }<br><br> <br><br><br> return SWITCH_STATUS_SUCCESS;<br><br>}<br><br><br><span style="background-color: rgb(255, 255, 51);">Core dump logs:</span><br>
<br>freeswitch@freeswitch> 2011-10-24 16:30:26.583369 [NOTICE] mod_xml_rpc.c:969 Starting HTTP Port 8787, DocRoot [/usr/local/freeswitch/htdocs]<br>2011-10-24 16:30:29.454743 [WARNING] sofia_reg.c:1337 SIP auth challenge (INVITE) on sofia profile 'internal' for [<a href="mailto:6628@224.193.106.204">6628@224.193.106.204</a>] from ip 223.128.70.10<br>
2011-10-24 16:30:30.254710 [NOTICE] switch_channel.c:897 New Channel sofia/internal/<a href="mailto:8068@224.193.106.204">8068@224.193.106.204</a> [196a50b8-eaa0-4ef0-a674-18602117f5ec]<br>is_b is: 0<br>excute external cmd: check_billing_before_answer 8068 6628 196a50b8-eaa0-4ef0-a674-18602117f5ec 9 223.128.70.10<br>
2011-10-24 16:30:30.254710 [INFO] mod_nibblebill.c:1017 check_billing_before_routing, in_username: 8068, in_calledstation: 6628, in_uniqueid: 196a50b8-eaa0-4ef0-a674-18602117f5ec in_type: 9, in_network_addr: 223.128.70.10 <br>
the result of excuting external cmd: <br>the result of excuting external cmd: 60<br>Segmentation fault (core dumped)<br>[root@freeswitch bin]# <br><br>-- <br>Regards,<br>Charles<br><br>