fix-indent-bug-with-lock-macros-20030729

Add trailing semicolons to lock/unlock macro invocations to make
indent do the right thing, and re-indent.
This commit is contained in:
Nickolai Zeldovich 2003-07-29 19:58:19 +00:00
parent 42396526a7
commit 5227918cb9
6 changed files with 735 additions and 438 deletions

File diff suppressed because it is too large Load Diff

View File

@ -537,7 +537,8 @@ FDel(register struct FileEntry *fe)
int
InitCallBack(int nblks)
{
H_LOCK tfirst = CBtime(FT_ApproxTime());
H_LOCK;
tfirst = CBtime(FT_ApproxTime());
/* N.B. The "-1", below, is because
* FE[0] and CB[0] are not used--and not allocated */
FE = ((struct FileEntry *)(calloc(nblks, sizeof(struct FileEntry)))) - 1;
@ -558,7 +559,8 @@ InitCallBack(int nblks)
FreeCB(&CB[cbstuff.nCBs]); /* This is correct */
cbstuff.nblks = nblks;
cbstuff.nbreakers = 0;
H_UNLOCK return 0;
H_UNLOCK;
return 0;
}
afs_int32
@ -592,8 +594,10 @@ XCallBackBulk_r(struct host * ahost, struct AFSFid * fids, afs_int32 nfids)
tc.AFSCBs_len = i;
tc.AFSCBs_val = tcbs;
H_UNLOCK code |= RXAFSCB_CallBack(ahost->callback_rxcon, &tf, &tc);
H_LOCK}
H_UNLOCK;
code |= RXAFSCB_CallBack(ahost->callback_rxcon, &tf, &tc);
H_LOCK;
}
return code;
}
@ -612,7 +616,8 @@ AddCallBack1(struct host *host, AFSFid * fid, afs_uint32 * thead, int type,
int locked)
{
int retVal;
H_LOCK if (!locked) {
H_LOCK;
if (!locked) {
h_Lock_r(host);
}
retVal = AddCallBack1_r(host, fid, thead, type, 1);
@ -620,7 +625,8 @@ AddCallBack1(struct host *host, AFSFid * fid, afs_uint32 * thead, int type,
if (!locked) {
h_Unlock_r(host);
}
H_UNLOCK return retVal;
H_UNLOCK;
return retVal;
}
static int
@ -781,7 +787,8 @@ MultiBreakCallBack_r(struct cbstruct cba[], int ncbas,
if (j) { /* who knows what multi would do with 0 conns? */
cbstuff.nbreakers++;
H_UNLOCK multi_Rx(conns, j) {
H_UNLOCK;
multi_Rx(conns, j) {
multi_RXAFSCB_CallBack(afidp, &tc);
if (multi_error) {
afs_uint32 idx;
@ -825,7 +832,8 @@ MultiBreakCallBack_r(struct cbstruct cba[], int ncbas,
ntohs(hp->port)));
}
H_LOCK h_Lock_r(hp);
H_LOCK;
h_Lock_r(hp);
hp->hostFlags |= VENUSDOWN;
/**
* We always go into AddCallBack1_r with the host locked
@ -833,12 +841,14 @@ MultiBreakCallBack_r(struct cbstruct cba[], int ncbas,
AddCallBack1_r(hp, afidp->AFSCBFids_val, itot(idx),
CB_DELAYED, 1);
h_Unlock_r(hp);
H_UNLOCK}
H_UNLOCK;
}
}
}
}
multi_End;
H_LOCK cbstuff.nbreakers--;
H_LOCK;
cbstuff.nbreakers--;
}
for (i = 0; i < ncbas; i++) {
@ -878,7 +888,8 @@ BreakCallBack(struct host *xhost, AFSFid * fid, int flag)
afs_inet_ntoa_r(xhost->host, hoststr), ntohs(xhost->port),
fid->Volume, fid->Vnode, fid->Unique));
H_LOCK cbstuff.BreakCallBacks++;
H_LOCK;
cbstuff.BreakCallBacks++;
fe = FindFE(fid);
if (!fe) {
goto done;
@ -937,7 +948,8 @@ BreakCallBack(struct host *xhost, AFSFid * fid, int flag)
}
done:
H_UNLOCK return 0;
H_UNLOCK;
return 0;
}
/* Delete (do not break) single call back for fid */
@ -950,13 +962,15 @@ DeleteCallBack(struct host *host, AFSFid * fid)
cbstuff.DeleteCallBacks++;
H_LOCK h_Lock_r(host);
H_LOCK;
h_Lock_r(host);
fe = FindFE(fid);
if (!fe) {
h_Unlock_r(host);
H_UNLOCK ViceLog(8,
("DCB: No call backs for fid (%u, %u, %u)\n",
fid->Volume, fid->Vnode, fid->Unique));
H_UNLOCK;
ViceLog(8,
("DCB: No call backs for fid (%u, %u, %u)\n",
fid->Volume, fid->Vnode, fid->Unique));
return 0;
}
pcb = FindCBPtr(fe, host);
@ -966,13 +980,15 @@ DeleteCallBack(struct host *host, AFSFid * fid)
afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port),
fid->Volume, fid->Vnode, fid->Unique));
h_Unlock_r(host);
H_UNLOCK return 0;
H_UNLOCK;
return 0;
}
HDel(itocb(*pcb));
TDel(itocb(*pcb));
CDelPtr(fe, pcb, 1);
h_Unlock_r(host);
H_UNLOCK return 0;
H_UNLOCK;
return 0;
}
/*
@ -989,12 +1005,14 @@ DeleteFileCallBacks(AFSFid * fid)
register afs_uint32 cbi;
register int n;
H_LOCK cbstuff.DeleteFiles++;
H_LOCK;
cbstuff.DeleteFiles++;
fe = FindFE(fid);
if (!fe) {
H_UNLOCK ViceLog(8,
("DF: No fid (%u,%u,%u) to delete\n", fid->Volume,
fid->Vnode, fid->Unique));
H_UNLOCK;
ViceLog(8,
("DF: No fid (%u,%u,%u) to delete\n", fid->Volume,
fid->Vnode, fid->Unique));
return 0;
}
for (n = 0, cbi = fe->firstcb; cbi; n++) {
@ -1005,7 +1023,8 @@ DeleteFileCallBacks(AFSFid * fid)
FreeCB(cb);
}
FDel(fe);
H_UNLOCK return 0;
H_UNLOCK;
return 0;
}
/* Delete (do not break) all call backs for host. The host should be
@ -1041,8 +1060,10 @@ int
BreakDelayedCallBacks(struct host *host)
{
int retVal;
H_LOCK retVal = BreakDelayedCallBacks_r(host);
H_UNLOCK return retVal;
H_LOCK;
retVal = BreakDelayedCallBacks_r(host);
H_UNLOCK;
return retVal;
}
int
@ -1060,12 +1081,16 @@ BreakDelayedCallBacks_r(struct host *host)
if (!(host->hostFlags & RESETDONE) && !(host->hostFlags & HOSTDELETED)) {
host->hostFlags &= ~ALTADDR; /* alterrnate addresses are invalid */
if (host->interface) {
H_UNLOCK code =
H_UNLOCK;
code =
RXAFSCB_InitCallBackState3(host->callback_rxcon,
&FS_HostUUID);
H_LOCK} else {
H_UNLOCK code = RXAFSCB_InitCallBackState(host->callback_rxcon);
H_LOCK}
H_LOCK;
} else {
H_UNLOCK;
code = RXAFSCB_InitCallBackState(host->callback_rxcon);
H_LOCK;
}
host->hostFlags |= ALTADDR; /* alternate addresses are valid */
if (code) {
if (ShowProblems) {
@ -1219,8 +1244,10 @@ MultiBreakVolumeCallBack(struct host *host, int isheld,
struct VCBParams *parms)
{
int retval;
H_LOCK retval = MultiBreakVolumeCallBack_r(host, isheld, parms, 1);
H_UNLOCK return retval;
H_LOCK;
retval = MultiBreakVolumeCallBack_r(host, isheld, parms, 1);
H_UNLOCK;
return retval;
}
/*
@ -1232,8 +1259,10 @@ MultiBreakVolumeLaterCallBack(struct host *host, int isheld,
struct VCBParams *parms)
{
int retval;
H_LOCK retval = MultiBreakVolumeCallBack_r(host, isheld, parms, 0);
H_UNLOCK return retval;
H_LOCK;
retval = MultiBreakVolumeCallBack_r(host, isheld, parms, 0);
H_UNLOCK;
return retval;
}
/*
@ -1262,7 +1291,8 @@ BreakVolumeCallBacks(afs_uint32 volume)
struct VCBParams henumParms;
afs_uint32 tthead = 0; /* zero is illegal value */
H_LOCK fid.Volume = volume, fid.Vnode = fid.Unique = 0;
H_LOCK;
fid.Volume = volume, fid.Vnode = fid.Unique = 0;
for (hash = 0; hash < VHASH; hash++) {
for (feip = &HashTable[hash]; (fe = itofe(*feip));) {
if (fe->volid == volume) {
@ -1289,13 +1319,16 @@ BreakVolumeCallBacks(afs_uint32 volume)
if (!tthead) {
/* didn't find any callbacks, so return right away. */
H_UNLOCK return 0;
H_UNLOCK;
return 0;
}
henumParms.ncbas = 0;
henumParms.fid = &fid;
henumParms.thead = tthead;
H_UNLOCK h_Enumerate(MultiBreakVolumeCallBack, (char *)&henumParms);
H_LOCK if (henumParms.ncbas) { /* do left-overs */
H_UNLOCK;
h_Enumerate(MultiBreakVolumeCallBack, (char *)&henumParms);
H_LOCK;
if (henumParms.ncbas) { /* do left-overs */
struct AFSCBFids tf;
tf.AFSCBFids_len = 1;
tf.AFSCBFids_val = &fid;
@ -1304,7 +1337,8 @@ BreakVolumeCallBacks(afs_uint32 volume)
henumParms.ncbas = 0;
}
H_UNLOCK return 0;
H_UNLOCK;
return 0;
}
#ifdef AFS_PTHREAD_ENV
@ -1324,7 +1358,8 @@ BreakVolumeCallBacksLater(afs_uint32 volume)
int found = 0;
ViceLog(25, ("Setting later on volume %u\n", volume));
H_LOCK for (hash = 0; hash < VHASH; hash++) {
H_LOCK;
for (hash = 0; hash < VHASH; hash++) {
for (feip = &HashTable[hash]; fe = itofe(*feip);) {
if (fe->volid == volume) {
register struct CallBack *cbnext;
@ -1334,13 +1369,16 @@ BreakVolumeCallBacksLater(afs_uint32 volume)
cb->status = CB_DELAYED;
cbnext = itocb(cb->cnext);
}
FSYNC_LOCK fe->status |= FE_LATER;
FSYNC_UNLOCK found++;
FSYNC_LOCK;
fe->status |= FE_LATER;
FSYNC_UNLOCK;
found++;
}
feip = &fe->fnext;
}
}
H_UNLOCK if (!found) {
H_UNLOCK;
if (!found) {
/* didn't find any callbacks, so return right away. */
return 0;
}
@ -1369,9 +1407,9 @@ BreakLaterCallBacks(void)
/* Unchain first */
ViceLog(25, ("Looking for FileEntries to unchain\n"));
H_LOCK
/* Pick the first volume we see to clean up */
fid.Volume = fid.Vnode = fid.Unique = 0;
H_LOCK;
/* Pick the first volume we see to clean up */
fid.Volume = fid.Vnode = fid.Unique = 0;
for (hash = 0; hash < VHASH; hash++) {
for (feip = &HashTable[hash]; fe = itofe(*feip);) {
@ -1391,11 +1429,13 @@ BreakLaterCallBacks(void)
}
if (!myfe) {
H_UNLOCK return 0;
H_UNLOCK;
return 0;
}
/* loop over FEs from myfe and free/break */
FSYNC_UNLOCK tthead = 0;
FSYNC_UNLOCK;
tthead = 0;
for (fe = myfe; fe;) {
register struct CallBack *cbnext;
for (cb = itocb(fe->firstcb); cb; cb = cbnext) {
@ -1420,9 +1460,10 @@ BreakLaterCallBacks(void)
henumParms.ncbas = 0;
henumParms.fid = &fid;
henumParms.thead = tthead;
H_UNLOCK h_Enumerate(MultiBreakVolumeLaterCallBack,
(char *)&henumParms);
H_LOCK if (henumParms.ncbas) { /* do left-overs */
H_UNLOCK;
h_Enumerate(MultiBreakVolumeLaterCallBack, (char *)&henumParms);
H_LOCK;
if (henumParms.ncbas) { /* do left-overs */
struct AFSCBFids tf;
tf.AFSCBFids_len = 1;
tf.AFSCBFids_val = &fid;
@ -1431,9 +1472,11 @@ BreakLaterCallBacks(void)
henumParms.ncbas = 0;
}
}
FSYNC_LOCK H_UNLOCK
/* Arrange to be called again */
return 1;
FSYNC_LOCK;
H_UNLOCK;;
/* Arrange to be called again */
return 1;
}
/*
@ -1443,8 +1486,10 @@ BreakLaterCallBacks(void)
int
CleanupTimedOutCallBacks(void)
{
H_LOCK CleanupTimedOutCallBacks_r();
H_UNLOCK}
H_LOCK;
CleanupTimedOutCallBacks_r();
H_UNLOCK;
}
int
CleanupTimedOutCallBacks_r(void)
@ -1603,11 +1648,15 @@ ClearHostCallbacks_r(struct host *hp, int locked)
/* host is up, try a call */
hp->hostFlags &= ~ALTADDR; /* alternate addresses are invalid */
if (hp->interface) {
H_UNLOCK code =
H_UNLOCK;
code =
RXAFSCB_InitCallBackState3(hp->callback_rxcon, &FS_HostUUID);
H_LOCK} else {
H_UNLOCK code = RXAFSCB_InitCallBackState(hp->callback_rxcon);
H_LOCK}
H_LOCK;
} else {
H_UNLOCK;
code = RXAFSCB_InitCallBackState(hp->callback_rxcon);
H_LOCK;
}
hp->hostFlags |= ALTADDR; /* alternate addresses are valid */
if (code) {
/* failed, mark host down and need reset */
@ -1871,8 +1920,10 @@ int
MultiBreakCallBackAlternateAddress(struct host *host, struct AFSCBFids *afidp)
{
int retVal;
H_LOCK retVal = MultiBreakCallBackAlternateAddress_r(host, afidp);
H_UNLOCK return retVal;
H_LOCK;
retVal = MultiBreakCallBackAlternateAddress_r(host, afidp);
H_UNLOCK;
return retVal;
}
int
@ -1928,12 +1979,14 @@ MultiBreakCallBackAlternateAddress_r(struct host *host,
ViceLog(125,
("Starting multibreakcall back on all addr for host %s\n",
afs_inet_ntoa_r(host->host, hoststr)));
H_UNLOCK multi_Rx(conns, j) {
H_UNLOCK;
multi_Rx(conns, j) {
multi_RXAFSCB_CallBack(afidp, &tc);
if (!multi_error) {
/* first success */
H_LOCK if (host->callback_rxcon)
rx_DestroyConnection(host->callback_rxcon);
H_LOCK;
if (host->callback_rxcon)
rx_DestroyConnection(host->callback_rxcon);
host->callback_rxcon = conns[multi_i];
host->host = addr[multi_i];
connSuccess = conns[multi_i];
@ -1942,13 +1995,14 @@ MultiBreakCallBackAlternateAddress_r(struct host *host,
ViceLog(125,
("multibreakcall success with addr %s\n",
afs_inet_ntoa_r(addr[multi_i], hoststr)));
H_UNLOCK multi_Abort;
H_UNLOCK;
multi_Abort;
}
}
multi_End_Ignore;
H_LOCK
/* Destroy all connections except the one on which we succeeded */
for (i = 0; i < j; i++)
H_LOCK;
/* Destroy all connections except the one on which we succeeded */
for (i = 0; i < j; i++)
if (conns[i] != connSuccess)
rx_DestroyConnection(conns[i]);
@ -2016,12 +2070,14 @@ MultiProbeAlternateAddress_r(struct host *host)
ViceLog(125,
("Starting multiprobe on all addr for host %s\n",
afs_inet_ntoa_r(host->host, hoststr)));
H_UNLOCK multi_Rx(conns, j) {
H_UNLOCK;
multi_Rx(conns, j) {
multi_RXAFSCB_ProbeUuid(&host->interface->uuid);
if (!multi_error) {
/* first success */
H_LOCK if (host->callback_rxcon)
rx_DestroyConnection(host->callback_rxcon);
H_LOCK;
if (host->callback_rxcon)
rx_DestroyConnection(host->callback_rxcon);
host->callback_rxcon = conns[multi_i];
host->host = addr[multi_i];
connSuccess = conns[multi_i];
@ -2030,13 +2086,14 @@ MultiProbeAlternateAddress_r(struct host *host)
ViceLog(125,
("multiprobe success with addr %s\n",
afs_inet_ntoa_r(addr[multi_i], hoststr)));
H_UNLOCK multi_Abort;
H_UNLOCK;
multi_Abort;
}
}
multi_End_Ignore;
H_LOCK
/* Destroy all connections except the one on which we succeeded */
for (i = 0; i < j; i++)
H_LOCK;
/* Destroy all connections except the one on which we succeeded */
for (i = 0; i < j; i++)
if (conns[i] != connSuccess)
rx_DestroyConnection(conns[i]);

View File

@ -261,8 +261,10 @@ static short consolePort = 0;
int
h_Release(register struct host *host)
{
H_LOCK h_Release_r(host);
H_UNLOCK return 0;
H_LOCK;
h_Release_r(host);
H_UNLOCK;
return 0;
}
/**
@ -309,8 +311,10 @@ h_OtherHolds_r(register struct host *host)
int
h_Lock_r(register struct host *host)
{
H_UNLOCK h_Lock(host);
H_LOCK return 0;
H_UNLOCK;
h_Lock(host);
H_LOCK;
return 0;
}
/**
@ -325,15 +329,17 @@ h_NBLock_r(register struct host *host)
struct Lock *hostLock = &host->lock;
int locked = 0;
H_UNLOCK LOCK_LOCK(hostLock)
H_UNLOCK;
LOCK_LOCK(hostLock);
if (!(hostLock->excl_locked) && !(hostLock->readers_reading))
hostLock->excl_locked = WRITE_LOCK;
hostLock->excl_locked = WRITE_LOCK;
else
locked = 1;
LOCK_UNLOCK(hostLock)
H_LOCK if (locked)
return 1;
LOCK_UNLOCK(hostLock);
H_LOCK;
if (locked)
return 1;
else
return 0;
}
@ -445,8 +451,10 @@ h_gethostcps_r(register struct host *host, register afs_int32 now)
host->hcps.prlist_len = 0;
slept ? (host->cpsCall = FT_ApproxTime()) : (host->cpsCall = now);
H_UNLOCK code = pr_GetHostCPS(htonl(host->host), &host->hcps);
H_LOCK if (code) {
H_UNLOCK;
code = pr_GetHostCPS(htonl(host->host), &host->hcps);
H_LOCK;
if (code) {
/*
* Although ubik_Call (called by pr_GetHostCPS) traverses thru all protection servers
* and reevaluates things if no sync server or quorum is found we could still end up
@ -503,13 +511,15 @@ h_flushhostcps(register afs_uint32 hostaddr, register afs_uint32 hport)
register struct host *host;
int held = 0;
H_LOCK host = h_Lookup_r(hostaddr, hport, &held);
H_LOCK;
host = h_Lookup_r(hostaddr, hport, &held);
if (host) {
host->hcpsfailed = 1;
if (!held)
h_Release_r(host);
}
H_UNLOCK return;
H_UNLOCK;
return;
}
@ -816,9 +826,11 @@ h_FreeConnection(struct rx_connection *tcon)
client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
if (client) {
H_LOCK if (client->tcon == tcon)
H_LOCK;
if (client->tcon == tcon)
client->tcon = (struct rx_connection *)0;
H_UNLOCK}
H_UNLOCK;
}
} /*h_FreeConnection */
@ -836,8 +848,10 @@ h_Enumerate(int (*proc) (), char *param)
register int *held;
register int i, count;
H_LOCK if (hostCount == 0) {
H_UNLOCK return;
H_LOCK;
if (hostCount == 0) {
H_UNLOCK;
return;
}
list = (struct host **)malloc(hostCount * sizeof(struct host *));
if (!list) {
@ -855,7 +869,8 @@ h_Enumerate(int (*proc) (), char *param)
h_Hold_r(host);
}
assert(count == hostCount);
H_UNLOCK for (i = 0; i < count; i++) {
H_UNLOCK;
for (i = 0; i < count; i++) {
held[i] = (*proc) (list[i], held[i], param);
if (!held[i])
h_Release(list[i]); /* this might free up the host */
@ -962,11 +977,13 @@ h_GetHost_r(struct rx_connection *tcon)
goto retry;
}
host->hostFlags &= ~ALTADDR;
H_UNLOCK code =
H_UNLOCK;
code =
RXAFSCB_TellMeAboutYourself(host->callback_rxcon, &interf, &caps);
if (code == RXGEN_OPCODE)
code = RXAFSCB_WhoAreYou(host->callback_rxcon, &interf);
H_LOCK if (code == RXGEN_OPCODE) {
H_LOCK;
if (code == RXGEN_OPCODE) {
identP = (struct Identity *)malloc(sizeof(struct Identity));
if (!identP) {
ViceLog(0, ("Failed malloc in h_GetHost_r\n"));
@ -1079,12 +1096,14 @@ h_GetHost_r(struct rx_connection *tcon)
h_gethostcps_r(host, FT_ApproxTime());
if (!(host->Console & 1)) {
int pident = 0;
H_UNLOCK code =
H_UNLOCK;
code =
RXAFSCB_TellMeAboutYourself(host->callback_rxcon, &interf,
&caps);
if (code == RXGEN_OPCODE)
code = RXAFSCB_WhoAreYou(host->callback_rxcon, &interf);
H_LOCK if (code == RXGEN_OPCODE) {
H_LOCK;
if (code == RXGEN_OPCODE) {
if (!identP)
identP =
(struct Identity *)malloc(sizeof(struct Identity));
@ -1125,9 +1144,10 @@ h_GetHost_r(struct rx_connection *tcon)
ntohs(host->port)));
}
if (code == 0 && !identP->valid) {
H_UNLOCK code =
RXAFSCB_InitCallBackState(host->callback_rxcon);
H_LOCK} else if (code == 0) {
H_UNLOCK;
code = RXAFSCB_InitCallBackState(host->callback_rxcon);
H_LOCK;
} else if (code == 0) {
oldHost = h_LookupUuid_r(&identP->uuid);
if (oldHost) {
/* This is a new address for an existing host. Update
@ -1150,10 +1170,12 @@ h_GetHost_r(struct rx_connection *tcon)
} else {
/* This really is a new host */
hashInsertUuid_r(&identP->uuid, host);
H_UNLOCK code =
H_UNLOCK;
code =
RXAFSCB_InitCallBackState3(host->callback_rxcon,
&FS_HostUUID);
H_LOCK if (code == 0) {
H_LOCK;
if (code == 0) {
ViceLog(25,
("InitCallBackState3 success on %s:%d\n",
afs_inet_ntoa_r(host->host, hoststr),
@ -1259,8 +1281,10 @@ MapName_r(char *aname, char *acell, afs_int32 * aval)
}
}
H_UNLOCK code = pr_NameToId(&lnames, &lids);
H_LOCK if (code == 0) {
H_UNLOCK;
code = pr_NameToId(&lnames, &lids);
H_LOCK;
if (code == 0) {
if (lids.idlist_val) {
*aval = lids.idlist_val[0];
if (*aval == AnonymousID) {
@ -1293,20 +1317,25 @@ h_ID2Client(afs_int32 vid)
register struct client *client;
register struct host *host;
H_LOCK for (host = hostList; host; host = host->next) {
H_LOCK;
for (host = hostList; host; host = host->next) {
if (host->hostFlags & HOSTDELETED)
continue;
for (client = host->FirstClient; client; client = client->next) {
if (!client->deleted && client->ViceId == vid) {
client->refCount++;
H_UNLOCK ObtainSharedLock(&client->lock);
H_LOCK client->refCount--;
H_UNLOCK return client;
H_UNLOCK;
ObtainSharedLock(&client->lock);
H_LOCK;
client->refCount--;
H_UNLOCK;
return client;
}
}
}
H_UNLOCK return 0;
H_UNLOCK;
return 0;
}
/*
@ -1347,8 +1376,10 @@ h_FindClient_r(struct rx_connection *tcon)
*/
return client;
}
H_UNLOCK ObtainWriteLock(&client->lock); /* released at end */
H_LOCK} else if (client) {
H_UNLOCK;
ObtainWriteLock(&client->lock); /* released at end */
H_LOCK;
} else if (client) {
client->refCount++;
}
@ -1427,8 +1458,10 @@ h_FindClient_r(struct rx_connection *tcon)
client->tcon = (struct rx_connection *)0;
}
client->refCount++;
H_UNLOCK ObtainWriteLock(&client->lock);
H_LOCK break;
H_UNLOCK;
ObtainWriteLock(&client->lock);
H_LOCK;
break;
}
}
@ -1468,8 +1501,10 @@ h_FindClient_r(struct rx_connection *tcon)
client->CPS.prlist_len = AnonCPS.prlist_len;
client->CPS.prlist_val = AnonCPS.prlist_val;
} else {
H_UNLOCK code = pr_GetCPS(viceid, &client->CPS);
H_LOCK if (code) {
H_UNLOCK;
code = pr_GetCPS(viceid, &client->CPS);
H_LOCK;
if (code) {
char hoststr[16];
ViceLog(0,
("pr_GetCPS failed(%d) for user %d, host %s:%d\n",
@ -1540,19 +1575,21 @@ GetClient(struct rx_connection *tcon, struct client **cp)
{
register struct client *client;
H_LOCK *cp = client =
(struct client *)rx_GetSpecific(tcon, rxcon_client_key);
H_LOCK;
*cp = client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
if (client == NULL || client->tcon == NULL) {
ViceLog(0,
("GetClient: no client in conn %x (host %x), VBUSYING\n",
tcon, rx_HostOf(rx_PeerOf(tcon))));
H_UNLOCK return VBUSY;
H_UNLOCK;
return VBUSY;
}
if (rxr_CidOf(client->tcon) != client->sid) {
ViceLog(0,
("GetClient: tcon %x tcon sid %d client sid %d\n",
client->tcon, rxr_CidOf(client->tcon), client->sid));
H_UNLOCK return VBUSY;
H_UNLOCK;
return VBUSY;
}
if (!(client && client->tcon && rxr_CidOf(client->tcon) == client->sid)) {
if (!client)
@ -1570,10 +1607,12 @@ GetClient(struct rx_connection *tcon, struct client **cp)
("Token for %s at %s:%d expired %d\n", h_UserName(client),
afs_inet_ntoa_r(client->host->host, hoststr),
ntohs(client->host->port), client->expTime));
H_UNLOCK return VICETOKENDEAD;
H_UNLOCK;
return VICETOKENDEAD;
}
H_UNLOCK return 0;
H_UNLOCK;
return 0;
} /*GetClient */
@ -1627,8 +1666,10 @@ h_PrintClient(register struct host *host, int held, StreamHandle_t * file)
char tbuffer[32];
char hoststr[16];
H_LOCK if (host->hostFlags & HOSTDELETED) {
H_UNLOCK return held;
H_LOCK;
if (host->hostFlags & HOSTDELETED) {
H_UNLOCK;
return held;
}
(void)afs_snprintf(tmpStr, sizeof tmpStr,
"Host %s:%d down = %d, LastCall %s",
@ -1672,7 +1713,8 @@ h_PrintClient(register struct host *host, int held, StreamHandle_t * file)
STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
}
}
H_UNLOCK return held;
H_UNLOCK;
return held;
} /*h_PrintClient */
@ -1715,15 +1757,16 @@ h_DumpHost(register struct host *host, int held, StreamHandle_t * file)
int i;
char tmpStr[256];
H_LOCK(void) afs_snprintf(tmpStr, sizeof tmpStr,
"ip:%x port:%d hidx:%d cbid:%d lock:%x last:%u active:%u down:%d del:%d cons:%d cldel:%d\n\t hpfailed:%d hcpsCall:%u hcps [",
host->host, ntohs(host->port), host->index,
host->cblist, CheckLock(&host->lock),
host->LastCall, host->ActiveCall,
(host->hostFlags & VENUSDOWN),
host->hostFlags & HOSTDELETED, host->Console,
host->hostFlags & CLIENTDELETED,
host->hcpsfailed, host->cpsCall);
H_LOCK;
(void)afs_snprintf(tmpStr, sizeof tmpStr,
"ip:%x port:%d hidx:%d cbid:%d lock:%x last:%u active:%u down:%d del:%d cons:%d cldel:%d\n\t hpfailed:%d hcpsCall:%u hcps [",
host->host, ntohs(host->port), host->index,
host->cblist, CheckLock(&host->lock),
host->LastCall, host->ActiveCall,
(host->hostFlags & VENUSDOWN),
host->hostFlags & HOSTDELETED, host->Console,
host->hostFlags & CLIENTDELETED,
host->hcpsfailed, host->cpsCall);
STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
if (host->hcps.prlist_val)
for (i = 0; i < host->hcps.prlist_len; i++) {
@ -1748,7 +1791,8 @@ h_DumpHost(register struct host *host, int held, StreamHandle_t * file)
sprintf(tmpStr, " slot/bit: %d/%d\n", h_holdSlot(), h_holdbit());
STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file);
H_UNLOCK return held;
H_UNLOCK;
return held;
} /*h_DumpHost */
@ -1791,7 +1835,8 @@ h_GetWorkStats(int *nump, int *activep, int *delp, afs_int32 cutofftime)
register struct host *host;
register int num = 0, active = 0, del = 0;
H_LOCK for (host = hostList; host; host = host->next) {
H_LOCK;
for (host = hostList; host; host = host->next) {
if (!(host->hostFlags & HOSTDELETED)) {
num++;
if (host->ActiveCall > cutofftime)
@ -1800,8 +1845,9 @@ h_GetWorkStats(int *nump, int *activep, int *delp, afs_int32 cutofftime)
del++;
}
}
H_UNLOCK if (nump)
*nump = num;
H_UNLOCK;
if (nump)
*nump = num;
if (activep)
*activep = active;
if (delp)
@ -1965,7 +2011,8 @@ h_GetHostNetStats(afs_int32 * a_numHostsP, afs_int32 * a_sameNetOrSubnetP,
*a_diffSubnetP = (afs_int32) 0;
*a_diffNetworkP = (afs_int32) 0;
H_LOCK for (hostP = hostList; hostP; hostP = hostP->next) {
H_LOCK;
for (hostP = hostList; hostP; hostP = hostP->next) {
if (!(hostP->hostFlags & HOSTDELETED)) {
/*
* Bump the number of undeleted host entries found.
@ -1979,7 +2026,8 @@ h_GetHostNetStats(afs_int32 * a_numHostsP, afs_int32 * a_sameNetOrSubnetP,
a_diffNetworkP);
} /*Only look at non-deleted hosts */
} /*For each host record hashed to this index */
H_UNLOCK} /*h_GetHostNetStats */
H_UNLOCK;
} /*h_GetHostNetStats */
static afs_uint32 checktime;
static afs_uint32 clientdeletetime;
@ -1998,7 +2046,8 @@ CheckHost(register struct host *host, int held)
int code;
/* Host is held by h_Enumerate */
H_LOCK for (client = host->FirstClient; client; client = client->next) {
H_LOCK;
for (client = host->FirstClient; client; client = client->next) {
if (client->refCount == 0 && client->LastCall < clientdeletetime) {
client->deleted = 1;
host->hostFlags |= CLIENTDELETED;
@ -2012,13 +2061,17 @@ CheckHost(register struct host *host, int held)
if (!(host->hostFlags & VENUSDOWN)) {
host->hostFlags &= ~ALTADDR; /* alternate address invalid */
if (host->interface) {
H_UNLOCK code =
H_UNLOCK;
code =
RXAFSCB_InitCallBackState3(host->callback_rxcon,
&FS_HostUUID);
H_LOCK} else {
H_UNLOCK code =
H_LOCK;
} else {
H_UNLOCK;
code =
RXAFSCB_InitCallBackState(host->callback_rxcon);
H_LOCK}
H_LOCK;
}
host->hostFlags |= ALTADDR; /* alternate addresses valid */
if (code) {
char hoststr[16];
@ -2039,9 +2092,10 @@ CheckHost(register struct host *host, int held)
if (!(host->hostFlags & VENUSDOWN) && host->cblist) {
if (host->interface) {
afsUUID uuid = host->interface->uuid;
H_UNLOCK code =
RXAFSCB_ProbeUuid(host->callback_rxcon, &uuid);
H_LOCK if (code) {
H_UNLOCK;
code = RXAFSCB_ProbeUuid(host->callback_rxcon, &uuid);
H_LOCK;
if (code) {
if (MultiProbeAlternateAddress_r(host)) {
char hoststr[16];
(void)afs_inet_ntoa_r(host->host, hoststr);
@ -2052,8 +2106,10 @@ CheckHost(register struct host *host, int held)
}
}
} else {
H_UNLOCK code = RXAFSCB_Probe(host->callback_rxcon);
H_LOCK if (code) {
H_UNLOCK;
code = RXAFSCB_Probe(host->callback_rxcon);
H_LOCK;
if (code) {
char hoststr[16];
(void)afs_inet_ntoa_r(host->host, hoststr);
ViceLog(0,
@ -2067,7 +2123,8 @@ CheckHost(register struct host *host, int held)
}
h_Unlock_r(host);
}
H_UNLOCK return held;
H_UNLOCK;
return held;
} /*CheckHost */

View File

@ -22,9 +22,9 @@
#include <pthread.h>
extern pthread_mutex_t host_glock_mutex;
#define H_LOCK \
assert(pthread_mutex_lock(&host_glock_mutex) == 0);
assert(pthread_mutex_lock(&host_glock_mutex) == 0)
#define H_UNLOCK \
assert(pthread_mutex_unlock(&host_glock_mutex) == 0);
assert(pthread_mutex_unlock(&host_glock_mutex) == 0)
#else /* AFS_PTHREAD_ENV */
#define H_LOCK
#define H_UNLOCK

View File

@ -470,7 +470,8 @@ FsyncCheckLWP()
assert(pthread_mutex_init(&fsync_glock_mutex, NULL) == 0);
#endif
FSYNC_LOCK while (1) {
FSYNC_LOCK;
while (1) {
#ifdef AFS_PTHREAD_ENV
/* rounding is fine */
fsync_next.tv_nsec = 0;

View File

@ -204,14 +204,14 @@ extern int busyonrst;
#include <assert.h>
extern pthread_mutex_t fileproc_glock_mutex;
#define FS_LOCK \
assert(pthread_mutex_lock(&fileproc_glock_mutex) == 0);
assert(pthread_mutex_lock(&fileproc_glock_mutex) == 0)
#define FS_UNLOCK \
assert(pthread_mutex_unlock(&fileproc_glock_mutex) == 0);
assert(pthread_mutex_unlock(&fileproc_glock_mutex) == 0)
extern pthread_mutex_t fsync_glock_mutex;
#define FSYNC_LOCK \
assert(pthread_mutex_lock(&fsync_glock_mutex) == 0);
assert(pthread_mutex_lock(&fsync_glock_mutex) == 0)
#define FSYNC_UNLOCK \
assert(pthread_mutex_unlock(&fsync_glock_mutex) == 0);
assert(pthread_mutex_unlock(&fsync_glock_mutex) == 0)
#else /* AFS_PTHREAD_ENV */
#define FS_LOCK
#define FS_UNLOCK