summaryrefslogtreecommitdiff
path: root/kern/thread.c
diff options
context:
space:
mode:
Diffstat (limited to 'kern/thread.c')
-rw-r--r--kern/thread.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/kern/thread.c b/kern/thread.c
index ec722898..c1f1b02a 100644
--- a/kern/thread.c
+++ b/kern/thread.c
@@ -1494,6 +1494,7 @@ thread_destroy(struct thread *thread)
{
struct thread_runq *runq;
unsigned long flags, state;
+ unsigned int i;
do {
runq = thread_lock_runq(thread, &flags);
@@ -1501,6 +1502,14 @@ thread_destroy(struct thread *thread)
thread_unlock_runq(runq, flags);
} while (state != THREAD_DEAD);
+ for (i = 0; i < thread_nr_keys; i++) {
+ if ((thread->tsd[i] == NULL)
+ || (thread_dtors[i] == NULL))
+ continue;
+
+ thread_dtors[i](thread->tsd[i]);
+ }
+
task_remove_thread(thread->task, thread);
kmem_cache_free(&thread_stack_cache, thread->stack);
kmem_cache_free(&thread_cache, thread);