summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2013-03-04 14:38:51 +0100
committerHarald Hoyer <harald@redhat.com>2013-03-04 14:51:32 +0100
commita0b6422689e37ffee37742d027f91af8bacfa78d (patch)
tree0171f82a315cfee81788b29e462c23beaefd0134 /src/core
parent19fbec19192998fa7fc0c24a58038b98cf989802 (diff)
core/manager: fix conditions to start and stop watching running jobs
Harald encountered division by zero in manager_print_jobs_in_progress. Clearly we had the watch enabled when we shouldn't - there were no running jobs in m->jobs, only waiting ones. This is either a deadlock, or maybe some of them would be detected as runnable in the next dispatch of the run queue. In any case we mustn't crash. Fix it by starting and stopping the watch based on n_running_jobs instead of the number of all jobs.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/manager.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/core/manager.c b/src/core/manager.c
index 91d773c2f6..1d188081a1 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -1144,7 +1144,7 @@ unsigned manager_dispatch_run_queue(Manager *m) {
m->dispatching_run_queue = false;
- if (hashmap_size(m->jobs) > 0)
+ if (m->n_running_jobs > 0)
manager_watch_jobs_in_progress(m);
return n;
@@ -2368,10 +2368,11 @@ void manager_check_finished(Manager *m) {
assert(m);
- if (hashmap_size(m->jobs) > 0) {
- manager_jobs_in_progress_mod_timer(m);
+ if (m->n_running_jobs == 0)
+ manager_unwatch_jobs_in_progress(m);
+
+ if (hashmap_size(m->jobs) > 0)
return;
- }
/* Notify Type=idle units that we are done now */
close_pipe(m->idle_pipe);
@@ -2379,8 +2380,6 @@ void manager_check_finished(Manager *m) {
/* Turn off confirm spawn now */
m->confirm_spawn = false;
- manager_unwatch_jobs_in_progress(m);
-
if (dual_timestamp_is_set(&m->finish_timestamp))
return;