Re: Compiling libpq with VisualC - Mailing list pgsql-patches

From Andreas Pflug
Subject Re: Compiling libpq with VisualC
Date
Msg-id 40C97CEB.6030404@pse-consulting.de
Whole thread Raw
In response to Re: Compiling libpq with VisualC  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: Compiling libpq with VisualC  (Manfred Spraul <manfred@colorfullife.com>)
List pgsql-patches
Bruce Momjian wrote:

>I have looked over this patch.  I noticed this:
>
>    -static pthread_mutex_t init_mutex = PTHREAD_MUTEX_INITIALIZER;
>    -
>    +        static pthread_mutex_t init_mutex;
>    +        static int mutex_initialized = 0;
>    +        if (!mutex_initialized)
>    +        {
>    +                mutex_initialized = 1;
>    +                pthread_mutex_init(&init_mutex, NULL);
>    +        }
>
>While this might work using your pthread compatibility implementation
>using CreateMutex(), it will not work on a native pthread implementation
>because you can only call pthread_mutex_init() once.  Your code allows
>two threads to both call it.
>
>
I don't really think so. That mutex_initialized is a globally static
variable, not a thread local one. Thread interruption between testing
mutex_initialized and setting it is very unlikely and still wouldn't do
much harm if it actually does happen.

>Also, do you not have the problem with SIGPIPE from send(), so you don't
>need set/get_thread_specific()?
>
>

There's no SIGPIPE under win32, thus no problem.

Regards,
Andreas



pgsql-patches by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: pg_ctl using START with paths needing quotes
Next
From: "Zeugswetter Andreas SB SD"
Date:
Subject: path.c char[strlen("xxx")] not portable