Skip to content

Commit

Permalink
Catch exception of DeserializeNodes
Browse files Browse the repository at this point in the history
Fix calls to DeserializeNodes. They must
catch possible exceptions

Signed-off-by: Lucas Dias <[email protected]>
  • Loading branch information
lucassdiass authored and aberaud committed Dec 17, 2024
1 parent 7c184e1 commit 83ae498
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/network_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,13 @@ NetworkEngine::process(std::unique_ptr<ParsedMessage>&& msg, const SockAddr& fro
throw DhtProtocolException {DhtProtocolException::UNKNOWN_TID, "Can't find socket", msg->id};
node->received(now, {});
onNewNode(node, 2);
deserializeNodes(*msg, from);
rsocket->on_receive(node, std::move(*msg));
try {
deserializeNodes(*msg, from);
rsocket->on_receive(node, std::move(*msg));
} catch (const DhtProtocolException& e) {
if (logger_)
logger_->w("Can't deserialize nodes %s", e.what());
}
}
else if (msg->type == MessageType::Error or msg->type == MessageType::Reply) {
auto rsocket = node->getSocket(msg->tid);
Expand Down Expand Up @@ -590,13 +595,22 @@ NetworkEngine::process(std::unique_ptr<ParsedMessage>&& msg, const SockAddr& fro
r.node->authSuccess();
}
r.reply_time = scheduler.time();

deserializeNodes(*msg, from);
r.setDone(std::move(*msg));
try {
deserializeNodes(*msg, from);
r.setDone(std::move(*msg));
} catch (const DhtProtocolException& e) {
if (logger_)
logger_->w("Can't deserialize nodes %s", e.what());
}
break;
} else { /* request socket data */
deserializeNodes(*msg, from);
rsocket->on_receive(node, std::move(*msg));
try {
deserializeNodes(*msg, from);
rsocket->on_receive(node, std::move(*msg));
} catch (const DhtProtocolException& e) {
if (logger_)
logger_->w("Can't deserialize nodes %s", e.what());
}
}
break;
default:
Expand Down

0 comments on commit 83ae498

Please sign in to comment.