diff options
author | Rajarshi Karmakar <rkarmaka98@gmail.com> | 2023-05-22 16:51:57 +0000 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2023-05-30 21:10:03 +0200 |
commit | 2631a941469864a35258130082096876e7243225 (patch) | |
tree | 823fc20fccf16d06ff710535f89a23cbcd369f11 /crypto | |
parent | f53479f98a2f2a6149192c5e3ef4ddf0926dceba (diff) |
OSSL_sleep(): Calling sleep() function if sleepTime > 1sec
On some systems usleep() func does not support time >1sec.
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21010)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/sleep.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/crypto/sleep.c b/crypto/sleep.c index 95d6c79233..d57a9e3caa 100644 --- a/crypto/sleep.c +++ b/crypto/sleep.c @@ -12,6 +12,7 @@ /* system-specific variants defining OSSL_sleep() */ #if defined(OPENSSL_SYS_UNIX) || defined(__DJGPP__) +#include <unistd.h> void OSSL_sleep(uint64_t millis) { @@ -36,7 +37,11 @@ void OSSL_sleep(uint64_t millis) usleep(millis * 1000); # endif # else - usleep(millis * 1000); + unsigned int s = (unsigned int)(millis / 1000); + unsigned int us = (unsigned int)((millis % 1000) * 1000); + + sleep(s); + usleep(us); # endif } #elif defined(_WIN32) && !defined(OPENSSL_SYS_UEFI) |