Commit 2aded6f9 authored by Yoni Fogel's avatar Yoni Fogel

Addresses #1032

Native windows locking replaces ydb_lock and ydb_unlock for CYGWIN only

git-svn-id: file:///svn/tokudb@5853 c7de825b-a66e-492c-adef-691d508d4ae1
parent 20df6f8d
...@@ -15,6 +15,25 @@ ...@@ -15,6 +15,25 @@
#include <pthread.h> #include <pthread.h>
#include <sys/types.h> #include <sys/types.h>
#ifdef __CYGWIN__
#include <windows.h>
#include <winbase.h>
CRITICAL_SECTION ydb_big_lock;
void toku_ydb_lock(void) {
static int initialized = 0;
if (!initialized) {
initialized=1;
InitializeCriticalSection(&ydb_big_lock);
}
EnterCriticalSection(&ydb_big_lock);
}
void toku_ydb_unlock(void) {
LeaveCriticalSection(&ydb_big_lock);
}
#else //Not Cygwin
#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP #ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
static pthread_mutex_t ydb_big_lock = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; static pthread_mutex_t ydb_big_lock = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
#else #else
...@@ -28,4 +47,5 @@ void toku_ydb_lock(void) { ...@@ -28,4 +47,5 @@ void toku_ydb_lock(void) {
void toku_ydb_unlock(void) { void toku_ydb_unlock(void) {
int r = pthread_mutex_unlock(&ydb_big_lock); assert(r == 0); int r = pthread_mutex_unlock(&ydb_big_lock); assert(r == 0);
} }
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment