diff options
author | trasz <trasz@FreeBSD.org> | 2011-09-03 08:08:24 +0000 |
---|---|---|
committer | trasz <trasz@FreeBSD.org> | 2011-09-03 08:08:24 +0000 |
commit | a6059bf016f4f1c6ce4e37142d4e06ed08e69759 (patch) | |
tree | cef62739ee17eec0c95bfe8ef97eb6d7437c6af4 /sys/kern | |
parent | f18a6196d77d71d90e7f726cfc30101abb2958e1 (diff) | |
download | FreeBSD-src-a6059bf016f4f1c6ce4e37142d4e06ed08e69759.zip FreeBSD-src-a6059bf016f4f1c6ce4e37142d4e06ed08e69759.tar.gz |
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)
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_racct.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/sys/kern/kern_racct.c b/sys/kern/kern_racct.c index 401ce1d..b12b7c7 100644 --- a/sys/kern/kern_racct.c +++ b/sys/kern/kern_racct.c @@ -605,6 +605,7 @@ out: 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 |