[systemd-commits] 3 commits - src/core src/shared src/systemctl
Lennart Poettering
lennart at kemper.freedesktop.org
Fri Nov 22 10:28:36 PST 2013
src/core/job.c | 7 ++++++-
src/core/service.c | 40 ++++++++++++++++++++++++----------------
src/shared/util.h | 4 ++++
src/systemctl/systemctl.c | 10 ++++++++++
4 files changed, 44 insertions(+), 17 deletions(-)
New commits:
commit dbc2c080debdc45683bc5534e327455d4fbbbea7
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Nov 22 19:18:52 2013 +0100
systemctl: indicate in list-dependencies whether a unit is already running
diff --git a/src/shared/util.h b/src/shared/util.h
index 00d2364..e46438c 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -395,6 +395,10 @@ static inline const char *ansi_highlight_green(void) {
return on_tty() ? ANSI_HIGHLIGHT_GREEN_ON : "";
}
+static inline const char *ansi_highlight_yellow(void) {
+ return on_tty() ? ANSI_HIGHLIGHT_YELLOW_ON : "";
+}
+
static inline const char *ansi_highlight_off(void) {
return on_tty() ? ANSI_HIGHLIGHT_OFF : "";
}
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index bd443e9..fa64476 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -137,6 +137,8 @@ static bool arg_plain = false;
static int daemon_reload(sd_bus *bus, char **args);
static int halt_now(enum action a);
+static int check_one_unit(sd_bus *bus, const char *name, const char *good_states, bool quiet);
+
static void pager_open_if_enabled(void) {
if (arg_no_pager)
@@ -1309,6 +1311,8 @@ static int list_dependencies_one(
qsort_safe(deps, strv_length(deps), sizeof (char*), list_dependencies_compare);
STRV_FOREACH(c, deps) {
+ int state;
+
if (strv_contains(u, *c)) {
if (!arg_plain) {
r = list_dependencies_print("...", level + 1, (branches << 1) | (c[1] == NULL ? 0 : 1), 1);
@@ -1318,6 +1322,12 @@ static int list_dependencies_one(
continue;
}
+ state = check_one_unit(bus, *c, "activating\0active\0reloading\0", true);
+ if (state > 0)
+ printf("%s%s%s", ansi_highlight_green(), draw_special_char(DRAW_BLACK_CIRCLE), ansi_highlight_off());
+ else
+ printf("%s%s%s", ansi_highlight_red(), draw_special_char(DRAW_BLACK_CIRCLE), ansi_highlight_off());
+
r = list_dependencies_print(*c, level, branches, c[1] == NULL);
if (r < 0)
return r;
commit 92c1622e14dd99890928b1a1596e4a670b31a7ff
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Nov 22 19:17:52 2013 +0100
service: honour that for services RestartSec=0 means immediate restarts but TimeoutSec= means no timing out at all
diff --git a/src/core/service.c b/src/core/service.c
index d9e525e..e408338 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -346,11 +346,6 @@ static int service_arm_timer(Service *s, usec_t usec) {
assert(s);
- if (usec <= 0) {
- s->timer_event_source = sd_event_source_unref(s->timer_event_source);
- return 0;
- }
-
if (s->timer_event_source) {
r = sd_event_source_set_time(s->timer_event_source, now(CLOCK_MONOTONIC) + usec);
if (r < 0)
@@ -1597,21 +1592,30 @@ static int service_coldplug(Unit *u) {
s->deserialized_state == SERVICE_STOP_SIGKILL ||
s->deserialized_state == SERVICE_STOP_POST ||
s->deserialized_state == SERVICE_FINAL_SIGTERM ||
- s->deserialized_state == SERVICE_FINAL_SIGKILL ||
- s->deserialized_state == SERVICE_AUTO_RESTART) {
+ s->deserialized_state == SERVICE_FINAL_SIGKILL) {
+
+ usec_t k;
- if (s->deserialized_state == SERVICE_AUTO_RESTART || s->timeout_start_usec > 0) {
+ k = s->deserialized_state == SERVICE_START_PRE || s->deserialized_state == SERVICE_START ||
+ s->deserialized_state == SERVICE_START_POST || s->deserialized_state == SERVICE_RELOAD ?
+ s->timeout_start_usec : s->timeout_stop_usec;
- r = service_arm_timer(s,
- s->deserialized_state == SERVICE_AUTO_RESTART ? s->restart_usec :
- s->deserialized_state == SERVICE_START_PRE || s->deserialized_state == SERVICE_START ||
- s->deserialized_state == SERVICE_START_POST || s->deserialized_state == SERVICE_RELOAD ? s->timeout_start_usec :
- s->timeout_stop_usec);
+ /* For the start/stop timeouts 0 means off */
+ if (k > 0) {
+ r = service_arm_timer(s, k);
if (r < 0)
return r;
}
}
+ if (s->deserialized_state == SERVICE_AUTO_RESTART) {
+
+ /* The restart timeouts 0 means immediately */
+ r = service_arm_timer(s, s->restart_usec);
+ if (r < 0)
+ return r;
+ }
+
if ((s->deserialized_state == SERVICE_START &&
(s->type == SERVICE_FORKING ||
s->type == SERVICE_DBUS ||
@@ -1651,6 +1655,7 @@ static int service_coldplug(Unit *u) {
service_set_state(s, s->deserialized_state);
}
+
return 0;
}
@@ -1763,9 +1768,12 @@ static int service_spawn(
}
}
- r = service_arm_timer(s, timeout ? s->timeout_start_usec : 0);
- if (r < 0)
- goto fail;
+ if (timeout && s->timeout_start_usec > 0) {
+ r = service_arm_timer(s, s->timeout_start_usec);
+ if (r < 0)
+ goto fail;
+ } else
+ s->timer_event_source = sd_event_source_unref(s->timer_event_source);
r = unit_full_printf_strv(UNIT(s), c->argv, &argv);
if (r < 0)
commit 66ca4ec48a63ee0e71532148b9b373cda318c7e2
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Nov 22 19:14:11 2013 +0100
job: fix serialization
diff --git a/src/core/job.c b/src/core/job.c
index f053d57..f791299 100644
--- a/src/core/job.c
+++ b/src/core/job.c
@@ -403,6 +403,11 @@ static bool job_is_runnable(Job *j) {
* job type) or before (in the case of a 'negative' job
* type. */
+ /* Note that unit types have a say in what is runnable,
+ * too. For example, if they return -EAGAIN from
+ * unit_start() they can indicate they are not
+ * runnable yet. */
+
/* First check if there is an override */
if (j->ignore_order)
return true;
@@ -909,7 +914,7 @@ int job_serialize(Job *j, FILE *f, FDSet *fds) {
fprintf(f, "job-ignore-order=%s\n", yes_no(j->ignore_order));
if (j->begin_usec > 0)
- fprintf(f, "job-begin=%llu", (unsigned long long) j->begin_usec);
+ fprintf(f, "job-begin=%llu\n", (unsigned long long) j->begin_usec);
bus_client_track_serialize(j->manager, f, j->subscribed);
More information about the systemd-commits
mailing list