summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/eventtimeout.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/rtems/src/eventtimeout.c')
-rw-r--r--cpukit/rtems/src/eventtimeout.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/cpukit/rtems/src/eventtimeout.c b/cpukit/rtems/src/eventtimeout.c
index 58dee84b1b..31eb04311e 100644
--- a/cpukit/rtems/src/eventtimeout.c
+++ b/cpukit/rtems/src/eventtimeout.c
@@ -49,13 +49,18 @@ void _Event_Timeout(
* a timeout is not allowed to occur.
*/
_ISR_Disable( level );
- #if defined(RTEMS_DEBUG)
- if ( !the_thread->Wait.count ) { /* verify thread is waiting */
- _Thread_Unnest_dispatch();
- _ISR_Enable( level );
- return;
- }
- #endif
+ /*
+ * Verify that the thread is still waiting for the event condition.
+ * This test is necessary to avoid state corruption if the timeout
+ * happens after the event condition is satisfied in
+ * _Event_Surrender(). A satisfied event condition is indicated with
+ * count set to zero.
+ */
+ if ( !the_thread->Wait.count ) {
+ _Thread_Unnest_dispatch();
+ _ISR_Enable( level );
+ return;
+ }
the_thread->Wait.count = 0;
if ( _Thread_Is_executing( the_thread ) ) {