DEVEL15-windows-deadlock-20070619
authorJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 19 Jun 2007 13:04:04 +0000 (13:04 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 19 Jun 2007 13:04:04 +0000 (13:04 +0000)
fix deadlock on cm_volumeLock introduced by last week's work

in cm_Analyze, make sure we get a cm_cell_t reference otherwise we
won't find the cm_volume_t we are searching for when ALLOFFLINE or
ALLBUSY.

(cherry picked from commit 59db9812209d5e54cc47fc32d626b8b73f7fc22b)

src/WINNT/afsd/cm_conn.c
src/WINNT/afsd/cm_volume.c

index 37b93d6..1b675b1 100644 (file)
@@ -222,6 +222,9 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
                 if ( refp->server )
                     cellp = refp->server->cellp;
             }
+        } 
+        if (cellp == NULL && fidp) {
+            cellp = cm_FindCellByID(fidp->cell);
         }
     }
 
index 9e377d8..1c4c651 100644 (file)
@@ -762,16 +762,16 @@ long cm_GetVolumeByName(struct cm_cell *cellp, char *volumeNamep,
         cm_AddVolumeToNameHashTable(volp);
         lock_ReleaseWrite(&cm_volumeLock);
     }
-    else if (volp) {
+    else {
         lock_ReleaseRead(&cm_volumeLock);
-        cm_GetVolume(volp);
-        lock_ObtainMutex(&volp->mx);
+        if (volp) {
+            cm_GetVolume(volp);
+            lock_ObtainMutex(&volp->mx);
+        } else {
+            return CM_ERROR_NOSUCHVOLUME;
+        }
     }
 
-    /* if we don't have a volp structure return no such volume */
-    if (!volp)
-        return CM_ERROR_NOSUCHVOLUME;
-
     /* if we get here we are holding the mutex */
     if (volp->flags & CM_VOLUMEFLAG_RESET) {
        code = cm_UpdateVolume(cellp, userp, reqp, volp);