From: Mark Vitale Date: Thu, 23 May 2019 03:03:11 +0000 (-0400) Subject: auth: eliminate pointless retries in ktc_ListTokensEx X-Git-Tag: debian/1.8.4_pre1-1~9^2^2~9 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=8733253e2f61bf33a2fea5724b7cd6a8de50a10f;p=packages%2Fo%2Fopenafs.git auth: eliminate pointless retries in ktc_ListTokensEx ktc_ListTokensEx is an iterator to provide the names of each cell for which a user has a token set. It does this by looking for the 1 through nth token set for a given user. However, as currently implemented, it always continues searching up to the 100x safety limit even when there are no more token sets for the user. Instead, return immediately when VIOC_GETTOK2 returns EDOM (no more tokens for this user). Introduced by commit a86ad262d2a8be36f43ab0885a84dde37ddfc464 'auth: Add the ktc_ListTokensEx function'. Reviewed-on: https://gerrit.openafs.org/13598 Reviewed-by: Andrew Deason Tested-by: BuildBot Reviewed-by: Benjamin Kaduk (cherry picked from commit 95ae30c30d98a3219fd021e0ed83200c1b6c266f) Change-Id: Ib0489b78b92861ae25b625b3054caf68f3b0a074 Reviewed-on: https://gerrit.openafs.org/13678 Reviewed-by: Michael Meffie Tested-by: BuildBot Reviewed-by: Andrew Deason Reviewed-by: Stephan Wiesand --- diff --git a/src/auth/ktc.c b/src/auth/ktc.c index ecb97081c..99cf1ffc9 100644 --- a/src/auth/ktc.c +++ b/src/auth/ktc.c @@ -796,6 +796,9 @@ ktc_ListTokensEx(int prevIndex, int *newIndex, char **cellName) { code = PIOCTL(0, VIOC_GETTOK2, &iob, 0); + if (code == -1 && errno == EDOM) + return KTC_NOENT; /* no more tokens to be found */ + /* Can't use new pioctl, so must use old one */ if (code == -1 && errno == EINVAL) { struct ktc_principal server;