Re: libpq WSACleanup is not needed

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Andrew Chernow <ac(at)esilo(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: libpq WSACleanup is not needed
Date: 2009-01-16 14:36:26
Message-ID: 49709B6A.5010308@hagander.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alvaro Herrera wrote:
> Magnus Hagander wrote:
>> Andrew Chernow wrote:
>>> WSACleanup is not really needed during a PQfinish. Its horribly slow if
>>> the library ref count is 0 and it actually unloads the winsock library,
>>> adds 225ms to PQfinish.
>>>
>>> Solution:
>>> A) Call WSAStartup once and never clean it up. When the app dies, so do
>>> the ref counts and winsock is automatically unloaded.
>
>> If you want to override this behavior today, you can just call
>> WSAStartup() in your application, and it should never happen. Right?
>
> Or perhaps use _init() and _fini() or the Win32 equivalents?

You are not allowed to call WSAStartup() and WSACleanup() from these,
since they may load/unload DLLs...

I think you can find traces of that in the cvs history if you're
interested :-D

//Magnus

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Teodor Sigaev 2009-01-16 14:42:28 Re: Review: B-Tree emulation for GIN
Previous Message Heikki Linnakangas 2009-01-16 14:33:07 Re: Hot Standby dev build (v8)