chiark / gitweb /
journald: check session owner UID rather then audit ID when splitting up journal...
[elogind.git] / src / core / manager.c
index 5527e9d429299fd6c49912c0f6a50bd7263dcb23..1d188081a1d71f5bac416242ec3744c94461e624 100644 (file)
@@ -269,8 +269,9 @@ static void manager_print_jobs_in_progress(Manager *m) {
                 if (j->state == JOB_RUNNING && counter++ == print_nr)
                         break;
 
-       if (!j)
-               return;
+        /* m->n_running_jobs must be consistent with the contents of m->jobs,
+         * so the above loop must have succeeded in finding j. */
+        assert(counter == print_nr + 1);
 
         cylon_pos = m->jobs_in_progress_iteration % 14;
         if (cylon_pos >= 8)
@@ -678,6 +679,9 @@ static void manager_clear_jobs_and_units(Manager *m) {
 
         assert(hashmap_isempty(m->jobs));
         assert(hashmap_isempty(m->units));
+
+        m->n_on_console = 0;
+        m->n_running_jobs = 0;
 }
 
 void manager_free(Manager *m) {
@@ -1140,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;
@@ -2364,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);
@@ -2375,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;
 
@@ -2476,9 +2479,9 @@ static int create_generator_dir(Manager *m, char **generator, const char *name)
                         return log_oom();
 
                 if (!mkdtemp(p)) {
-                        free(p);
                         log_error("Failed to create generator directory %s: %m",
                                   p);
+                        free(p);
                         return -errno;
                 }
         }