Skip to content

Commit 441c7f8

Browse files
authored
traffic_ctl - Add ECONNREFUSED to the retry list when connection to the rpc. (#12342)
1 parent 67064f6 commit 441c7f8

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/shared/rpc/IPCSocketClient.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ IPCSocketClient::self_reference
3838
IPCSocketClient::connect(std::chrono::milliseconds wait_ms, int attempts)
3939
{
4040
std::string text;
41-
int err, tries{attempts};
41+
int err, attempts_remaining{attempts};
4242
bool done{false};
4343
_sock = socket(AF_UNIX, SOCK_STREAM, 0);
4444

@@ -58,13 +58,13 @@ IPCSocketClient::connect(std::chrono::milliseconds wait_ms, int attempts)
5858
// Socket and if it tell us to retry we just wait for a few ms and try again for
5959
// X times.
6060
do {
61-
--tries;
61+
--attempts_remaining;
6262
if (::connect(_sock, (struct sockaddr *)&_server, sizeof(struct sockaddr_un)) >= 0) {
6363
done = true;
6464
break;
6565
}
6666

67-
if (errno == EAGAIN || errno == EINPROGRESS) {
67+
if (errno == EAGAIN || errno == EINPROGRESS || errno == ECONNREFUSED) {
6868
// Connection cannot be completed immediately
6969
// EAGAIN for UDS should suffice, but just in case.
7070
std::this_thread::sleep_for(wait_ms);
@@ -75,13 +75,13 @@ IPCSocketClient::connect(std::chrono::milliseconds wait_ms, int attempts)
7575
err = errno;
7676
break;
7777
}
78-
} while (tries != 0);
78+
} while (attempts_remaining != 0);
7979

80-
if ((tries == 0 && !done) || !done) {
80+
if ((attempts_remaining == 0 && !done) || !done) {
8181
this->close();
8282
errno = err;
8383
throw std::runtime_error(swoc::bwprint(text, "connect(attempts={}/{}): Couldn't open connection with {}. Last error: {}({})\n",
84-
(attempts - tries), attempts, _path, std::strerror(errno), errno));
84+
(attempts - attempts_remaining), attempts, _path, std::strerror(errno), errno));
8585
}
8686
return *this;
8787
}

0 commit comments

Comments
 (0)