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
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=347227
@ -883,18 +883,20 @@ fork1(struct thread *td, struct fork_req *fr)
|
||||
* processes; don't let root exceed the limit.
|
||||
*/
|
||||
nprocs_new = atomic_fetchadd_int(&nprocs, 1) + 1;
|
||||
if ((nprocs_new >= maxproc - 10 &&
|
||||
priv_check_cred(td->td_ucred, PRIV_MAXPROC) != 0) ||
|
||||
nprocs_new >= maxproc) {
|
||||
error = EAGAIN;
|
||||
sx_xlock(&allproc_lock);
|
||||
if (ppsratecheck(&lastfail, &curfail, 1)) {
|
||||
printf("maxproc limit exceeded by uid %u (pid %d); "
|
||||
"see tuning(7) and login.conf(5)\n",
|
||||
td->td_ucred->cr_ruid, p1->p_pid);
|
||||
if (nprocs_new >= maxproc - 10) {
|
||||
if (priv_check_cred(td->td_ucred, PRIV_MAXPROC) != 0 ||
|
||||
nprocs_new >= maxproc) {
|
||||
error = EAGAIN;
|
||||
sx_xlock(&allproc_lock);
|
||||
if (ppsratecheck(&lastfail, &curfail, 1)) {
|
||||
printf("maxproc limit exceeded by uid %u "
|
||||
"(pid %d); see tuning(7) and "
|
||||
"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…
Reference in New Issue
Block a user