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