Fix panic that happens when fork(2) fails due to a limit other than

the rctl one - for example, it happens when someone reaches maximum
number of processes in the system.

Approved by:	re (kib)
This commit is contained in:
Edward Tomasz Napierala 2011-09-03 08:08:24 +00:00
parent 6fae67da24
commit 2419d7f93b

View File

@ -605,6 +605,7 @@ racct_proc_fork(struct proc *parent, struct proc *child)
void
racct_proc_exit(struct proc *p)
{
int i;
uint64_t runtime;
PROC_LOCK(p);
@ -618,14 +619,18 @@ racct_proc_exit(struct proc *p)
if (runtime < p->p_prev_runtime)
runtime = p->p_prev_runtime;
#endif
racct_set(p, RACCT_CPU, runtime);
mtx_lock(&racct_lock);
racct_set_locked(p, RACCT_CPU, runtime);
/*
* XXX: Free this some other way.
*/
racct_set(p, RACCT_NPTS, 0);
racct_set(p, RACCT_NTHR, 0);
racct_set(p, RACCT_RSS, 0);
for (i = 0; i <= RACCT_MAX; i++) {
if (p->p_racct->r_resources[i] == 0)
continue;
if (!RACCT_IS_RECLAIMABLE(i))
continue;
racct_set_locked(p, i, 0);
}
mtx_unlock(&racct_lock);
PROC_UNLOCK(p);
#ifdef RCTL