MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / run_failure_handlers

Function run_failure_handlers

modules/tm/t_reply.c:594–657  ·  view source on GitHub ↗

return 1 if a failure_route processes */

Source from the content-addressed store, hash-verified

592
593/* return 1 if a failure_route processes */
594static inline int run_failure_handlers(struct cell *t)
595{
596 static struct sip_msg faked_req;
597 struct sip_msg *shmem_msg;
598 struct ua_client *uac;
599 int on_failure_idx;
600 int old_route_type;
601
602 shmem_msg = t->uas.request;
603 uac = & TM_BRANCH(t, picked_branch);
604
605 /* failure_route for a local UAC? */
606 if (!shmem_msg || REQ_LINE(shmem_msg).method_value==METHOD_CANCEL ) {
607 LM_WARN("no UAC or CANCEL support (%s, %d) \n",
608 ref_script_route_name(t->on_negative), t->tmcb_hl.reg_types);
609 return 0;
610 }
611
612 /* don't start faking anything if we don't have to */
613 if ( !ref_script_route_check_and_update(t->on_negative) &&
614 !has_tran_tmcbs( t, TMCB_ON_FAILURE) ) {
615 LM_WARN("no failure route (%s/%d), callbacks (%d)\n",
616 ref_script_route_name(t->on_negative),
617 ref_script_route_idx(t->on_negative),
618 t->tmcb_hl.reg_types);
619 return 1;
620 }
621
622 if (!fake_req(&faked_req, shmem_msg, &t->uas, NULL)) {
623 LM_ERR("fake_req failed\n");
624 return 0;
625 }
626 /* fake also the env. conforming to the fake msg */
627 faked_env( t, &faked_req);
628
629 /* DONE with faking ;-) -> run the failure handlers */
630 if ( has_tran_tmcbs( t, TMCB_ON_FAILURE) ) {
631 run_trans_callbacks( TMCB_ON_FAILURE, t, &faked_req,
632 uac->reply, uac->last_received);
633 }
634 if (ref_script_route_is_valid(t->on_negative)) {
635 /* update flags in transaction if changed by callbacks */
636 shmem_msg->flags = faked_req.flags;
637 /* avoid recursion -- if failure_route forwards, and does not
638 * set next failure route, failure_route will not be reentered
639 * on failure */
640 on_failure_idx = t->on_negative->idx;
641 t_on_negative(NULL);
642 /* run a reply_route action if some was marked */
643 swap_route_type(old_route_type, FAILURE_ROUTE);
644 run_top_route(sroutes->failure[on_failure_idx], &faked_req);
645 set_route_type(old_route_type);
646 }
647
648 /* restore original environment and free the fake msg */
649 faked_env( t, 0);
650 free_faked_req(&faked_req,t);
651

Callers 1

t_should_relay_responseFunction · 0.85

Calls 6

fake_reqFunction · 0.85
faked_envFunction · 0.85
run_trans_callbacksFunction · 0.85
t_on_negativeFunction · 0.85
run_top_routeFunction · 0.85
free_faked_reqFunction · 0.85

Tested by

no test coverage detected