As required by posix.

Reported-by: Brent Baccala <[email protected]> 's Claude assistant
---
 htl/pt-exit.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/htl/pt-exit.c b/htl/pt-exit.c
index ad60f063ed..e08b3252cf 100644
--- a/htl/pt-exit.c
+++ b/htl/pt-exit.c
@@ -55,15 +55,15 @@ __pthread_exit (void *status)
 
   __pthread_setcancelstate (oldstate, &oldstate);
 
+  /* Destroy any thread specific data.  */
+  __pthread_destroy_specific (self);
+
   /* Decrease the number of threads.  We use an atomic operation to
      make sure that only the last thread calls `exit'.  */
   if (atomic_fetch_add_relaxed (&__pthread_total, -1) == 1)
     /* We are the last thread.  */
     exit (0);
 
-  /* Destroy any thread specific data.  */
-  __pthread_destroy_specific (self);
-
   /* Note that after this point the process can be terminated at any
      point if another thread calls `pthread_exit' and happens to be
      the last thread.  */
-- 
2.51.0


Reply via email to