Commit 290fc0c5 authored by Dominik Charousset's avatar Dominik Charousset

Fix payload of actor messages

parent 9c26fb25
...@@ -190,26 +190,32 @@ error application::handle_handshake(write_packet_callback&, header hdr, ...@@ -190,26 +190,32 @@ error application::handle_handshake(write_packet_callback&, header hdr,
error application::handle_actor_message(write_packet_callback&, header hdr, error application::handle_actor_message(write_packet_callback&, header hdr,
byte_span payload) { byte_span payload) {
// Deserialize payload. // Deserialize payload.
actor_id src; actor_id src_id;
actor_id dst; node_id src_node;
actor_id dst_id;
std::vector<strong_actor_ptr> fwd_stack; std::vector<strong_actor_ptr> fwd_stack;
message content; message content;
binary_deserializer source{system(), payload}; binary_deserializer source{system(), payload};
if (auto err = source(src, dst, fwd_stack, content)) if (auto err = source(src_node, src_id, dst_id, fwd_stack, content))
return err; return err;
// Sanity checks. // Sanity checks.
if (dst == 0) if (dst_id == 0)
return ec::invalid_payload; return ec::invalid_payload;
// Try to fetch the receiver. // Try to fetch the receiver.
auto src_hdl = system().registry().get(dst); auto dst_hdl = system().registry().get(dst_id);
if (src_hdl == nullptr) { if (dst_hdl == nullptr) {
CAF_LOG_DEBUG("no actor found for given ID, drop message"); CAF_LOG_DEBUG("no actor found for given ID, drop message");
return caf::none; return caf::none;
} }
// Try to fetch the sender.
strong_actor_ptr src_hdl;
if (src_node != none && src_id != 0)
src_hdl = proxies_->get_or_put(src_node, src_id);
// Ship the message. // Ship the message.
src_hdl->get()->eq_impl(make_message_id(hdr.operation_data), auto ptr = make_mailbox_element(std::move(src_hdl),
proxies_->get_or_put(peer_id_, src), nullptr, make_message_id(hdr.operation_data),
std::move(content)); std::move(fwd_stack), std::move(content));
dst_hdl->get()->enqueue(std::move(ptr), nullptr);
return none; return none;
} }
......
...@@ -217,7 +217,7 @@ CAF_TEST(actor message) { ...@@ -217,7 +217,7 @@ CAF_TEST(actor message) {
sys.registry().put(self->id(), self); sys.registry().put(self->id(), self);
CAF_REQUIRE_EQUAL(self->mailbox().size(), 0u); CAF_REQUIRE_EQUAL(self->mailbox().size(), 0u);
MOCK(basp::message_type::actor_message, make_message_id().integer_value(), MOCK(basp::message_type::actor_message, make_message_id().integer_value(),
actor_id{42}, self->id(), std::vector<strong_actor_ptr>{}, mars, actor_id{42}, self->id(), std::vector<strong_actor_ptr>{},
make_message("hello world!")); make_message("hello world!"));
allow((atom_value, strong_actor_ptr), allow((atom_value, strong_actor_ptr),
from(_).to(self).with(atom("monitor"), _)); from(_).to(self).with(atom("monitor"), _));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment