From b224ff6e2c23ef795019de18f4bbfcd53c27c3f9 Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Tue, 30 Aug 2022 11:41:10 +0200 Subject: [PATCH] TT#187250 pv_header: fixes from upstream related to tm manage See https://github.com/kamailio/kamailio/issues/3156 for details Change-Id: If0d6b44a4cb3a9861a43241b606d5530618dda71 (cherry picked from commit 0dc19111a868e7fa1aa32cd35467f100f9bd3a60) --- debian/patches/series | 4 +- ..._unset-based-on-vref-instead-of-rese.patch | 34 ++++++++ ...ded-t_unset-intermodule-API-function.patch | 80 +++++++++++++++++++ 3 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 debian/patches/upstream/pv_headers-use-t_unset-based-on-vref-instead-of-rese.patch create mode 100644 debian/patches/upstream/tm-added-t_unset-intermodule-API-function.patch diff --git a/debian/patches/series b/debian/patches/series index a9cf30ba5..c9d4f400d 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -62,8 +62,10 @@ sipwise/pv_headers-rework-pvh_remove_header_param.patch ### active development sipwise/presence-be-more-resilient-doing-clean-up.patch sipwise/tm-check-again-T-just-in-case-before-UNREF.patch -upstream/pv_headers-use-tm.t_find-API.patch upstream/tm-new-inter-module-API-function-t_find.patch +upstream/pv_headers-use-tm.t_find-API.patch +upstream/tm-added-t_unset-intermodule-API-function.patch +upstream/pv_headers-use-t_unset-based-on-vref-instead-of-rese.patch sipwise/pv_headers-rework-pvh_remove_header_param-take-two.patch # ### Don't just put stuff in any order diff --git a/debian/patches/upstream/pv_headers-use-t_unset-based-on-vref-instead-of-rese.patch b/debian/patches/upstream/pv_headers-use-t_unset-based-on-vref-instead-of-rese.patch new file mode 100644 index 000000000..607d2975c --- /dev/null +++ b/debian/patches/upstream/pv_headers-use-t_unset-based-on-vref-instead-of-rese.patch @@ -0,0 +1,34 @@ +From 72234f9efbb5b299823b33dc4eda84a43d5f6384 Mon Sep 17 00:00:00 2001 +From: Daniel-Constantin Mierla +Date: Tue, 30 Aug 2022 10:58:39 +0200 +Subject: [PATCH] pv_headers: use t_unset() based on vref instead of resetting + global t always + +--- + src/modules/pv_headers/pv_headers.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/modules/pv_headers/pv_headers.c b/src/modules/pv_headers/pv_headers.c +index 7da426c184..b900ae5be6 100644 +--- a/src/modules/pv_headers/pv_headers.c ++++ b/src/modules/pv_headers/pv_headers.c +@@ -555,12 +555,12 @@ 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 && vref) { +- tmb.unref_cell(t); ++ if(t != NULL && t != T_UNDEFINED && vref != 0) { ++ /* t_find() above has the side effect of setting T and ++ REFerencing T => we must unref and unset it */ ++ tmb.t_unset(); + LM_DBG("T:%p unref\n", t); + } +- tmb.t_sett(T_UNDEFINED, T_BR_UNDEFINED); +- LM_DBG("reset tm\n"); + + return 1; + } +-- +2.30.2 + diff --git a/debian/patches/upstream/tm-added-t_unset-intermodule-API-function.patch b/debian/patches/upstream/tm-added-t_unset-intermodule-API-function.patch new file mode 100644 index 000000000..ba3b7c300 --- /dev/null +++ b/debian/patches/upstream/tm-added-t_unset-intermodule-API-function.patch @@ -0,0 +1,80 @@ +From f69c13a587df53fb93999d81cd02dc99ab223187 Mon Sep 17 00:00:00 2001 +From: Daniel-Constantin Mierla +Date: Tue, 30 Aug 2022 10:53:15 +0200 +Subject: [PATCH] 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 +--- + src/modules/tm/t_lookup.c | 13 +++++++++++++ + src/modules/tm/t_lookup.h | 3 +++ + src/modules/tm/tm_load.c | 1 + + src/modules/tm/tm_load.h | 1 + + 4 files changed, 18 insertions(+) + +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; +-- +2.30.2 +