From 9206625663b2721af888553ee467b8d0f980f9c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CYourUsername=E2=80=9D?= <“YourEmail”> Date: Tue, 15 Oct 2024 09:32:12 +0300 Subject: [PATCH] Fix-fast-connection-rate-issue-for-v16 --- src/interfaces/libpq/fe-connect.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 6bce6f647b..99cffa06f6 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -3040,6 +3040,7 @@ keep_going: /* We will come back to here until there is * Start/make connection. This should not block, since we * are in nonblock mode. If it does, well, too bad. */ +retry_connect: if (connect(conn->sock, (struct sockaddr *) &addr_cur->addr.addr, addr_cur->addr.salen) < 0) { @@ -3057,6 +3058,12 @@ keep_going: /* We will come back to here until there is conn->status = CONNECTION_STARTED; return PGRES_POLLING_WRITING; } + + if (SOCK_ERRNO == EAGAIN) + { + pg_usleep(100000L); /* wait 0.1 sec */ + goto retry_connect; + } /* otherwise, trouble */ } else -- 2.39.2