MINOR: activity: use nanoseconds, not timeval to compute uptime
Now that we have the required functions, let's get rid of the timeval
in intermediary calculations.
diff --git a/src/activity.c b/src/activity.c
index 5a7d844..0065b60 100644
--- a/src/activity.c
+++ b/src/activity.c
@@ -1026,7 +1026,8 @@
struct stconn *sc = appctx_sc(appctx);
struct show_activity_ctx *actctx = appctx->svcctx;
int tgt = actctx->thr; // target thread, -1 for all, 0 for total only
- struct timeval up;
+ uint up_sec, up_usec;
+ ullong up;
int thr;
/* FIXME: Don't watch the other side ! */
@@ -1086,11 +1087,13 @@
} while (0)
/* retrieve uptime */
- tv_remain(&start_time, &now, &up);
+ up = tv_to_ns(&now) - tv_to_ns(&start_time);
+ up_sec = ns_to_sec(up);
+ up_usec = (up / 1000U) % 1000000U;
chunk_appendf(&trash, "thread_id: %u (%u..%u)\n", tid + 1, 1, global.nbthread);
chunk_appendf(&trash, "date_now: %lu.%06lu\n", (ulong)date.tv_sec, (ulong)date.tv_usec);
- chunk_appendf(&trash, "uptime_now: %lu.%06lu\n", (ulong)up.tv_sec, (ulong)up.tv_usec);
+ chunk_appendf(&trash, "uptime_now: %u.%06u\n", up_sec, up_usec);
chunk_appendf(&trash, "ctxsw:"); SHOW_TOT(thr, activity[thr].ctxsw);
chunk_appendf(&trash, "tasksw:"); SHOW_TOT(thr, activity[thr].tasksw);
chunk_appendf(&trash, "empty_rq:"); SHOW_TOT(thr, activity[thr].empty_rq);