This is an automated email from the ASF dual-hosted git repository.

dmeden pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 441c7f8753 traffic_ctl - Add ECONNREFUSED to the retry list when 
connection to the rpc. (#12342)
441c7f8753 is described below

commit 441c7f8753a940705be6eedf99caab70980c1e32
Author: Damian Meden <[email protected]>
AuthorDate: Tue Jul 15 10:48:21 2025 +0200

    traffic_ctl - Add ECONNREFUSED to the retry list when connection to the 
rpc. (#12342)
---
 src/shared/rpc/IPCSocketClient.cc | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/shared/rpc/IPCSocketClient.cc 
b/src/shared/rpc/IPCSocketClient.cc
index 45a67061b5..bed9c58dc6 100644
--- a/src/shared/rpc/IPCSocketClient.cc
+++ b/src/shared/rpc/IPCSocketClient.cc
@@ -38,7 +38,7 @@ IPCSocketClient::self_reference
 IPCSocketClient::connect(std::chrono::milliseconds wait_ms, int attempts)
 {
   std::string text;
-  int         err, tries{attempts};
+  int         err, attempts_remaining{attempts};
   bool        done{false};
   _sock = socket(AF_UNIX, SOCK_STREAM, 0);
 
@@ -58,13 +58,13 @@ IPCSocketClient::connect(std::chrono::milliseconds wait_ms, 
int attempts)
   // Socket and if it tell us to retry we just wait for a few ms and try again 
for
   // X times.
   do {
-    --tries;
+    --attempts_remaining;
     if (::connect(_sock, (struct sockaddr *)&_server, sizeof(struct 
sockaddr_un)) >= 0) {
       done = true;
       break;
     }
 
-    if (errno == EAGAIN || errno == EINPROGRESS) {
+    if (errno == EAGAIN || errno == EINPROGRESS || errno == ECONNREFUSED) {
       // Connection cannot be completed immediately
       // EAGAIN for UDS should suffice, but just in case.
       std::this_thread::sleep_for(wait_ms);
@@ -75,13 +75,13 @@ IPCSocketClient::connect(std::chrono::milliseconds wait_ms, 
int attempts)
       err = errno;
       break;
     }
-  } while (tries != 0);
+  } while (attempts_remaining != 0);
 
-  if ((tries == 0 && !done) || !done) {
+  if ((attempts_remaining == 0 && !done) || !done) {
     this->close();
     errno = err;
     throw std::runtime_error(swoc::bwprint(text, "connect(attempts={}/{}): 
Couldn't open connection with {}. Last error: {}({})\n",
-                                           (attempts - tries), attempts, 
_path, std::strerror(errno), errno));
+                                           (attempts - attempts_remaining), 
attempts, _path, std::strerror(errno), errno));
   }
   return *this;
 }

Reply via email to