Commit efe8ce42 authored by Dominik Charousset's avatar Dominik Charousset

Fix response handling in blocking actors

parent 28fb8c9b
......@@ -327,7 +327,8 @@ void blocking_actor::receive_impl(receive_cond& rcc,
timed_out = false;
auto& x = seq.value();
// skip messages that don't match our message ID
if (mid.valid() && mid != x.mid) {
if ((mid.valid() && mid != x.mid)
|| (!mid.valid() && x.mid.is_response())) {
skipped = true;
} else {
// blocking actors can use nested receives => restore current_element_
......
......@@ -452,4 +452,30 @@ CAF_TEST(async_request) {
anon_send(foo, 1);
}
CAF_TEST(skip_responses) {
auto mirror = system.spawn<sync_mirror>();
auto future = self->request(mirror, infinite, 42);
self->send(mirror, 42);
self->receive([](int x) {
CAF_CHECK_EQUAL(x, 42);
});
// second receive must time out
self->receive(
[](int) {
CAF_FAIL("received response message as ordinary message");
},
after(std::chrono::milliseconds(20)) >> [] {
CAF_MESSAGE("second receive timed out as expected");
}
);
future.receive(
[](int x) {
CAF_CHECK_EQUAL(x, 42);
},
[&](const error& err) {
CAF_FAIL(system.render(err));
}
);
}
CAF_TEST_FIXTURE_SCOPE_END()
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