[systemd-commits] 3 commits - src/core src/sysv-generator src/test
Lennart Poettering
lennart at kemper.freedesktop.org
Wed Jan 28 06:19:08 PST 2015
src/core/automount.c | 4 ++--
src/core/busname.c | 4 ++--
src/core/mount.c | 4 ++--
src/core/path.c | 4 ++--
src/core/scope.c | 4 ++--
src/core/service.c | 4 ++--
src/core/slice.c | 4 ++--
src/core/snapshot.c | 4 ++--
src/core/socket.c | 4 ++--
src/core/swap.c | 4 ++--
src/core/target.c | 4 ++--
src/core/timer.c | 4 ++--
src/core/unit.c | 36 +++++++++++++++++++++++++-----------
src/sysv-generator/sysv-generator.c | 12 ++++--------
src/test/test-list.c | 14 ++++++++++++++
15 files changed, 67 insertions(+), 43 deletions(-)
New commits:
commit 3315f085178f46155fda345d9526c09083b45946
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Jan 28 15:11:49 2015 +0100
sysv-generator: no need to check for identical symlinks source and target twice
http://lists.freedesktop.org/archives/systemd-devel/2015-January/027594.html
diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c
index 662d08c..673f04d 100644
--- a/src/sysv-generator/sysv-generator.c
+++ b/src/sysv-generator/sysv-generator.c
@@ -119,11 +119,6 @@ static int add_alias(const char *service, const char *alias) {
assert(service);
assert(alias);
- if (streq(service, alias)) {
- log_error("Ignoring creation of an alias %s for itself", service);
- return 0;
- }
-
link = strjoin(arg_dest, "/", alias, NULL);
if (!link)
return log_oom();
@@ -300,8 +295,10 @@ static int sysv_translate_facility(const char *name, const char *filename, char
/* strip ".sh" suffix from file name for comparison */
filename_no_sh = strdupa(filename);
e = endswith(filename_no_sh, ".sh");
- if (e)
+ if (e) {
*e = '\0';
+ filename = filename_no_sh;
+ }
/* If we don't know this name, fallback heuristics to figure
* out whether something is a target or a service alias. */
@@ -312,13 +309,12 @@ static int sysv_translate_facility(const char *name, const char *filename, char
/* Facilities starting with $ are most likely targets */
r = unit_name_build(n, NULL, ".target");
- } else if (filename && streq(name, filename_no_sh))
+ } else if (streq_ptr(n, filename))
/* Names equaling the file name of the services are redundant */
return 0;
else
/* Everything else we assume to be normal service names */
r = sysv_translate_name(n);
-
if (!r)
return -ENOMEM;
commit 82a2b6bb5e4e5d294f09af778c48974a7857afb6
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Jan 28 15:07:13 2015 +0100
core: output unit status output strings to console, only if we actually are changing unit state
Unit _start() and _stop() implementations can fail with -EAGAIN to delay
execution temporarily. Thus, we should not output status messages before
invoking these calls, but after, and only when we know that the
invocation actually made a change.
diff --git a/src/core/automount.c b/src/core/automount.c
index 51f7373..d47e6fa 100644
--- a/src/core/automount.c
+++ b/src/core/automount.c
@@ -603,7 +603,7 @@ static int automount_start(Unit *u) {
a->result = AUTOMOUNT_SUCCESS;
automount_enter_waiting(a);
- return 0;
+ return 1;
}
static int automount_stop(Unit *u) {
@@ -613,7 +613,7 @@ static int automount_stop(Unit *u) {
assert(a->state == AUTOMOUNT_WAITING || a->state == AUTOMOUNT_RUNNING);
automount_enter_dead(a, AUTOMOUNT_SUCCESS);
- return 0;
+ return 1;
}
static int automount_serialize(Unit *u, FILE *f, FDSet *fds) {
diff --git a/src/core/busname.c b/src/core/busname.c
index 00e5668..ca9ceb8 100644
--- a/src/core/busname.c
+++ b/src/core/busname.c
@@ -615,7 +615,7 @@ static int busname_start(Unit *u) {
n->result = BUSNAME_SUCCESS;
busname_enter_making(n);
- return 0;
+ return 1;
}
static int busname_stop(Unit *u) {
@@ -638,7 +638,7 @@ static int busname_stop(Unit *u) {
assert(IN_SET(n->state, BUSNAME_REGISTERED, BUSNAME_LISTENING, BUSNAME_RUNNING));
busname_enter_dead(n, BUSNAME_SUCCESS);
- return 0;
+ return 1;
}
static int busname_serialize(Unit *u, FILE *f, FDSet *fds) {
diff --git a/src/core/mount.c b/src/core/mount.c
index f944c02..6bd6914 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -1037,7 +1037,7 @@ static int mount_start(Unit *u) {
m->reload_result = MOUNT_SUCCESS;
mount_enter_mounting(m);
- return 0;
+ return 1;
}
static int mount_stop(Unit *u) {
@@ -1061,7 +1061,7 @@ static int mount_stop(Unit *u) {
m->state == MOUNT_REMOUNTING_SIGKILL);
mount_enter_unmounting(m);
- return 0;
+ return 1;
}
static int mount_reload(Unit *u) {
diff --git a/src/core/path.c b/src/core/path.c
index 0fdf483..e5ea79f 100644
--- a/src/core/path.c
+++ b/src/core/path.c
@@ -572,7 +572,7 @@ static int path_start(Unit *u) {
p->result = PATH_SUCCESS;
path_enter_waiting(p, true, true);
- return 0;
+ return 1;
}
static int path_stop(Unit *u) {
@@ -582,7 +582,7 @@ static int path_stop(Unit *u) {
assert(p->state == PATH_WAITING || p->state == PATH_RUNNING);
path_enter_dead(p, PATH_SUCCESS);
- return 0;
+ return 1;
}
static int path_serialize(Unit *u, FILE *f, FDSet *fds) {
diff --git a/src/core/scope.c b/src/core/scope.c
index e0da6e4..b41db78 100644
--- a/src/core/scope.c
+++ b/src/core/scope.c
@@ -295,7 +295,7 @@ static int scope_start(Unit *u) {
s->result = SCOPE_SUCCESS;
scope_set_state(s, SCOPE_RUNNING);
- return 0;
+ return 1;
}
static int scope_stop(Unit *u) {
@@ -311,7 +311,7 @@ static int scope_stop(Unit *u) {
s->state == SCOPE_ABANDONED);
scope_enter_signal(s, SCOPE_STOP_SIGTERM, SCOPE_SUCCESS);
- return 0;
+ return 1;
}
static void scope_reset_failed(Unit *u) {
diff --git a/src/core/service.c b/src/core/service.c
index 120510c..15a2ed7 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -1837,7 +1837,7 @@ static int service_start(Unit *u) {
s->notify_state = NOTIFY_UNKNOWN;
service_enter_start_pre(s);
- return 0;
+ return 1;
}
static int service_stop(Unit *u) {
@@ -1878,7 +1878,7 @@ static int service_stop(Unit *u) {
s->state == SERVICE_EXITED);
service_enter_stop(s, SERVICE_SUCCESS);
- return 0;
+ return 1;
}
static int service_reload(Unit *u) {
diff --git a/src/core/slice.c b/src/core/slice.c
index a31e629..ae9819d 100644
--- a/src/core/slice.c
+++ b/src/core/slice.c
@@ -187,7 +187,7 @@ static int slice_start(Unit *u) {
unit_realize_cgroup(u);
slice_set_state(t, SLICE_ACTIVE);
- return 0;
+ return 1;
}
static int slice_stop(Unit *u) {
@@ -200,7 +200,7 @@ static int slice_stop(Unit *u) {
* unit_notify() will do that for us anyway. */
slice_set_state(t, SLICE_DEAD);
- return 0;
+ return 1;
}
static int slice_kill(Unit *u, KillWho who, int signo, sd_bus_error *error) {
diff --git a/src/core/snapshot.c b/src/core/snapshot.c
index 068a077..b70c3be 100644
--- a/src/core/snapshot.c
+++ b/src/core/snapshot.c
@@ -111,7 +111,7 @@ static int snapshot_start(Unit *u) {
if (s->cleanup)
unit_add_to_cleanup_queue(u);
- return 0;
+ return 1;
}
static int snapshot_stop(Unit *u) {
@@ -121,7 +121,7 @@ static int snapshot_stop(Unit *u) {
assert(s->state == SNAPSHOT_ACTIVE);
snapshot_set_state(s, SNAPSHOT_DEAD);
- return 0;
+ return 1;
}
static int snapshot_serialize(Unit *u, FILE *f, FDSet *fds) {
diff --git a/src/core/socket.c b/src/core/socket.c
index b671fff..85f7f16 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -1954,7 +1954,7 @@ static int socket_start(Unit *u) {
s->result = SOCKET_SUCCESS;
socket_enter_start_pre(s);
- return 0;
+ return 1;
}
static int socket_stop(Unit *u) {
@@ -1985,7 +1985,7 @@ static int socket_stop(Unit *u) {
assert(s->state == SOCKET_LISTENING || s->state == SOCKET_RUNNING);
socket_enter_stop_pre(s, SOCKET_SUCCESS);
- return 0;
+ return 1;
}
static int socket_serialize(Unit *u, FILE *f, FDSet *fds) {
diff --git a/src/core/swap.c b/src/core/swap.c
index 1ef672f..4fbabda 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -837,7 +837,7 @@ static int swap_start(Unit *u) {
s->result = SWAP_SUCCESS;
swap_enter_activating(s);
- return 0;
+ return 1;
}
static int swap_stop(Unit *u) {
@@ -860,7 +860,7 @@ static int swap_stop(Unit *u) {
return -EPERM;
swap_enter_deactivating(s);
- return 0;
+ return 1;
}
static int swap_serialize(Unit *u, FILE *f, FDSet *fds) {
diff --git a/src/core/target.c b/src/core/target.c
index 68be22b..33fb66b 100644
--- a/src/core/target.c
+++ b/src/core/target.c
@@ -137,7 +137,7 @@ static int target_start(Unit *u) {
assert(t->state == TARGET_DEAD);
target_set_state(t, TARGET_ACTIVE);
- return 0;
+ return 1;
}
static int target_stop(Unit *u) {
@@ -147,7 +147,7 @@ static int target_stop(Unit *u) {
assert(t->state == TARGET_ACTIVE);
target_set_state(t, TARGET_DEAD);
- return 0;
+ return 1;
}
static int target_serialize(Unit *u, FILE *f, FDSet *fds) {
diff --git a/src/core/timer.c b/src/core/timer.c
index 309852a..45744c7 100644
--- a/src/core/timer.c
+++ b/src/core/timer.c
@@ -548,7 +548,7 @@ static int timer_start(Unit *u) {
t->result = TIMER_SUCCESS;
timer_enter_waiting(t, true);
- return 0;
+ return 1;
}
static int timer_stop(Unit *u) {
@@ -558,7 +558,7 @@ static int timer_stop(Unit *u) {
assert(t->state == TIMER_WAITING || t->state == TIMER_RUNNING || t->state == TIMER_ELAPSED);
timer_enter_dead(t, TIMER_SUCCESS);
- return 0;
+ return 1;
}
static int timer_serialize(Unit *u, FILE *f, FDSet *fds) {
diff --git a/src/core/unit.c b/src/core/unit.c
index 7311c58..23ad7c1 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -1423,6 +1423,7 @@ static void unit_status_log_starting_stopping_reloading(Unit *u, JobType t) {
int unit_start(Unit *u) {
UnitActiveState state;
Unit *following;
+ int r;
assert(u);
@@ -1461,9 +1462,6 @@ int unit_start(Unit *u) {
return unit_start(following);
}
- unit_status_log_starting_stopping_reloading(u, JOB_START);
- unit_status_print_starting_stopping(u, JOB_START);
-
if (UNIT_VTABLE(u)->supported && !UNIT_VTABLE(u)->supported(u->manager))
return -ENOTSUP;
@@ -1479,7 +1477,14 @@ int unit_start(Unit *u) {
unit_add_to_dbus_queue(u);
- return UNIT_VTABLE(u)->start(u);
+ r = UNIT_VTABLE(u)->start(u);
+ if (r <= 0)
+ return r;
+
+ /* Log if the start function actually did something */
+ unit_status_log_starting_stopping_reloading(u, JOB_START);
+ unit_status_print_starting_stopping(u, JOB_START);
+ return r;
}
bool unit_can_start(Unit *u) {
@@ -1503,6 +1508,7 @@ bool unit_can_isolate(Unit *u) {
int unit_stop(Unit *u) {
UnitActiveState state;
Unit *following;
+ int r;
assert(u);
@@ -1516,15 +1522,18 @@ int unit_stop(Unit *u) {
return unit_stop(following);
}
- unit_status_log_starting_stopping_reloading(u, JOB_STOP);
- unit_status_print_starting_stopping(u, JOB_STOP);
-
if (!UNIT_VTABLE(u)->stop)
return -EBADR;
unit_add_to_dbus_queue(u);
- return UNIT_VTABLE(u)->stop(u);
+ r = UNIT_VTABLE(u)->stop(u);
+ if (r <= 0)
+ return r;
+
+ unit_status_log_starting_stopping_reloading(u, JOB_STOP);
+ unit_status_print_starting_stopping(u, JOB_STOP);
+ return r;
}
/* Errors:
@@ -1535,6 +1544,7 @@ int unit_stop(Unit *u) {
int unit_reload(Unit *u) {
UnitActiveState state;
Unit *following;
+ int r;
assert(u);
@@ -1559,10 +1569,14 @@ int unit_reload(Unit *u) {
return unit_reload(following);
}
- unit_status_log_starting_stopping_reloading(u, JOB_RELOAD);
-
unit_add_to_dbus_queue(u);
- return UNIT_VTABLE(u)->reload(u);
+
+ r = UNIT_VTABLE(u)->reload(u);
+ if (r <= 0)
+ return r;
+
+ unit_status_log_starting_stopping_reloading(u, JOB_RELOAD);
+ return r;
}
bool unit_can_reload(Unit *u) {
commit 3ad85e3775d018f32098a2957ce25e1f53440da1
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Jan 28 14:22:13 2015 +0100
test: duplicate LIST_FOREACH_OTHERS test to check for corner cases of end and start of list
diff --git a/src/test/test-list.c b/src/test/test-list.c
index 399ec8e..f6da1a7 100644
--- a/src/test/test-list.c
+++ b/src/test/test-list.c
@@ -45,6 +45,20 @@ int main(int argc, const char *argv[]) {
}
assert_se(i == ELEMENTSOF(items)-1);
+ i = 0;
+ LIST_FOREACH_OTHERS(item, cursor, &items[0]) {
+ i++;
+ assert_se(cursor != &items[0]);
+ }
+ assert_se(i == ELEMENTSOF(items)-1);
+
+ i = 0;
+ LIST_FOREACH_OTHERS(item, cursor, &items[3]) {
+ i++;
+ assert_se(cursor != &items[3]);
+ }
+ assert_se(i == ELEMENTSOF(items)-1);
+
assert_se(!LIST_JUST_US(item, head));
assert_se(items[0].item_next == NULL);
More information about the systemd-commits
mailing list