summaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/pthread-win32.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/interfaces/libpq/pthread-win32.c')
-rw-r--r--src/interfaces/libpq/pthread-win32.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/interfaces/libpq/pthread-win32.c b/src/interfaces/libpq/pthread-win32.c
index 08629ca957..0133b8c92d 100644
--- a/src/interfaces/libpq/pthread-win32.c
+++ b/src/interfaces/libpq/pthread-win32.c
@@ -35,24 +35,27 @@ pthread_getspecific(pthread_key_t key)
int
pthread_mutex_init(pthread_mutex_t *mp, void *attr)
{
- *mp = CreateMutex(0, 0, 0);
- if (*mp == NULL)
+ *mp = (CRITICAL_SECTION *)malloc(sizeof(CRITICAL_SECTION));
+ if (!*mp)
return 1;
+ InitializeCriticalSection(*mp);
return 0;
}
int
pthread_mutex_lock(pthread_mutex_t *mp)
{
- if (WaitForSingleObject(*mp, INFINITE) != WAIT_OBJECT_0)
+ if (!*mp)
return 1;
+ EnterCriticalSection(*mp);
return 0;
}
int
pthread_mutex_unlock(pthread_mutex_t *mp)
{
- if (!ReleaseMutex(*mp))
+ if (!*mp)
return 1;
+ LeaveCriticalSection(*mp);
return 0;
}