summaryrefslogtreecommitdiff
path: root/exit.c
diff options
context:
space:
mode:
authorrpj <rpj>1998-07-26 11:33:21 +0000
committerrpj <rpj>1998-07-26 11:33:21 +0000
commite564950fd61e9ada9a0c6a599457508b8429c81b (patch)
tree994bf5d5a4cbe364aee88e1e0a4174ee16e3027c /exit.c
parente54818fa1513ff6802c929d27f01df2257d8c153 (diff)
Sun Jul 26 13:06:12 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* exit.c (_pthread_exit): Move thread entry delete call from _pthread_vacuum() into here. Add more explanation of thread entry deletion.
Diffstat (limited to 'exit.c')
-rw-r--r--exit.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/exit.c b/exit.c
index 37b5595..3714aa2 100644
--- a/exit.c
+++ b/exit.c
@@ -28,21 +28,6 @@ _pthread_vacuum(void)
_pthread_handler_pop_all(_PTHREAD_FORKCHILD_STACK,
_PTHREAD_HANDLER_NOEXECUTE);
-
- /* CRITICAL SECTION */
- pthread_mutex_lock(&_pthread_table_mutex);
-
- /* Remove the thread entry on exit only if pthread_detach()
- was called and there are no waiting joins. */
-
- if (us->detach == TRUE
- && us->join_count == 0)
- {
- _pthread_delete_thread_entry(us);
- }
-
- pthread_mutex_lock(&_pthread_table_mutex);
- /* END CRITICAL SECTION */
}
void
@@ -62,6 +47,23 @@ _pthread_exit(void * value, int return_code)
_pthread_vacuum();
+ /* CRITICAL SECTION */
+ pthread_mutex_lock(&_pthread_table_mutex);
+
+ /* Remove the thread entry on exit only if pthread_detach() was
+ called AND there are no waiting joins. Otherwise the thread entry
+ will be deleted by the last waiting pthread_join() after this
+ thread has terminated. */
+
+ if (us->detach == TRUE
+ && us->join_count == 0)
+ {
+ _pthread_delete_thread_entry(us);
+ }
+
+ pthread_mutex_lock(&_pthread_table_mutex);
+ /* END CRITICAL SECTION */
+
_endthreadex(return_code);
}