Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with hanging shutdown when not started #155

Merged
merged 1 commit into from
Oct 13, 2021
Merged
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
2 changes: 2 additions & 0 deletions include/faabric/transport/MessageEndpointServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,7 @@ class MessageEndpointServer

std::shared_ptr<faabric::util::Latch> requestLatch;
std::shared_ptr<faabric::util::Latch> shutdownLatch;

bool started = false;
};
}
9 changes: 9 additions & 0 deletions src/transport/MessageEndpointServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ MessageEndpointServer::MessageEndpointServer(int asyncPortIn,
*/
void MessageEndpointServer::start()
{
started = true;

// This latch allows use to block on the handlers until _just_ before they
// start their proxies.
auto startLatch = faabric::util::Latch::create(3);
Expand All @@ -243,6 +245,11 @@ void MessageEndpointServer::start()

void MessageEndpointServer::stop()
{
if (!started) {
SPDLOG_DEBUG("Not stopping server on {}, not started", syncPort);
return;
}

// Here we send shutdown messages to each worker in turn, however, because
// they're all connected on the same inproc port, we have to wait until each
// one has shut down fully (i.e. the zmq socket has gone out of scope),
Expand Down Expand Up @@ -284,6 +291,8 @@ void MessageEndpointServer::stop()
// Join the handlers
asyncHandler.join();
syncHandler.join();

started = false;
}

void MessageEndpointServer::setRequestLatch()
Expand Down