From: | Andrew Chernow <ac(at)esilo(dot)com> |
---|---|
To: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
Cc: | Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: libpq WSACleanup is not needed |
Date: | 2009-01-16 14:44:18 |
Message-ID: | 49709D42.2010101@esilo.com |
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?
>
The Win32 equivalent is DllMain, which I believe only works when your a
dll. Although, from the WSAStartup docs:
"the WSAStartup function should not be called from the DllMain function
in a application DLL. This can potentially cause deadlocks."
That doesn't sound inviting. C++ static intializers would probably
work, if isolated in some small far away distant project file with an
ugly file name.
Outside of user-land work arounds, the real fix would be to have a libpq
library init and shutdown (shutdown only useful for those wanting to
free resources or re-init libpq differently). Not sure there's any
interest in this idea.
--
Andrew Chernow
eSilo, LLC
every bit counts
http://www.esilo.com/
From | Date | Subject | |
---|---|---|---|
Next Message | Merlin Moncure | 2009-01-16 14:48:27 | Re: libpq WSACleanup is not needed |
Previous Message | Teodor Sigaev | 2009-01-16 14:42:28 | Re: Review: B-Tree emulation for GIN |