aboutsummaryrefslogtreecommitdiff
path: root/node/node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'node/node.cpp')
-rw-r--r--node/node.cpp27
1 files changed, 25 insertions, 2 deletions
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;
+ }
+}