Skip to content

Commit

Permalink
tm: skip resuming suspended transactions put on wait
Browse files Browse the repository at this point in the history
- transaction is expired in that moment, pending its destroy process
- GH #2055

(cherry picked from commit 52afc7b)
  • Loading branch information
miconda committed Oct 9, 2019
1 parent fc9ca0f commit c44bd17
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
36 changes: 30 additions & 6 deletions src/modules/tm/t_lookup.c
Expand Up @@ -1568,11 +1568,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;
Expand All @@ -1590,9 +1591,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);
Expand All @@ -1604,14 +1615,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
Expand Down
2 changes: 2 additions & 0 deletions src/modules/tm/t_lookup.h
Expand Up @@ -92,6 +92,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);

Expand Down
4 changes: 2 additions & 2 deletions src/modules/tm/t_suspend.c
Expand Up @@ -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;
}

Expand Down

0 comments on commit c44bd17

Please sign in to comment.