Browse Source

dialog: Correctly restore dialog lifetime from DB

Restore the lifetime to the configured value instead of the offset from the
time the reload from the DB took place.

(cherry picked from commit 3d5f8af6efb5a33e46427a1a9b273e445a3064c7)
(cherry picked from commit 8925975c4e82693fbf262ed45ac179e494fb0ca3)
Alex Hermann 11 years ago
parent
commit
bd7251fa21
1 changed files with 5 additions and 3 deletions
  1. 5 3
      modules/dialog/dlg_db_handler.c

+ 5 - 3
modules/dialog/dlg_db_handler.c

@@ -383,11 +383,13 @@ static int load_dialog_info_from_db(int dlg_hash_size, int fetch_num_rows)
 			dlg->tl.timeout = (unsigned int)(VAL_INT(values+9));
 			LM_DBG("db dialog timeout is %u (%u/%u)\n", dlg->tl.timeout,
 					get_ticks(), (unsigned int)time(0));
-			if (dlg->tl.timeout<=(unsigned int)time(0))
+			if (dlg->tl.timeout<=(unsigned int)time(0)) {
 				dlg->tl.timeout = 0;
-			else
+				dlg->lifetime = 0;
+			} else {
+				dlg->lifetime = dlg->tl.timeout - dlg->start_ts;
 				dlg->tl.timeout -= (unsigned int)time(0);
-			dlg->lifetime = dlg->tl.timeout;
+			}
 
 			GET_STR_VALUE(cseq1, values, 10 , 1, 1);
 			GET_STR_VALUE(cseq2, values, 11 , 1, 1);