From fc09b92dce32025c8e1ac762b3f8f07bc731869a Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Sun, 17 Mar 2002 17:53:00 +0000 Subject: [PATCH] callback-function-fixes-20020317 suggested by lha@stacken.kth.se drop locks when rxi_Alloc fails, and rework SRXAFSCB_GetCellServDB to use afs_GetCellByIndex. He suggested same for GetLocalCell, and as long as cell 1 and not CPrimary is the local cell indicator that works, but I left that part of the code as is for now. --- src/afs/afs_callback.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/afs/afs_callback.c b/src/afs/afs_callback.c index 69a010b25..cf7da16d7 100644 --- a/src/afs/afs_callback.c +++ b/src/afs/afs_callback.c @@ -1189,23 +1189,22 @@ int SRXAFSCB_GetCellServDB( /* search the list for the cell with this index */ ObtainReadLock(&afs_xcell); - for (i=0, cq = CellLRU.next; cq != &CellLRU && i<= a_index; cq = tq, i++) { - tq = QNext(cq); - if (i == a_index) { - tcell = QTOC(cq); - p_name = tcell->cellName; - for (j = 0 ; j < AFSMAXCELLHOSTS && tcell->cellHosts[j] ; j++) { - a_hosts[j] = ntohl(tcell->cellHosts[j]->addr->sa_ip); - } + + tcell = afs_GetCellByIndex(a_index, READ_LOCK, 0); + + if (!tcell) { + i = 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); } + i = strlen(p_name); } - if (p_name) - i = strlen(p_name); - else - i = 0; t_name = (char *)rxi_Alloc(i+1); if (t_name == NULL) { + ReleaseReadLock(&afs_xcell); RX_AFS_GUNLOCK(); return ENOMEM; } @@ -1259,6 +1258,7 @@ int SRXAFSCB_GetLocalCell( * the primary cell is when no other cell is explicitly marked as * the primary cell. */ ObtainReadLock(&afs_xcell); + for (cq = CellLRU.next; cq != &CellLRU; cq = tq) { tq = QNext(cq); tcell = QTOC(cq); @@ -1277,6 +1277,7 @@ int SRXAFSCB_GetLocalCell( plen = 0; t_name = (char *)rxi_Alloc(plen+1); if (t_name == NULL) { + ReleaseReadLock(&afs_xcell); RX_AFS_GUNLOCK(); return ENOMEM; } -- 2.39.5