]> granicus.if.org Git - postgresql/commitdiff
Back out thread fix until I get clarification.
authorBruce Momjian <bruce@momjian.us>
Mon, 12 Jul 2004 14:16:28 +0000 (14:16 +0000)
committerBruce Momjian <bruce@momjian.us>
Mon, 12 Jul 2004 14:16:28 +0000 (14:16 +0000)
src/interfaces/libpq/fe-connect.c
src/interfaces/libpq/fe-secure.c

index 9b60efa3e67a6af26f5b17ea415c4e490710de9e..89130a0f17bf80d6093a6a901a412e70254367ba 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.276 2004/07/12 14:11:17 momjian Exp $
+ *       $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.277 2004/07/12 14:16:28 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -3193,16 +3193,10 @@ default_threadlock(int acquire)
 #ifndef WIN32
        static pthread_mutex_t singlethread_lock = PTHREAD_MUTEX_INITIALIZER;
 #else
-       static pthread_mutex_t singlethread_lock = NULL;
-       static long mutex_initlock = 0;
-
-       if (singlethread_lock == NULL) {
-               while(InterlockedExchange(&mutex_initlock, 1) == 1)
-                       /* loop, another thread own the lock */ ;
-               if (singlethread_lock == NULL)
-                       pthread_mutex_init(&singlethread_lock, NULL);
-               InterlockedExchange(&mutex_initlock,0);
-       }
+       static pthread_mutex_t singlethread_lock;
+        static long mutex_initialized = 0;
+        if (!InterlockedExchange(&mutex_initialized, 1L))
+                pthread_mutex_init(&singlethread_lock, NULL);
 #endif
        if (acquire)
                pthread_mutex_lock(&singlethread_lock);
index ad7897ff7f4fe3c8f96e42a289f98f2afc81372b..a60f34875d969c8c60658a39f155a28a93e4011e 100644 (file)
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.43 2004/07/12 14:11:17 momjian Exp $
+ *       $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.44 2004/07/12 14:16:28 momjian Exp $
  *
  * NOTES
  *       The client *requires* a valid server certificate.  Since
@@ -867,16 +867,10 @@ init_ssl_system(PGconn *conn)
 #ifndef WIN32
         static pthread_mutex_t init_mutex = PTHREAD_MUTEX_INITIALIZER;
 #else
-       static pthread_mutex_t init_mutex = NULL;
-       static long mutex_initlock = 0;
-
-       if (init_mutex == NULL) {
-               while(InterlockedExchange(&mutex_initlock, 1) == 1)
-                       /* loop, another thread own the lock */ ;
-               if (init_mutex == NULL)
-                       pthread_mutex_init(&init_mutex, NULL);
-               InterlockedExchange(&mutex_initlock,0);
-       }
+        static pthread_mutex_t init_mutex;
+        static long mutex_initialized = 0L;
+        if (!InterlockedExchange(&mutex_initialized, 1L))
+                pthread_mutex_init(&init_mutex, NULL);
 #endif
        pthread_mutex_lock(&init_mutex);