Skip to content

Commit

Permalink
dialog: fix dialog timeout when loading from db
Browse files Browse the repository at this point in the history
Prevent the module from adding the ticks jiffies twice to the dialog
timeout.
  • Loading branch information
razvancrainea committed Apr 16, 2018
1 parent 0784c38 commit dcb3502
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions modules/dialog/dlg_db_handler.c
Expand Up @@ -648,8 +648,8 @@ static int load_dialog_info_from_db(int dlg_hash_size)
* syncing from cluster is finished */
dlg->flags |= DLG_FLAG_FROM_DB;

/* calculcate timeout */
dlg->tl.timeout = (unsigned int)(VAL_INT(values+8)) + get_ticks();
/* calculate timeout */
dlg->tl.timeout = (unsigned int)(VAL_INT(values+8));
if (dlg->tl.timeout<=(unsigned int)time(0))
dlg->tl.timeout = 0;
else
Expand Down Expand Up @@ -1675,8 +1675,8 @@ static int sync_dlg_db_mem(void)
if (dlg_db_mode==DB_MODE_SHUTDOWN)
dlg->flags |= DLG_FLAG_NEW;

/* calculcate timeout */
dlg->tl.timeout = (unsigned int)(VAL_INT(values+8)) + get_ticks();
/* calculate timeout */
dlg->tl.timeout = (unsigned int)(VAL_INT(values+8));
if (dlg->tl.timeout<=(unsigned int)time(0))
dlg->tl.timeout = 0;
else
Expand Down Expand Up @@ -1738,12 +1738,12 @@ static int sync_dlg_db_mem(void)
/* same state :-( no way to tell which is newer */

/* play nice and store longest timeout, although not always correct*/
db_timeout = (unsigned int)(VAL_INT(values+8)) +
get_ticks();
db_timeout = (unsigned int)(VAL_INT(values+8));
if (db_timeout<=(unsigned int)time(0))
db_timeout = 0;
else
db_timeout -= (unsigned int)time(0);
db_timeout += get_ticks();

if (known_dlg->tl.timeout < db_timeout)
known_dlg->tl.timeout = db_timeout;
Expand Down Expand Up @@ -1848,12 +1848,12 @@ static int sync_dlg_db_mem(void)
known_dlg->state = VAL_INT(values+7);

/* update timeout */
known_dlg->tl.timeout = (unsigned int)(VAL_INT(values+8)) +
get_ticks();
known_dlg->tl.timeout = (unsigned int)(VAL_INT(values+8));
if (known_dlg->tl.timeout<=(unsigned int)time(0))
known_dlg->tl.timeout = 0;
else
known_dlg->tl.timeout -= (unsigned int)time(0);
known_dlg->tl.timeout += get_ticks();

/* update cseqs */
if (!VAL_NULL(values+9)) {
Expand Down

0 comments on commit dcb3502

Please sign in to comment.