Browse Source

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

Daniel-Constantin Mierla 10 months ago
parent
commit
db2672636a
1 changed files with 8 additions and 0 deletions
  1. 8 0
      src/modules/tm/t_reply.c

+ 8 - 0
src/modules/tm/t_reply.c

@@ -2990,6 +2990,8 @@ void rpc_reply(rpc_t *rpc, void *c)
 {
 {
 	int ret;
 	int ret;
 	struct cell *trans;
 	struct cell *trans;
+	tm_cell_t *orig_t = NULL;
+	int orig_branch;
 	unsigned int hash_index, label, code;
 	unsigned int hash_index, label, code;
 	str ti, body, headers, tag, reason;
 	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);
 	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) {
 	if(t_lookup_ident(&trans, hash_index, label) < 0) {
 		ERR("Lookup failed\n");
 		ERR("Lookup failed\n");
 		rpc->fault(c, 481, "No such transaction");
 		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
 	/* it's refcounted now, t_reply_with body unrefs for me -- I can
 	 * continue but may not use T anymore  */
 	 * continue but may not use T anymore  */
 	ret = t_reply_with_body(trans, code, &reason, &body, &headers, &tag);
 	ret = t_reply_with_body(trans, code, &reason, &body, &headers, &tag);
+	tm_set_tb(orig_t, orig_branch);
 
 
 	if(ret < 0) {
 	if(ret < 0) {
 		LM_ERR("Reply failed\n");
 		LM_ERR("Reply failed\n");
@@ -3056,6 +3060,8 @@ void rpc_reply_callid(rpc_t *rpc, void *c)
 {
 {
 	int code;
 	int code;
 	tm_cell_t *trans;
 	tm_cell_t *trans;
+	tm_cell_t *orig_t = NULL;
+	int orig_branch;
 	str reason = {0, 0};
 	str reason = {0, 0};
 	str totag = {0, 0};
 	str totag = {0, 0};
 	str hdrs = {0, 0};
 	str hdrs = {0, 0};
@@ -3098,6 +3104,7 @@ void rpc_reply_callid(rpc_t *rpc, void *c)
 		return;
 		return;
 	}
 	}
 
 
+	tm_get_tb(&orig_t, &orig_branch);
 	if(t_lookup_callid(&trans, callid, cseq) < 0) {
 	if(t_lookup_callid(&trans, callid, cseq) < 0) {
 		rpc->fault(c, 404, "Transaction not found");
 		rpc->fault(c, 404, "Transaction not found");
 		return;
 		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
 	/* it's refcounted now, t_reply_with body unrefs for me -- I can
 	 * continue but may not use T anymore  */
 	 * continue but may not use T anymore  */
 	n = t_reply_with_body(trans, code, &reason, &body, &hdrs, &totag);
 	n = t_reply_with_body(trans, code, &reason, &body, &hdrs, &totag);
+	tm_set_tb(orig_t, orig_branch);
 
 
 	if(n < 0) {
 	if(n < 0) {
 		rpc->fault(c, 500, "Reply failed");
 		rpc->fault(c, 500, "Reply failed");