From 98ffafe16e11b7cbe52fc6cc7cf6efd7a2521a09 Mon Sep 17 00:00:00 2001 From: Brian Cloutier Date: Thu, 15 Mar 2018 16:53:35 -0700 Subject: [PATCH] Fix error handling in connection_management --- .../connection/connection_management.c | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/backend/distributed/connection/connection_management.c b/src/backend/distributed/connection/connection_management.c index 5150a3e5a..d345ceea4 100644 --- a/src/backend/distributed/connection/connection_management.c +++ b/src/backend/distributed/connection/connection_management.c @@ -533,20 +533,27 @@ FinishConnectionEstablishment(MultiConnection *connection) */ break; } - else if (pollResult != EINTR) - { - /* Retrying, signal interrupted. So check. */ - CHECK_FOR_INTERRUPTS(); - } else { - /* - * We ERROR here, instead of just returning a failed - * connection, because this shouldn't happen, and indicates a - * programming error somewhere, not a network etc. issue. - */ - ereport(ERROR, (errcode_for_socket_access(), - errmsg("poll() failed: %m"))); + int errorCode = errno; +#ifdef WIN32 + errorCode = WSAGetLastError(); +#endif + if (errorCode == EINTR) + { + /* Retrying, signal interrupted. So check. */ + CHECK_FOR_INTERRUPTS(); + } + else + { + /* + * We ERROR here, instead of just returning a failed + * connection, because this shouldn't happen, and indicates a + * programming error somewhere, not a network etc. issue. + */ + ereport(ERROR, (errcode_for_socket_access(), + errmsg("poll()/select() failed: %m"))); + } } } }