Engine::PluginRet BaseKillPlugin::run()

in src/oomd/plugins/BaseKillPlugin.cpp [81:109]


Engine::PluginRet BaseKillPlugin::run(OomdContext& ctx) {
  KillResult ret;

  if (prekill_hook_state_) {
    ret = resumeFromPrekillHook(ctx);
  } else {
    ret = tryToKillSomething(ctx, ctx.addToCacheAndGet(cgroups_));
  }

  if (ret == KillResult::DEFER) {
    return Engine::PluginRet::ASYNC_PAUSED;
  }

  if (prekill_hook_state_ != std::nullopt) {
    OLOG << "Error: there shouldn't be a running prekill hook"
            " once we're done with a kill cycle";
    prekill_hook_state_ = std::nullopt;
  }

  if (ret == KillResult::FAILED || always_continue_) {
    return Engine::PluginRet::CONTINUE;
  }

  auto ruleset = ctx.getInvokingRuleset();
  if (ruleset && post_action_delay_) {
    (*ruleset)->pause_actions(std::chrono::seconds(*post_action_delay_));
  }
  return Engine::PluginRet::STOP;
}