Re: [PATCHES] Compiling libpq with VisualC

Поиск
Список
Период
Сортировка
От pgsql@mohawksoft.com
Тема Re: [PATCHES] Compiling libpq with VisualC
Дата
Msg-id 17038.24.91.171.78.1087168669.squirrel@mail.mohawksoft.com
обсуждение исходный текст
Ответ на Re: [PATCHES] Compiling libpq with VisualC  (Bruce Momjian <pgman@candle.pha.pa.us>)
Ответы Re: [pgsql-hackers-win32] [PATCHES] Compiling libpq with VisualC  (Bruce Momjian <pgman@candle.pha.pa.us>)
Re: [PATCHES] Compiling libpq with VisualC  (Manfred Spraul <manfred@colorfullife.com>)
Список pgsql-hackers
>
> [ 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.


>
> ---------------------------------------------------------------------------
>
> 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@candle.pha.pa.us               |  (610) 359-1001
>   +  If your life is a hard drive,     |  13 Roberts Road
>   +  Christ can be your backup.        |  Newtown Square, Pennsylvania
> 19073
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>


В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Mark Cave-Ayland"
Дата:
Сообщение: Re: Can get GiST RECHECK clause to work
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Can get GiST RECHECK clause to work