]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE14-viced-firstclient-retry-20050619
authorDerrick Brashear <shadow@dementia.org>
Tue, 21 Jun 2005 21:20:41 +0000 (21:20 +0000)
committerDerrick Brashear <shadow@dementia.org>
Tue, 21 Jun 2005 21:20:41 +0000 (21:20 +0000)
FIXES 1345

avoid race as we add a new client

(cherry picked from commit 0f61c69103bada5f4039ffd3968d7e8b92eb9bf6)

src/viced/host.c

index 0c44c63946fc189fd9be6ed521886d8bb5a274c2..21c1b4d1f49cbe5b0fc144551977a719da0df03c 100644 (file)
@@ -1452,6 +1452,7 @@ h_FindClient_r(struct rx_connection *tcon)
     if (!client) {
        host = h_GetHost_r(tcon);       /* Returns it h_Held */
 
+    retryfirstclient:
        /* First try to find the client structure */
        for (client = host->FirstClient; client; client = client->next) {
            if (!client->deleted && (client->sid == rxr_CidOf(tcon))
@@ -1485,6 +1486,15 @@ h_FindClient_r(struct rx_connection *tcon)
 
        /* Still no client structure - get one */
        if (!client) {
+           h_Lock_r(host);
+           /* Retry to find the client structure */
+           for (client = host->FirstClient; client; client = client->next) {
+               if (!client->deleted && (client->sid == rxr_CidOf(tcon))
+                   && (client->VenusEpoch == rxr_GetEpoch(tcon))) {
+                   h_Unlock_r(host);
+                   goto retryfirstclient;
+               }
+           }
            client = GetCE();
            ObtainWriteLock(&client->lock);
            client->refCount = 1;
@@ -1501,6 +1511,7 @@ h_FindClient_r(struct rx_connection *tcon)
            client->VenusEpoch = rxr_GetEpoch(tcon);
            client->CPS.prlist_val = 0;
            client->CPS.prlist_len = 0;
+           h_Unlock_r(host);
            CurrentConnections++;       /* increment number of connections */
        }
     }