[sr-dev] use failure_route for local transaction

Luis Azedo luis.azedo at factorlusitano.com
Tue Mar 5 12:31:18 CET 2019


Hi,

i have a use case where i need to use failure_route for local transactions
like this.

route[TIMER_ROUTE]
{
    ... do sql
    while rows
      t_uac_send ...
}

event_route[tm:local-request]
{
    if this is my request
       t_on_reply("MY_REPLY");
       t_on_failure("MY_FAULT");
       t_set_fr(0, MY_TIMEOUT);
       handle_ruri_alias();
       record_route();
}

but MY_FAULT is never called even for 408 (timeout)

i tracked down to t_reply:run_failure_handlers where the check fails.
...
struct sip_msg *shmem_msg = t->uas.request;
...
if (!shmem_msg) {
LM_WARN("no UAC support (%d, %d) \n", on_failure, t->tmcb_hl.reg_types);
return 0;
}
...

i changed the code a bit  to check for is_local and parse the the request
and it works for me, however i would like other to comment on this approach
as there may be a simpler solution.
thanks

if (!shmem_msg) {
sip_msg_t local_msg;

if(!is_local(t)) {
LM_WARN("no UAC support (%d, %d) \n", on_failure, t->tmcb_hl.reg_types);
return 0;
}

/* parse the retr. buffer */
memset(&local_msg, 0, sizeof(struct sip_msg));
local_msg.buf = t->uac[picked_branch].request.buffer;
local_msg.len = t->uac[picked_branch].request.buffer_len;
if (parse_msg(local_msg.buf, local_msg.len, &local_msg) != 0) {
LM_ERR("failed to parse retr buffer (weird!): \n%.*s\n",
(int)local_msg.len, local_msg.buf);
return 0;
}

t->uas.request = sip_msg_shm_clone(&local_msg, NULL, 1);

free_sip_msg(&local_msg);

if(!t->uas.request) {
LM_ERR("UAS REQ IS NULL AFTER PARSE \n");
return 0;
}

shmem_msg = t->uas.request;

}



>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20190305/321ef4d9/attachment-0001.html>


More information about the sr-dev mailing list