diff options
author | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2020-02-21 23:41:56 +0300 |
---|---|---|
committer | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2020-02-21 23:41:56 +0300 |
commit | e8d0819d52b2741fcb4ddb79ced4d824c3056918 (patch) | |
tree | 751519d69bc54c407c7431f1a0efd1d1017a177a /include/internal | |
parent | 745fc918e7eeb86b2ac541325a8ae5c6e374ee56 (diff) |
Don't exclude quite so much in a no-sock build
We were excluding more code than we needed to in the OCSP/HTTP code in
the event of no-sock. We should also not assume that a BIO passed to our
API is socket based.
This fixes the no-sock build
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/11134)
Diffstat (limited to 'include/internal')
-rw-r--r-- | include/internal/cryptlib.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/include/internal/cryptlib.h b/include/internal/cryptlib.h index dbb68f2c44..7ad6007fd9 100644 --- a/include/internal/cryptlib.h +++ b/include/internal/cryptlib.h @@ -198,4 +198,41 @@ const void *ossl_bsearch(const void *key, const void *base, int num, int size, int (*cmp) (const void *, const void *), int flags); +/* system-specific variants defining ossl_sleep() */ +#ifdef OPENSSL_SYS_UNIX +# include <unistd.h> +static ossl_inline void ossl_sleep(unsigned long millis) +{ +# ifdef OPENSSL_SYS_VXWORKS + struct timespec ts; + ts.tv_sec = (long int) (millis / 1000); + ts.tv_nsec = (long int) (millis % 1000) * 1000000ul; + nanosleep(&ts, NULL); +# else + usleep(millis * 1000); +# endif +} +#elif defined(_WIN32) +# include <windows.h> +static ossl_inline void ossl_sleep(unsigned long millis) +{ + Sleep(millis); +} +#else +/* Fallback to a busy wait */ +static ossl_inline void ossl_sleep(unsigned long millis) +{ + struct timeval start, now; + unsigned long elapsedms; + + gettimeofday(&start, NULL); + do { + gettimeofday(&now, NULL); + elapsedms = (((now.tv_sec - start.tv_sec) * 1000000) + + now.tv_usec - start.tv_usec) / 1000; + } while (elapsedms < millis); +} +#endif /* defined OPENSSL_SYS_UNIX */ + + #endif |