Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_thread.c
Show First 20 Lines • Show All 446 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
void | void | ||||
thread_cow_get_proc(struct thread *newtd, struct proc *p) | thread_cow_get_proc(struct thread *newtd, struct proc *p) | ||||
{ | { | ||||
PROC_LOCK_ASSERT(p, MA_OWNED); | PROC_LOCK_ASSERT(p, MA_OWNED); | ||||
newtd->td_ucred = crhold(p->p_ucred); | newtd->td_ucred = crhold(p->p_ucred); | ||||
newtd->td_credwrap = crwhold(p->p_credwrap); | |||||
newtd->td_limit = lim_hold(p->p_limit); | newtd->td_limit = lim_hold(p->p_limit); | ||||
newtd->td_cowgen = p->p_cowgen; | newtd->td_cowgen = p->p_cowgen; | ||||
} | } | ||||
void | void | ||||
thread_cow_get(struct thread *newtd, struct thread *td) | thread_cow_get(struct thread *newtd, struct thread *td) | ||||
{ | { | ||||
newtd->td_ucred = crhold(td->td_ucred); | newtd->td_ucred = crhold(td->td_ucred); | ||||
newtd->td_credwrap = crwhold(td->td_credwrap); | |||||
newtd->td_limit = lim_hold(td->td_limit); | newtd->td_limit = lim_hold(td->td_limit); | ||||
newtd->td_cowgen = td->td_cowgen; | newtd->td_cowgen = td->td_cowgen; | ||||
} | } | ||||
void | void | ||||
thread_cow_free(struct thread *td) | thread_cow_free(struct thread *td) | ||||
{ | { | ||||
if (td->td_ucred != NULL) | if (td->td_ucred != NULL) | ||||
crfree(td->td_ucred); | crfree(td->td_ucred); | ||||
if (td->td_credwrap != NULL) | |||||
crwfree(td->td_credwrap); | |||||
if (td->td_limit != NULL) | if (td->td_limit != NULL) | ||||
lim_free(td->td_limit); | lim_free(td->td_limit); | ||||
} | } | ||||
void | void | ||||
thread_cow_update(struct thread *td) | thread_cow_update(struct thread *td) | ||||
{ | { | ||||
struct proc *p; | struct proc *p; | ||||
struct ucred *oldcred; | struct ucred *oldcred; | ||||
struct credwrap *oldcredwrap; | |||||
struct plimit *oldlimit; | struct plimit *oldlimit; | ||||
p = td->td_proc; | p = td->td_proc; | ||||
oldcred = NULL; | oldcred = NULL; | ||||
oldcredwrap = NULL; | |||||
oldlimit = NULL; | oldlimit = NULL; | ||||
PROC_LOCK(p); | PROC_LOCK(p); | ||||
if (td->td_ucred != p->p_ucred) { | if (td->td_ucred != p->p_ucred) { | ||||
oldcred = td->td_ucred; | oldcred = td->td_ucred; | ||||
td->td_ucred = crhold(p->p_ucred); | td->td_ucred = crhold(p->p_ucred); | ||||
} | } | ||||
if (td->td_credwrap != p->p_credwrap) { | |||||
oldcredwrap = td->td_credwrap; | |||||
td->td_credwrap = crwhold(p->p_credwrap); | |||||
} | |||||
if (td->td_limit != p->p_limit) { | if (td->td_limit != p->p_limit) { | ||||
oldlimit = td->td_limit; | oldlimit = td->td_limit; | ||||
td->td_limit = lim_hold(p->p_limit); | td->td_limit = lim_hold(p->p_limit); | ||||
} | } | ||||
td->td_cowgen = p->p_cowgen; | td->td_cowgen = p->p_cowgen; | ||||
PROC_UNLOCK(p); | PROC_UNLOCK(p); | ||||
if (oldcred != NULL) | if (oldcred != NULL) | ||||
crfree(oldcred); | crfree(oldcred); | ||||
if (oldcredwrap != NULL) | |||||
crwfree(oldcredwrap); | |||||
if (oldlimit != NULL) | if (oldlimit != NULL) | ||||
lim_free(oldlimit); | lim_free(oldlimit); | ||||
} | } | ||||
/* | /* | ||||
* Discard the current thread and exit from its context. | * Discard the current thread and exit from its context. | ||||
* Always called with scheduler locked. | * Always called with scheduler locked. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 764 Lines • Show Last 20 Lines |