Re: [pgsql-hackers-win32] [PATCHES] Compiling libpq with VisualC

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: pgsql(at)mohawksoft(dot)com
Cc: Andreas Pflug <pgadmin(at)pse-consulting(dot)de>, PostgreSQL Win32 port list <pgsql-hackers-win32(at)postgresql(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [pgsql-hackers-win32] [PATCHES] Compiling libpq with VisualC
Date: 2004-06-13 23:57:18
Message-ID: 200406132357.i5DNvIZ27381@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-hackers-win32 pgsql-patches

pgsql(at)mohawksoft(dot)com wrote:
> >
> > [ 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.
>
> A mutex is inherently a global object. CreateMutex(NULL, FALSE, NULL) will
> return a handle to an unowned mutex.

Yes, but consider that two threads could both call it, with one perhaps
using the first value, and the second overwriting the first. Obviously
not something we want.

--
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

Browse pgsql-hackers by date

  From Date Subject
Next Message Oliver Jowett 2004-06-14 00:09:38 Re: Delaying the planning of unnamed statements until Bind
Previous Message Bruce Momjian 2004-06-13 23:55:39 Re: [PATCHES] Configuration patch

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Manfred Spraul 2004-06-14 05:32:37 Re: [PATCHES] Compiling libpq with VisualC
Previous Message Bruce Momjian 2004-06-13 23:44:58 Re: pg_ctl vs. Windows locking

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2004-06-14 00:10:50 Re: [PATCHES] Configuration patch
Previous Message Bruce Momjian 2004-06-13 23:55:39 Re: [PATCHES] Configuration patch