Skip site navigation (1) Skip section navigation (2)

Re: [PATCHES] Compiling libpq with VisualC

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Andreas Pflug <pgadmin(at)pse-consulting(dot)de>
Cc: PostgreSQL Win32 port list <pgsql-hackers-win32(at)postgresql(dot)org>,PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCHES] Compiling libpq with VisualC
Date: 2004-06-11 18:03:28
Message-ID: 200406111803.i5BI3SG13273@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-hackers-win32pgsql-patches
[ Thread moved to hackers and win32.]

Andreas Pflug wrote:
> Bruce Momjian wrote:
> 
> >
> >
> >Agreed.  My pthread book says pthread_mutex_init() should be called only
> >once, and we have to guarantee that.  If the Windows implentation allows
> >it to be called multiple times, just create a function to be called only
> >by Win32 that does that and leave the Unix safe.
> >
> >  
> >
> Ok, so here's the win32 workaround with the unix stuff left untouched.
> There's no memory interlocking api in win32 that wouldn't need some 
> initializing api call itself, so we'd have to go for assembly level 
> test-and-set code or introduce a mandatory global libpq initializing 
> api. Considering the probably quite low usage of kerberos/ssl together 
> with threads under win32, and the very low probability of two 
> threads/processors (!) trying to initiate a connection at the same time, 
> it doesn't seem to be worth the compiler hassle with assembly inline.

What is the recommended way to create mutex objects (CreateMutex) from
Win32 libraries?  There must be a clean way like there is in pthreads.

---------------------------------------------------------------------------

In the patch Win32, pthread_mutex_init() == CreateMutex():
	
	+#ifndef WIN32
	        static pthread_mutex_t singlethread_lock = PTHREAD_MUTEX_INITIALIZER;
	+#else
	+       static pthread_mutex_t singlethread_lock;
	+        static int mutex_initialized = 0;
	+        if (!mutex_initialized)
	+        {
	+                mutex_initialized = 1;
	+                pthread_mutex_init(&singlethread_lock, NULL);
	+        }
	+#endif

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman(at)candle(dot)pha(dot)pa(dot)us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

In response to

Responses

pgsql-hackers by date

Next:From: Steve AtkinsDate: 2004-06-11 18:06:13
Subject: Re: Accelerating aggregates
Previous:From: Alvaro HerreraDate: 2004-06-11 17:58:15
Subject: Re: msession for PostgreSQL?

pgsql-patches by date

Next:From: Bruce MomjianDate: 2004-06-11 18:04:23
Subject: Re: pg_ctl using START with paths needing quotes
Previous:From: Andrew DunstanDate: 2004-06-11 17:59:16
Subject: Re: pg_ctl using START with paths needing quotes

pgsql-hackers-win32 by date

Next:From: Bruce MomjianDate: 2004-06-11 18:04:23
Subject: Re: pg_ctl using START with paths needing quotes
Previous:From: Andrew DunstanDate: 2004-06-11 17:59:16
Subject: Re: pg_ctl using START with paths needing quotes

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group