On 3/4/17 01:45, Petr Jelinek wrote:
> I can see one difference though (I didn't see this code before) and that
> is, the connectDBComplete starts with waiting for socket to become
> writable and only then calls PQconnectPoll, while my patch starts with
> PQconnectPoll call. And I see following comment in connectDBstart
>> /*
>> * The code for processing CONNECTION_NEEDED state is in PQconnectPoll(),
>> * so that it can easily be re-executed if needed again during the
>> * asynchronous startup process. However, we must run it once here,
>> * because callers expect a success return from this routine to mean that
>> * we are in PGRES_POLLING_WRITING connection state.
>> */
Yes, the libpq documentation also says that.
> If that's the case, the attached should fix it, but I have no way of
> testing it on windows, I can only say that it still works on my machine
> so at least it hopefully does not make things worse.
Committed that. Let's see how it goes.
I rewrote the while loop as a for loop so that the control logic isn't
spread out over three screens.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services