mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-05 04:25:06 -05:00
cmdmon: add reset command
The reset command drops all measurements and switches the reference to the unsynchronised state. This command can help chronyd with recovery when the measurements are known to be no longer valid or accurate, e.g. due to moving the computer to a different network, or resuming the computer from a low-power state (which resets the system clock).
This commit is contained in:
17
cmdmon.c
17
cmdmon.c
@@ -134,6 +134,7 @@ static const char permissions[] = {
|
||||
PERMIT_AUTH, /* ONOFFLINE */
|
||||
PERMIT_AUTH, /* ADD_SOURCE */
|
||||
PERMIT_OPEN, /* NTP_SOURCE_NAME */
|
||||
PERMIT_AUTH, /* RESET */
|
||||
};
|
||||
|
||||
/* ================================================== */
|
||||
@@ -1218,6 +1219,18 @@ handle_ntp_source_name(CMD_Request *rx_message, CMD_Reply *tx_message)
|
||||
sizeof (tx_message->data.ntp_source_name.name));
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
static void
|
||||
handle_reset(CMD_Request *rx_message, CMD_Reply *tx_message)
|
||||
{
|
||||
struct timespec cooked_now, now;
|
||||
|
||||
SRC_ResetSources();
|
||||
SCH_GetLastEventTime(&cooked_now, NULL, &now);
|
||||
LCL_NotifyExternalTimeStep(&now, &cooked_now, 0.0, 0.0);
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
/* Read a packet and process it */
|
||||
|
||||
@@ -1595,6 +1608,10 @@ read_from_cmd_socket(int sock_fd, int event, void *anything)
|
||||
handle_ntp_source_name(&rx_message, &tx_message);
|
||||
break;
|
||||
|
||||
case REQ_RESET:
|
||||
handle_reset(&rx_message, &tx_message);
|
||||
break;
|
||||
|
||||
default:
|
||||
DEBUG_LOG("Unhandled command %d", rx_command);
|
||||
tx_message.status = htons(STT_FAILED);
|
||||
|
||||
Reference in New Issue
Block a user