Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions cpp/src/arrow/flight/flight_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,24 @@ TEST(TestFlight, BuilderHook) {
ASSERT_OK(server->Shutdown());
}

TEST(TestFlight, ServeShutdown) {
// Regression test for ARROW-15181
constexpr int kIterations = 10;
for (int i = 0; i < kIterations; i++) {
Location location;
std::unique_ptr<FlightServerBase> server = ExampleTestServer();

ASSERT_OK(Location::ForGrpcTcp("localhost", 0, &location));
FlightServerOptions options(location);
ASSERT_OK(server->Init(options));
ASSERT_GT(server->port(), 0);
std::thread t([&]() { ASSERT_OK(server->Serve()); });
ASSERT_OK(server->Shutdown());
ASSERT_OK(server->Wait());
t.join();
}
}

// ----------------------------------------------------------------------
// Client tests

Expand Down
3 changes: 2 additions & 1 deletion cpp/src/arrow/flight/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -826,9 +826,9 @@ class ServerSignalHandler {
errno != EWOULDBLOCK && errno != EINTR) {
return arrow::internal::IOErrorFromErrno(errno, "Could not unblock signal thread");
}
handle_signals_.join();
RETURN_NOT_OK(arrow::internal::FileClose(self_pipe_.rfd));
RETURN_NOT_OK(arrow::internal::FileClose(self_pipe_.wfd));
handle_signals_.join();
self_pipe_.rfd = 0;
self_pipe_.wfd = 0;
return Status::OK();
Expand Down Expand Up @@ -1012,6 +1012,7 @@ Status FlightServerBase::Shutdown() {
if (!server) {
return Status::Invalid("Shutdown() on uninitialized FlightServerBase");
}
impl_->running_instance_ = nullptr;
impl_->server_->Shutdown();
return Status::OK();
}
Expand Down