windows-deadlock-20070619
authorJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 19 Jun 2007 12:51:11 +0000 (12:51 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 19 Jun 2007 12:51:11 +0000 (12:51 +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.

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

index 7a8ff4f..01fc399 100644 (file)
@@ -211,6 +211,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 b56c33d..5016a16 100644 (file)
@@ -758,16 +758,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);