summaryrefslogtreecommitdiff
path: root/nuttx/sched/timer_create.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_create.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_create.c')
-rw-r--r--nuttx/sched/timer_create.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/nuttx/sched/timer_create.c b/nuttx/sched/timer_create.c
index 645007c9f..a9e19dc2a 100644
--- a/nuttx/sched/timer_create.c
+++ b/nuttx/sched/timer_create.c
@@ -74,7 +74,8 @@
static struct posix_timer_s *timer_allocate(void)
{
struct posix_timer_s *ret;
- irqstate_t flags;
+ irqstate_t flags;
+ ubyte pt_flags;
/* Try to get a preallocated timer from the free list */
@@ -84,23 +85,31 @@ static struct posix_timer_s *timer_allocate(void)
irqrestore(flags);
/* Did we get one? */
-
- if (!ret)
+
+ if (ret)
+ {
+ pt_flags = PT_FLAGS_PREALLOCATED;
+ }
+ else
#endif
{
/* Allocate a new timer from the heap */
- ret = (struct posix_timer_s*)malloc(sizeof(struct posix_timer_s));
- if (ret)
- {
- ret->pt_flags = 0;
- }
+ ret = (struct posix_timer_s*)malloc(sizeof(struct posix_timer_s));
+ pt_flags = 0;
}
/* If we have a timer, then put it into the allocated timer list */
if (ret)
{
+ /* Initialize the timer structure */
+
+ memset(ret, 0, sizeof(struct posix_timer_s));
+ ret->pt_flags = pt_flags;
+
+ /* And add it to the end of the list of allocated timers */
+
flags = irqsave();
sq_addlast((sq_entry_t*)ret, (sq_queue_t*)&g_alloctimers);
irqrestore(flags);