Skip to content

Commit

Permalink
Fix handling of system messages when using await
Browse files Browse the repository at this point in the history
This is a backport of the upstream fix for CAF 0.19.x[^1].

[^1]: actor-framework@30e6e94
  • Loading branch information
dominiklohmann committed Oct 9, 2023
1 parent 70999f4 commit 8f9c40c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions libcaf_core/src/scheduled_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,9 +676,19 @@ invoke_message_result scheduled_actor::consume(mailbox_element& x) {
if (!awaited_responses_.empty()) {
auto invoke = select_invoke_fun();
auto& pr = awaited_responses_.front();
// skip all messages until we receive the currently awaited response
if (x.mid != pr.first)
// Skip all other messages until we receive the currently awaited response
// except for internal (system) messages.
if (x.mid != pr.first) {
// Responses are never internal messages and must be skipped here.
// Otherwise, an error to a response would run into the default handler.
if (x.mid.is_response())
return invoke_message_result::skipped;
if (categorize(x) == message_category::internal) {
CAF_LOG_DEBUG("handled system message");
return invoke_message_result::consumed;
}
return invoke_message_result::skipped;
}
auto f = std::move(pr.second);
awaited_responses_.pop_front();
if (!invoke(this, f, x)) {
Expand Down

0 comments on commit 8f9c40c

Please sign in to comment.