Browse code

dialog: added duration field in dialog rpc output

Daniel-Constantin Mierla authored on 13/12/2021 08:54:29
Showing 1 changed files
... ...
@@ -2324,10 +2324,20 @@ static inline void internal_rpc_print_dlg(rpc_t *rpc, void *c, dlg_cell_t *dlg,
2324 2324
 	void *h, *sh, *ssh;
2325 2325
 	dlg_profile_link_t *pl;
2326 2326
 	dlg_var_t *var;
2327
+	time_t tnow;
2328
+	int tdur;
2327 2329
 
2328 2330
 	if (rpc->add(c, "{", &h) < 0) goto error;
2329 2331
 
2330
-	rpc->struct_add(h, "dddSSSddddddddd",
2332
+	tnow = time(NULL);
2333
+	if(dlg->end_ts) {
2334
+		tdur = (int)(dlg->end_ts - dlg->start_ts);
2335
+	} if(dlg->start_ts) {
2336
+		tdur = (int)(tnow - dlg->start_ts);
2337
+	} else {
2338
+		tdur = 0;
2339
+	}
2340
+	rpc->struct_add(h, "dddSSSdddddddddd",
2331 2341
 		"h_entry", dlg->h_entry,
2332 2342
 		"h_id", dlg->h_id,
2333 2343
 		"ref", dlg->ref,
... ...
@@ -2338,7 +2348,8 @@ static inline void internal_rpc_print_dlg(rpc_t *rpc, void *c, dlg_cell_t *dlg,
2338 2348
 		"start_ts", dlg->start_ts,
2339 2349
 		"init_ts", dlg->init_ts,
2340 2350
 		"end_ts", dlg->end_ts,
2341
-		"timeout", dlg->tl.timeout ? time(0) + dlg->tl.timeout - get_ticks() : 0,
2351
+		"duration", tdur,
2352
+		"timeout", dlg->tl.timeout ? tnow + dlg->tl.timeout - get_ticks() : 0,
2342 2353
 		"lifetime", dlg->lifetime,
2343 2354
 		"dflags", dlg->dflags,
2344 2355
 		"sflags", dlg->sflags,