@@ -85,7 +85,8 @@ int dd_conn_init( // NOLINT(readability-function-cognitive-complexity)
8585 res = connect (
8686 conn -> socket , (struct sockaddr * )& conn -> addr , sizeof (conn -> addr ));
8787 if (res == -1 ) {
88- if (errno == EINPROGRESS ) {
88+ int errno_copy = errno ;
89+ if (errno_copy == EINPROGRESS ) {
8990 struct pollfd pfds [] = {
9091 {.fd = conn -> socket , .events = POLLIN | POLLOUT }};
9192 struct timespec now ;
@@ -123,8 +124,8 @@ int dd_conn_init( // NOLINT(readability-function-cognitive-complexity)
123124 }
124125 // else good
125126 } else {
126- if (errno == ENOENT ) {
127- // the socket does not exist. Retry
127+ if (errno_copy == ENOENT || errno_copy == ECONNREFUSED ) {
128+ // the socket does not exist or is not being listened on . Retry
128129 struct timespec now ;
129130 clock_gettime (CLOCK_MONOTONIC , & now );
130131 long time_left = _timespec_delta_ms (& deadline , & now );
@@ -134,8 +135,10 @@ int dd_conn_init( // NOLINT(readability-function-cognitive-complexity)
134135 return dd_error ;
135136 }
136137
137- mlog (dd_log_debug ,
138- "Socket does not exist. Waiting 100 ms for next retry" );
138+ mlog (dd_log_debug , "Socket %s. Waiting %d ms for next retry" ,
139+ errno_copy == ENOENT ? "does not exist"
140+ : "is not being listened on" ,
141+ CONNECT_RETRY_PAUSE );
139142 int ret = usleep (CONNECT_RETRY_PAUSE * 1000 ); // NOLINT
140143 if (ret == 0 ) {
141144 goto try_again ;
@@ -146,6 +149,7 @@ int dd_conn_init( // NOLINT(readability-function-cognitive-complexity)
146149 }
147150
148151 dd_conn_destroy (conn );
152+ errno = errno_copy ; // restore for mlog_err
149153 mlog_err (
150154 dd_log_info , "Failed connecting to helper (connect() call)" );
151155 return dd_error ;
0 commit comments