MINOR: checks: use a nanosecond counters instead of timeval for checks->start
Now we store the checks start date as a nanosecond timestamps instead
of a timeval, this will simplify the operations with "now" in the near
future.
diff --git a/include/haproxy/check-t.h b/include/haproxy/check-t.h
index c489ae3..5b80189 100644
--- a/include/haproxy/check-t.h
+++ b/include/haproxy/check-t.h
@@ -156,7 +156,7 @@
struct buffer bi, bo; /* input and output buffers to send/recv check */
struct buffer_wait buf_wait; /* Wait list for buffer allocation */
struct task *task; /* the task associated to the health check processing, NULL if disabled */
- struct timeval start; /* last health check start time */
+ ullong start; /* last health check start time */
long duration; /* time in ms took to finish last health check */
short status, code; /* check result, check code */
unsigned short port; /* the port to use for the health checks */
diff --git a/src/check.c b/src/check.c
index a8aeb9a..1d67dfd 100644
--- a/src/check.c
+++ b/src/check.c
@@ -471,7 +471,7 @@
if (status == HCHK_STATUS_START) {
check->result = CHK_RES_UNKNOWN; /* no result yet */
check->desc[0] = '\0';
- check->start = now;
+ check->start = tv_to_ns(&now);
return;
}
@@ -490,10 +490,10 @@
if (status == HCHK_STATUS_HANA)
check->duration = -1;
- else if (!tv_iszero(&check->start)) {
+ else if (check->start) {
/* set_server_check_status() may be called more than once */
- check->duration = ns_to_ms(tv_to_ns(&now) - tv_to_ns(&check->start));
- tv_zero(&check->start);
+ check->duration = ns_to_ms(tv_to_ns(&now) - check->start);
+ check->start = 0;
}
/* no change is expected if no state change occurred */
@@ -1499,7 +1499,7 @@
/* check this every ms */
t->expire = tick_add(now_ms, MS_TO_TICKS(mininter * srvpos / nbcheck));
- check->start = now;
+ check->start = tv_to_ns(&now);
task_queue(t);
return 1;
diff --git a/src/mailers.c b/src/mailers.c
index 05d5313..89732d5 100644
--- a/src/mailers.c
+++ b/src/mailers.c
@@ -145,7 +145,7 @@
/* check this in one ms */
t->expire = TICK_ETERNITY;
- check->start = now;
+ check->start = tv_to_ns(&now);
task_queue(t);
}