Fix notifier race happening with very fast notifiers (#2370)

What would happen is the Stop() call would happen between the notifier loop being triggered and calling UpdateAlarm(). This would cause the Update to overwrite the stop.
This commit is contained in:
Thad House
2020-02-18 20:38:05 -08:00
committed by GitHub
parent 65eab93527
commit 60c09ea51f
2 changed files with 11 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -129,6 +129,8 @@ void Notifier::StartPeriodic(units::second_t period) {
}
void Notifier::Stop() {
std::scoped_lock lock(m_processMutex);
m_periodic = false;
int32_t status = 0;
HAL_CancelNotifierAlarm(m_notifier, &status);
wpi_setHALError(status);