[OpenAFS-devel] Re: [OpenAFS] OopenAFS 1.2.13: ever increasing number of fileserver connections - h_Hold leak

Harald Barth haba@pdc.kth.se
Tue, 15 Feb 2005 17:45:22 +0100 (MET)


> the point is that no initialisation is required! lih_host_held is set 
> whenever lih_host is set to something else than 0, and only used 
> afterwards if lih_host is not 0. lih_host in turn is set to '0' "by 
> hand" prior to starting the h_Enumerate.

static int
lih_r(register struct host *host, register int held,
      register struct host *hostp)
{
    if (host->cblist
        && ((hostp && host != hostp) || (!held && !h_OtherHolds_r(host)))
        && (!lih_host || host->ActiveCall < lih_host->ActiveCall)) {
        if (lih_host != NULL && lih_host_held) {
            h_Release_r(lih_host);
        }
        lih_host = host;
        lih_host_held = !held;
        held = 1;
    }
    return held;
}

Yes, as there is no code path which can sets lih_host and does not set
lih_host_held and the evaluation of (lih_host != NULL && lih_host_held)
is lasy it is safe to leave lih_host_held uninitialized. 

> I took the initialisation away because its presence confused me. A 
> comment /* No need to initialise this */ would have made it more 
> obvious. Alternatively, you can always waste a few cycles and add 
> lih_host_held=0; just after lih_host=0;

Might be good for futre safety, depending how obvious you think
the connection between lih_host and lih_host_held is.

Harald.