From: Jeffrey Altman Date: Thu, 9 Mar 2006 21:50:18 +0000 (+0000) Subject: STABLE14-host-tossstuff-locking-20060309 X-Git-Tag: openafs-stable-1_4_1-rc10~11 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=7e80ee67e119d9602b6ba2ae7842dbac2bd1b8ae;p=packages%2Fo%2Fopenafs.git STABLE14-host-tossstuff-locking-20060309 the nonblocking locking was my fault. (cherry picked from commit 9b1fa66828ecb02d782378f1717ac813ff657fdf) --- diff --git a/src/viced/host.c b/src/viced/host.c index a678b5ffc..eaab8077c 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -713,16 +713,27 @@ h_TossStuff_r(register struct host *host) /* ASSUMPTION: rxi_FreeConnection() does not yield */ for (cp = &host->FirstClient; (client = *cp);) { if ((host->hostFlags & HOSTDELETED) || client->deleted) { + int code; + ObtainWriteLockNoBlock(&client->lock, code); + if (code < 0) { + char hoststr[16]; + ViceLog(0, + ("Warning: h_TossStuff_r failed: Host %s:%d client %x was locked.\n", + afs_inet_ntoa_r(host->host, hoststr), + ntohs(host->port), client)); + return; + } + if (client->refCount) { char hoststr[16]; ViceLog(0, - ("Warning: Host %s:%d client %x refcount %d while deleting, failing.\n", + ("Warning: h_TossStuff_r failed: Host %s:%d client %x refcount %d.\n", afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port), client, client->refCount)); /* This is the same thing we do if the host is locked */ + ReleaseWriteLock(&client->lock); return; } - /* We can't protect this without dropping the H_LOCK */ client->CPS.prlist_len = 0; if ((client->ViceId != ANONYMOUSID) && client->CPS.prlist_val) free(client->CPS.prlist_val); @@ -732,6 +743,7 @@ h_TossStuff_r(register struct host *host) } CurrentConnections--; *cp = client->next; + ReleaseWriteLock(&client->lock); FreeCE(client); } else cp = &client->next;