We need to restore unallocated_objects if objcache alloc fails.
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 26 Dec 2008 12:40:34 +0000 (20:40 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 27 Dec 2008 05:02:02 +0000 (13:02 +0800)
Reviewed-by: dillon@
sys/kern/kern_objcache.c

index 20b8c43..5a4cc7f 100644 (file)
@@ -432,14 +432,15 @@ retry:
                        if (oc->ctor(obj, oc->privdata, ocflags))
                                return (obj);
                        oc->free(obj, oc->allocator_args);
+                       obj = NULL;
+               }
+               if (obj == NULL) {
                        spin_lock_wr(&depot->spin);
                        ++depot->unallocated_objects;
                        spin_unlock_wr(&depot->spin);
                        if (depot->waiting)
                                wakeup(depot);
-                       obj = NULL;
-               }
-               if (obj == NULL) {
+
                        crit_enter();
                        /*
                         * makes debugging easier when gets_cumulative does