From ed24a0e81937bb14878d309b7a466a908d203134 Mon Sep 17 00:00:00 2001 From: Jelte Fennema Date: Tue, 28 Dec 2021 23:12:18 +0100 Subject: [PATCH] Treat ETIMEDOUT as indicating a non-recoverable connection failure. When the TCP_USER_TIMEOUT socket option is defined on a connection and the timeout is reached, it will cause a read to return ETIMEDOUT. After that the socket will be closed by the kernel. This considers ETIMEDOUT an unrecoverable connection failure when TCP_USER_TIMEOUT is defined. It specifically does not do make this change when WIN32 is defined. This is to reduce the chance of introducing issues and also so that win32_port.h does not have to be changed in an ABI incompatible way. --- src/include/port.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/include/port.h b/src/include/port.h index 82f63de325..e1db0ecb86 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -111,6 +111,18 @@ extern void pgfnames_cleanup(char **filenames); * are actually reporting errors typically single out EPIPE and ECONNRESET, * while allowing the network failures to be reported generically. */ +#ifndef WIN32 +#define ALL_CONNECTION_FAILURE_ERRNOS \ + EPIPE: \ + case ECONNRESET: \ + case ECONNABORTED: \ + case EHOSTDOWN: \ + case EHOSTUNREACH: \ + case ENETDOWN: \ + case ENETRESET: \ + case ENETUNREACH: \ + case ETIMEDOUT +#else #define ALL_CONNECTION_FAILURE_ERRNOS \ EPIPE: \ case ECONNRESET: \ @@ -120,6 +132,7 @@ extern void pgfnames_cleanup(char **filenames); case ENETDOWN: \ case ENETRESET: \ case ENETUNREACH +#endif /* Portable locale initialization (in exec.c) */ extern void set_pglocale_pgservice(const char *argv0, const char *app); -- 2.17.1