Unverified Commit b7d4f4be authored by Dominik Charousset's avatar Dominik Charousset Committed by GitHub

Merge pull request #1069

Fix handling of spawn requests to the local node
parents 1d2b18e4 ecd5abc4
...@@ -148,16 +148,29 @@ auto middleman_actor_impl::make_behavior() -> behavior_type { ...@@ -148,16 +148,29 @@ auto middleman_actor_impl::make_behavior() -> behavior_type {
delegate(broker_, atm, p); delegate(broker_, atm, p);
return {}; return {};
}, },
[=](spawn_atom atm, node_id& nid, std::string& str, message& msg, [=](spawn_atom atm, node_id& nid, std::string& name, message& args,
std::set<std::string>& ifs) -> delegated<strong_actor_ptr> { std::set<std::string>& ifs) -> result<strong_actor_ptr> {
CAF_LOG_TRACE(""); 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 // This local variable prevents linker errors (delegate forms an lvalue
// reference but spawn_server_id is constexpr). // reference but spawn_server_id is constexpr).
auto id = basp::header::spawn_server_id; auto id = basp::header::spawn_server_id;
delegate(broker_, forward_atom_v, nid, 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))); std::move(ifs)));
return {}; return delegated<strong_actor_ptr>{};
}, },
[=](get_atom atm, [=](get_atom atm,
node_id nid) -> delegated<node_id, std::string, uint16_t> { 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