Module: kamailio
Branch: master
Commit: e8167a570b534f4fd1af8441af573539543d485b
URL: 
https://github.com/kamailio/kamailio/commit/e8167a570b534f4fd1af8441af573539543d485b

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2026-05-25T08:03:37+02:00

topos: restore old values after event route execution

---

Modified: src/modules/topos/topos_mod.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/e8167a570b534f4fd1af8441af573539543d485b.diff
Patch: 
https://github.com/kamailio/kamailio/commit/e8167a570b534f4fd1af8441af573539543d485b.patch

---

diff --git a/src/modules/topos/topos_mod.c b/src/modules/topos/topos_mod.c
index 2270f733b7f..a88f63d2233 100644
--- a/src/modules/topos/topos_mod.c
+++ b/src/modules/topos/topos_mod.c
@@ -719,7 +719,9 @@ static int tps_execute_event_route(sip_msg_t *msg, 
sr_event_param_t *evp,
 {
        sip_msg_t *fmsg = NULL;
        struct run_act_ctx ctx;
-       int rtb;
+       int rtb = 0;
+       int ret = 0;
+       int route_set = 0;
        sr_kemi_eng_t *keng = NULL;
        onsend_info_t onsnd_info = {0};
        onsend_info_t *p_onsend_bak = 0;
@@ -771,6 +773,7 @@ static int tps_execute_event_route(sip_msg_t *msg, 
sr_event_param_t *evp,
 
        rtb = get_route_type();
        set_route_type(REQUEST_ROUTE);
+       route_set = 1;
        init_run_actions_ctx(&ctx);
        if(evidx >= 0) {
                run_top_route(event_rt.rlist[evidx], (msg) ? msg : fmsg, &ctx);
@@ -780,28 +783,25 @@ static int tps_execute_event_route(sip_msg_t *msg, 
sr_event_param_t *evp,
                                           &_tps_eventrt_callback, evname)
                                        < 0) {
                                LM_ERR("error running event route kemi 
callback\n");
-                               p_onsend = p_onsend_bak;
-                               if(fmsg != NULL && evp->rcv != NULL) {
-                                       fmsg->rcv = fmsg_rcv_bak;
-                               }
-                               return -1;
+                               ret = -1;
+                               goto done;
                        }
                }
        }
-       if(fmsg != NULL && evp->rcv != NULL) {
-               fmsg->rcv = fmsg_rcv_bak;
-       }
-
-       set_route_type(rtb);
        if(ctx.run_flags & DROP_R_F) {
                LM_DBG("exit due to 'drop' in event route\n");
-               p_onsend = p_onsend_bak;
-               return 1;
+               ret = 1;
        }
 
 done:
+       if(route_set) {
+               set_route_type(rtb);
+       }
+       if(fmsg != NULL && evp->rcv != NULL) {
+               fmsg->rcv = fmsg_rcv_bak;
+       }
        p_onsend = p_onsend_bak;
-       return 0;
+       return ret;
 }
 
 /**

_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to