From: Jeffrey Altman Date: Wed, 1 Mar 2006 19:12:37 +0000 (+0000) Subject: STABLE14-viced-h_Enumerate_r-fix-20060301 X-Git-Tag: openafs-stable-1_4_1-rc9~8 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=08039832aa0a834db047a13d0bf118040b446eee;p=packages%2Fo%2Fopenafs.git STABLE14-viced-h_Enumerate_r-fix-20060301 In h_Enumerate_r it is possible that the host may be released by the called procedure. Therefore, we must preserve the pointer to host->next before the call and hold the host it points to in order to ensure that it does not disappear out from under us. This ensures that although the H_LOCK can be dropped during the procedure and the host list can be rearranged we won't miss more than a handful of hosts during the enumeration. (cherry picked from commit 36a8e29045adfcf5d3c144b0ff0bc9d1398d11b0) --- diff --git a/src/viced/host.c b/src/viced/host.c index 768120e73..fb56e93ba 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -903,10 +903,10 @@ h_Enumerate_r(int (*proc) (), struct host *enumstart, char *param) if (enumstart && !(held = h_Held_r(enumstart))) h_Hold_r(enumstart); for (host = enumstart; host; host = next, held = nheld) { - held = (*proc) (host, held, param); next = host->next; if (next && !(nheld = h_Held_r(next))) h_Hold_r(next); + held = (*proc) (host, held, param); if (!held) h_Release_r(host); /* this might free up the host */ }