From: Jeffrey Altman Date: Wed, 1 Mar 2006 06:43:14 +0000 (+0000) Subject: STABLE14-viced-h_gethost_r-host-hold-leak-20060228 X-Git-Tag: openafs-stable-1_4_1-rc9~9 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=139292df4bd60d3fcf2172c537baf3be64c3b57d;p=packages%2Fo%2Fopenafs.git STABLE14-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 (cherry picked from commit 31fd9994db1c58d5e851e5a0bd9d04a031557c8d) --- diff --git a/src/viced/host.c b/src/viced/host.c index 43c0eb5ba..768120e73 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -1384,9 +1384,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); @@ -1568,6 +1573,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)