summaryrefslogtreecommitdiff
path: root/nuttx/sched/timer_settime.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-06-01 17:46:26 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-06-01 17:46:26 +0000
commit60baf60892705bec8c3180025cd797c5d64a1e1e (patch)
tree26e2646c057a968cf9b83f137d533badf5eb219a /nuttx/sched/timer_settime.c
parente6e16479eb1559c46d23c0187f0c33735935185a (diff)
downloadpx4-nuttx-60baf60892705bec8c3180025cd797c5d64a1e1e.tar.gz
px4-nuttx-60baf60892705bec8c3180025cd797c5d64a1e1e.tar.bz2
px4-nuttx-60baf60892705bec8c3180025cd797c5d64a1e1e.zip
Fix problem when timer deleted by timer handler
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@762 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched/timer_settime.c')
-rw-r--r--nuttx/sched/timer_settime.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/nuttx/sched/timer_settime.c b/nuttx/sched/timer_settime.c
index 27f7d2af1..ab130210e 100644
--- a/nuttx/sched/timer_settime.c
+++ b/nuttx/sched/timer_settime.c
@@ -39,7 +39,9 @@
#include <nuttx/config.h>
#include <time.h>
+#include <string.h>
#include <errno.h>
+
#include "os_internal.h"
#include "clock_internal.h"
#include "sig_internal.h"
@@ -181,21 +183,47 @@ static void timer_timeout(int argc, uint32 itimer)
/* Send the specified signal to the specified task. */
+ u.timer->pt_flags |= PT_FLAGS_BUSY;
timer_sigqueue(u.timer);
+ u.timer->pt_flags &= ~PT_FLAGS_BUSY;
+
+ /* Check if the signal handler attempted to delete the timer */
+
+ if ((u.timer->pt_flags & PT_FLAGS_DELETED) != 0)
+ {
+ /* Yes.. delete the timer now that we are no longer busy */
- /* If this is a repetitive timer, the restart the watchdog */
+ timer_delete(u.timer);
+ }
+ else
+ {
+ /* If this is a repetitive timer, the restart the watchdog */
- timer_restart(u.timer, itimer);
+ timer_restart(u.timer, itimer);
+ }
#else
FAR struct posix_timer_s *timer = (FAR struct posix_timer_s *)itimer;
/* Send the specified signal to the specified task. */
+ timer->pt_flags |= PT_FLAGS_BUSY;
timer_sigqueue(timer);
+ timer->pt_flags &= ~PT_FLAGS_BUSY;
- /* If this is a repetitive timer, the restart the watchdog */
+ /* Check if the signal handler attempted to delete the timer */
- timer_restart(timer, itimer);
+ if ((timer->pt_flags & PT_FLAGS_DELETED) != 0)
+ {
+ /* Yes.. delete the timer now that we are no longer busy */
+
+ timer_delete(timer);
+ }
+ else
+ {
+ /* If this is a repetitive timer, the restart the watchdog */
+
+ timer_restart(timer, itimer);
+ }
#endif
}