|
|
3d3dc8 |
From 894d307d0d149adb46e630550566e5a3f6ff8d2e Mon Sep 17 00:00:00 2001
|
|
|
3d3dc8 |
From: Lennart Poettering <lennart@poettering.net>
|
|
|
3d3dc8 |
Date: Mon, 18 Mar 2019 12:21:27 +0100
|
|
|
3d3dc8 |
Subject: [PATCH] core: rename unit_{start_limit|condition|assert}_test() to
|
|
|
3d3dc8 |
unit_test_xyz()
|
|
|
3d3dc8 |
|
|
|
3d3dc8 |
Just some renaming, no change in behaviour.
|
|
|
3d3dc8 |
|
|
|
3d3dc8 |
Background: I'd like to add more functions unit_test_xyz() that test
|
|
|
3d3dc8 |
various things, hence let's streamline the naming a bit.
|
|
|
3d3dc8 |
|
|
|
3d3dc8 |
(cherry picked from commit 97a3f4ee052e1b8a0ff03accfa478e352891a84f)
|
|
|
3d3dc8 |
|
|
|
3d3dc8 |
Related: #2036608
|
|
|
3d3dc8 |
---
|
|
|
3d3dc8 |
src/core/automount.c | 2 +-
|
|
|
3d3dc8 |
src/core/mount.c | 2 +-
|
|
|
3d3dc8 |
src/core/path.c | 2 +-
|
|
|
3d3dc8 |
src/core/service.c | 2 +-
|
|
|
3d3dc8 |
src/core/socket.c | 2 +-
|
|
|
3d3dc8 |
src/core/swap.c | 2 +-
|
|
|
3d3dc8 |
src/core/timer.c | 2 +-
|
|
|
3d3dc8 |
src/core/unit.c | 11 +++++------
|
|
|
3d3dc8 |
src/core/unit.h | 2 +-
|
|
|
3d3dc8 |
9 files changed, 13 insertions(+), 14 deletions(-)
|
|
|
3d3dc8 |
|
|
|
3d3dc8 |
diff --git a/src/core/automount.c b/src/core/automount.c
|
|
|
3d3dc8 |
index 76e70f4dac..2bc160cb07 100644
|
|
|
3d3dc8 |
--- a/src/core/automount.c
|
|
|
3d3dc8 |
+++ b/src/core/automount.c
|
|
|
3d3dc8 |
@@ -808,7 +808,7 @@ static int automount_start(Unit *u) {
|
|
|
3d3dc8 |
return -ENOENT;
|
|
|
3d3dc8 |
}
|
|
|
3d3dc8 |
|
|
|
3d3dc8 |
- r = unit_start_limit_test(u);
|
|
|
3d3dc8 |
+ r = unit_test_start_limit(u);
|
|
|
3d3dc8 |
if (r < 0) {
|
|
|
3d3dc8 |
automount_enter_dead(a, AUTOMOUNT_FAILURE_START_LIMIT_HIT);
|
|
|
3d3dc8 |
return r;
|
|
|
3d3dc8 |
diff --git a/src/core/mount.c b/src/core/mount.c
|
|
|
3d3dc8 |
index 7e80a0c974..aa586d88cb 100644
|
|
|
3d3dc8 |
--- a/src/core/mount.c
|
|
|
3d3dc8 |
+++ b/src/core/mount.c
|
|
|
3d3dc8 |
@@ -1065,7 +1065,7 @@ static int mount_start(Unit *u) {
|
|
|
3d3dc8 |
|
|
|
3d3dc8 |
assert(IN_SET(m->state, MOUNT_DEAD, MOUNT_FAILED));
|
|
|
3d3dc8 |
|
|
|
3d3dc8 |
- r = unit_start_limit_test(u);
|
|
|
3d3dc8 |
+ r = unit_test_start_limit(u);
|
|
|
3d3dc8 |
if (r < 0) {
|
|
|
3d3dc8 |
mount_enter_dead(m, MOUNT_FAILURE_START_LIMIT_HIT);
|
|
|
3d3dc8 |
return r;
|
|
|
3d3dc8 |
diff --git a/src/core/path.c b/src/core/path.c
|
|
|
3d3dc8 |
index ed40bc6c19..4bccc0396b 100644
|
|
|
3d3dc8 |
--- a/src/core/path.c
|
|
|
3d3dc8 |
+++ b/src/core/path.c
|
|
|
3d3dc8 |
@@ -565,7 +565,7 @@ static int path_start(Unit *u) {
|
|
|
3d3dc8 |
return -ENOENT;
|
|
|
3d3dc8 |
}
|
|
|
3d3dc8 |
|
|
|
3d3dc8 |
- r = unit_start_limit_test(u);
|
|
|
3d3dc8 |
+ r = unit_test_start_limit(u);
|
|
|
3d3dc8 |
if (r < 0) {
|
|
|
3d3dc8 |
path_enter_dead(p, PATH_FAILURE_START_LIMIT_HIT);
|
|
|
3d3dc8 |
return r;
|
|
|
3d3dc8 |
diff --git a/src/core/service.c b/src/core/service.c
|
|
|
3d3dc8 |
index 7969bbf071..1a1de43d0d 100644
|
|
|
3d3dc8 |
--- a/src/core/service.c
|
|
|
3d3dc8 |
+++ b/src/core/service.c
|
|
|
3d3dc8 |
@@ -2388,7 +2388,7 @@ static int service_start(Unit *u) {
|
|
|
3d3dc8 |
assert(IN_SET(s->state, SERVICE_DEAD, SERVICE_FAILED));
|
|
|
3d3dc8 |
|
|
|
3d3dc8 |
/* Make sure we don't enter a busy loop of some kind. */
|
|
|
3d3dc8 |
- r = unit_start_limit_test(u);
|
|
|
3d3dc8 |
+ r = unit_test_start_limit(u);
|
|
|
3d3dc8 |
if (r < 0) {
|
|
|
3d3dc8 |
service_enter_dead(s, SERVICE_FAILURE_START_LIMIT_HIT, false);
|
|
|
3d3dc8 |
return r;
|
|
|
3d3dc8 |
diff --git a/src/core/socket.c b/src/core/socket.c
|
|
|
3d3dc8 |
index 50c32ed8f4..09491c6677 100644
|
|
|
3d3dc8 |
--- a/src/core/socket.c
|
|
|
3d3dc8 |
+++ b/src/core/socket.c
|
|
|
3d3dc8 |
@@ -2469,7 +2469,7 @@ static int socket_start(Unit *u) {
|
|
|
3d3dc8 |
|
|
|
3d3dc8 |
assert(IN_SET(s->state, SOCKET_DEAD, SOCKET_FAILED));
|
|
|
3d3dc8 |
|
|
|
3d3dc8 |
- r = unit_start_limit_test(u);
|
|
|
3d3dc8 |
+ r = unit_test_start_limit(u);
|
|
|
3d3dc8 |
if (r < 0) {
|
|
|
3d3dc8 |
socket_enter_dead(s, SOCKET_FAILURE_START_LIMIT_HIT);
|
|
|
3d3dc8 |
return r;
|
|
|
3d3dc8 |
diff --git a/src/core/swap.c b/src/core/swap.c
|
|
|
3d3dc8 |
index a8f127f660..823699699e 100644
|
|
|
3d3dc8 |
--- a/src/core/swap.c
|
|
|
3d3dc8 |
+++ b/src/core/swap.c
|
|
|
3d3dc8 |
@@ -851,7 +851,7 @@ static int swap_start(Unit *u) {
|
|
|
3d3dc8 |
if (UNIT(other)->job && UNIT(other)->job->state == JOB_RUNNING)
|
|
|
3d3dc8 |
return -EAGAIN;
|
|
|
3d3dc8 |
|
|
|
3d3dc8 |
- r = unit_start_limit_test(u);
|
|
|
3d3dc8 |
+ r = unit_test_start_limit(u);
|
|
|
3d3dc8 |
if (r < 0) {
|
|
|
3d3dc8 |
swap_enter_dead(s, SWAP_FAILURE_START_LIMIT_HIT);
|
|
|
3d3dc8 |
return r;
|
|
|
3d3dc8 |
diff --git a/src/core/timer.c b/src/core/timer.c
|
|
|
3d3dc8 |
index 1718ffc5a5..be16321296 100644
|
|
|
3d3dc8 |
--- a/src/core/timer.c
|
|
|
3d3dc8 |
+++ b/src/core/timer.c
|
|
|
3d3dc8 |
@@ -599,7 +599,7 @@ static int timer_start(Unit *u) {
|
|
|
3d3dc8 |
return -ENOENT;
|
|
|
3d3dc8 |
}
|
|
|
3d3dc8 |
|
|
|
3d3dc8 |
- r = unit_start_limit_test(u);
|
|
|
3d3dc8 |
+ r = unit_test_start_limit(u);
|
|
|
3d3dc8 |
if (r < 0) {
|
|
|
3d3dc8 |
timer_enter_dead(t, TIMER_FAILURE_START_LIMIT_HIT);
|
|
|
3d3dc8 |
return r;
|
|
|
3d3dc8 |
diff --git a/src/core/unit.c b/src/core/unit.c
|
|
|
3d3dc8 |
index 23afa24c77..9013186d8a 100644
|
|
|
3d3dc8 |
--- a/src/core/unit.c
|
|
|
3d3dc8 |
+++ b/src/core/unit.c
|
|
|
3d3dc8 |
@@ -1633,7 +1633,7 @@ static bool unit_condition_test_list(Unit *u, Condition *first, const char *(*to
|
|
|
3d3dc8 |
return triggered != 0;
|
|
|
3d3dc8 |
}
|
|
|
3d3dc8 |
|
|
|
3d3dc8 |
-static bool unit_condition_test(Unit *u) {
|
|
|
3d3dc8 |
+static bool unit_test_condition(Unit *u) {
|
|
|
3d3dc8 |
assert(u);
|
|
|
3d3dc8 |
|
|
|
3d3dc8 |
dual_timestamp_get(&u->condition_timestamp);
|
|
|
3d3dc8 |
@@ -1642,7 +1642,7 @@ static bool unit_condition_test(Unit *u) {
|
|
|
3d3dc8 |
return u->condition_result;
|
|
|
3d3dc8 |
}
|
|
|
3d3dc8 |
|
|
|
3d3dc8 |
-static bool unit_assert_test(Unit *u) {
|
|
|
3d3dc8 |
+static bool unit_test_assert(Unit *u) {
|
|
|
3d3dc8 |
assert(u);
|
|
|
3d3dc8 |
|
|
|
3d3dc8 |
dual_timestamp_get(&u->assert_timestamp);
|
|
|
3d3dc8 |
@@ -1657,8 +1657,7 @@ void unit_status_printf(Unit *u, const char *status, const char *unit_status_msg
|
|
|
3d3dc8 |
REENABLE_WARNING;
|
|
|
3d3dc8 |
}
|
|
|
3d3dc8 |
|
|
|
3d3dc8 |
-
|
|
|
3d3dc8 |
-int unit_start_limit_test(Unit *u) {
|
|
|
3d3dc8 |
+int unit_test_start_limit(Unit *u) {
|
|
|
3d3dc8 |
assert(u);
|
|
|
3d3dc8 |
|
|
|
3d3dc8 |
if (ratelimit_below(&u->start_limit)) {
|
|
|
3d3dc8 |
@@ -1750,14 +1749,14 @@ int unit_start(Unit *u) {
|
|
|
3d3dc8 |
* speed up activation in case there is some hold-off time,
|
|
|
3d3dc8 |
* but we don't want to recheck the condition in that case. */
|
|
|
3d3dc8 |
if (state != UNIT_ACTIVATING &&
|
|
|
3d3dc8 |
- !unit_condition_test(u)) {
|
|
|
3d3dc8 |
+ !unit_test_condition(u)) {
|
|
|
3d3dc8 |
log_unit_debug(u, "Starting requested but condition failed. Not starting unit.");
|
|
|
3d3dc8 |
return -EALREADY;
|
|
|
3d3dc8 |
}
|
|
|
3d3dc8 |
|
|
|
3d3dc8 |
/* If the asserts failed, fail the entire job */
|
|
|
3d3dc8 |
if (state != UNIT_ACTIVATING &&
|
|
|
3d3dc8 |
- !unit_assert_test(u)) {
|
|
|
3d3dc8 |
+ !unit_test_assert(u)) {
|
|
|
3d3dc8 |
log_unit_notice(u, "Starting requested but asserts failed.");
|
|
|
3d3dc8 |
return -EPROTO;
|
|
|
3d3dc8 |
}
|
|
|
3d3dc8 |
diff --git a/src/core/unit.h b/src/core/unit.h
|
|
|
3d3dc8 |
index ec45b5fb48..a8bc350b66 100644
|
|
|
3d3dc8 |
--- a/src/core/unit.h
|
|
|
3d3dc8 |
+++ b/src/core/unit.h
|
|
|
3d3dc8 |
@@ -786,7 +786,7 @@ static inline bool unit_supported(Unit *u) {
|
|
|
3d3dc8 |
void unit_warn_if_dir_nonempty(Unit *u, const char* where);
|
|
|
3d3dc8 |
int unit_fail_if_noncanonical(Unit *u, const char* where);
|
|
|
3d3dc8 |
|
|
|
3d3dc8 |
-int unit_start_limit_test(Unit *u);
|
|
|
3d3dc8 |
+int unit_test_start_limit(Unit *u);
|
|
|
3d3dc8 |
|
|
|
3d3dc8 |
void unit_unref_uid(Unit *u, bool destroy_now);
|
|
|
3d3dc8 |
int unit_ref_uid(Unit *u, uid_t uid, bool clean_ipc);
|