mirror of
https://github.com/systemd/systemd.git
synced 2024-10-27 10:25:37 +03:00
core: change emergency_action() to return void
The function so far always returned -ECANCELLED, which is ignored in all cases the function is invoked, except one: in unit_test_start_limit() where -ECANCELLED is returned when the start limit is hit, which is part of unit_start()'s protocol of return values. Since the emergency_action() logic should be relatively generic and is used in many places, let's drop the return value from it, since it's constant anyway, and in alll cases useless. Instead, let's return it in unit_test_start_limit(), where it's part of the protocol. No change in behaviour.
This commit is contained in:
parent
2de9b9793b
commit
36c4dc089e
@ -20,7 +20,7 @@ static void log_and_status(Manager *m, bool warn, const char *message, const cha
|
|||||||
"%s: %s", message, reason);
|
"%s: %s", message, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
int emergency_action(
|
void emergency_action(
|
||||||
Manager *m,
|
Manager *m,
|
||||||
EmergencyAction action,
|
EmergencyAction action,
|
||||||
EmergencyActionFlags options,
|
EmergencyActionFlags options,
|
||||||
@ -33,11 +33,11 @@ int emergency_action(
|
|||||||
assert(action < _EMERGENCY_ACTION_MAX);
|
assert(action < _EMERGENCY_ACTION_MAX);
|
||||||
|
|
||||||
if (action == EMERGENCY_ACTION_NONE)
|
if (action == EMERGENCY_ACTION_NONE)
|
||||||
return -ECANCELED;
|
return;
|
||||||
|
|
||||||
if (FLAGS_SET(options, EMERGENCY_ACTION_IS_WATCHDOG) && !m->service_watchdogs) {
|
if (FLAGS_SET(options, EMERGENCY_ACTION_IS_WATCHDOG) && !m->service_watchdogs) {
|
||||||
log_warning("Watchdog disabled! Not acting on: %s", reason);
|
log_warning("Watchdog disabled! Not acting on: %s", reason);
|
||||||
return -ECANCELED;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool warn = FLAGS_SET(options, EMERGENCY_ACTION_WARN);
|
bool warn = FLAGS_SET(options, EMERGENCY_ACTION_WARN);
|
||||||
@ -125,8 +125,6 @@ int emergency_action(
|
|||||||
default:
|
default:
|
||||||
assert_not_reached("Unknown emergency action");
|
assert_not_reached("Unknown emergency action");
|
||||||
}
|
}
|
||||||
|
|
||||||
return -ECANCELED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* const emergency_action_table[_EMERGENCY_ACTION_MAX] = {
|
static const char* const emergency_action_table[_EMERGENCY_ACTION_MAX] = {
|
||||||
|
@ -24,9 +24,9 @@ typedef enum EmergencyActionFlags {
|
|||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
#include "manager.h"
|
#include "manager.h"
|
||||||
|
|
||||||
int emergency_action(Manager *m,
|
void emergency_action(Manager *m,
|
||||||
EmergencyAction action, EmergencyActionFlags options,
|
EmergencyAction action, EmergencyActionFlags options,
|
||||||
const char *reboot_arg, int exit_status, const char *reason);
|
const char *reboot_arg, int exit_status, const char *reason);
|
||||||
|
|
||||||
const char* emergency_action_to_string(EmergencyAction i) _const_;
|
const char* emergency_action_to_string(EmergencyAction i) _const_;
|
||||||
EmergencyAction emergency_action_from_string(const char *s) _pure_;
|
EmergencyAction emergency_action_from_string(const char *s) _pure_;
|
||||||
|
@ -1682,9 +1682,11 @@ int unit_test_start_limit(Unit *u) {
|
|||||||
|
|
||||||
reason = strjoina("unit ", u->id, " failed");
|
reason = strjoina("unit ", u->id, " failed");
|
||||||
|
|
||||||
return emergency_action(u->manager, u->start_limit_action,
|
emergency_action(u->manager, u->start_limit_action,
|
||||||
EMERGENCY_ACTION_IS_WATCHDOG|EMERGENCY_ACTION_WARN,
|
EMERGENCY_ACTION_IS_WATCHDOG|EMERGENCY_ACTION_WARN,
|
||||||
u->reboot_arg, -1, reason);
|
u->reboot_arg, -1, reason);
|
||||||
|
|
||||||
|
return -ECANCELED;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool unit_shall_confirm_spawn(Unit *u) {
|
bool unit_shall_confirm_spawn(Unit *u) {
|
||||||
@ -2511,10 +2513,10 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, UnitNotifyFlag
|
|||||||
|
|
||||||
if (os != UNIT_FAILED && ns == UNIT_FAILED) {
|
if (os != UNIT_FAILED && ns == UNIT_FAILED) {
|
||||||
reason = strjoina("unit ", u->id, " failed");
|
reason = strjoina("unit ", u->id, " failed");
|
||||||
(void) emergency_action(m, u->failure_action, 0, u->reboot_arg, unit_failure_action_exit_status(u), reason);
|
emergency_action(m, u->failure_action, 0, u->reboot_arg, unit_failure_action_exit_status(u), reason);
|
||||||
} else if (!UNIT_IS_INACTIVE_OR_FAILED(os) && ns == UNIT_INACTIVE) {
|
} else if (!UNIT_IS_INACTIVE_OR_FAILED(os) && ns == UNIT_INACTIVE) {
|
||||||
reason = strjoina("unit ", u->id, " succeeded");
|
reason = strjoina("unit ", u->id, " succeeded");
|
||||||
(void) emergency_action(m, u->success_action, 0, u->reboot_arg, unit_success_action_exit_status(u), reason);
|
emergency_action(m, u->success_action, 0, u->reboot_arg, unit_success_action_exit_status(u), reason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user