summaryrefslogtreecommitdiff
path: root/pthread/pt-detach.c
diff options
context:
space:
mode:
Diffstat (limited to 'pthread/pt-detach.c')
-rw-r--r--pthread/pt-detach.c24
1 files changed, 5 insertions, 19 deletions
diff --git a/pthread/pt-detach.c b/pthread/pt-detach.c
index 4ed8d2c..3431f1b 100644
--- a/pthread/pt-detach.c
+++ b/pthread/pt-detach.c
@@ -50,30 +50,16 @@ pthread_detach (pthread_t thread)
consequences instead of blocking indefinitely. */
pthread_cond_broadcast (&pthread->state_cond);
__pthread_mutex_unlock (&pthread->state_lock);
+
+ __pthread_dealloc (pthread);
break;
case PTHREAD_EXITED:
- /* THREAD has already exited. Make sure that nobody can
- reference it anymore, and mark it as terminated. */
-
__pthread_mutex_unlock (&pthread->state_lock);
- /* Make sure the thread is not running before we remove its
- stack. (The only possibility is that it is in a call to
- __pthread_thread_halt itself, but that is enough to cause a
- sigsegv.) */
- __pthread_thread_halt (pthread);
-
- /* Destroy the stack, the kernel resources and the control
- block. */
- if (pthread->stack)
- {
- __pthread_stack_dealloc (pthread->stackaddr, pthread->stacksize);
- pthread->stack = 0;
- }
-
- __pthread_thread_dealloc (pthread);
-
+ /* THREAD has already exited. PTHREAD remained after the thread
+ exited in order to provide the exit status, but it turns out
+ it won't be needed. */
__pthread_dealloc (pthread);
break;