summaryrefslogtreecommitdiff
path: root/src/core/manager.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-01-05 17:22:10 +0100
committerLennart Poettering <lennart@poettering.net>2015-01-05 17:54:59 +0100
commit9c3349e23b14db27e7ba45f82cf647899c563ea9 (patch)
tree387cb16085148be5626917ae4a83afdc3bc61d3e /src/core/manager.c
parentbbe05969ec5b8b89a20f052f63ebb3790c0c5574 (diff)
core: rework counting of running jobs
Let's unify the code that counts the running jobs a bit, in order to make sure we are less likely to miss one. This is related to this bug: https://bugs.freedesktop.org/show_bug.cgi?id=87349 However, it probably won't fix it fully, and I cannot reproduce the issue. The change also adds an explicit assert change when the counter is off.
Diffstat (limited to 'src/core/manager.c')
-rw-r--r--src/core/manager.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/core/manager.c b/src/core/manager.c
index 9705e64da9..519b374382 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -162,6 +162,7 @@ static void manager_print_jobs_in_progress(Manager *m) {
uint64_t x;
assert(m);
+ assert(m->n_running_jobs > 0);
manager_flip_auto_status(m, true);
@@ -184,8 +185,7 @@ static void manager_print_jobs_in_progress(Manager *m) {
m->jobs_in_progress_iteration++;
if (m->n_running_jobs > 1)
- if (asprintf(&job_of_n, "(%u of %u) ", counter, m->n_running_jobs) < 0)
- job_of_n = NULL;
+ asprintf(&job_of_n, "(%u of %u) ", counter, m->n_running_jobs);
format_timespan(time, sizeof(time), now(CLOCK_MONOTONIC) - j->begin_usec, 1*USEC_PER_SEC);
if (job_get_timeout(j, &x) > 0)
@@ -197,7 +197,6 @@ static void manager_print_jobs_in_progress(Manager *m) {
job_type_to_string(j->type),
unit_description(j->unit),
time, limit);
-
}
static int have_ask_password(void) {
@@ -2635,9 +2634,6 @@ void manager_check_finished(Manager *m) {
assert(m);
- if (m->n_running_jobs == 0)
- m->jobs_in_progress_event_source = sd_event_source_unref(m->jobs_in_progress_event_source);
-
if (hashmap_size(m->jobs) > 0) {
if (m->jobs_in_progress_event_source)