Instead of using hand-rolled loops where not needed switch them
to FOREACH_PROC_IN_SYSTEM() to have a single pattern to look for. Reviewed by: kib MFC after: 2 weeks Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D15916
This commit is contained in:
parent
c30e5927b6
commit
7938a4425a
@ -2286,7 +2286,7 @@ prison_remove_one(struct prison *pr)
|
||||
* Kill all processes unfortunate enough to be attached to this prison.
|
||||
*/
|
||||
sx_slock(&allproc_lock);
|
||||
LIST_FOREACH(p, &allproc, p_list) {
|
||||
FOREACH_PROC_IN_SYSTEM(p) {
|
||||
PROC_LOCK(p);
|
||||
if (p->p_state != PRS_NEW && p->p_ucred &&
|
||||
p->p_ucred->cr_prison == pr)
|
||||
|
@ -3176,7 +3176,7 @@ resume_all_proc(void)
|
||||
}
|
||||
}
|
||||
/* Did the loop above missed any stopped process ? */
|
||||
LIST_FOREACH(p, &allproc, p_list) {
|
||||
FOREACH_PROC_IN_SYSTEM(p) {
|
||||
/* No need for proc lock. */
|
||||
if ((p->p_flag & P_TOTAL_STOP) != 0)
|
||||
goto again;
|
||||
|
@ -580,14 +580,12 @@ kdb_thr_first(void)
|
||||
struct proc *p;
|
||||
struct thread *thr;
|
||||
|
||||
p = LIST_FIRST(&allproc);
|
||||
while (p != NULL) {
|
||||
FOREACH_PROC_IN_SYSTEM(p) {
|
||||
if (p->p_flag & P_INMEM) {
|
||||
thr = FIRST_THREAD_IN_PROC(p);
|
||||
if (thr != NULL)
|
||||
return (thr);
|
||||
}
|
||||
p = LIST_NEXT(p, p_list);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
@ -597,11 +595,9 @@ kdb_thr_from_pid(pid_t pid)
|
||||
{
|
||||
struct proc *p;
|
||||
|
||||
p = LIST_FIRST(&allproc);
|
||||
while (p != NULL) {
|
||||
FOREACH_PROC_IN_SYSTEM(p) {
|
||||
if (p->p_flag & P_INMEM && p->p_pid == pid)
|
||||
return (FIRST_THREAD_IN_PROC(p));
|
||||
p = LIST_NEXT(p, p_list);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user