summaryrefslogtreecommitdiff
path: root/ssl.c
diff options
context:
space:
mode:
authorMichael Grunder <michael.grunder@gmail.com>2020-04-09 08:05:14 -0700
committerGitHub <noreply@github.com>2020-04-09 08:05:14 -0700
commitec08c2b94a6d2e3f3572dfdac734fb8a92682ac8 (patch)
tree0a47e95eec8ad6f9dc31b03c8c2fe3dc55a66e01 /ssl.c
parentb314c0df3d05b362d484fffe5cc03ca98584e084 (diff)
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 <nrivera@blizzard.com> Co-authored-by: Nick <heronr1@gmail.com>
Diffstat (limited to 'ssl.c')
-rw-r--r--ssl.c23
1 files changed, 21 insertions, 2 deletions
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 <assert.h>
-#include <pthread.h>
#include <errno.h>
#include <string.h>
+#ifdef WIN32
+#include <windows.h>
+#else
+#include <pthread.h>
+#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
+#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;