Commit 47b6cbc9 authored by Dominik Charousset's avatar Dominik Charousset

fixed nullptr exception in

parent cf31a46a
...@@ -63,13 +63,20 @@ void default_protocol::publish(const actor_ptr& whom, variant_args args) { ...@@ -63,13 +63,20 @@ void default_protocol::publish(const actor_ptr& whom, variant_args args) {
CPPA_LOG_TRACE("whom: " << to_string(whom) CPPA_LOG_TRACE("whom: " << to_string(whom)
<< ", args.size() = " << args.size()); << ", args.size() = " << args.size());
if (!whom) return; if (!whom) return;
CPPA_REQUIRE(args.size() == 2); CPPA_REQUIRE(args.size() == 2 || args.size() == 1);
auto i = args.begin(); auto i = args.begin();
auto port = get<uint16_t>(*i++); if (args.size() == 1) {
auto& addr = get<string>(*i); auto port = get<uint16_t>(*i++);
publish(whom, publish(whom,
unique_ptr<acceptor>(ipv4_acceptor::create(port, addr.c_str())), unique_ptr<acceptor>(ipv4_acceptor::create(port, nullptr)),
{}); {});
}
else if (args.size() == 2) {
auto port = get<uint16_t>(*i++);
auto& addr = get<string>(*i);
publish(whom, unique_ptr<acceptor>(ipv4_acceptor::create(port, addr.c_str())), {});
}
else throw logic_error("wrong number of arguments, expected one or two");
} }
void default_protocol::publish(const actor_ptr& whom, void default_protocol::publish(const actor_ptr& whom,
......
...@@ -76,7 +76,8 @@ actor_ptr remote_actor(io_stream_ptr_pair io) { ...@@ -76,7 +76,8 @@ actor_ptr remote_actor(io_stream_ptr_pair io) {
} }
void publish(actor_ptr whom, std::uint16_t port, const char* addr) { void publish(actor_ptr whom, std::uint16_t port, const char* addr) {
proto()->publish(whom, {port, addr}); if (!addr) proto()->publish(whom, {port});
else proto()->publish(whom, {port, addr});
} }
actor_ptr remote_actor(const char* host, std::uint16_t port) { actor_ptr remote_actor(const char* host, std::uint16_t port) {
......
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