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

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2024-11-15T09:44:54+01:00

tm: backup/restor current T/branch for rpc reply commands

---

Modified: src/modules/tm/t_reply.c

---

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

---

diff --git a/src/modules/tm/t_reply.c b/src/modules/tm/t_reply.c
index a87a9281bf7..a7221235844 100644
--- a/src/modules/tm/t_reply.c
+++ b/src/modules/tm/t_reply.c
@@ -2990,6 +2990,8 @@ void rpc_reply(rpc_t *rpc, void *c)
 {
        int ret;
        struct cell *trans;
+       tm_cell_t *orig_t = NULL;
+       int orig_branch;
        unsigned int hash_index, label, code;
        str ti, body, headers, tag, reason;
 
@@ -3025,6 +3027,7 @@ void rpc_reply(rpc_t *rpc, void *c)
        }
        LM_DBG("hash_index=%u label=%u\n", hash_index, label);
 
+       tm_get_tb(&orig_t, &orig_branch);
        if(t_lookup_ident(&trans, hash_index, label) < 0) {
                ERR("Lookup failed\n");
                rpc->fault(c, 481, "No such transaction");
@@ -3034,6 +3037,7 @@ void rpc_reply(rpc_t *rpc, void *c)
        /* it's refcounted now, t_reply_with body unrefs for me -- I can
         * continue but may not use T anymore  */
        ret = t_reply_with_body(trans, code, &reason, &body, &headers, &tag);
+       tm_set_tb(orig_t, orig_branch);
 
        if(ret < 0) {
                LM_ERR("Reply failed\n");
@@ -3056,6 +3060,8 @@ void rpc_reply_callid(rpc_t *rpc, void *c)
 {
        int code;
        tm_cell_t *trans;
+       tm_cell_t *orig_t = NULL;
+       int orig_branch;
        str reason = {0, 0};
        str totag = {0, 0};
        str hdrs = {0, 0};
@@ -3098,6 +3104,7 @@ void rpc_reply_callid(rpc_t *rpc, void *c)
                return;
        }
 
+       tm_get_tb(&orig_t, &orig_branch);
        if(t_lookup_callid(&trans, callid, cseq) < 0) {
                rpc->fault(c, 404, "Transaction not found");
                return;
@@ -3106,6 +3113,7 @@ void rpc_reply_callid(rpc_t *rpc, void *c)
        /* it's refcounted now, t_reply_with body unrefs for me -- I can
         * continue but may not use T anymore  */
        n = t_reply_with_body(trans, code, &reason, &body, &hdrs, &totag);
+       tm_set_tb(orig_t, orig_branch);
 
        if(n < 0) {
                rpc->fault(c, 500, "Reply failed");

_______________________________________________
Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to