mirror of
https://gitlab.com/chrony/chrony.git
synced 2026-03-10 16:49:38 -04:00
client+test: switch from gettimeofday() to clock_gettime()
Replace the remaining calls of gettimeofday().
This commit is contained in:
6
client.c
6
client.c
@@ -1396,7 +1396,7 @@ submit_request(CMD_Request *request, CMD_Reply *reply)
|
||||
new_attempt = 1;
|
||||
|
||||
do {
|
||||
if (gettimeofday(&tv, NULL))
|
||||
if (clock_gettime(CLOCK_REALTIME, &ts_now) < 0)
|
||||
return 0;
|
||||
|
||||
if (new_attempt) {
|
||||
@@ -1405,7 +1405,7 @@ submit_request(CMD_Request *request, CMD_Reply *reply)
|
||||
if (n_attempts > max_retries)
|
||||
return 0;
|
||||
|
||||
UTI_TimevalToTimespec(&tv, &ts_start);
|
||||
ts_start = ts_now;
|
||||
|
||||
UTI_GetRandomBytes(&request->sequence, sizeof (request->sequence));
|
||||
request->attempt = htons(n_attempts);
|
||||
@@ -1428,8 +1428,6 @@ submit_request(CMD_Request *request, CMD_Reply *reply)
|
||||
return 0;
|
||||
}
|
||||
|
||||
UTI_TimevalToTimespec(&tv, &ts_now);
|
||||
|
||||
/* Check if the clock wasn't stepped back */
|
||||
if (UTI_CompareTimespecs(&ts_now, &ts_start) < 0)
|
||||
ts_start = ts_now;
|
||||
|
||||
@@ -45,8 +45,8 @@ main(int argc, char **argv)
|
||||
{
|
||||
LOG_Severity log_severity;
|
||||
char *test_name, *s;
|
||||
struct timespec ts;
|
||||
int i, seed = 0;
|
||||
struct timeval tv;
|
||||
|
||||
test_name = argv[0];
|
||||
s = strrchr(test_name, '.');
|
||||
@@ -69,8 +69,8 @@ main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
srandom(seed ? seed : tv.tv_sec ^ (tv.tv_usec << 10));
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
srandom(seed ? seed : ts.tv_sec ^ (ts.tv_nsec << 10));
|
||||
|
||||
printf("Testing %-30s ", test_name);
|
||||
fflush(stdout);
|
||||
|
||||
Reference in New Issue
Block a user