summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2010-10-12 00:36:56 +0000
committerdavidxu <davidxu@FreeBSD.org>2010-10-12 00:36:56 +0000
commit47dfb514f552fe3cfa9cd48c17ec7385fccb0422 (patch)
tree43667f7a478e1706c1c21e4e637f9930addbd2fd /sys/kern
parent5d3cd8d3f07a0534fb7bee6f952bb2c1a7978ce6 (diff)
downloadFreeBSD-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.c14
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);
}
OpenPOWER on IntegriCloud