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

Commitb67c9c1

Browse files
committed
Fix poor errno handling in libpq's version of our custom OpenSSL BIO.
Thom Brown reported that SSL connections didn't seem to work on Windows in9.5. Asif Naeem figured out that the cause was my_sock_read() looking at"errno" when it needs to look at "SOCK_ERRNO". This mistake was introducedin commit680513a, which cloned thebackend's custom SSL BIO code into libpq, and didn't translate the errnohandling properly. Moreover, it introduced unnecessary errno save/restorelogic, which was particularly confusing because it was incomplete; and itfailed to check for all three of EINTR, EAGAIN, and EWOULDBLOCK inmy_sock_write. (That might not be necessary; but since we're copyingwell-tested backend code that does do that, it seems prudent to copy itfaithfully.)
1 parentce58502 commitb67c9c1

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

‎src/interfaces/libpq/fe-secure-openssl.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,14 +1598,13 @@ static int
15981598
my_sock_read(BIO*h,char*buf,intsize)
15991599
{
16001600
intres;
1601-
intsave_errno;
16021601

16031602
res=pqsecure_raw_read((PGconn*)h->ptr,buf,size);
1604-
save_errno=errno;
16051603
BIO_clear_retry_flags(h);
16061604
if (res<0)
16071605
{
1608-
switch (save_errno)
1606+
/* If we were interrupted, tell caller to retry */
1607+
switch (SOCK_ERRNO)
16091608
{
16101609
#ifdefEAGAIN
16111610
caseEAGAIN:
@@ -1622,24 +1621,33 @@ my_sock_read(BIO *h, char *buf, int size)
16221621
}
16231622
}
16241623

1625-
errno=save_errno;
16261624
returnres;
16271625
}
16281626

16291627
staticint
16301628
my_sock_write(BIO*h,constchar*buf,intsize)
16311629
{
16321630
intres;
1633-
intsave_errno;
16341631

16351632
res=pqsecure_raw_write((PGconn*)h->ptr,buf,size);
1636-
save_errno=errno;
16371633
BIO_clear_retry_flags(h);
16381634
if (res <=0)
16391635
{
1640-
if (save_errno==EINTR)
1636+
/* If we were interrupted, tell caller to retry */
1637+
switch (SOCK_ERRNO)
16411638
{
1642-
BIO_set_retry_write(h);
1639+
#ifdefEAGAIN
1640+
caseEAGAIN:
1641+
#endif
1642+
#if defined(EWOULDBLOCK)&& (!defined(EAGAIN)|| (EWOULDBLOCK!=EAGAIN))
1643+
caseEWOULDBLOCK:
1644+
#endif
1645+
caseEINTR:
1646+
BIO_set_retry_write(h);
1647+
break;
1648+
1649+
default:
1650+
break;
16431651
}
16441652
}
16451653

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp