cyb70289 commented on a change in pull request #12465:
URL: https://github.com/apache/arrow/pull/12465#discussion_r816459209



##########
File path: cpp/src/arrow/flight/client.cc
##########
@@ -1399,21 +1328,41 @@ Status FlightClient::DoPut(const FlightCallOptions& 
options,
                            std::unique_ptr<FlightStreamWriter>* stream,
                            std::unique_ptr<FlightMetadataReader>* reader) {
   RETURN_NOT_OK(CheckOpen());
-  return impl_->DoPut(options, descriptor, schema, stream, reader);
+  std::unique_ptr<internal::ClientDataStream> remote_stream;
+  RETURN_NOT_OK(impl_->DoPut(options, &remote_stream));
+  std::shared_ptr<internal::ClientDataStream> shared_stream = 
std::move(remote_stream);
+  *reader =
+      std::unique_ptr<FlightMetadataReader>(new 
ClientMetadataReader(shared_stream));
+  *stream = std::unique_ptr<FlightStreamWriter>(
+      new ClientStreamWriter(std::move(shared_stream), options.write_options,
+                             write_size_limit_bytes_, descriptor));
+  RETURN_NOT_OK((*stream)->Begin(schema, options.write_options));
+  return Status::OK();
 }
 
 Status FlightClient::DoExchange(const FlightCallOptions& options,
                                 const FlightDescriptor& descriptor,
                                 std::unique_ptr<FlightStreamWriter>* writer,
                                 std::unique_ptr<FlightStreamReader>* reader) {
   RETURN_NOT_OK(CheckOpen());
-  return impl_->DoExchange(options, descriptor, writer, reader);
+  std::unique_ptr<internal::ClientDataStream> remote_stream;
+  RETURN_NOT_OK(impl_->DoExchange(options, &remote_stream));
+  std::shared_ptr<internal::ClientDataStream> shared_stream = 
std::move(remote_stream);
+  *reader = std::unique_ptr<FlightStreamReader>(
+      new ClientStreamReader(shared_stream, options.read_options, 
options.stop_token));
+  auto stream_writer = std::unique_ptr<ClientStreamWriter>(
+      new ClientStreamWriter(std::move(shared_stream), options.write_options,
+                             write_size_limit_bytes_, descriptor));
+  RETURN_NOT_OK(stream_writer->Begin());
+  *writer = std::move(stream_writer);
+  return Status::OK();
 }
 
 Status FlightClient::Close() {
-  // gRPC doesn't offer an explicit shutdown
-  impl_.reset(nullptr);
-  // TODO(ARROW-15473): if we track ongoing RPCs, we can cancel them first
+  if (impl_) {
+    RETURN_NOT_OK(impl_->Close());
+    impl_.reset(nullptr);

Review comment:
       Still hangs 10 seconds on my test machine. Removing this `reset` looks 
fixes it.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to