Avoid Watchdog thread clobbering m_isExpired flag after callback (#1527)

This commit is contained in:
Tyler Veness
2019-01-08 21:37:59 -06:00
committed by Peter Johnson
parent bc2c932f92
commit f121ccff0d
2 changed files with 12 additions and 2 deletions

View File

@@ -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