diff options
author | mjg <mjg@FreeBSD.org> | 2015-07-16 14:30:11 +0000 |
---|---|---|
committer | mjg <mjg@FreeBSD.org> | 2015-07-16 14:30:11 +0000 |
commit | 2a7f187b066fc0dadb52c1b26fd1412d52cbcc4f (patch) | |
tree | a903eaf03b250ebd30b0b48c7fb144a6d35af1f9 /sys/kern/kern_thread.c | |
parent | 28fa5eedfe3c8c9827db6b8b82eab79e95f15bdd (diff) | |
download | FreeBSD-src-2a7f187b066fc0dadb52c1b26fd1412d52cbcc4f.zip FreeBSD-src-2a7f187b066fc0dadb52c1b26fd1412d52cbcc4f.tar.gz |
Get rid of lim_update_thread and cred_update_thread.
Their primary use was in thread_cow_update to free up old resources.
Freeing had to be done with proc lock held and _cow_ funcs already knew
how to free old structs.
Diffstat (limited to 'sys/kern/kern_thread.c')
-rw-r--r-- | sys/kern/kern_thread.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index 0f65403..3c6232c 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -409,9 +409,9 @@ void thread_cow_free(struct thread *td) { - if (td->td_ucred) + if (td->td_ucred != NULL) crfree(td->td_ucred); - if (td->td_limit) + if (td->td_limit != NULL) lim_free(td->td_limit); } @@ -419,15 +419,27 @@ void thread_cow_update(struct thread *td) { struct proc *p; + struct ucred *oldcred; + struct plimit *oldlimit; p = td->td_proc; + oldcred = NULL; + oldlimit = NULL; 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); + if (td->td_ucred != p->p_ucred) { + oldcred = td->td_ucred; + td->td_ucred = crhold(p->p_ucred); + } + if (td->td_limit != p->p_limit) { + oldlimit = td->td_limit; + td->td_limit = lim_hold(p->p_limit); + } td->td_cowgen = p->p_cowgen; PROC_UNLOCK(p); + if (oldcred != NULL) + crfree(oldcred); + if (oldlimit != NULL) + lim_free(oldlimit); } /* |