[sr-dev] git:master:f69c13a5: tm: added t_unset() intermodule API function

Daniel-Constantin Mierla miconda at gmail.com
Tue Aug 30 10:59:49 CEST 2022


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2022-08-30T10:53:15+02:00

tm: added t_unset() intermodule API function

- reset global t and branch without releasing the transaction
- useful for cases when global t needs to be set in callbacks and then
  reset before config execution is finished

---

Modified: src/modules/tm/t_lookup.c
Modified: src/modules/tm/t_lookup.h
Modified: src/modules/tm/tm_load.c
Modified: src/modules/tm/tm_load.h

---

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

---

diff --git a/src/modules/tm/t_lookup.c b/src/modules/tm/t_lookup.c
index ad41f0de93..dd2ed6f0ae 100644
--- a/src/modules/tm/t_lookup.c
+++ b/src/modules/tm/t_lookup.c
@@ -167,6 +167,19 @@ struct cell* t_find(struct sip_msg *msg, int *branch, int *vref)
 	return T;
 }
 
+/**
+ * unref and reset T globals
+ */
+void t_unset(void)
+{
+	if(T == NULL || T == T_UNDEFINED) {
+		return;
+	}
+
+	UNREF( T );
+	set_t(T_UNDEFINED, T_BR_UNDEFINED);
+}
+
 static inline int parse_dlg( struct sip_msg *msg )
 {
 	if (parse_headers(msg, HDR_FROM_F | HDR_CSEQ_F | HDR_TO_F, 0)==-1) {
diff --git a/src/modules/tm/t_lookup.h b/src/modules/tm/t_lookup.h
index de65be8365..c4b5404cf8 100644
--- a/src/modules/tm/t_lookup.h
+++ b/src/modules/tm/t_lookup.h
@@ -71,6 +71,9 @@ struct cell *get_t(void);
 typedef struct cell* (*tfind_f)(struct sip_msg*, int*, int*);
 struct cell* t_find(struct sip_msg *msg, int *branch, int *vref);
 
+typedef void (*tunset_f)(void);
+void t_unset(void);
+
 typedef int (*tgett_branch_f)(void);
 int get_t_branch(void);
 
diff --git a/src/modules/tm/tm_load.c b/src/modules/tm/tm_load.c
index c9f39b576e..d5fc6e7884 100644
--- a/src/modules/tm/tm_load.c
+++ b/src/modules/tm/tm_load.c
@@ -93,6 +93,7 @@ int load_tm( struct tm_binds *tmb)
 	tmb->print_dlg = print_dlg;
 	tmb->t_gett = get_t;
 	tmb->t_find = t_find;
+	tmb->t_unset = t_unset;
 	tmb->t_gett_branch = get_t_branch;
 	tmb->t_sett = set_t;
 	tmb->calculate_hooks = w_calculate_hooks;
diff --git a/src/modules/tm/tm_load.h b/src/modules/tm/tm_load.h
index 1f97061d1e..130d01503a 100644
--- a/src/modules/tm/tm_load.h
+++ b/src/modules/tm/tm_load.h
@@ -72,6 +72,7 @@ struct tm_binds {
 	print_dlg_f        print_dlg;
 	tgett_f            t_gett;
 	tfind_f            t_find;
+	tunset_f           t_unset;
 	tgett_branch_f     t_gett_branch;
 	tsett_f            t_sett;
 	calculate_hooks_f  calculate_hooks;




More information about the sr-dev mailing list