mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
Avoid Watchdog thread clobbering m_isExpired flag after callback (#1527)
This commit is contained in:
committed by
Peter Johnson
parent
bc2c932f92
commit
f121ccff0d
@@ -58,10 +58,15 @@ void Watchdog::Thread::Main() {
|
||||
<< "s\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Set expiration flag before calling the callback so any manipulation
|
||||
// of the flag in the callback (e.g., calling Disable()) isn't
|
||||
// clobbered.
|
||||
watchdog->m_isExpired = true;
|
||||
|
||||
lock.unlock();
|
||||
watchdog->m_callback();
|
||||
lock.lock();
|
||||
watchdog->m_isExpired = true;
|
||||
}
|
||||
// Otherwise, a Watchdog removed itself from the queue (it notifies the
|
||||
// scheduler of this) or a spurious wakeup occurred, so just rewait with
|
||||
|
||||
@@ -247,10 +247,15 @@ public class Watchdog implements Closeable, Comparable<Watchdog> {
|
||||
System.out.format("Watchdog not fed within %.6fs\n", watchdog.m_timeout / 1.0e6);
|
||||
}
|
||||
}
|
||||
|
||||
// Set expiration flag before calling the callback so any
|
||||
// manipulation of the flag in the callback (e.g., calling
|
||||
// Disable()) isn't clobbered.
|
||||
watchdog.m_isExpired = true;
|
||||
|
||||
m_queueMutex.unlock();
|
||||
watchdog.m_callback.run();
|
||||
m_queueMutex.lock();
|
||||
watchdog.m_isExpired = true;
|
||||
}
|
||||
// Otherwise, a Watchdog removed itself from the queue (it notifies
|
||||
// the scheduler of this) or a spurious wakeup occurred, so just
|
||||
|
||||
Reference in New Issue
Block a user