char afs_AfsdbHandler_Completed = 0;
-static struct cell *afs_GetCellByName_int();
+struct cell *afs_GetCellByName2();
int afs_strcasecmp(s1, s2)
register char *s1, *s2;
if (realName)
afs_osi_Free(realName, strlen(realName) + 1);
- return afs_GetCellByName_int(acellName, locktype, 0);
+ return afs_GetCellByName2(acellName, locktype, 0);
bad:
if (realName)
}
-static struct cell *afs_GetCellByName_int(acellName, locktype, trydns)
+struct cell *afs_GetCellByName2(acellName, locktype, trydns)
register char *acellName;
afs_int32 locktype;
char trydns;
{
register struct cell *tc;
register struct afs_q *cq, *tq;
+ int didAlias = 0;
AFS_STATCNT(afs_GetCellByName);
+retry:
ObtainWriteLock(&afs_xcell,100);
for (cq = CellLRU.next; cq != &CellLRU; cq = tq) {
tc = QTOC(cq); tq = QNext(cq);
QAdd(&CellLRU, &tc->lruq);
ReleaseWriteLock(&afs_xcell);
afs_RefreshCell(tc);
- if (tc->states & CAlias) {
- tc = tc->alias;
- afs_RefreshCell(tc);
+ if ((tc->states & CAlias) && (didAlias == 0)) {
+ acellName = tc->realName;
+ if (!acellName) return (struct cell *) 0;
+ didAlias = 1;
+ goto retry;
}
return tc;
}
return trydns ? afs_GetCellByName_Dns(acellName, locktype)
: (struct cell *) 0;
-} /*afs_GetCellByName_int*/
+} /*afs_GetCellByName2*/
struct cell *afs_GetCellByName(acellName, locktype)
register char *acellName;
afs_int32 locktype;
{
- return afs_GetCellByName_int(acellName, locktype, 1);
+ return afs_GetCellByName2(acellName, locktype, 1);
} /*afs_GetCellByName*/
} /*afs_GetCell*/
-struct cell *afs_GetCellByIndex(cellindex, locktype)
+struct cell *afs_GetCellByIndex(cellindex, locktype, refresh)
register afs_int32 cellindex;
afs_int32 locktype;
+ afs_int32 refresh;
{
register struct cell *tc;
register struct afs_q *cq, *tq;
QRemove(&tc->lruq);
QAdd(&CellLRU, &tc->lruq);
ReleaseWriteLock(&afs_xcell);
- afs_RefreshCell(tc);
+ if (refresh) afs_RefreshCell(tc);
return tc;
}
}
}
else {
tc = (struct cell *) afs_osi_Alloc(sizeof(struct cell));
+ memset((char *)tc, 0, sizeof(*tc));
QAdd(&CellLRU, &tc->lruq); /* put in lruq */
tc->cellName = (char *) afs_osi_Alloc(strlen(acellName)+1);
strcpy(tc->cellName, acellName);
}
tc->states |= aflags;
tc->timeout = timeout;
+
+ /* Allow converting an alias into a real cell */
+ if (!(aflags & CAlias)) tc->states &= ~CAlias;
memset((char *)tc->cellHosts, 0, sizeof(tc->cellHosts));
if (aflags & CAlias) {
- struct cell *tca = NULL;
-
if (!aliasFor) {
code = EINVAL;
goto bad;
}
- for (cq = CellLRU.next; cq != &CellLRU; cq = tq) {
- tca = QTOC(cq); tq = QNext(cq);
- if (!afs_strcasecmp(tca->cellName, aliasFor))
- break;
- }
- if (!tca) {
- code = ENOENT;
- goto bad;
- }
- tc->alias = tca;
+ if (tc->realName) afs_osi_Free(tc->realName, strlen(tc->realName)+1);
+ tc->realName = (char *) afs_osi_Alloc(strlen(aliasFor)+1);
+ strcpy(tc->realName, aliasFor);
goto done;
}