From 37315f877ef27d0f8585389f0c83cd00a31577c1 Mon Sep 17 00:00:00 2001 From: Dennis Brentjes Date: Mon, 21 Nov 2016 15:22:48 +0100 Subject: Reworked server and client to do one mix and shutdown. This is done as cleanly as possible to track down any memory leaks. unfortunately there is still one async operation running on the nodes. when there should be none. So the nodes are still forced to stop with a. io_service.stop(). --- node/node.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'node/node.cpp') diff --git a/node/node.cpp b/node/node.cpp index 3ad4a2d..cc5e47a 100644 --- a/node/node.cpp +++ b/node/node.cpp @@ -154,12 +154,12 @@ void Node::handle_message(Purgatory::iterator handle, cmix_proto::CMixMessage me void Node::start_precomputation() { BOOST_LOG_TRIVIAL(trace) << "Starting precomputation for " << clients.size() << " clients."; index_map.clear(); - if(start_mix(&cmix_ctx, clients.size()) != no_error) { + if(start_mix(&cmix_ctx, messages.size()) != no_error) { exit(-1); } unsigned int i = 0; - for(auto&& pair : clients) { + for(auto&& pair : messages) { index_map[pair.first] = i++; } @@ -252,3 +252,26 @@ void Node::start_realtime_phase() { next_node.async_send(realpre); } + +void Node::shutdown() +{ + server.close(); + for(auto&& pair : clients) { + pair.second.async_send(cmix_proto::Bye()); + } +} + +bool Node::send_bye(bool got_bye) +{ + if(got_bye) { + if(!shutting_down) { + next_node.async_send(cmix_proto::Bye()); + } + io_service.stop(); + return true; + } else { + next_node.async_send(cmix_proto::Bye()); + shutting_down = true; + return false; + } +} -- cgit v1.2.3-70-g09d2