Remove duplicated code
[platform/core/appfw/rpc-port.git] / 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
   }