get-server-list-20040729
authorJeffrey Altman <jaltman@mit.edu>
Fri, 30 Jul 2004 05:04:27 +0000 (05:04 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 30 Jul 2004 05:04:27 +0000 (05:04 +0000)
Undo the previous patch.  the server list can't be cloned.
instead we will have to refCount the cm_serverRef_t objects.
This is going to be a lot of work.  To be continued ...

src/WINNT/afsd/cm_conn.c

index 4ac642d..856f31d 100644 (file)
@@ -103,7 +103,6 @@ long cm_GetServerList(struct cm_fid *fidp, struct cm_user *userp,
        long code;
         cm_volume_t *volp = NULL;
         cm_serverRef_t *serversp = NULL;
-    cm_serverRef_t *newServersp = NULL;
         cm_cell_t *cellp = NULL;
 
         if (!fidp) {
@@ -117,7 +116,6 @@ long cm_GetServerList(struct cm_fid *fidp, struct cm_user *userp,
         code = cm_GetVolumeByID(cellp, fidp->volume, userp, reqp, &volp);
         if (code) return code;
         
-    lock_ObtainMutex(&volp->mx);
        if (fidp->volume == volp->rwID)
                serversp = volp->rwServersp;
        else if (fidp->volume == volp->roID)
@@ -127,36 +125,8 @@ long cm_GetServerList(struct cm_fid *fidp, struct cm_user *userp,
        else
                serversp = NULL;
 
-    /* make a copy of the server list because by the time the 
-    caller tries to use it, it might have been freed.
-    Preserve server order. */
-    if(serversp) {
-        cm_serverRef_t ** nl;
-        cm_serverRef_t * tref;
-
-        nl = &newServersp;
-
-        lock_ObtainWrite(&cm_serverLock);
-        while(serversp) {
-
-            tref = malloc(sizeof(cm_serverRef_t));
-            tref->next = NULL;
-            tref->server = serversp->server;
-            tref->status = serversp->status;
-
-            tref->server->refCount++;
-
-            *nl = tref;
-            nl = &tref->next;
-
-            serversp = serversp->next;
-        }
-        lock_ReleaseWrite(&cm_serverLock);
-    }
-    lock_ReleaseMutex(&volp->mx);
-
         cm_PutVolume(volp);
-    *serverspp = newServersp;
+       *serverspp = serversp;
        return 0;
 }
 
@@ -247,7 +217,6 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
 
             retry = 1;
         }
-        cm_FreeServerList(&serversp);
 
         if (fidp != NULL)   /* Not a VLDB call */
             cm_ForceUpdateVolume(fidp, userp, reqp);
@@ -262,7 +231,6 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
                                tsrp->status = not_busy;
                }
         lock_ReleaseWrite(&cm_serverLock);
-        cm_FreeServerList(&serversp);
                thrd_Sleep(5000);
                retry = 1;
        }
@@ -279,7 +247,6 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
                        }
                }
         lock_ReleaseWrite(&cm_serverLock);
-        cm_FreeServerList(&serversp);
                retry = 1;
        }
 
@@ -312,11 +279,11 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
 
                /* Mark server offline for this volume */
                cm_GetServerList(fidp, userp, reqp, &serversp);
+
                for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
                        if (tsrp->server == serverp)
                                tsrp->status = offline;
                }
-        cm_FreeServerList(&serversp);
                retry = 1;
        }
 
@@ -589,6 +556,5 @@ long cm_Conn(struct cm_fid *fidp, struct cm_user *userp, cm_req_t *reqp,
        }
 
        code = cm_ConnByMServers(serversp, userp, reqp, connpp);
-    cm_FreeServerList(&serversp);
         return code;
 }