Simplify the test against maxproc in fork1().
Previously nprocs_new would be tested against maxprocs twice when nprocs_new < maxprocs - 10. Eliminate the unnecessary comparison. Submitted by: Wuyang Chung <wuyang.chung1@gmail.com> GitHub PR: https://github.com/freebsd/freebsd/pull/397 MFC after: 1 week
This commit is contained in:
parent
bf03b1f1f9
commit
7d43b5c98e
@ -883,18 +883,20 @@ fork1(struct thread *td, struct fork_req *fr)
|
|||||||
* processes; don't let root exceed the limit.
|
* processes; don't let root exceed the limit.
|
||||||
*/
|
*/
|
||||||
nprocs_new = atomic_fetchadd_int(&nprocs, 1) + 1;
|
nprocs_new = atomic_fetchadd_int(&nprocs, 1) + 1;
|
||||||
if ((nprocs_new >= maxproc - 10 &&
|
if (nprocs_new >= maxproc - 10) {
|
||||||
priv_check_cred(td->td_ucred, PRIV_MAXPROC) != 0) ||
|
if (priv_check_cred(td->td_ucred, PRIV_MAXPROC) != 0 ||
|
||||||
nprocs_new >= maxproc) {
|
nprocs_new >= maxproc) {
|
||||||
error = EAGAIN;
|
error = EAGAIN;
|
||||||
sx_xlock(&allproc_lock);
|
sx_xlock(&allproc_lock);
|
||||||
if (ppsratecheck(&lastfail, &curfail, 1)) {
|
if (ppsratecheck(&lastfail, &curfail, 1)) {
|
||||||
printf("maxproc limit exceeded by uid %u (pid %d); "
|
printf("maxproc limit exceeded by uid %u "
|
||||||
"see tuning(7) and login.conf(5)\n",
|
"(pid %d); see tuning(7) and "
|
||||||
td->td_ucred->cr_ruid, p1->p_pid);
|
"login.conf(5)\n",
|
||||||
|
td->td_ucred->cr_ruid, p1->p_pid);
|
||||||
|
}
|
||||||
|
sx_xunlock(&allproc_lock);
|
||||||
|
goto fail2;
|
||||||
}
|
}
|
||||||
sx_xunlock(&allproc_lock);
|
|
||||||
goto fail2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user