mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[hal,wpilib] Fix TimedRobot notifier race (#8445)
It was possible for the alarm to fire between the set alarm and ack, resulting in a hang on next wait. It's not possible to ack before set alarm due to a race in sim step timing, so the fix is to provide an atomic ack and set alarm; the easiest way to implement this in the API was to change ack to optionally also set the alarm again.
This commit is contained in:
@@ -113,14 +113,18 @@ Java_org_wpilib_hardware_hal_NotifierJNI_cancelNotifierAlarm
|
||||
/*
|
||||
* Class: org_wpilib_hardware_hal_NotifierJNI
|
||||
* Method: acknowledgeNotifierAlarm
|
||||
* Signature: (I)V
|
||||
* Signature: (IZJJZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_wpilib_hardware_hal_NotifierJNI_acknowledgeNotifierAlarm
|
||||
(JNIEnv* env, jclass cls, jint notifierHandle)
|
||||
(JNIEnv* env, jclass cls, jint notifierHandle, jboolean setAlarm,
|
||||
jlong alarmTime, jlong intervalTime, jboolean absolute)
|
||||
{
|
||||
int32_t status = 0;
|
||||
HAL_AcknowledgeNotifierAlarm((HAL_NotifierHandle)notifierHandle, &status);
|
||||
HAL_AcknowledgeNotifierAlarm((HAL_NotifierHandle)notifierHandle, setAlarm,
|
||||
static_cast<uint64_t>(alarmTime),
|
||||
static_cast<uint64_t>(intervalTime), absolute,
|
||||
&status);
|
||||
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user