aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2021-09-30 14:16:08 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2021-09-30 14:16:08 -0400
commitb484ddf4d2eb81736512efa35ed3e5d2a72993d8 (patch)
tree1481fbc764c05bc0c2c5baff6d6650e094b897f5 /src/backend
parentd03bca4d70c29cca4f09e3a0e78a56cf97e237f3 (diff)
downloadpostgresql-b484ddf4d2eb81736512efa35ed3e5d2a72993d8.tar.gz
postgresql-b484ddf4d2eb81736512efa35ed3e5d2a72993d8.zip
Treat ETIMEDOUT as indicating a non-recoverable connection failure.
Add ETIMEDOUT to ALL_CONNECTION_FAILURE_ERRNOS' list of "errnos that identify hard failure of a previously-established network connection". While one could imagine that this is sometimes recoverable, the same could be said of other entries such as ENETDOWN. In support of this, handle ETIMEDOUT on par with other socket errors in relevant infrastructure, such as TranslateSocketError(). (I made a couple of cosmetic adjustments in TranslateSocketError(), too.) The code now assumes that ETIMEDOUT is defined everywhere, which it should be given that POSIX has required it since SUSv2. Perhaps this should be back-patched, but I'm hesitant to do so given the lack of previous complaints, and the hazard that there's a small ABI break on Windows from redefining the symbol. Even if we decide to do that, it'd be prudent to let this bake awhile in HEAD first. Jelte Fennema Discussion: https://postgr.es/m/AM5PR83MB01782BFF2978505F6D6C559AF7AA9@AM5PR83MB0178.EURPRD83.prod.outlook.com
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/port/win32/socket.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/backend/port/win32/socket.c b/src/backend/port/win32/socket.c
index af151e84709..70592afe54e 100644
--- a/src/backend/port/win32/socket.c
+++ b/src/backend/port/win32/socket.c
@@ -47,8 +47,8 @@ int pgwin32_noblock = 0;
*
* Note: where there is a direct correspondence between a WSAxxx error code
* and a Berkeley error symbol, this mapping is actually a no-op, because
- * in win32.h we redefine the network-related Berkeley error symbols to have
- * the values of their WSAxxx counterparts. The point of the switch is
+ * in win32_port.h we redefine the network-related Berkeley error symbols to
+ * have the values of their WSAxxx counterparts. The point of the switch is
* mostly to translate near-miss error codes into something that's sensible
* in the Berkeley universe.
*/
@@ -141,10 +141,15 @@ TranslateSocketError(void)
case WSAEDISCON:
errno = ENOTCONN;
break;
+ case WSAETIMEDOUT:
+ errno = ETIMEDOUT;
+ break;
default:
ereport(NOTICE,
- (errmsg_internal("unrecognized win32 socket error code: %d", WSAGetLastError())));
+ (errmsg_internal("unrecognized win32 socket error code: %d",
+ WSAGetLastError())));
errno = EINVAL;
+ break;
}
}