From 29433cb5eee3817351d2efa8281031b1f3a52406 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 5 Apr 2024 08:29:44 +0900 Subject: [PATCH] Remove duplicated code Before entering the if statement code, calling SetNonblock() can be called. Change-Id: I901e18226c8abb822acecfb2fd1e4e5057611286 Signed-off-by: Hwankyu Jhun --- src/proxy-internal.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/proxy-internal.cc b/src/proxy-internal.cc index 1978829..458a43c 100644 --- a/src/proxy-internal.cc +++ b/src/proxy-internal.cc @@ -156,6 +156,7 @@ int Proxy::MainPortConnect(const std::string& instance, bool sync) { int ret = SendRequest(main_client_.get(), request); if (ret != 0) return RPC_PORT_ERROR_IO_ERROR; // LCOV_EXCL_LINE + main_client_->SetNonblock(); if (sync) { Response* response = nullptr; ret = ReceiveResponse(main_client_.get(), &response); @@ -167,10 +168,8 @@ int Proxy::MainPortConnect(const std::string& instance, bool sync) { return RPC_PORT_ERROR_PERMISSION_DENIED; // LCOV_EXCL_LINE } - main_client_->SetNonblock(); fds_[0] = main_client_->RemoveFd(); } else { - main_client_->SetNonblock(); ret = main_client_->Watch(); if (ret != 0) return RPC_PORT_ERROR_IO_ERROR; // LCOV_EXCL_LINE } @@ -189,6 +188,7 @@ int Proxy::DelegatePortConnect(const std::string& instance, bool sync) { int ret = SendRequest(delegate_client_.get(), request); if (ret != 0) return RPC_PORT_ERROR_IO_ERROR; // LCOV_EXCL_LINE + delegate_client_->SetNonblock(); if (sync) { Response* response = nullptr; ret = ReceiveResponse(delegate_client_.get(), &response); @@ -200,10 +200,8 @@ int Proxy::DelegatePortConnect(const std::string& instance, bool sync) { return RPC_PORT_ERROR_PERMISSION_DENIED; // LCOV_EXCL_LINE } - delegate_client_->SetNonblock(); fds_[1] = delegate_client_->RemoveFd(); } else { - delegate_client_->SetNonblock(); ret = delegate_client_->Watch(); if (ret != 0) return RPC_PORT_ERROR_IO_ERROR; // LCOV_EXCL_LINE } -- 2.7.4