h-enumerate-r-safety-20051128

FIXES 23336

needs further testing, configure a low number of callbacks and hit the server.
This commit is contained in:
Chaskiel M Grundman 2005-11-29 03:40:58 +00:00 committed by Derrick Brashear
parent bb7b7cef79
commit 390fd697a0

View File

@ -895,16 +895,19 @@ h_Enumerate(int (*proc) (), char *param)
void
h_Enumerate_r(int (*proc) (), struct host *enumstart, char *param)
{
register struct host *host;
register int held;
register struct host *host, *next;
register int held, nheld;
if (hostCount == 0) {
return;
}
for (host = enumstart; host; host = host->next) {
if (!(held = h_Held_r(host)))
h_Hold_r(host);
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);
if (!held)
h_Release_r(host); /* this might free up the host */
}