Skip to content

Commit

Permalink
cgrates: serialize variables in a different var
Browse files Browse the repository at this point in the history
This prevents ongoing sessions from being overwritten by the serialized
value.

(cherry picked from commit ae10e1a)
  • Loading branch information
razvancrainea committed Dec 17, 2018
1 parent 6d1eda3 commit 3dab829
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions modules/cgrates/cgrates_acc.c
Expand Up @@ -37,6 +37,7 @@ static void cgr_dlg_callback(struct dlg_cell *dlg, int type,
struct dlg_cb_params *_params);

static str cgr_ctx_str = str_init("cgrX_ctx");
static str cgr_serial_str = str_init("cgrX_serial");

static inline struct cgr_acc_ctx *cgr_new_acc_ctx(struct dlg_cell *dlg)
{
Expand Down Expand Up @@ -789,7 +790,7 @@ static void cgr_dlg_onwrite(struct dlg_cell *dlg, int type,
LM_BUG("length mismatch between computed and result: %d != %d\n",
buf.len, (int)(p - buf.s));

if (cgr_dlgb.store_dlg_value(dlg, &cgr_ctx_str, &buf) < 0)
if (cgr_dlgb.store_dlg_value(dlg, &cgr_serial_str, &buf) < 0)
LM_ERR("cannot store the serialized context value!\n");

pkg_free(buf.s);
Expand Down Expand Up @@ -1053,7 +1054,7 @@ void cgr_loaded_callback(struct dlg_cell *dlg, int type,
return;
}

if (cgr_dlgb.fetch_dlg_value(dlg, &cgr_ctx_str, &buf, 0) < 0) {
if (cgr_dlgb.fetch_dlg_value(dlg, &cgr_serial_str, &buf, 0) < 0) {
LM_DBG("ctx was not saved in dialog\n");
return;
}
Expand Down

0 comments on commit 3dab829

Please sign in to comment.