Skip to content

Commit c7f19dc

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 0b3b091 commit c7f19dc

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
@@ -148,7 +148,7 @@ do_x509storeissuer(size_t num)
148148
{
149149
X509_STORE_CTX *ctx = X509_STORE_CTX_new();
150150
X509 *issuer = NULL;
151-
OSSL_TIME time;
151+
OSSL_TIME time = ossl_time_now();
152152

153153
if (ctx == NULL || !X509_STORE_CTX_init(ctx, store, x509_nonce, NULL)) {
154154
warnx("Failed to initialise X509_STORE_CTX");
@@ -172,7 +172,8 @@ do_x509storeissuer(size_t num)
172172
}
173173
issuer = NULL;
174174
counts[num]++;
175-
time = ossl_time_now();
175+
if ((count & 0x3f) == 0)
176+
time = ossl_time_now();
176177
} while (time.t < max_time.t);
177178

178179
err:

0 commit comments

Comments
 (0)