mirror of https://github.com/sipwise/kamailio.git
See https://github.com/kamailio/kamailio/issues/3156#issuecomment-1227171208 for details Change-Id: Ie9d17b42a5e913b64a3311e7ed23cf7480d4bf63 (cherry picked from commitmr10.5.1514e257329) (cherry picked from commitfe4ca249a5)
parent
f24857d77f
commit
8fce53709d
@ -0,0 +1,58 @@
|
||||
From 836d122af8575c66651232f3ad25bad085bfb972 Mon Sep 17 00:00:00 2001
|
||||
From: Victor Seva <linuxmaniac@torreviejawireless.org>
|
||||
Date: Sun, 28 Aug 2022 22:59:44 +0200
|
||||
Subject: [PATCH] pv_headers: use tm.t_find API
|
||||
|
||||
---
|
||||
src/modules/pv_headers/pv_headers.c | 21 ++++++++-------------
|
||||
1 file changed, 8 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/src/modules/pv_headers/pv_headers.c b/src/modules/pv_headers/pv_headers.c
|
||||
index e555e0265b..7da426c184 100644
|
||||
--- a/src/modules/pv_headers/pv_headers.c
|
||||
+++ b/src/modules/pv_headers/pv_headers.c
|
||||
@@ -526,6 +526,7 @@ int handle_msg_branch_cb(struct sip_msg *msg, unsigned int flags, void *cb)
|
||||
|
||||
int handle_msg_reply_cb(struct sip_msg *msg, unsigned int flags, void *cb)
|
||||
{
|
||||
+ int vref = 0;
|
||||
tm_cell_t *t = NULL;
|
||||
sr_xavp_t **backup_xavis = NULL;
|
||||
sr_xavp_t **list = NULL;
|
||||
@@ -534,18 +535,12 @@ int handle_msg_reply_cb(struct sip_msg *msg, unsigned int flags, void *cb)
|
||||
return 1;
|
||||
LM_DBG("msg:%p previous branch:%d\n", msg, _branch);
|
||||
|
||||
- if(tmb.t_check(msg, &_branch) == -1) {
|
||||
- LM_ERR("failed find UAC branch\n");
|
||||
- } else {
|
||||
- t = tmb.t_gett();
|
||||
- if(t == NULL || t == T_UNDEFINED) {
|
||||
- LM_DBG("cannot lookup the transaction\n");
|
||||
- } else {
|
||||
- LM_DBG("T:%p t_check-branch:%d xavi_list:%p branches:%d\n", t,
|
||||
- _branch, &t->xavis_list, t->nr_of_outgoings);
|
||||
- list = &t->xavis_list;
|
||||
- backup_xavis = xavi_set_list(&t->xavis_list);
|
||||
- }
|
||||
+ t = tmb.t_find(msg, &_branch, &vref);
|
||||
+ if(t != NULL && t != T_UNDEFINED) {
|
||||
+ LM_DBG("T:%p t_check-branch:%d xavi_list:%p branches:%d\n", t,
|
||||
+ _branch, &t->xavis_list, t->nr_of_outgoings);
|
||||
+ list = &t->xavis_list;
|
||||
+ backup_xavis = xavi_set_list(&t->xavis_list);
|
||||
}
|
||||
|
||||
pvh_get_branch_index(msg, &_branch);
|
||||
@@ -560,7 +555,7 @@ int handle_msg_reply_cb(struct sip_msg *msg, unsigned int flags, void *cb)
|
||||
xavi_set_list(backup_xavis);
|
||||
LM_DBG("restored backup_xavis:%p\n", *backup_xavis);
|
||||
}
|
||||
- if(t) {
|
||||
+ if(t && vref) {
|
||||
tmb.unref_cell(t);
|
||||
LM_DBG("T:%p unref\n", t);
|
||||
}
|
||||
--
|
||||
2.30.2
|
||||
|
||||
@ -0,0 +1,88 @@
|
||||
From a9cf4577c25d7933531b8969a1941bac4faf8d68 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel-Constantin Mierla <miconda@gmail.com>
|
||||
Date: Thu, 25 Aug 2022 14:51:23 +0200
|
||||
Subject: [PATCH] tm: new inter-module API function t_find(...)
|
||||
|
||||
- combines get_t() with t_check_msg(...) to get the transaction,
|
||||
returning also if it was referenced or not
|
||||
---
|
||||
src/modules/tm/t_lookup.c | 22 ++++++++++++++++++++++
|
||||
src/modules/tm/t_lookup.h | 3 +++
|
||||
src/modules/tm/tm_load.c | 1 +
|
||||
src/modules/tm/tm_load.h | 1 +
|
||||
4 files changed, 27 insertions(+)
|
||||
|
||||
diff --git a/src/modules/tm/t_lookup.c b/src/modules/tm/t_lookup.c
|
||||
index f041116bb8..ad41f0de93 100644
|
||||
--- a/src/modules/tm/t_lookup.c
|
||||
+++ b/src/modules/tm/t_lookup.c
|
||||
@@ -145,6 +145,28 @@ int get_t_branch()
|
||||
return T_branch;
|
||||
}
|
||||
|
||||
+/**
|
||||
+ * return the transaction by combining get() and t_check_msg()
|
||||
+ * - if T is not set, checks the transactions table for msg, and if found,
|
||||
+ * sets T and *branch as well as *vref=1 to signal that T was ref'ed
|
||||
+ */
|
||||
+struct cell* t_find(struct sip_msg *msg, int *branch, int *vref)
|
||||
+{
|
||||
+ if(vref) {
|
||||
+ *vref = 0;
|
||||
+ }
|
||||
+ if(T != NULL && T != T_UNDEFINED) {
|
||||
+ return T;
|
||||
+ }
|
||||
+ t_check_msg(msg, branch);
|
||||
+ if(T != NULL && T != T_UNDEFINED) {
|
||||
+ if(vref) {
|
||||
+ *vref = 1;
|
||||
+ }
|
||||
+ }
|
||||
+ return T;
|
||||
+}
|
||||
+
|
||||
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 1f6596a90d..de65be8365 100644
|
||||
--- a/src/modules/tm/t_lookup.h
|
||||
+++ b/src/modules/tm/t_lookup.h
|
||||
@@ -68,6 +68,9 @@ int t_check_msg(struct sip_msg* , int *branch );
|
||||
typedef struct cell * (*tgett_f)(void);
|
||||
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 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 8635b90eae..c9f39b576e 100644
|
||||
--- a/src/modules/tm/tm_load.c
|
||||
+++ b/src/modules/tm/tm_load.c
|
||||
@@ -92,6 +92,7 @@ int load_tm( struct tm_binds *tmb)
|
||||
tmb->free_dlg = free_dlg;
|
||||
tmb->print_dlg = print_dlg;
|
||||
tmb->t_gett = get_t;
|
||||
+ tmb->t_find = t_find;
|
||||
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 4695a8f7e1..1f97061d1e 100644
|
||||
--- a/src/modules/tm/tm_load.h
|
||||
+++ b/src/modules/tm/tm_load.h
|
||||
@@ -71,6 +71,7 @@ struct tm_binds {
|
||||
free_dlg_f free_dlg;
|
||||
print_dlg_f print_dlg;
|
||||
tgett_f t_gett;
|
||||
+ tfind_f t_find;
|
||||
tgett_branch_f t_gett_branch;
|
||||
tsett_f t_sett;
|
||||
calculate_hooks_f calculate_hooks;
|
||||
--
|
||||
2.30.2
|
||||
|
||||
Loading…
Reference in new issue