Correct the h_Enumerate_r hostList safety check
authorAndrew Deason <adeason@sinenomine.net>
Fri, 12 Feb 2010 22:30:44 +0000 (16:30 -0600)
committerDerrick Brashear <shadow@dementia.org>
Mon, 22 Feb 2010 18:31:43 +0000 (10:31 -0800)
commit4dfbbd34ce66c09593a0b1a88831ec0f36848fe8
treeb6f2a79940477ff852dd1f0f5aa7d77c2e3c0b4f
parent45aceee9842265fb0ccdb5e8f3f6d32c8d2b99ea
Correct the h_Enumerate_r hostList safety check

Ide1e5aca7c2c4a4af3f62bc07821db694f2f9999 added safety checks for a few
traversals through hostList, including the traversal in h_Enumerate_r.
Unfortunately, h_Enumerate_r may not hold H_LOCK over its entire
traversal (h_Release_r can drop and reacquire it), so the value of
hostCount is not guaranteed to stay the same.

A host may be deleted during the loop, or right near the end, decreasing
hostCount to below our current running 'count' of hosts, triggering the
panic unnecessarily.

Also, we break out of the loop if the H_ENUMERATE_ISSET_BAIL test
succeeds, making the panic also incorrectly trigger then.

So instead, remember the value of hostCount, and ensure that we've
actually exceeded that count in the post-loop check.

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