summaryrefslogtreecommitdiff
path: root/usr/src/lib/libfakekernel/common/thread.c
diff options
context:
space:
mode:
authorDan McDonald <danmcd@mnx.io>2022-09-23 10:51:19 -0400
committerDan McDonald <danmcd@mnx.io>2022-09-23 10:51:19 -0400
commitca257d7a23f93ffed7da91764f0622977a1db51e (patch)
treee1e17775dec04b666ddf10ebf32dac1697771c51 /usr/src/lib/libfakekernel/common/thread.c
parentf80fffffb15bd016da0e6de56b81eadf9c20f583 (diff)
parentbbcfe1fdf407bba4db5c2e62a69b67be0c4cb443 (diff)
downloadillumos-joyent-ca257d7a23f93ffed7da91764f0622977a1db51e.tar.gz
[illumos-gate merge]
commit bbcfe1fdf407bba4db5c2e62a69b67be0c4cb443 14987 smb: DsFreeDcInfo leaks commit 589f9b6223af8482576c4b68c4acc0626246eb32 14958 fakekernel: avoid LWP <defunc> threads commit a3eabe598a0af8378581201cb0d027e3589fd3f7 14863 Makefile.syshdrs: machine specific headers appear to be quite common
Diffstat (limited to 'usr/src/lib/libfakekernel/common/thread.c')
-rw-r--r--usr/src/lib/libfakekernel/common/thread.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/usr/src/lib/libfakekernel/common/thread.c b/usr/src/lib/libfakekernel/common/thread.c
index 31421a723b..d20bd9b91b 100644
--- a/usr/src/lib/libfakekernel/common/thread.c
+++ b/usr/src/lib/libfakekernel/common/thread.c
@@ -11,13 +11,14 @@
/*
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
- * Copyright 2017 RackTop Systems.
+ * Copyright 2018 RackTop Systems.
*/
#include <sys/cmn_err.h>
#include <sys/thread.h>
#include <sys/zone.h>
#include <sys/proc.h>
+#include <sys/atomic.h>
#define _SYNCH_H /* keep out <synch.h> */
#include <thread.h>
@@ -81,6 +82,14 @@ thread_create(
void
thread_exit(void)
{
+ static thread_t reap_tid;
+ thread_t prev;
+
+ /* reap previous thread exit */
+ prev = atomic_swap_uint(&reap_tid, thr_self());
+ if (prev != 0)
+ (void) thr_join(prev, NULL, NULL); /* joinable thread */
+
thr_exit(NULL);
}