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.
This commit is contained in:
Willy Tarreau 2023-04-28 14:39:50 +02:00
parent b68d308aec
commit e8e4712771
3 changed files with 7 additions and 7 deletions

View File

@ -156,7 +156,7 @@ struct check {
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 */

View File

@ -471,7 +471,7 @@ void set_server_check_status(struct check *check, short status, const char *desc
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 @@ void set_server_check_status(struct check *check, short status, const char *desc
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 @@ int start_check_task(struct check *check, int mininter,
/* 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;

View File

@ -145,7 +145,7 @@ int init_email_alert(struct mailers *mls, struct proxy *p, char **err)
/* check this in one ms */
t->expire = TICK_ETERNITY;
check->start = now;
check->start = tv_to_ns(&now);
task_queue(t);
}