Module: kamailio
Branch: 5.2
Commit: f36d6562e54acc2b2f72c04a628b8e85f36bc9dd
URL:
https://github.com/kamailio/kamailio/commit/f36d6562e54acc2b2f72c04a628b8e8…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-10-09T19:37:58+02:00
tm: skip resuming suspended transactions put on wait
- transaction is expired in that moment, pending its destroy process
- GH #2055
(cherry picked from commit 52afc7b70f8e4abfb347c84872ab7daa202a6a24)
(cherry picked from commit c44bd17c79bc0119ae201b826d84b9514700eda9)
---
Modified: src/modules/tm/t_lookup.c
Modified: src/modules/tm/t_lookup.h
Modified: src/modules/tm/t_suspend.c
---
Diff:
https://github.com/kamailio/kamailio/commit/f36d6562e54acc2b2f72c04a628b8e8…
Patch:
https://github.com/kamailio/kamailio/commit/f36d6562e54acc2b2f72c04a628b8e8…
---
diff --git a/src/modules/tm/t_lookup.c b/src/modules/tm/t_lookup.c
index 45cbf0b4ed..e2baadb2ae 100644
--- a/src/modules/tm/t_lookup.c
+++ b/src/modules/tm/t_lookup.c
@@ -1586,11 +1586,12 @@ int t_get_canceled_ident(struct sip_msg* msg, unsigned int*
hash_index,
* 0).
* @param hash_index - searched transaction hash_index (part of the ident).
* @param label - searched transaction label (part of the ident).
+ * @param filter - if 1, skip transaction put on-wait (terminated state).
* @return -1 on error/not found, 1 on success (found)
* Side-effects: sets T and T_branch (T_branch always to T_BR_UNDEFINED).
*/
-int t_lookup_ident(struct cell ** trans, unsigned int hash_index,
- unsigned int label)
+int t_lookup_ident_filter(struct cell ** trans, unsigned int hash_index,
+ unsigned int label, int filter)
{
struct cell* p_cell;
struct entry* hash_bucket;
@@ -1608,9 +1609,19 @@ int t_lookup_ident(struct cell ** trans, unsigned int hash_index,
#endif
hash_bucket=&(get_tm_table()->entries[hash_index]);
/* all the transactions from the entry are compared */
- clist_foreach(hash_bucket, p_cell, next_c){
+ clist_foreach(hash_bucket, p_cell, next_c) {
prefetch_loc_r(p_cell->next_c, 1);
- if(p_cell->label == label){
+ if(p_cell->label == label) {
+ if(filter==1) {
+ if(t_on_wait(p_cell)) {
+ /* transaction in terminated state */
+ UNLOCK_HASH(hash_index);
+ set_t(0, T_BR_UNDEFINED);
+ *trans=NULL;
+ LM_DBG("transaction in terminated phase - skipping\n");
+ return -1;
+ }
+ }
REF_UNSAFE(p_cell);
UNLOCK_HASH(hash_index);
set_t(p_cell, T_BR_UNDEFINED);
@@ -1622,14 +1633,27 @@ int t_lookup_ident(struct cell ** trans, unsigned int hash_index,
UNLOCK_HASH(hash_index);
set_t(0, T_BR_UNDEFINED);
- *trans=p_cell;
+ *trans=NULL;
LM_DBG("transaction not found\n");
return -1;
}
-
+/** lookup a transaction based on its identifier (hash_index:label).
+ * @param trans - double pointer to cell structure, that will be filled
+ * with the result (a pointer to an existing transaction or
+ * 0).
+ * @param hash_index - searched transaction hash_index (part of the ident).
+ * @param label - searched transaction label (part of the ident).
+ * @return -1 on error/not found, 1 on success (found)
+ * Side-effects: sets T and T_branch (T_branch always to T_BR_UNDEFINED).
+ */
+int t_lookup_ident(struct cell ** trans, unsigned int hash_index,
+ unsigned int label)
+{
+ return t_lookup_ident_filter(trans, hash_index, label, 0);
+}
/** check if a transaction is local or not.
* Check if the transaction corresponding to the current message
diff --git a/src/modules/tm/t_lookup.h b/src/modules/tm/t_lookup.h
index 2180311f69..d01528518b 100644
--- a/src/modules/tm/t_lookup.h
+++ b/src/modules/tm/t_lookup.h
@@ -94,6 +94,8 @@ typedef int (*tset_fr_f)(struct sip_msg*, unsigned int, unsigned int);
int t_is_local(struct sip_msg*);
int t_get_trans_ident(struct sip_msg* p_msg, unsigned int* hash_index, unsigned int*
label);
int t_lookup_ident(struct cell** trans, unsigned int hash_index, unsigned int label);
+int t_lookup_ident_filter(struct cell ** trans, unsigned int hash_index,
+ unsigned int label, int filter);
/* lookup a transaction by callid and cseq */
int t_lookup_callid(struct cell** trans, str callid, str cseq);
diff --git a/src/modules/tm/t_suspend.c b/src/modules/tm/t_suspend.c
index c2c0773b3f..3f129303fe 100644
--- a/src/modules/tm/t_suspend.c
+++ b/src/modules/tm/t_suspend.c
@@ -187,9 +187,9 @@ int t_continue_helper(unsigned int hash_index, unsigned int label,
backup_T = get_t();
backup_T_branch = get_t_branch();
- if (t_lookup_ident(&t, hash_index, label) < 0) {
+ if (t_lookup_ident_filter(&t, hash_index, label, 1) < 0) {
set_t(backup_T, backup_T_branch);
- LM_ERR("transaction not found\n");
+ LM_ERR("active transaction not found\n");
return -1;
}