From: Jeffrey Altman Date: Wed, 1 Mar 2006 06:42:46 +0000 (+0000) Subject: viced-h_gethost_r-host-hold-leak-20060228 X-Git-Tag: mp-rxtcp-20060314~38 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=31fd9994db1c58d5e851e5a0bd9d04a031557c8d;p=packages%2Fo%2Fopenafs.git viced-h_gethost_r-host-hold-leak-20060228 when h_GetHost_r replaces 'host' with 'oldHost' we need to release the hold on 'host' and maintain the hold on 'oldHost' because if a hold was placed on 'host' in CallPreamble() it will no longer be released in CallPostamble() since 'oldHost' will now be bound to the client --- diff --git a/src/viced/host.c b/src/viced/host.c index 2d719684f..1dc27ffb0 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -1385,9 +1385,14 @@ h_GetHost_r(struct rx_connection *tcon) } host->hostFlags |= HOSTDELETED; h_Unlock_r(host); - if (!held) - h_Release_r(host); + /* regardless of whether or not we obtained the hold on + * 'host', we are going to release it here because we + * are replacing it with 'oldHost' and when CallPostamble + * is called, the host that is obtained is going to be + * 'oldHost' and not 'host'. */ + h_Release_r(host); host = oldHost; + /* the new host is held and locked */ } else { /* This really is a new host */ hashInsertUuid_r(&identP->uuid, host); @@ -1582,6 +1587,9 @@ h_ID2Client(afs_int32 vid) * isn't around. The client is returned with its reference count incremented * by one. The caller must call h_ReleaseClient_r when finished with * the client. + * + * the client->host is returned held. h_ReleaseClient_r does not release + * the hold on client->host. */ struct client * h_FindClient_r(struct rx_connection *tcon)