From: Garrett Wollman Date: Mon, 16 Jul 2012 02:07:05 +0000 (-0400) Subject: ubik: refactor error exits in internal CallIter() X-Git-Tag: upstream/1.8.0_pre1^2~2204 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=56b5b9a1c51c2197923aa373c180a834edabe4f6;p=packages%2Fo%2Fopenafs.git 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 Reviewed-by: Derrick Brashear --- diff --git a/src/ubik/ubikclient.c b/src/ubik/ubikclient.c index 1d23378b1..dda1f35ff 100644 --- a/src/ubik/ubikclient.c +++ b/src/ubik/ubikclient.c @@ -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); }