Commit 1f918980 for quagga.net
commit 1f918980c08d9fb9215609db39f7fb279c2e1807
Author: Paul Jakma <paul@jakma.org>
Date: Sat Mar 3 15:22:58 2018 +0000
lib/thread: Address other paths from thread_execute to thread_add_unuse
* lib/thread.c: There are further paths from thread_execute to
thread_add_unuse, beyond that from bugzilla bug#975.
Make the paths from thread_execute to thread_add_unuse, inc.
thread_add_unuse itself, tolerant to the "dummy" threads of
thread_execute.
Another option would be to have thread_execute properly obtain a
thread struct, rather than fake one on its heap.
(thread_add_unuse) Be tolerant of NULL master threads passed in, that
/ought/ to be dummy/non-heap threads, and just ignore. Don't assert.
(thread_call) no point checking for NULL master here anymore.
See https://bugzilla.quagga.net/show_bug.cgi?id=977
With thanks to John Hay, john@sanren.ac.za, for testing and verifying
the fix.
diff --git a/lib/thread.c b/lib/thread.c
index f7d1a5ff..120fbd50 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -603,8 +603,12 @@ thread_add_fd (struct thread **thread_array, struct thread *thread)
static void
thread_add_unuse (struct thread *thread)
{
+ assert (thread);
+ /* thread_execute uses dummy threads, allocated on its stack */
+ if (thread->master == NULL)
+ return;
+
thread->type = THREAD_UNUSED;
- assert (thread->master != NULL && thread != NULL);
assert (thread->next == NULL);
assert (thread->prev == NULL);
thread_list_add (&thread->master->unuse, thread);
@@ -1342,9 +1346,7 @@ thread_call (struct thread *thread)
}
#endif /* CONSUMED_TIME_CHECK */
-
- if (thread->master)
- thread_add_unuse (thread);
+ thread_add_unuse (thread);
}
/* Execute thread */