diff options
author | deischen <deischen@FreeBSD.org> | 2003-11-04 20:04:45 +0000 |
---|---|---|
committer | deischen <deischen@FreeBSD.org> | 2003-11-04 20:04:45 +0000 |
commit | 1191fa7e324052c4d97e45f85cbb566eb985c1c6 (patch) | |
tree | c66d125bd34129e0d434c2444369c5dd31c55ad0 /lib/libkse/thread/thr_kern.c | |
parent | 573b8090444db7cfee8d60b937cc6d39632c8bbc (diff) | |
download | FreeBSD-src-1191fa7e324052c4d97e45f85cbb566eb985c1c6.zip FreeBSD-src-1191fa7e324052c4d97e45f85cbb566eb985c1c6.tar.gz |
Add an implementation for pthread_atfork().
Aside from the POSIX requirements for pthread_atfork(), when
fork()ing, take the malloc lock to keep malloc state consistent
in the child.
Reviewed by: davidxu
Diffstat (limited to 'lib/libkse/thread/thr_kern.c')
-rw-r--r-- | lib/libkse/thread/thr_kern.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/libkse/thread/thr_kern.c b/lib/libkse/thread/thr_kern.c index e16a1b0..7909838 100644 --- a/lib/libkse/thread/thr_kern.c +++ b/lib/libkse/thread/thr_kern.c @@ -329,6 +329,20 @@ _kse_single_thread(struct pthread *curthread) _kse_initial = NULL; _libpthread_init(curthread); #else + int i; + + /* Reset the current thread and KSE lock data. */ + for (i = 0; i < curthread->locklevel; i++) { + _lockuser_reinit(&curthread->lockusers[i], (void *)curthread); + } + curthread->locklevel = 0; + for (i = 0; i < curthread->kse->k_locklevel; i++) { + _lockuser_reinit(&curthread->kse->k_lockusers[i], + (void *)curthread->kse); + _LCK_SET_PRIVATE2(&curthread->kse->k_lockusers[i], NULL); + } + curthread->kse->k_locklevel = 0; + _thr_spinlock_init(); if (__isthreaded) { _thr_rtld_fini(); _thr_signal_deinit(); @@ -2015,7 +2029,7 @@ _thr_setrunnable(struct pthread *curthread, struct pthread *thread) kmbx = _thr_setrunnable_unlocked(thread); KSE_SCHED_UNLOCK(curthread->kse, thread->kseg); _kse_critical_leave(crit); - if (kmbx != NULL) + if ((kmbx != NULL) && (__isthreaded != 0)) kse_wakeup(kmbx); } |