viced: Release all hosts in h_Enumerate*

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.

Change-Id: I6f405fad3d2767c9e0b3567c40cbbd1de8ac26aa
Reviewed-on: http://gerrit.openafs.org/4530
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
This commit is contained in:
Andrew Deason 2011-04-23 16:52:30 -05:00 committed by Derrick Brashear
parent 8b07814e03
commit 211e906c86

View File

@ -1007,6 +1007,16 @@ h_Enumerate(int (*proc) (struct host*, void *), void *param)
ShutDownAndCore(PANIC); 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); free((void *)list);
} /* h_Enumerate */ } /* h_Enumerate */
@ -1087,6 +1097,9 @@ h_Enumerate_r(int (*proc) (struct host *, void *),
flags = (*proc) (host, param); flags = (*proc) (host, param);
if (H_ENUMERATE_ISSET_BAIL(flags)) { if (H_ENUMERATE_ISSET_BAIL(flags)) {
h_Release_r(host); /* this might free up the host */ h_Release_r(host); /* this might free up the host */
if (next) {
h_Release_r(next);
}
break; break;
} else if (flags) { } else if (flags) {
ViceLog(0, ("h_Enumerate_r got back invalid return value %d\n", flags)); ViceLog(0, ("h_Enumerate_r got back invalid return value %d\n", flags));