chiark / gitweb /
implement proper binding on ports
[elogind.git] / job.c
diff --git a/job.c b/job.c
index 0ae1a765fb06a3f387296d0eda76e377da4a3c6f..7accf7267b1a58a839e3a2564d7e85cca13863a2 100644 (file)
--- a/job.c
+++ b/job.c
@@ -362,6 +362,8 @@ int job_run_and_invalidate(Job *j) {
         if (j->state != JOB_WAITING)
                 return 0;
 
+        j->state = JOB_RUNNING;
+
         switch (j->type) {
 
                 case JOB_START:
@@ -422,11 +424,12 @@ int job_run_and_invalidate(Job *j) {
                         ;
         }
 
-        if (r >= 0)
-                j->state = JOB_RUNNING;
-        else if (r == -EALREADY)
+        if (r == -EALREADY)
                 r = job_finish_and_invalidate(j, true);
-        else if (r != -EAGAIN)
+        else if (r == -EAGAIN) {
+                j->state = JOB_WAITING;
+                return -EAGAIN;
+        } else if (r < 0)
                 r = job_finish_and_invalidate(j, false);
 
         return r;