diff --git a/src/interfaces/libpq/pthread-win32.c b/src/interfaces/libpq/pthread-win32.c
index 1fdd264171c6ecb1fee03f12dc31139da66cab3d..0f9b3a648895611f6189d6684baf530e55173227 100644
--- a/src/interfaces/libpq/pthread-win32.c
+++ b/src/interfaces/libpq/pthread-win32.c
@@ -5,7 +5,7 @@
 *
 * Copyright (c) 2004-2008, PostgreSQL Global Development Group
 * IDENTIFICATION
-*	$PostgreSQL: pgsql/src/interfaces/libpq/pthread-win32.c,v 1.16 2008/05/16 18:30:53 mha Exp $
+*	$PostgreSQL: pgsql/src/interfaces/libpq/pthread-win32.c,v 1.17 2008/05/21 14:20:48 mha Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -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;
 }
diff --git a/src/port/pthread-win32.h b/src/port/pthread-win32.h
index 1552ae37385be4922f95ebcb2d3598f60404fdce..e8e4a559ce4316335968e69a44a48def341d2338 100644
--- a/src/port/pthread-win32.h
+++ b/src/port/pthread-win32.h
@@ -1,11 +1,11 @@
 /*
- * $PostgreSQL: pgsql/src/port/pthread-win32.h,v 1.4 2008/05/17 01:28:25 adunstan Exp $ 
+ * $PostgreSQL: pgsql/src/port/pthread-win32.h,v 1.5 2008/05/21 14:20:48 mha Exp $ 
  */
 #ifndef __PTHREAD_H
 #define __PTHREAD_H
 
 typedef ULONG pthread_key_t;
-typedef HANDLE pthread_mutex_t;
+typedef CRITICAL_SECTION *pthread_mutex_t;
 typedef int pthread_once_t;
 
 DWORD		pthread_self(void);