pgsql: Expect EWOULDBLOCK from a non-blocking connect() call only on Wi - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Expect EWOULDBLOCK from a non-blocking connect() call only on Wi
Date
Msg-id E1UsFCy-0005t1-41@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Expect EWOULDBLOCK from a non-blocking connect() call only on Windows.

On Unix-ish platforms, EWOULDBLOCK may be the same as EAGAIN, which is
*not* a success return, at least not on Linux.  We need to treat it as a
failure to avoid giving a misleading error message.  Per the Single Unix
Spec, only EINPROGRESS and EINTR returns indicate that the connection
attempt is in progress.

On Windows, on the other hand, EWOULDBLOCK (WSAEWOULDBLOCK) is the expected
case.  We must accept EINPROGRESS as well because Cygwin will return that,
and it doesn't seem worth distinguishing Cygwin from native Windows here.
It's not very clear whether EINTR can occur on Windows, but let's leave
that part of the logic alone in the absence of concrete trouble reports.

Also, remove the test for errno == 0, effectively reverting commit
da9501bddb42222dc33c031b1db6ce2133bcee7b, which AFAICS was just a thinko;
or at best it might have been a workaround for a platform-specific bug,
which we can hope is gone now thirteen years later.  In any case, since
libpq makes no effort to reset errno to zero before calling connect(),
it seems unlikely that that test has ever reliably done anything useful.

Andres Freund and Tom Lane

Branch
------
REL9_3_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/0b173ced93ee7a0da0d38fa13926e7ec4925075e

Modified Files
--------------
src/interfaces/libpq/fe-connect.c |    5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)


pgsql-committers by date:

Previous
From: Michael Meskes
Date:
Subject: pgsql: Fixed incorrect description of EXEC SQL VAR command.
Next
From: Tom Lane
Date:
Subject: pgsql: Expect EWOULDBLOCK from a non-blocking connect() call only on Wi