diff options
author | dim <dim@FreeBSD.org> | 2015-06-20 19:34:50 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2015-06-20 19:34:50 +0000 |
commit | e109f99dcb6c95c84bbec22229de29a25491f7c2 (patch) | |
tree | d142d742b698973a366ae768a3f4033924e314c8 /sys/kern/kern_thread.c | |
parent | 238df27d058d0d8912acf0a186d3f43289a0a2b6 (diff) | |
parent | cb167b45a82327b0d6d88e85e3d6e2e326291ee4 (diff) | |
download | FreeBSD-src-e109f99dcb6c95c84bbec22229de29a25491f7c2.zip FreeBSD-src-e109f99dcb6c95c84bbec22229de29a25491f7c2.tar.gz |
Merge ^/head r284188 through r284643.
Diffstat (limited to 'sys/kern/kern_thread.c')
-rw-r--r-- | sys/kern/kern_thread.c | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index dce760c..4343b64 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -327,8 +327,7 @@ thread_reap(void) mtx_unlock_spin(&zombie_lock); while (td_first) { td_next = TAILQ_NEXT(td_first, td_slpq); - if (td_first->td_ucred) - crfree(td_first->td_ucred); + thread_cow_free(td_first); thread_free(td_first); td_first = td_next; } @@ -384,6 +383,50 @@ thread_free(struct thread *td) uma_zfree(thread_zone, td); } +void +thread_cow_get_proc(struct thread *newtd, struct proc *p) +{ + + PROC_LOCK_ASSERT(p, MA_OWNED); + newtd->td_ucred = crhold(p->p_ucred); + newtd->td_limit = lim_hold(p->p_limit); + newtd->td_cowgen = p->p_cowgen; +} + +void +thread_cow_get(struct thread *newtd, struct thread *td) +{ + + newtd->td_ucred = crhold(td->td_ucred); + newtd->td_limit = lim_hold(td->td_limit); + newtd->td_cowgen = td->td_cowgen; +} + +void +thread_cow_free(struct thread *td) +{ + + if (td->td_ucred) + crfree(td->td_ucred); + if (td->td_limit) + lim_free(td->td_limit); +} + +void +thread_cow_update(struct thread *td) +{ + struct proc *p; + + p = td->td_proc; + PROC_LOCK(p); + if (td->td_ucred != p->p_ucred) + cred_update_thread(td); + if (td->td_limit != p->p_limit) + lim_update_thread(td); + td->td_cowgen = p->p_cowgen; + PROC_UNLOCK(p); +} + /* * Discard the current thread and exit from its context. * Always called with scheduler locked. @@ -521,7 +564,7 @@ thread_wait(struct proc *p) cpuset_rel(td->td_cpuset); td->td_cpuset = NULL; cpu_thread_clean(td); - crfree(td->td_ucred); + thread_cow_free(td); thread_reap(); /* check for zombie threads etc. */ } |