Re: libpq WSACleanup is not needed - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: libpq WSACleanup is not needed
Date
Msg-id 200901191920.n0JJKIE17857@momjian.us
Whole thread Raw
In response to Re: libpq WSACleanup is not needed  (James Mansion <james@mansionfamily.plus.com>)
Responses Re: libpq WSACleanup is not needed  (Andrew Chernow <ac@esilo.com>)
List pgsql-hackers
James Mansion wrote:
> Magnus Hagander wrote:
> > The use-case of rapidly creating and dropping connections isn't
> > particularly common, I think. And there is a perfectly functioning
> > workaround - something that we should perhaps document in the FAQ or
> > somewhere in the documentation?
> >
> Would it be accetable to do initialise if the number of connections
> is changing from 0, and tidy if the cumber goes back to 0?
> Applications that retain a connection would not suffer the cost
> on subsequent connect/disconnect.

Yes, we do that now to clear the SSL callbacks in libpq (see
variable 'ssl_open_connections'):
           CRYPTO_set_locking_callback(NULL);           CRYPTO_set_id_callback(NULL);

If we don't remove them when going to zero connections then unloading
libpq can cause PHP to crash because it thinks the callback functions
are still loaded.

We could have gone with a more elegant init/uninit solution but there is
a history of slow upstream adoption of libpq API changes.

In this case I am thinking WSACleanup() should probably follow the same
pattern.  Having load/unload is superior, but if adoption of that API is
<10%, you will probably get the most advantage for the most users in
making it automatic.

The one big difference with SSL is that the SSL callback unload calls
where cheap, while WSACleanup() is expensive.

-- Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + If your life is a hard drive, Christ can be your backup. +


pgsql-hackers by date:

Previous
From: Jeff Davis
Date:
Subject: Re: Review: B-Tree emulation for GIN
Next
From: Andrew Chernow
Date:
Subject: Re: libpq WSACleanup is not needed