diff options
author | Daniel Eischen <deischen@FreeBSD.org> | 2003-05-24 02:29:25 +0000 |
---|---|---|
committer | Daniel Eischen <deischen@FreeBSD.org> | 2003-05-24 02:29:25 +0000 |
commit | 1cb570c53190e8b569091f708781c6bf9c3126c7 (patch) | |
tree | e99d3167d044ff37cf6b26fa4f4fe83140c8af79 /lib/libpthread/thread/thr_find_thread.c | |
parent | a224a3919d4b2260bb1d91fb7f848de673444c26 (diff) |
Notes
Diffstat (limited to 'lib/libpthread/thread/thr_find_thread.c')
-rw-r--r-- | lib/libpthread/thread/thr_find_thread.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/libpthread/thread/thr_find_thread.c b/lib/libpthread/thread/thr_find_thread.c index 0c813db6ad54a..ef469d94d2ada 100644 --- a/lib/libpthread/thread/thr_find_thread.c +++ b/lib/libpthread/thread/thr_find_thread.c @@ -47,13 +47,15 @@ _thr_ref_add(struct pthread *curthread, struct pthread *thread, { kse_critical_t crit; struct pthread *pthread; + struct kse *curkse; if (thread == NULL) /* Invalid thread: */ return (EINVAL); crit = _kse_critical_enter(); - KSE_LOCK_ACQUIRE(curthread->kse, &_thread_list_lock); + curkse = _get_curkse(); + KSE_LOCK_ACQUIRE(curkse, &_thread_list_lock); TAILQ_FOREACH(pthread, &_thread_list, tle) { if (pthread == thread) { if ((include_dead == 0) && @@ -63,12 +65,13 @@ _thr_ref_add(struct pthread *curthread, struct pthread *thread, pthread = NULL; else { thread->refcount++; - curthread->critical_count++; + if (curthread != NULL) + curthread->critical_count++; } break; } } - KSE_LOCK_RELEASE(curthread->kse, &_thread_list_lock); + KSE_LOCK_RELEASE(curkse, &_thread_list_lock); _kse_critical_leave(crit); /* Return zero if the thread exists: */ @@ -79,16 +82,19 @@ void _thr_ref_delete(struct pthread *curthread, struct pthread *thread) { kse_critical_t crit; + struct kse *curkse; if (thread != NULL) { crit = _kse_critical_enter(); - KSE_LOCK_ACQUIRE(curthread->kse, &_thread_list_lock); + curkse = _get_curkse(); + KSE_LOCK_ACQUIRE(curkse, &_thread_list_lock); thread->refcount--; - curthread->critical_count--; + if (curthread != NULL) + curthread->critical_count--; if ((thread->refcount == 0) && (thread->flags & THR_FLAGS_GC_SAFE) != 0) THR_GCLIST_ADD(thread); - KSE_LOCK_RELEASE(curthread->kse, &_thread_list_lock); + KSE_LOCK_RELEASE(curkse, &_thread_list_lock); _kse_critical_leave(crit); } } |