diff options
author | davidxu <davidxu@FreeBSD.org> | 2010-10-12 00:36:56 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2010-10-12 00:36:56 +0000 |
commit | 47dfb514f552fe3cfa9cd48c17ec7385fccb0422 (patch) | |
tree | 43667f7a478e1706c1c21e4e637f9930addbd2fd /sys/kern | |
parent | 5d3cd8d3f07a0534fb7bee6f952bb2c1a7978ce6 (diff) | |
download | FreeBSD-src-47dfb514f552fe3cfa9cd48c17ec7385fccb0422.zip FreeBSD-src-47dfb514f552fe3cfa9cd48c17ec7385fccb0422.tar.gz |
Add a flag TDF_TIDHASH to prevent a thread from being
added to or removed from thread hash table multiple times.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_thread.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index 89f6137..40652b6 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -981,7 +981,12 @@ void tidhash_add(struct thread *td) { rw_wlock(&tidhash_lock); - LIST_INSERT_HEAD(TIDHASH(td->td_tid), td, td_hash); + thread_lock(td); + if ((td->td_flags & TDF_TIDHASH) == 0) { + LIST_INSERT_HEAD(TIDHASH(td->td_tid), td, td_hash); + td->td_flags |= TDF_TIDHASH; + } + thread_unlock(td); rw_wunlock(&tidhash_lock); } @@ -989,6 +994,11 @@ void tidhash_remove(struct thread *td) { rw_wlock(&tidhash_lock); - LIST_REMOVE(td, td_hash); + thread_lock(td); + if ((td->td_flags & TDF_TIDHASH) != 0) { + LIST_REMOVE(td, td_hash); + td->td_flags &= ~TDF_TIDHASH; + } + thread_unlock(td); rw_wunlock(&tidhash_lock); } |