| 499 | } |
| 500 | |
| 501 | Status Close() override { |
| 502 | // Do not CheckStarted - Close applies to data and metadata |
| 503 | if (!closed_) { |
| 504 | closed_ = true; |
| 505 | if (batch_writer_ && !writer_closed_) { |
| 506 | // This is important! Close() calls |
| 507 | // IpcPayloadWriter::CheckStarted() which will force the initial |
| 508 | // schema message to be written to the stream. This is required |
| 509 | // to unstick the server, else the client and the server end up |
| 510 | // waiting for each other. This happens if the client never |
| 511 | // wrote anything before calling Close(). |
| 512 | writer_closed_ = true; |
| 513 | final_status_ = stream_->Finish(batch_writer_->Close()); |
| 514 | } else { |
| 515 | final_status_ = stream_->Finish(Status::OK()); |
| 516 | } |
| 517 | } |
| 518 | return final_status_; |
| 519 | } |
| 520 | |
| 521 | ipc::WriteStats stats() const override { |
| 522 | ARROW_CHECK_NE(batch_writer_, nullptr); |