client: avoid reading clock after sending request
If chronyc sent a request which caused chronyd to step the clock (e.g. makestep, settime) and the second reading of the clock before calling select() to wait for a response happened after the clock was stepped, a new request could be sent immediately and chronyd would process the same command twice. If the second request failed (e.g. a settime request too close to the first request), chronyc would report an error. Change the submit_request() function to read the clock only once per select() to wait for the first response even when the clock was stepped.
This commit is contained in:
parent
de8708f331
commit
6863e43269
1 changed files with 3 additions and 6 deletions
9
client.c
9
client.c
|
@ -1347,15 +1347,15 @@ submit_request(CMD_Request *request, CMD_Reply *reply)
|
||||||
new_attempt = 1;
|
new_attempt = 1;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
if (gettimeofday(&tv, NULL))
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (new_attempt) {
|
if (new_attempt) {
|
||||||
new_attempt = 0;
|
new_attempt = 0;
|
||||||
|
|
||||||
if (n_attempts > max_retries)
|
if (n_attempts > max_retries)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (gettimeofday(&tv, NULL))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
UTI_TimevalToTimespec(&tv, &ts_start);
|
UTI_TimevalToTimespec(&tv, &ts_start);
|
||||||
|
|
||||||
UTI_GetRandomBytes(&request->sequence, sizeof (request->sequence));
|
UTI_GetRandomBytes(&request->sequence, sizeof (request->sequence));
|
||||||
|
@ -1383,9 +1383,6 @@ submit_request(CMD_Request *request, CMD_Reply *reply)
|
||||||
DEBUG_LOG("Sent %d bytes", command_length);
|
DEBUG_LOG("Sent %d bytes", command_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gettimeofday(&tv, NULL))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
UTI_TimevalToTimespec(&tv, &ts_now);
|
UTI_TimevalToTimespec(&tv, &ts_now);
|
||||||
|
|
||||||
/* Check if the clock wasn't stepped back */
|
/* Check if the clock wasn't stepped back */
|
||||||
|
|
Loading…
Reference in a new issue