summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPaul Jakma <paul@quagga.net>2012-02-28 18:32:56 +0000
committerPaul Jakma <paul@quagga.net>2012-02-28 18:35:45 +0000
commitb5043aabb03567b46a16463d88a8afce2acda35e (patch)
tree7b975c45bdbf513f62a1ad7f1aad35afb01606c9 /lib
parentb51a3a31500133e3e26f12e7639f297c655bc735 (diff)
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>.
Diffstat (limited to 'lib')
-rw-r--r--lib/thread.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/thread.c b/lib/thread.c
index 6d3c3cb3..b36c43a9 100644
--- a/lib/thread.c
+++ b/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);