chiark / gitweb /
core/unit: fix unit_add_target_dependencies() for units with no dependencies
[elogind.git] / src / core / job.c
index 1bcf4968e2c5df0d31e59b0f771efd0382cfb2bc..2f998f89585a053183bd3004b7842d4e28ef0059 100644 (file)
@@ -864,12 +864,15 @@ static int job_dispatch_timer(sd_event_source *s, uint64_t monotonic, void *user
 int job_start_timer(Job *j) {
         int r;
 
-        if (j->unit->job_timeout <= 0 || j->timer_event_source)
+        if (j->timer_event_source)
                 return 0;
 
         j->begin_usec = now(CLOCK_MONOTONIC);
 
-        r = sd_event_add_monotonic(j->manager->event, j->begin_usec + j->unit->job_timeout, 0, job_dispatch_timer, j, &j->timer_event_source);
+        if (j->unit->job_timeout <= 0)
+                return 0;
+
+        r = sd_event_add_monotonic(j->manager->event, &j->timer_event_source, j->begin_usec + j->unit->job_timeout, 0, job_dispatch_timer, j);
         if (r < 0)
                 return r;
 
@@ -1048,13 +1051,13 @@ int job_coldplug(Job *j) {
 
         assert(j);
 
-        if (j->begin_usec <= 0)
+        if (j->begin_usec == 0 || j->unit->job_timeout == 0)
                 return 0;
 
         if (j->timer_event_source)
                 j->timer_event_source = sd_event_source_unref(j->timer_event_source);
 
-        r = sd_event_add_monotonic(j->manager->event, j->begin_usec + j->unit->job_timeout, 0, job_dispatch_timer, j, &j->timer_event_source);
+        r = sd_event_add_monotonic(j->manager->event, &j->timer_event_source, j->begin_usec + j->unit->job_timeout, 0, job_dispatch_timer, j);
         if (r < 0)
                 log_debug("Failed to restart timeout for job: %s", strerror(-r));
 
@@ -1115,9 +1118,6 @@ int job_get_timeout(Job *j, uint64_t *timeout) {
 
         *timeout = MIN(x, y);
 
-        log_info("job_get_timeout %s %d/%"PRIu64" %d/%"PRIu64" -> 1/%"PRIu64,
-                 j->unit->id, r, x, q, y, *timeout);
-
         return 1;
 }