From dcb35022ba9b3bad3bf8b6a356f0b96199ce0e92 Mon Sep 17 00:00:00 2001 From: Razvan Crainea Date: Mon, 16 Apr 2018 11:45:04 +0300 Subject: [PATCH] dialog: fix dialog timeout when loading from db Prevent the module from adding the ticks jiffies twice to the dialog timeout. --- modules/dialog/dlg_db_handler.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/dialog/dlg_db_handler.c b/modules/dialog/dlg_db_handler.c index ffad5f06e66..61e470af4a5 100644 --- a/modules/dialog/dlg_db_handler.c +++ b/modules/dialog/dlg_db_handler.c @@ -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 @@ -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 @@ -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; @@ -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)) {