]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
viced: Release all hosts in h_Enumerate*
authorAndrew Deason <adeason@sinenomine.net>
Sat, 23 Apr 2011 21:52:30 +0000 (16:52 -0500)
committerDerrick Brashear <shadow@dementia.org>
Tue, 3 May 2011 02:18:22 +0000 (19:18 -0700)
h_Enumerate and h_Enumerate_r were not releasing all of the holds they
obtained when the callback function caused the enumeration to bail
early. Correct them so all host holds are released.

Reviewed-on: http://gerrit.openafs.org/4530
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
(cherry picked from commit 211e906c86be9ad9cba324e776d56093579b6653)

Change-Id: Iceb1e2961e9bbb11640c6fccdeb8713a9657df99
Reviewed-on: http://gerrit.openafs.org/4534
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
src/viced/host.c

index 2e83476700010a7787bfb3a4008a8dd3c415754c..662bf2b49423ebc22aea14abfc13cf466d90fbac 100644 (file)
@@ -1018,6 +1018,16 @@ h_Enumerate(int (*proc) (struct host*, void *), void *param)
            ShutDownAndCore(PANIC);
        }
     }
+    if (i < count-1) {
+       /* we bailed out of enumerating hosts early; we still have holds on
+        * some of the hosts in 'list', so release them */
+       i++;
+       H_LOCK;
+       for ( ; i < count; i++) {
+           h_Release_r(list[i]);
+       }
+       H_UNLOCK;
+    }
     free((void *)list);
 }      /* h_Enumerate */
 
@@ -1098,6 +1108,9 @@ h_Enumerate_r(int (*proc) (struct host *, void *),
            flags = (*proc) (host, param);
            if (H_ENUMERATE_ISSET_BAIL(flags)) {
                h_Release_r(host); /* this might free up the host */
+               if (next) {
+                   h_Release_r(next);
+               }
                break;
            } else if (flags) {
                ViceLog(0, ("h_Enumerate_r got back invalid return value %d\n", flags));