Skip to content

Commit

Permalink
[acc][bugfix] enable acc flags refcount only after dlg callbacks called
Browse files Browse the repository at this point in the history
(cherry picked from commit a9a8fba51da95d3244ab46e22b3ed6cd8d0bea9e)
  • Loading branch information
ionutrazvanionita committed Jun 15, 2016
1 parent 4357fe8 commit a0cf37a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
21 changes: 17 additions & 4 deletions modules/acc/acc_logic.c
Expand Up @@ -132,6 +132,11 @@ static int is_cdr_enabled=0;
#define set_cdr_values_registered(_mask) \
(_mask) |= ACC_CDR_REGISTERED;

#define set_dlg_cb_used(_mask) \
(_mask) |= ACC_DLG_CB_USED;

#define was_dlg_cb_used(_mask) (_mask&ACC_DLG_CB_USED)

#define cdr_values_registered(_mask) ((_mask)&ACC_CDR_REGISTERED)


Expand Down Expand Up @@ -159,11 +164,13 @@ static int is_cdr_enabled=0;

#define ACC_MASK_DEC_REF(mask) \
do { \
if (!(mask&0xFF00000000000000)) { \
LM_BUG("More substitutions than additions in acc mask!\n"); \
return; \
if (was_dlg_cb_used(mask)) { \
if (!(mask&0xFF00000000000000)) { \
LM_BUG("More substitutions than additions in acc mask!\n"); \
return; \
} \
mask = mask - (0x100000000000000); \
} \
mask = mask - (0x100000000000000); \
} while (0);

/* read the value of the 8th byte as a char type value */
Expand Down Expand Up @@ -736,6 +743,12 @@ static void acc_dlg_callback(struct dlg_cell *dlg, int type,
LM_DBG("flags[%p] ref counter value after referencing [%llu]\n",
*_params->param,
ACC_MASK_GET_REF(*((unsigned long long*)*_params->param)));
/*
* this way we "enable" the refcount
* if opensips shuts down before dialog terminated then the refcount
* won't be enabled
*/
set_dlg_cb_used(*((unsigned long long*)*_params->param));

if (is_evi_acc_on(flags)) {
env_set_event(acc_cdr_event);
Expand Down
10 changes: 9 additions & 1 deletion modules/acc/acc_logic.h
Expand Up @@ -62,7 +62,15 @@
/* flags on the eigth byte - generic flags for all accounting types */
#define ACC_DIALOG_CONTEXT (((unsigned long long)1<<(8*6)) * (1<<0))
#define ACC_CDR_REGISTERED (((unsigned long long)1<<(8*6)) * (1<<1))

/*
* this flag will help to know if we entered at least once
* in the dialog callbacks
*
* this way, at shutdown, we will know that we didn't call any
* dialog callbacks and value 0 in the 8th byte(ref count)
* is valid
*/
#define ACC_DLG_CB_USED (((unsigned long long)1<<(8*6)) * (1<<2))
#define ACC_MASK_REF_BYTE (((unsigned long long)(0xFF)<<(8*7))


Expand Down

0 comments on commit a0cf37a

Please sign in to comment.