Author: trasz
Date: Sat Sep  3 08:08:24 2011
New Revision: 225364
URL: http://svn.freebsd.org/changeset/base/225364

Log:
  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)

Modified:
  head/sys/kern/kern_racct.c

Modified: head/sys/kern/kern_racct.c
==============================================================================
--- head/sys/kern/kern_racct.c  Sat Sep  3 08:03:25 2011        (r225363)
+++ head/sys/kern/kern_racct.c  Sat Sep  3 08:08:24 2011        (r225364)
@@ -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
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to