Remove duplicated code 06/309106/1
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 4 Apr 2024 23:29:44 +0000 (08:29 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 4 Apr 2024 23:29:44 +0000 (08:29 +0900)
Before entering the if statement code, calling SetNonblock() can be called.

Change-Id: I901e18226c8abb822acecfb2fd1e4e5057611286
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/proxy-internal.cc

index 1978829..458a43c 100644 (file)
@@ -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
   }