ubik: refactor error exits in internal CallIter()

Originally, the first store to "code" was dead here.  Refactor the
error exits to follow the non-error exit path, which has the effect
of making the store to "code" live again (and also makes it less
likely that any new cleanup code will be unintentionally omitted).
In the ubik_ClientInit recovery case, handle the possibility that
aproc() returned zero and return UINTERNAL rather than letting the
caller think that this operation succeeded.

Change-Id: Idc198aa7a6e21975faaca9f159e822c9e3f66d98
Reviewed-on: http://gerrit.openafs.org/7776
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
This commit is contained in:
Garrett Wollman 2012-07-15 22:07:05 -04:00 committed by Derrick Brashear
parent 33a761ebd1
commit 56b5b9a1c5

View File

@ -431,12 +431,8 @@ CallIter(int (*aproc) (), struct ubik_client *aclient,
while (*apos < MAXSERVERS) {
/* tc is the next conn to try */
tc = aclient->conns[*apos];
if (!tc) {
if (needlock) {
UNLOCK_UBIK_CLIENT(aclient);
}
return UNOSERVERS;
}
if (!tc)
goto errout;
if (rx_ConnError(tc)) {
tc = ubik_RefreshConn(tc);
@ -449,21 +445,17 @@ CallIter(int (*aproc) (), struct ubik_client *aclient,
break; /* this is the desired path */
}
}
if (*apos >= MAXSERVERS) {
if (needlock) {
UNLOCK_UBIK_CLIENT(aclient);
}
return UNOSERVERS;
}
if (*apos >= MAXSERVERS)
goto errout;
code =
(*aproc) (tc, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
p14, p15, p16);
if (aclient->initializationState != origLevel) {
if (needlock) {
UNLOCK_UBIK_CLIENT(aclient);
}
return code; /* somebody did a ubik_ClientInit */
/* somebody did a ubik_ClientInit */
if (code == 0)
code = UINTERNAL; /* no more specific error was returned */
goto errout;
}
/* what should I do in case of UNOQUORUM ? */
@ -475,6 +467,7 @@ CallIter(int (*aproc) (), struct ubik_client *aclient,
}
(*apos)++;
errout:
if (needlock) {
UNLOCK_UBIK_CLIENT(aclient);
}