From ec08c2b94a6d2e3f3572dfdac734fb8a92682ac8 Mon Sep 17 00:00:00 2001 From: Michael Grunder Date: Thu, 9 Apr 2020 08:05:14 -0700 Subject: Added CMake package config and fixed hiredis_ssl on Windows (#783) * Add CMake package configuration so hiredis can be more easily included in other projects. * Fixes hiredis_ssl such that it compiles and works in windows Co-authored-by: nrivera Co-authored-by: Nick --- ssl.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'ssl.c') diff --git a/ssl.c b/ssl.c index e1e4aba..502814d 100644 --- a/ssl.c +++ b/ssl.c @@ -34,13 +34,18 @@ #include "async.h" #include -#include #include #include +#ifdef WIN32 +#include +#else +#include +#endif #include #include +#include "win32.h" #include "async_private.h" void __redisSetError(redisContext *c, int type, const char *str); @@ -119,6 +124,18 @@ static void sslLogCallback(const SSL *ssl, int where, int ret) { #endif #ifdef HIREDIS_USE_CRYPTO_LOCKS +#ifdef WIN32 +typedef CRITICAL_SECTION sslLockType; +static void sslLockInit(sslLockType* l) { + InitializeCriticalSection(l); +} +static void sslLockAcquire(sslLockType* l) { + EnterCriticalSection(l); +} +static void sslLockRelease(sslLockType* l) { + LeaveCriticalSection(l); +} +#else typedef pthread_mutex_t sslLockType; static void sslLockInit(sslLockType *l) { pthread_mutex_init(l, NULL); @@ -129,7 +146,9 @@ static void sslLockAcquire(sslLockType *l) { static void sslLockRelease(sslLockType *l) { pthread_mutex_unlock(l); } -static pthread_mutex_t *ossl_locks; +#endif + +static sslLockType* ossl_locks; static void opensslDoLock(int mode, int lkid, const char *f, int line) { sslLockType *l = ossl_locks + lkid; -- cgit v1.2.3