]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
viced-h_Enumerate_r-fix-20060301
authorJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 1 Mar 2006 19:12:05 +0000 (19:12 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 1 Mar 2006 19:12:05 +0000 (19:12 +0000)
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.

src/viced/host.c

index 1dc27ffb0831ec44032bae99dbfbb97691fb6cec..71162d19391bd61b994de4f3ad0eea0a65414edf 100644 (file)
@@ -904,10 +904,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 */
     }