Browse files

lib: fix incorrect thread list processing loops

* thread.c: (thread_timer_process,thread_process) thread_list_delete nulls
  thread->next. Loops need to save next first, or will only process the head.
  Problem noted by Lou Berger <lberger@labn.net>.
  • Loading branch information...
1 parent b51a3a3 commit b5043aabb03567b46a16463d88a8afce2acda35e @pjakma pjakma committed Feb 28, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/thread.c
View
8 lib/thread.c
@@ -972,10 +972,12 @@ static unsigned int
thread_timer_process (struct thread_list *list, struct timeval *timenow)
{
struct thread *thread;
+ struct thread *next;
unsigned int ready = 0;
- for (thread = list->head; thread; thread = thread->next)
+ for (thread = list->head; thread; thread = next)
{
+ next = thread->next;
if (timeval_cmp (*timenow, thread->u.sands) < 0)
return ready;
thread_list_delete (list, thread);
@@ -991,10 +993,12 @@ static unsigned int
thread_process (struct thread_list *list)
{
struct thread *thread;
+ struct thread *next;
unsigned int ready = 0;
- for (thread = list->head; thread; thread = thread->next)
+ for (thread = list->head; thread; thread = next)
{
+ next = thread->next;
thread_list_delete (list, thread);
thread->type = THREAD_READY;
thread_list_add (&thread->master->ready, thread);

0 comments on commit b5043aa

Please sign in to comment.