Skip to content

Commit 7b75fc3

Browse files
committed
x509storeissuer: reduce the rate ossl_time_now() queries
While querying system time is usually cheap on Linux on IA-32, that might not be the case elsewhere, and that might impact the cost of the loop iteration significantly, as the measured call time is quite small (in the order of a microsecond). Signed-off-by: Eugene Syromiatnikov <[email protected]>
1 parent 11620ba commit 7b75fc3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

source/x509storeissuer.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ do_x509storeissuer(size_t num)
146146
{
147147
X509_STORE_CTX *ctx = X509_STORE_CTX_new();
148148
X509 *issuer = NULL;
149-
OSSL_TIME time;
149+
OSSL_TIME time = ossl_time_now();
150150

151151
if (ctx == NULL || !X509_STORE_CTX_init(ctx, store, x509_nonce, NULL)) {
152152
warnx("Failed to initialise X509_STORE_CTX");
@@ -170,7 +170,8 @@ do_x509storeissuer(size_t num)
170170
}
171171
issuer = NULL;
172172
counts[num]++;
173-
time = ossl_time_now();
173+
if ((count & 0x3f) == 0)
174+
time = ossl_time_now();
174175
} while (time.t < max_time.t);
175176

176177
err:

0 commit comments

Comments
 (0)