diff --git a/src/client/io.cc b/src/client/io.cc index 0097c952f..96c628373 100644 --- a/src/client/io.cc +++ b/src/client/io.cc @@ -25,6 +25,8 @@ limitations under the License. #include +#include "common/util/env.h" + namespace vineyard { static const int kNumConnectAttempts = 10; @@ -108,12 +110,16 @@ Status connect_ipc_socket_retry(const std::string& pathname, int& socket_fd) { auto status = connect_ipc_socket(pathname, socket_fd); + bool skip_retry = read_env("VINEYARD_IPC_SKIP_RETRY", "0") == "1"; while (!status.ok() && num_retries > 0) { std::clog << "[info] Connection to IPC socket failed for pathname " << pathname << " with ret = " << status << ", retrying " << num_retries << " more times." << std::endl; usleep(static_cast(timeout * 1000)); status = connect_ipc_socket(pathname, socket_fd); + if (!status.ok() && skip_retry) { + break; + } --num_retries; } if (!status.ok()) { @@ -130,12 +136,16 @@ Status connect_rpc_socket_retry(const std::string& host, const uint32_t port, auto status = connect_rpc_socket(host, port, socket_fd); + bool skip_retry = read_env("VINEYARD_RPC_SKIP_RETRY", "0") == "1"; while (!status.ok() && num_retries > 0) { std::clog << "[info] Connection to RPC socket failed for endpoint " << host << ":" << port << " with ret = " << status << ", retrying " << num_retries << " more times." << std::endl; usleep(static_cast(timeout * 1000)); status = connect_rpc_socket(host, port, socket_fd); + if (!status.ok() && skip_retry) { + break; + } --num_retries; } if (!status.ok()) {