Skip to content

Commit 586d06a

Browse files
Ning WuCommitfest Bot
Ning Wu
authored and
Commitfest Bot
committed
Fix error handling for non-blocking socket on Windows
The connection fails with a non-blocking socket error when using psql on Windows to connect to a PostgreSQL server with GSSAPI enabled. On Windows, the socket error code is obtained by WSAGetLastError() instead of errno. This causes the value of errno to be incorrect when handling with non-blocking socket error. By using the SOCK_ERRNO macro to ensure that all platforms can get the error code correctly. Authored-by: Ning Wu <[email protected]>
1 parent a7187c3 commit 586d06a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/interfaces/libpq/fe-secure-gssapi.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ gss_read(PGconn *conn, void *recv_buffer, size_t length, ssize_t *ret)
430430
*ret = pqsecure_raw_read(conn, recv_buffer, length);
431431
if (*ret < 0)
432432
{
433-
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR)
433+
if (SOCK_ERRNO == EAGAIN || SOCK_ERRNO == EWOULDBLOCK || SOCK_ERRNO == EINTR)
434434
return PGRES_POLLING_READING;
435435
else
436436
return PGRES_POLLING_FAILED;

0 commit comments

Comments
 (0)