aboutsummaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
authorDennis Brentjes <d.brentjes@gmail.com>2016-10-20 12:45:02 +0200
committerDennis Brentjes <d.brentjes@gmail.com>2016-10-20 12:45:02 +0200
commit02b48a4f83f5c6bcc5c1ac0afbbddcdaeb685af0 (patch)
tree440e5afd3b204db0c4e964b8fe6006ea147751f5 /node
parent843c664d1da8cbe9a6aa5a7d49d827b30e22d9db (diff)
downloadcmix-02b48a4f83f5c6bcc5c1ac0afbbddcdaeb685af0.tar.gz
cmix-02b48a4f83f5c6bcc5c1ac0afbbddcdaeb685af0.tar.bz2
cmix-02b48a4f83f5c6bcc5c1ac0afbbddcdaeb685af0.zip
Fixes the build and fixes a crash.
Diffstat (limited to 'node')
-rw-r--r--node/node.cpp28
-rw-r--r--node/node.hpp5
2 files changed, 4 insertions, 29 deletions
diff --git a/node/node.cpp b/node/node.cpp
index 280453d..c9d23cf 100644
--- a/node/node.cpp
+++ b/node/node.cpp
@@ -68,7 +68,7 @@ void Node::handle_node_initialization(const cmix_proto::Initialization& init)
if(init.public_share().size() != keypair.pub_len) {
prev_node.close();
cmix_proto::Bye bye;
- next_node.async_send(bye, [this]{stop();});
+ next_node.async_send(bye, [this]{io_service.stop();});
BOOST_LOG_TRIVIAL(fatal) << "Previous node dit not send proper initialization message.";
return;
}
@@ -101,18 +101,6 @@ void Node::handle_node_initialization(const cmix_proto::Initialization& init)
}
}
-void Node::handle_node_bye(cmix_proto::Bye) {
- prev_node.close();
- if (!shutting_down) {
- send_bye();
- prev_node.async_receive([this](cmix_proto::CMixMessage message){
- handle_node_message(message);
- });
- } else {
- io_service.stop();
- }
-}
-
void Node::handle_node_secretkey(cmix_proto::SecretKey const& secret)
{
std::string share = secret.secret_key();
@@ -123,13 +111,6 @@ void Node::handle_node_secretkey(cmix_proto::SecretKey const& secret)
}
}
-void Node::send_bye()
-{
- cmix_proto::Bye bye;
- next_node.async_send(bye);
- shutting_down = true;
-}
-
void Node::handle_node_message(cmix_proto::CMixMessage message)
{
switch(message.contents_case()) {
@@ -140,8 +121,8 @@ void Node::handle_node_message(cmix_proto::CMixMessage message)
}
case cmix_proto::CMixMessage::ContentsCase::kBye: {
BOOST_LOG_TRIVIAL(trace) << "Handling bye";
- handle_node_bye(message.bye());
- return;
+ //Todo: find a nice way to handle network shutdown.
+ break;
}
case cmix_proto::CMixMessage::ContentsCase::kSecretkey: {
BOOST_LOG_TRIVIAL(trace) << "Handling SecretKey";
@@ -169,9 +150,6 @@ void Node::handle_client_bye(ClientConnections::key_type handle, cmix_proto::Bye
{
clients.at(handle).close();
clients.erase(handle);
- if(clients.size() == 0) {
- send_bye();
- }
}
void Node::handle_client_message(ClientConnections::key_type handle, cmix_proto::CMixMessage message)
diff --git a/node/node.hpp b/node/node.hpp
index 5e3292b..ac379ca 100644
--- a/node/node.hpp
+++ b/node/node.hpp
@@ -56,16 +56,13 @@ class Node
std::vector<uint8_t> network_key;
bool shutting_down;
-
- void send_bye();
-
+
void accept_handler(boost::asio::ip::tcp::socket&& socket);
void start_precomputation();
void start_initialisation();
void handle_node_initialization(cmix_proto::Initialization const& init);
- void handle_node_bye(cmix_proto::Bye);
void handle_node_secretkey(cmix_proto::SecretKey const& secret);
void handle_node_message(cmix_proto::CMixMessage message);