Skip to content

Commit

Permalink
fraud_detection: Improve accuracy for 'concurrent calls'
Browse files Browse the repository at this point in the history
Avoid using the DLGCB_FAILED callback, since it has no protection
against the "408 Request Timeout / 200 OK" race condition, and simply
use DLGCB_DESTROY in order to decrement the concurrent calls counter.

This fixes a bug where a "408 Timeout / 200 OK" call would cause a
concurrent calls value of 4294967295, due to an extra decrement.

Fixes #2079

(cherry picked from commit 2404b96)
  • Loading branch information
liviuchircu committed Aug 3, 2020
1 parent 2535d70 commit a0fcf85
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions modules/dialog/dlg_cb.h
Expand Up @@ -124,7 +124,7 @@ typedef int (*register_dlgcb_f)(struct dlg_cell* dlg, int cb_types,
* care of generating proper BYEs for each participant)
* Registration: per-dialog, "dlg" must be given
* Trigger count: 0 - 1 times per dialog, exclusive with DLGCB_EXPIRED, and one
* of these two will always be called for a dialog
* of these two will always be called for an established dialog
*/
#define DLGCB_TERMINATED (1<<5)

Expand All @@ -137,7 +137,8 @@ typedef int (*register_dlgcb_f)(struct dlg_cell* dlg, int cb_types,
* Registration: per-dialog, "dlg" must be given
* Trigger count:
* * 0 - 1 times per dialog, exclusive with DLGCB_TERMINATED,
* and one of these two will always be called for a dialog
* and one of these two will always be called for an
* established dialog
*
* * if using replication sharing tags, this callback is only
* ran by the node that has the Active tag.
Expand Down
2 changes: 1 addition & 1 deletion modules/fraud_detection/fraud_detection.c
Expand Up @@ -455,7 +455,7 @@ static int check_fraud(struct sip_msg *msg, char *_user, char *_number, char *_p
param->calldur_warn = thr->call_duration_thr.warning;
param->calldur_crit = thr->call_duration_thr.critical;

if (dlgb.register_dlgcb(dlgc, DLGCB_TERMINATED|DLGCB_FAILED|DLGCB_EXPIRED,
if (dlgb.register_dlgcb(dlgc, DLGCB_DESTROY,
dialog_terminate_CB, param, free_dialog_CB_param) != 0) {
LM_ERR("failed to register dialog terminated callback\n");
shm_free(param->number.s);
Expand Down

0 comments on commit a0fcf85

Please sign in to comment.