host-tossstuff-require-unlocked-20030211
[openafs.git] / src / viced / host.c
index 93292ba..d8d4311 100644 (file)
@@ -682,7 +682,7 @@ struct host *h_LookupUuid_r(afsUUID *uuidp)
  */
 
 /* h_TossStuff_r:  Toss anything in the host structure (the host or
- * clients marked for deletion.  Called from r_Release ONLY.
+ * clients marked for deletion.  Called from h_Release_r ONLY.
  * To be called, there must be no holds, and either host->deleted
  * or host->clientDeleted must be set.
  */
@@ -696,6 +696,16 @@ int h_TossStuff_r(register struct host *host)
     if  (i!=h_maxSlots)
        return;
 
+    /* if somebody still has this host locked */
+    if (h_NBLock_r(host) != 0) {
+       char hoststr[16];
+       ViceLog(0, ("Warning:  h_TossStuff_r failed; Host %s:%d was locked.\n",
+                   afs_inet_ntoa_r(host->host, hoststr), host->port)); 
+       return;
+    } else {
+       h_Unlock_r(host);
+    }
+
     /* ASSUMPTION: r_FreeConnection() does not yield */
     for (cp = &host->FirstClient; (client = *cp); ) {
        if ((host->hostFlags & HOSTDELETED) || client->deleted) {