From 6c6852da90c1a106cc771522dcd6a6ca33fa4171 Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Sun, 21 Apr 2002 21:12:22 +0000 Subject: [PATCH] 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. (cherry picked from commit fc09b92dce32025c8e1ac762b3f8f07bc731869a) --- src/afs/afs_callback.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/afs/afs_callback.c b/src/afs/afs_callback.c index 002c02f64..fd5c227a4 100644 --- a/src/afs/afs_callback.c +++ b/src/afs/afs_callback.c @@ -1141,23 +1141,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); #ifdef RX_ENABLE_LOCKS AFS_GUNLOCK(); #endif /* RX_ENABLE_LOCKS */ @@ -1217,6 +1216,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); @@ -1235,6 +1235,7 @@ int SRXAFSCB_GetLocalCell( plen = 0; t_name = (char *)rxi_Alloc(plen+1); if (t_name == NULL) { + ReleaseReadLock(&afs_xcell); #ifdef RX_ENABLE_LOCKS AFS_GUNLOCK(); #endif /* RX_ENABLE_LOCKS */ -- 2.39.5