Commit 39333e29 authored by Dominik Charousset's avatar Dominik Charousset

handle invalid_actor in sync send + anon_send_exit

this patch checks in anon_send_exit for invalid_actor and
turns it into a NOP if needed, sync_send throws
std::invalid_argument to have at least a defined behavior
parent bba2acce
......@@ -197,6 +197,10 @@ message_id local_actor::timed_sync_send_tuple_impl(message_priority mp,
const actor& dest,
const util::duration& rtime,
any_tuple&& what) {
if (!dest) {
throw std::invalid_argument("cannot send synchronous message "
"to invalid_actor");
}
auto nri = new_request_id();
if (mp == message_priority::high) nri = nri.with_high_priority();
dest->enqueue({address(), dest, nri}, std::move(what), m_host);
......@@ -209,6 +213,10 @@ message_id local_actor::timed_sync_send_tuple_impl(message_priority mp,
message_id local_actor::sync_send_tuple_impl(message_priority mp,
const actor& dest,
any_tuple&& what) {
if (!dest) {
throw std::invalid_argument("cannot send synchronous message "
"to invalid_actor");
}
auto nri = new_request_id();
if (mp == message_priority::high) nri = nri.with_high_priority();
dest->enqueue({address(), dest, nri}, std::move(what), m_host);
......@@ -216,6 +224,7 @@ message_id local_actor::sync_send_tuple_impl(message_priority mp,
}
void anon_send_exit(const actor_addr& whom, std::uint32_t reason) {
if (!whom) return;
auto ptr = detail::raw_access::get(whom);
ptr->enqueue({invalid_actor_addr, ptr, message_id{}.with_high_priority()},
make_any_tuple(exit_msg{invalid_actor_addr, reason}), nullptr);
......
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