From b0bdd6eff685c2d678a052ebb1a0e9fa5512aaac Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 20 Nov 2010 10:46:51 +0000 Subject: Fixed bug 3113443. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2392 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/src/chevents.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/os/kernel/src/chevents.c b/os/kernel/src/chevents.c index a66a7fa28..a0ef2d1bb 100644 --- a/os/kernel/src/chevents.c +++ b/os/kernel/src/chevents.c @@ -382,11 +382,15 @@ eventmask_t chEvtWaitOneTimeout(eventmask_t mask, systime_t time) { chSysLock(); if ((m = (ctp->p_epending & mask)) == 0) { - if (TIME_IMMEDIATE == time) + if (TIME_IMMEDIATE == time) { + chSysUnlock(); return (eventmask_t)0; + } ctp->p_u.ewmask = mask; - if (chSchGoSleepTimeoutS(THD_STATE_WTOREVT, time) < RDY_OK) + if (chSchGoSleepTimeoutS(THD_STATE_WTOREVT, time) < RDY_OK) { + chSysUnlock(); return (eventmask_t)0; + } m = ctp->p_epending & mask; } m &= -m; @@ -421,11 +425,15 @@ eventmask_t chEvtWaitAnyTimeout(eventmask_t mask, systime_t time) { chSysLock(); if ((m = (ctp->p_epending & mask)) == 0) { - if (TIME_IMMEDIATE == time) + if (TIME_IMMEDIATE == time) { + chSysUnlock(); return (eventmask_t)0; + } ctp->p_u.ewmask = mask; - if (chSchGoSleepTimeoutS(THD_STATE_WTOREVT, time) < RDY_OK) + if (chSchGoSleepTimeoutS(THD_STATE_WTOREVT, time) < RDY_OK) { + chSysUnlock(); return (eventmask_t)0; + } m = ctp->p_epending & mask; } ctp->p_epending &= ~m; @@ -457,11 +465,15 @@ eventmask_t chEvtWaitAllTimeout(eventmask_t mask, systime_t time) { chSysLock(); if ((ctp->p_epending & mask) != mask) { - if (TIME_IMMEDIATE == time) + if (TIME_IMMEDIATE == time) { + chSysUnlock(); return (eventmask_t)0; + } ctp->p_u.ewmask = mask; - if (chSchGoSleepTimeoutS(THD_STATE_WTANDEVT, time) < RDY_OK) + if (chSchGoSleepTimeoutS(THD_STATE_WTANDEVT, time) < RDY_OK) { + chSysUnlock(); return (eventmask_t)0; + } } ctp->p_epending &= ~mask; -- cgit v1.2.3