Re: libpq WSACleanup is not needed

Поиск
Список
Период
Сортировка
От Magnus Hagander
Тема Re: libpq WSACleanup is not needed
Дата
Msg-id 49708E50.6030400@hagander.net
обсуждение исходный текст
Ответ на libpq WSACleanup is not needed  (Andrew Chernow <ac@esilo.com>)
Ответы Re: libpq WSACleanup is not needed  (Andrew Chernow <ac@esilo.com>)
Re: libpq WSACleanup is not needed  (Alvaro Herrera <alvherre@commandprompt.com>)
Re: libpq WSACleanup is not needed  ("Merlin Moncure" <mmoncure@gmail.com>)
Список pgsql-hackers
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.
> 
> B) Have a way of specifying the behavior, the way it is now or tell
> libpq to not initialize wsa at all (kinda like ssl init callbacks).
> Leave it up to the application.
> 
> I think the WSA startup/cleanup stuff is silly.  If I dynamically link
> with a DLL, I want it automatically loaded and cleaned up.
> 
> Worst case, your app makes lots of connections to different backends.
> So, it is constantly doing PQconnectdb and PQfinish; only has a single
> conn open at a time.  This means its constantly loading and unloading
> winsock.

Option A will make us leak the reference to it though, won't it? And we
are supposed to clean up after ourselves...

If you want to override this behavior today, you can just call
WSAStartup() in your application, and it should never happen. Right?

Now, if we actually had libpq_init()/uninit() or something like it, it
would make sense to move it there. But I'm not sure we want to just leak
the reference. But I'm not entirely convinced either way :-)

//Magnus


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

Предыдущее
От: Teodor Sigaev
Дата:
Сообщение: Re: [PATCHES] GIN improvements
Следующее
От: Andrew Chernow
Дата:
Сообщение: Re: libpq WSACleanup is not needed