Commit ecd5abc4 authored by Dominik Charousset's avatar Dominik Charousset

Fix handling of spawn requests to the local node

parent 40a769a5
......@@ -148,16 +148,29 @@ auto middleman_actor_impl::make_behavior() -> behavior_type {
delegate(broker_, atm, p);
return {};
},
[=](spawn_atom atm, node_id& nid, std::string& str, message& msg,
std::set<std::string>& ifs) -> delegated<strong_actor_ptr> {
[=](spawn_atom atm, node_id& nid, std::string& name, message& args,
std::set<std::string>& ifs) -> result<strong_actor_ptr> {
CAF_LOG_TRACE("");
if (!nid)
return make_error(sec::invalid_argument,
"cannot spawn actors on invalid nodes");
if (name.empty())
return make_error(sec::invalid_argument,
"cannot spawn actors without a type name");
if (nid == system().node()) {
if (auto res = system().spawn<actor>(name, std::move(args), nullptr,
true, &ifs))
return actor_cast<strong_actor_ptr>(std::move(*res));
else
return std::move(res.error());
}
// This local variable prevents linker errors (delegate forms an lvalue
// reference but spawn_server_id is constexpr).
auto id = basp::header::spawn_server_id;
delegate(broker_, forward_atom_v, nid, id,
make_message(atm, std::move(str), std::move(msg),
make_message(atm, std::move(name), std::move(args),
std::move(ifs)));
return {};
return delegated<strong_actor_ptr>{};
},
[=](get_atom atm,
node_id nid) -> delegated<node_id, std::string, uint16_t> {
......
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