diff options
author | Vitaliy Gusev <gusev.vitaliy@gmail.com> | 2018-02-08 14:03:12 +0300 |
---|---|---|
committer | Toomas Soome <tsoome@me.com> | 2022-09-23 09:51:53 +0300 |
commit | 589f9b6223af8482576c4b68c4acc0626246eb32 (patch) | |
tree | 678e2be0e4f18fb741b6b768f8add0d163f3cab4 /usr/src/lib | |
parent | a3eabe598a0af8378581201cb0d027e3589fd3f7 (diff) | |
download | illumos-joyent-589f9b6223af8482576c4b68c4acc0626246eb32.tar.gz |
14958 fakekernel: avoid LWP <defunc> threads
Reviewed by: Toomas Soome <tsoome@racktopsystems.com>
Reviewed by: Gordon Ross <Gordon.W.Ross@gmail.com>
Reviewed by: Matt Barden <mbarden@tintri.com>
Approved by: Patrick Mooney <pmooney@pfmooney.com>
Diffstat (limited to 'usr/src/lib')
-rw-r--r-- | usr/src/lib/libfakekernel/common/thread.c | 11 |
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); } |