Commit 44de1c92 authored by Dominik Charousset's avatar Dominik Charousset

Fix false warning when using response promises

parent 0c4ebcfe
......@@ -174,7 +174,10 @@ class invoke_policy {
if (res->empty()) {
// make sure synchronous requests always receive a response;
// note: !current_element() means client has forwarded the request
if (self->current_element() && mid.is_request() && !mid.is_answered()) {
auto& ptr = self->current_element();
if (ptr) {
mid = ptr->mid;
if (mid.is_request() && !mid.is_answered()) {
CAF_LOG_WARNING("actor with ID " << self->id()
<< " did not reply to a synchronous request message");
auto fhdl = fetch_response_promise(self, hdl);
......@@ -182,11 +185,11 @@ class invoke_policy {
fhdl.deliver(make_message(unit));
}
}
} else {
}
return res;
}
CAF_LOGF_DEBUG("res = " << to_string(*res));
if (res->size() == 2
&& res->match_element(0, detail::type_nr<atom_value>::value, nullptr)
&& res->match_element(1, detail::type_nr<uint64_t>::value, nullptr)
if (res->template match_elements<atom_value, uint64_t>()
&& res->template get_as<atom_value>(0) == atom("MESSAGE_ID")) {
CAF_LOG_DEBUG("message handler returned a message id wrapper");
auto id = res->template get_as<uint64_t>(1);
......@@ -208,17 +211,16 @@ class invoke_policy {
}
);
}
} else {
return res;
}
// respond by using the result of 'fun'
CAF_LOG_DEBUG("respond via response_promise");
auto fhdl = fetch_response_promise(self, hdl);
if (fhdl) {
fhdl.deliver(std::move(*res));
// inform caller about success
// inform caller about success by returning not none
return message{};
}
}
}
return res;
}
......
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