diff options
Diffstat (limited to 'lib/libthr/thread/thr_exit.c')
-rw-r--r-- | lib/libthr/thread/thr_exit.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/libthr/thread/thr_exit.c b/lib/libthr/thread/thr_exit.c index c83c12a..f6147054 100644 --- a/lib/libthr/thread/thr_exit.c +++ b/lib/libthr/thread/thr_exit.c @@ -124,9 +124,16 @@ _pthread_exit(void *status) exit(0); /* Never reach! */ } + THR_LOCK(curthread); + curthread->state = PS_DEAD; + THR_UNLOCK(curthread); + /* + * Thread was created with initial refcount 1, we drop the + * reference count to allow it to be garbage collected. + */ + curthread->refcount--; if (curthread->tlflags & TLFLAGS_DETACHED) THR_GCLIST_ADD(curthread); - curthread->state = PS_DEAD; THREAD_LIST_UNLOCK(curthread); if (SHOULD_REPORT_EVENT(curthread, TD_DEATH)) _thr_report_death(curthread); |