MCPcopy Create free account
hub / github.com/aws/clock-bound / handle_disruption

Method handle_disruption

clock-bound/src/daemon/clock_state/clock_adjust.rs:65–93  ·  view source on GitHub ↗
(&mut self, _new_disruption_marker: u64)

Source from the content-addressed store, hash-verified

63 }
64
65 fn handle_disruption(&mut self, _new_disruption_marker: u64) {
66 // Use the destructure pattern to get a mutable reference to each item.
67 //
68 // This makes it a compilation error if we add a new field to Self without handling it here
69 let Self {
70 ntp_adjtime: _,
71 state,
72 } = self;
73 // At least stop any ongoing phase correction slew or frequency correction, if the clock is disrupted.
74 // Notably, phase correction slew is recalculated at the top of a second, so we still might end up having some moderate slew
75 // of the clock happening til that time.
76 info!("Resetting ntp_adjtime parameters to zero any phase or frequency corrections");
77 match self
78 .ntp_adjtime
79 .adjust_clock(Duration::from_secs(0), Skew::from_ppm(0.0))
80 {
81 failed_adjtime @ Err(NtpAdjTimeError::Failure(_)) => {
82 failed_adjtime.unwrap();
83 }
84 Err(unexpected_adjtime_status) => {
85 error!("Unexpected adjtime result: {unexpected_adjtime_status}");
86 }
87 _ => {}
88 }
89 *state = State::Disrupted(Disrupted);
90 // TODO: We may want to reset `should_step` if we think it is acceptable to step the clock on next adjustment
91 // for faster recovery..
92 info!("Handled clock disruption event");
93 }
94
95 /// Helper to find out if `CLOCK_REALTIME` is now reliable...
96 /// Any initial states can be considered unreliable, since we have not

Calls 2

DisruptedClass · 0.85
adjust_clockMethod · 0.80

Tested by 1

handle_disruptionFunction · 0.36