chiark / gitweb /
remove unused variable
[elogind.git] / src / core / job.c
index f053d57349d4c6a2af9fae730fc04b9da83d732e..491c73d47b47dbfa7a02d6f05f31c254757d3705 100644 (file)
@@ -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;
@@ -503,7 +508,7 @@ int job_run_and_invalidate(Job *j) {
                         else if (t == UNIT_ACTIVATING)
                                 r = -EAGAIN;
                         else
-                                r = -ENOEXEC;
+                                r = -EBADR;
                         break;
                 }
 
@@ -532,8 +537,10 @@ int job_run_and_invalidate(Job *j) {
         if (j) {
                 if (r == -EALREADY)
                         r = job_finish_and_invalidate(j, JOB_DONE, true);
-                else if (r == -ENOEXEC)
+                else if (r == -EBADR)
                         r = job_finish_and_invalidate(j, JOB_SKIPPED, true);
+                else if (r == -ENOEXEC)
+                        r = job_finish_and_invalidate(j, JOB_INVALID, true);
                 else if (r == -EAGAIN) {
                         j->state = JOB_WAITING;
                         m->n_running_jobs--;
@@ -603,6 +610,8 @@ _pure_ static const char *job_get_status_message_format_try_harder(Unit *u, JobT
         return NULL;
 }
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
 static void job_print_status_message(Unit *u, JobType t, JobResult result) {
         const char *format;
 
@@ -669,6 +678,7 @@ static void job_print_status_message(Unit *u, JobType t, JobResult result) {
                         unit_status_printf(u, ANSI_HIGHLIGHT_ON " INFO " ANSI_HIGHLIGHT_OFF, "%s is not active.");
         }
 }
+#pragma GCC diagnostic pop
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wformat-nonliteral"
@@ -759,7 +769,7 @@ int job_finish_and_invalidate(Job *j, JobResult result, bool recursive) {
                 goto finish;
         }
 
-        if (result == JOB_FAILED)
+        if (result == JOB_FAILED || result == JOB_INVALID)
                 j->manager->n_failed_jobs ++;
 
         job_uninstall(j);
@@ -869,6 +879,9 @@ void job_add_to_run_queue(Job *j) {
         if (j->in_run_queue)
                 return;
 
+        if (!j->manager->run_queue)
+                sd_event_source_set_enabled(j->manager->run_queue_event_source, SD_EVENT_ONESHOT);
+
         LIST_PREPEND(run_queue, j->manager->run_queue, j);
         j->in_run_queue = true;
 }
@@ -909,7 +922,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);
 
@@ -1099,7 +1112,8 @@ static const char* const job_mode_table[_JOB_MODE_MAX] = {
         [JOB_REPLACE_IRREVERSIBLY] = "replace-irreversibly",
         [JOB_ISOLATE] = "isolate",
         [JOB_IGNORE_DEPENDENCIES] = "ignore-dependencies",
-        [JOB_IGNORE_REQUIREMENTS] = "ignore-requirements"
+        [JOB_IGNORE_REQUIREMENTS] = "ignore-requirements",
+        [JOB_FLUSH] = "flush",
 };
 
 DEFINE_STRING_TABLE_LOOKUP(job_mode, JobMode);
@@ -1110,7 +1124,8 @@ static const char* const job_result_table[_JOB_RESULT_MAX] = {
         [JOB_TIMEOUT] = "timeout",
         [JOB_FAILED] = "failed",
         [JOB_DEPENDENCY] = "dependency",
-        [JOB_SKIPPED] = "skipped"
+        [JOB_SKIPPED] = "skipped",
+        [JOB_INVALID] = "invalid",
 };
 
 DEFINE_STRING_TABLE_LOOKUP(job_result, JobResult);