Commit 16a1f99c authored by ufownl's avatar ufownl

Add kill exit reason

The kill exit reason should kill actors unconditionally, even if they
trap exit messages.
parent 90a18f93
......@@ -66,6 +66,11 @@ static constexpr uint32_t out_of_workers = 0x00007;
*/
static constexpr uint32_t user_shutdown = 0x00010;
/**
* Indicates that the actor was killed unconditionally.
*/
static constexpr uint32_t kill = 0x00011;
/**
* Indicates that an actor finishied execution because a connection
* to a remote link was closed unexpectedly.
......
......@@ -40,6 +40,7 @@ const char* as_string(uint32_t value) {
}
switch (value) {
case user_shutdown: return "user_shutdown";
case kill: return "kill";
case remote_link_unreachable: return "remote_link_unreachable";
default:
if (value < user_defined) {
......
......@@ -219,6 +219,10 @@ msg_type filter_msg(local_actor* self, mailbox_element& node) {
CAF_ASSERT(!mid.valid());
// make sure to get rid of attachables if they're no longer needed
self->unlink_from(em.source);
if (em.reason == exit_reason::kill) {
self->quit(em.reason);
return msg_type::non_normal_exit;
}
if (self->trap_exit() == false) {
if (em.reason != exit_reason::normal) {
self->quit(em.reason);
......@@ -583,15 +587,17 @@ resumable::resume_result local_actor::resume(execution_unit* eu,
bhvr_stack().clear();
bhvr_stack().cleanup();
on_exit();
if (has_behavior()) {
CAF_LOG_DEBUG("on_exit did set a new behavior");
planned_exit_reason(exit_reason::not_exited);
return false; // on_exit did set a new behavior
}
auto rsn = planned_exit_reason();
if (rsn == exit_reason::not_exited) {
rsn = exit_reason::normal;
planned_exit_reason(rsn);
if (rsn != exit_reason::kill) {
if (has_behavior()) {
CAF_LOG_DEBUG("on_exit did set a new behavior");
planned_exit_reason(exit_reason::not_exited);
return false; // on_exit did set a new behavior
}
if (rsn == exit_reason::not_exited) {
rsn = exit_reason::normal;
planned_exit_reason(rsn);
}
}
cleanup(rsn);
return true;
......
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