Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita099482

Browse files
committed
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 afailure to avoid giving a misleading error message. Per the Single UnixSpec, only EINPROGRESS and EINTR returns indicate that the connectionattempt is in progress.On Windows, on the other hand, EWOULDBLOCK (WSAEWOULDBLOCK) is the expectedcase. 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 leavethat part of the logic alone in the absence of concrete trouble reports.Also, remove the test for errno == 0, effectively reverting commitda9501b, 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, sincelibpq 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
1 parenta2769a4 commita099482

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

‎src/interfaces/libpq/fe-connect.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1780,9 +1780,10 @@ PQconnectPoll(PGconn *conn)
17801780
addr_cur->ai_addrlen)<0)
17811781
{
17821782
if (SOCK_ERRNO==EINPROGRESS||
1783+
#ifdefWIN32
17831784
SOCK_ERRNO==EWOULDBLOCK||
1784-
SOCK_ERRNO==EINTR||
1785-
SOCK_ERRNO==0)
1785+
#endif
1786+
SOCK_ERRNO==EINTR)
17861787
{
17871788
/*
17881789
* This is fine - we're in non-blocking mode, and

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp