Re: Compiling libpq with VisualC

From: Andreas Pflug <pgadmin(at)pse-consulting(dot)de>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Compiling libpq with VisualC
Date: 2004-06-11 09:35:39
Message-ID: 40C97CEB.6030404@pse-consulting.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-hackers-win32 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andreas Pflug 2004-06-11 09:41:11 Re: [pgsql-hackers-win32] Tablespaces
Previous Message Richard Huxton 2004-06-11 08:27:07 Re: Accelerating aggregates

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Andreas Pflug 2004-06-11 09:41:11 Re: [pgsql-hackers-win32] Tablespaces
Previous Message Andrew Dunstan 2004-06-11 09:03:10 Re: pg_ctl using START with paths needing quotes

Browse pgsql-patches by date

  From Date Subject
Next Message Zeugswetter Andreas SB SD 2004-06-11 10:14:37 path.c char[strlen("xxx")] not portable
Previous Message Andrew Dunstan 2004-06-11 09:03:10 Re: pg_ctl using START with paths needing quotes