From b1b2cf639ed41a4b5caeec9fcfe87e0c8aef950c Mon Sep 17 00:00:00 2001 From: mtm Date: Sun, 27 Jun 2004 09:53:06 +0000 Subject: In the case that the global thread list is being re-initialized after a fork, make sure that the current thread isn't detached and freed. As a consequence the thread should be inserted into the head of the active list only once (in the beginning). --- lib/libthr/thread/thr_init.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/libthr/thread/thr_init.c b/lib/libthr/thread/thr_init.c index 98c355a..cf1eb6b 100644 --- a/lib/libthr/thread/thr_init.c +++ b/lib/libthr/thread/thr_init.c @@ -205,7 +205,7 @@ init_tdlist(struct pthread *td, int reinit) */ if (reinit) { TAILQ_FOREACH_SAFE(tdTemp, &_thread_list, tle, tdTemp2) { - if (tdTemp != NULL) { + if (tdTemp != NULL && tdTemp != td) { TAILQ_REMOVE(&_thread_list, tdTemp, tle); free(tdTemp); } @@ -220,10 +220,10 @@ init_tdlist(struct pthread *td, int reinit) } else { TAILQ_INIT(&_thread_list); TAILQ_INIT(&_dead_list); - } - /* Insert this thread as the first thread in the active list */ - TAILQ_INSERT_HEAD(&_thread_list, td, tle); + /* Insert this thread as the first thread in the active list */ + TAILQ_INSERT_HEAD(&_thread_list, td, tle); + } /* * Initialize the active thread list lock and the -- cgit v1.1