From 2ce88e255cda64980f4c4c03845a1a9cebed6728 Mon Sep 17 00:00:00 2001 From: Marco Capetta Date: Mon, 16 Mar 2026 14:42:51 +0100 Subject: [PATCH] MT#63881 tm: use bitwise check for REQ_ERR_DELAYED in t_unref() Apply upstream patch 7da9a0a5da047ec2258f722a99447e06b5851dc8 Change-Id: Id8363e499211f3c9feb731d803dbe336e4134b90 (cherry picked from commit 383626e909712ee884d2a673119b86d148f4e38b) (cherry picked from commit d3b197bd0e80e724ee6922ea0b3ad98fbbec6e72) --- debian/patches/series | 1 + .../upstream/tm_drop_stuck_transaction.patch | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 debian/patches/upstream/tm_drop_stuck_transaction.patch diff --git a/debian/patches/series b/debian/patches/series index d99eb5153..22c668cc5 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -27,6 +27,7 @@ sipwise/sca-debug.patch sipwise/sca-fix-notify-after-bye.patch sipwise/sca-add-pai_avp-parameter.patch ## upstream master +upstream/tm_drop_stuck_transaction.patch # ### relevant for upstream sipwise/dialplan-don-t-stop-loading-rules-on-error.patch diff --git a/debian/patches/upstream/tm_drop_stuck_transaction.patch b/debian/patches/upstream/tm_drop_stuck_transaction.patch new file mode 100644 index 000000000..6e7cbadf2 --- /dev/null +++ b/debian/patches/upstream/tm_drop_stuck_transaction.patch @@ -0,0 +1,32 @@ +--- a/src/modules/tm/t_lookup.c ++++ b/src/modules/tm/t_lookup.c +@@ -2057,7 +2057,7 @@ int t_unref(struct sip_msg *p_msg) + return -1; + if(p_msg->first_line.type == SIP_REQUEST) { + kr = get_kr(); +- if(unlikely(kr == REQ_ERR_DELAYED)) { ++ if(unlikely(kr & REQ_ERR_DELAYED)) { + LM_DBG("delayed error reply generation(%d)\n", tm_error); + if(unlikely(is_route_type(FAILURE_ROUTE))) { + LM_BUG("called w/ kr=REQ_ERR_DELAYED in failure" +@@ -2074,15 +2074,12 @@ int t_unref(struct sip_msg *p_msg) + && !(kr & REQ_RLSD)))) { + LM_WARN("script writer didn't release transaction\n"); + t_release_transaction(T); +- } else if(unlikely((kr & REQ_ERR_DELAYED) +- && (kr +- & ~(REQ_RLSD | REQ_RPLD | REQ_ERR_DELAYED +- | REQ_FWDED)))) { +- LM_BUG("REQ_ERR DELAYED should have been caught much" +- " earlier for %p: %d (hex %x)\n", +- T, kr, kr); ++ } else if(unlikely(T->nr_of_outgoings == 0 ++ && !(T->flags & T_IN_AGONY))) { ++ LM_WARN("dropping orphaned transaction without branches" ++ " T=%p kr=%d\n", T, kr); + t_release_transaction(T); +- } ++ } + } + tm_error = 0; /* clear it */ + UNREF(T);