]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE12-getcellservdb-cleanup-20020608
authorDerrick Brashear <shadow@dementia.org>
Sat, 8 Jun 2002 12:00:28 +0000 (12:00 +0000)
committerDerrick Brashear <shadow@dementia.org>
Sat, 8 Jun 2002 12:00:28 +0000 (12:00 +0000)
based on comments and suggestion from Srikanth Vishwanathan <vsrikanth@in.ibm.com>
avoid deadlock. send back variable length list. allocate what we need to, and
be care to clean up after ourselves if there's an error. whether this
should be variable length is arguable but it's pretty clear no one was using
this before.

(cherry picked from commit 08bb209eef379534268ec6433a131bc52711d111)

src/afs/afs_callback.c
src/fsint/common.xg
src/vlserver/vldbint.xg

index 30bc1c478e689a69193da49231327fcb51734df4..fe6ccf79c2f8c985001100724ae25dc296c3d448 100644 (file)
@@ -1125,7 +1125,7 @@ int SRXAFSCB_GetCellServDB(
     struct rx_call *a_call,
     afs_int32 a_index,
     char **a_name,
-    afs_int32 *a_hosts)
+    serverList *a_hosts)
 {
     afs_int32 i, j;
     struct cell *tcell;
@@ -1137,27 +1137,27 @@ int SRXAFSCB_GetCellServDB(
 #endif /* RX_ENABLE_LOCKS */
     AFS_STATCNT(SRXAFSCB_GetCellServDB);
 
-    memset(a_hosts, 0, AFSMAXCELLHOSTS * sizeof(afs_int32));
-
-    /* search the list for the cell with this index */
-    ObtainReadLock(&afs_xcell);
-
     tcell = afs_GetCellByIndex(a_index, READ_LOCK, 0);
 
     if (!tcell) {
       i = 0;
+      a_hosts->serverList_val = 0;
+      a_hosts->serverList_len = 0;
     } else {
       p_name = tcell->cellName;
-      for (j = 0 ; j < AFSMAXCELLHOSTS && tcell->cellHosts[j] ; j++) {
-       a_hosts[j] = ntohl(tcell->cellHosts[j]->addr->sa_ip);
-      }
+      for (j = 0 ; j < AFSMAXCELLHOSTS && tcell->cellHosts[j] ; j++)
+       ;
       i = strlen(p_name);
+      a_hosts->serverList_val = (afs_int32 *)afs_osi_Alloc(j*sizeof(afs_int32));
+      a_hosts->serverList_len = j;
+      for (j = 0 ; j < AFSMAXCELLHOSTS && tcell->cellHosts[j] ; j++)
+       a_hosts->serverList_val[j] = ntohl(tcell->cellHosts[j]->addr->sa_ip);
       afs_PutCell(tcell, READ_LOCK);
     }
 
     t_name = (char *)afs_osi_Alloc(i+1);
     if (t_name == NULL) {
-        ReleaseReadLock(&afs_xcell);
+      afs_osi_Free(a_hosts->serverList_val, (j*sizeof(afs_int32)));
 #ifdef RX_ENABLE_LOCKS
        AFS_GUNLOCK();
 #endif /* RX_ENABLE_LOCKS */
@@ -1168,8 +1168,6 @@ int SRXAFSCB_GetCellServDB(
     if (p_name)
        memcpy(t_name, p_name, i);
 
-    ReleaseReadLock(&afs_xcell);
-
 #ifdef RX_ENABLE_LOCKS
     AFS_GUNLOCK();
 #endif /* RX_ENABLE_LOCKS */
index c658b6dfe2c3aa8a1db4faad22f87db745c51954..5215be4ab44068a3a2ee7703581a3315c8f44efc 100644 (file)
@@ -136,7 +136,7 @@ struct interfaceAddr {              /* for multihomed clients */
 };
 
 const AFSMAXCELLHOSTS = 8;     /*Max VLDB servers per cell*/
-typedef afs_int32 serverList[AFSMAXCELLHOSTS];
+typedef afs_int32 serverList<AFSMAXCELLHOSTS>;
 
 typedef afs_uint32 cacheConfig<>;
 
index 6b54cfbe607c556a7c3e7713e0eb2fd57e4f206e..9c175a57b1e7841c6ce7b46753fa930c5697aab1 100644 (file)
@@ -15,7 +15,7 @@ statindex 15
 %#include      "vl_opcodes.h"  /* directly to other places */
 
 %#ifdef KERNEL
-%#define       xdr_array(a,b,c,d,e,f)  xdr_arrayN(a,b,c,d,e,f)
+%#define       afs_xdr_array(a,b,c,d,e,f)      afs_xdr_arrayN(a,b,c,d,e,f)
 %#include "../afs/longc_procs.h"
 %#endif