summaryrefslogtreecommitdiff
path: root/src/backend/port/win32/socket.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2020-10-10 13:28:12 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2020-10-10 13:28:12 -0400
commitfe27009cbb5fff53f87969786ca8dac82ed7deba (patch)
tree953d89b695115498aa6d4d4235391453bfab3beb /src/backend/port/win32/socket.c
parented30b1a60dadf2b7cc58bce5009ad8676b8fe479 (diff)
downloadpostgresql-fe27009cbb5fff53f87969786ca8dac82ed7deba.tar.gz
Recognize network-failure errnos as indicating hard connection loss.
Up to now, only ECONNRESET (and EPIPE, in most but not quite all places) received special treatment in our error handling logic. This patch changes things so that related error codes such as ECONNABORTED are also recognized as indicating that the connection's dead and unlikely to come back. We continue to think, however, that only ECONNRESET and EPIPE should be reported as probable server crashes; the other cases indicate network connectivity problems but prove little about the server's state. Thus, there's no change in the error message texts that are output for such cases. The key practical effect is that errcode_for_socket_access() will report ERRCODE_CONNECTION_FAILURE rather than ERRCODE_INTERNAL_ERROR for a network failure. It's expected that this will fix buildfarm member lorikeet's failures since commit 32a9c0bdf, as that seems to be due to not treating ECONNABORTED equivalently to ECONNRESET. The set of errnos treated this way now includes ECONNABORTED, EHOSTDOWN, EHOSTUNREACH, ENETDOWN, ENETRESET, and ENETUNREACH. Several of these were second-class citizens in terms of their handling in places like get_errno_symbol(), so upgrade the infrastructure where necessary. As committed, this patch assumes that all these symbols are defined everywhere. POSIX specifies all of them except EHOSTDOWN, but that seems to exist on all platforms of interest; we'll see what the buildfarm says about that. Probably this should be back-patched, but let's see what the buildfarm thinks of it first. Fujii Masao and Tom Lane Discussion: https://postgr.es/m/2621622.1602184554@sss.pgh.pa.us
Diffstat (limited to 'src/backend/port/win32/socket.c')
-rw-r--r--src/backend/port/win32/socket.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/backend/port/win32/socket.c b/src/backend/port/win32/socket.c
index 6fbd1ed6fb..7c7611a01e 100644
--- a/src/backend/port/win32/socket.c
+++ b/src/backend/port/win32/socket.c
@@ -120,13 +120,21 @@ TranslateSocketError(void)
case WSAEADDRNOTAVAIL:
errno = EADDRNOTAVAIL;
break;
- case WSAEHOSTUNREACH:
case WSAEHOSTDOWN:
+ errno = EHOSTDOWN;
+ break;
+ case WSAEHOSTUNREACH:
case WSAHOST_NOT_FOUND:
+ errno = EHOSTUNREACH;
+ break;
case WSAENETDOWN:
+ errno = ENETDOWN;
+ break;
case WSAENETUNREACH:
+ errno = ENETUNREACH;
+ break;
case WSAENETRESET:
- errno = EHOSTUNREACH;
+ errno = ENETRESET;
break;
case WSAENOTCONN:
case WSAESHUTDOWN: