Browse Source

dialog: use ksr_time_uint() for getting unsigned int time values

Daniel-Constantin Mierla 10 months ago
parent
commit
e5f90cfce9

+ 2 - 2
src/modules/dialog/dialog.c

@@ -3323,8 +3323,8 @@ static void rpc_dlg_set_state(rpc_t *rpc, void *c)
 	/* updates for terminated dialogs */
 	if(ostate == DLG_STATE_CONFIRMED && sval == DLG_STATE_DELETED) {
 		/* updating timestamps, flags, dialog stats */
-		dlg->init_ts = (unsigned int)(time(0));
-		dlg->end_ts = (unsigned int)(time(0));
+		dlg->init_ts = ksr_time_uint(NULL, NULL);
+		dlg->end_ts = ksr_time_uint(NULL, NULL);
 	}
 	dlg->dflags |= DLG_FLAG_CHANGED;
 

+ 6 - 6
src/modules/dialog/dlg_db_handler.c

@@ -437,13 +437,13 @@ int load_dialog_info_from_db(
 
 			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)) {
+					get_ticks(), ksr_time_uint(NULL, NULL));
+			if(dlg->tl.timeout <= ksr_time_uint(NULL, NULL)) {
 				dlg->tl.timeout = 0;
 				dlg->lifetime = 0;
 			} else {
 				dlg->lifetime = dlg->tl.timeout - dlg->start_ts;
-				dlg->tl.timeout -= (unsigned int)time(0);
+				dlg->tl.timeout -= ksr_time_uint(NULL, NULL);
 			}
 
 			GET_STR_VALUE(cseq1, values, 10, 1, 1);
@@ -492,7 +492,7 @@ int load_dialog_info_from_db(
 
 			if(dlg->state == DLG_STATE_DELETED) {
 				/* end_ts used for force clean up not stored - set it to now */
-				dlg->end_ts = (unsigned int)time(0);
+				dlg->end_ts = ksr_time_uint(NULL, NULL);
 			}
 			/*restore the timer values */
 			if(0 != insert_dlg_timer(&(dlg->tl), (int)dlg->tl.timeout)) {
@@ -898,7 +898,7 @@ int update_dialog_dbinfo_unsafe(struct dlg_cell *cell)
 		VAL_INT(values + 1) = cell->h_id;
 		VAL_INT(values + 9) = cell->start_ts;
 		VAL_INT(values + 10) = cell->state;
-		VAL_INT(values + 11) = (unsigned int)((unsigned int)time(0)
+		VAL_INT(values + 11) = (unsigned int)(ksr_time_uint(NULL, NULL)
 											  + cell->tl.timeout - get_ticks());
 
 		SET_STR_VALUE(values + 2, cell->callid);
@@ -980,7 +980,7 @@ int update_dialog_dbinfo_unsafe(struct dlg_cell *cell)
 		VAL_INT(values) = cell->h_entry;
 		VAL_INT(values + 1) = cell->h_id;
 		VAL_INT(values + 10) = cell->state;
-		VAL_INT(values + 11) = (unsigned int)((unsigned int)time(0)
+		VAL_INT(values + 11) = (unsigned int)(ksr_time_uint(NULL, NULL)
 											  + cell->tl.timeout - get_ticks());
 
 		SET_STR_VALUE(values + 12, cell->cseq[DLG_CALLER_LEG]);

+ 1 - 1
src/modules/dialog/dlg_dmq.c

@@ -349,7 +349,7 @@ int dlg_dmq_handle_msg(
 					dlg->dflags |= DLG_FLAG_NEW;
 					/* keep dialog around for a bit, to prevent out-of-order
 					 * syncs to reestablish the dlg */
-					dlg->init_ts = time(NULL);
+					dlg->init_ts = ksr_time_uint(NULL, NULL);
 					break;
 				default:
 					LM_ERR("unhandled state update to state %u\n", state);

+ 2 - 2
src/modules/dialog/dlg_hash.c

@@ -225,7 +225,7 @@ int dlg_clean_run(ticks_t ti)
 	dlg_cell_t *dlg;
 	dlg_cell_t *tdlg;
 
-	tm = (unsigned int)time(NULL);
+	tm = ksr_time_uint(NULL, NULL);
 	for(i = 0; i < d_table->size; i++) {
 		dlg_lock(d_table, &d_table->entries[i]);
 		dlg = d_table->entries[i].first;
@@ -474,7 +474,7 @@ struct dlg_cell *build_new_dlg(
 
 	memset(dlg, 0, len);
 	dlg->state = DLG_STATE_UNCONFIRMED;
-	dlg->init_ts = (unsigned int)time(NULL);
+	dlg->init_ts = ksr_time_uint(NULL, NULL);
 
 	dlg->h_entry = core_hash(callid, 0, d_table->size);
 	LM_DBG("new dialog on hash %u\n", dlg->h_entry);