Skip to content

Commit 4ad8c75

Browse files
authored
Merge pull request #3822 from geniusgogo/master
fixed the iterator failure for softtimer list timeout check.
2 parents ca85c64 + 76d1651 commit 4ad8c75

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/timer.c

+5-12
Original file line numberDiff line numberDiff line change
@@ -595,20 +595,19 @@ rt_tick_t rt_timer_next_timeout_tick(void)
595595
void rt_soft_timer_check(void)
596596
{
597597
rt_tick_t current_tick;
598-
rt_list_t *n;
599598
struct rt_timer *t;
600599

601600
RT_DEBUG_LOG(RT_DEBUG_TIMER, ("software timer check enter\n"));
602601

603-
current_tick = rt_tick_get();
604-
605602
/* lock scheduler */
606603
rt_enter_critical();
607604

608-
for (n = rt_soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1].next;
609-
n != &(rt_soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1]);)
605+
while (!rt_list_isempty(&rt_soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1]))
610606
{
611-
t = rt_list_entry(n, struct rt_timer, row[RT_TIMER_SKIP_LIST_LEVEL - 1]);
607+
t = rt_list_entry(rt_soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1].next,
608+
struct rt_timer, row[RT_TIMER_SKIP_LIST_LEVEL - 1]);
609+
610+
current_tick = rt_tick_get();
612611

613612
/*
614613
* It supposes that the new tick shall less than the half duration of
@@ -618,9 +617,6 @@ void rt_soft_timer_check(void)
618617
{
619618
RT_OBJECT_HOOK_CALL(rt_timer_enter_hook, (t));
620619

621-
/* move node to the next */
622-
n = n->next;
623-
624620
/* remove timer from timer list firstly */
625621
_rt_timer_remove(t);
626622

@@ -629,9 +625,6 @@ void rt_soft_timer_check(void)
629625
/* call timeout function */
630626
t->timeout_func(t->parameter);
631627

632-
/* re-get tick */
633-
current_tick = rt_tick_get();
634-
635628
RT_OBJECT_HOOK_CALL(rt_timer_exit_hook, (t));
636629
RT_DEBUG_LOG(RT_DEBUG_TIMER, ("current tick: %d\n", current_tick));
637630

0 commit comments

Comments
 (0)