chiark / gitweb /
systemctl: properly report success
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 19 Sep 2012 06:15:07 +0000 (08:15 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 19 Sep 2012 06:27:34 +0000 (08:27 +0200)
Systemctl would always return 1, because it treated uninteresting dbus
messages ("job added") as errors. Just ignore everything apart from
interesting ("job removed") messages.

src/systemctl/systemctl.c

index 15c0866..729d4dd 100644 (file)
@@ -1322,7 +1322,10 @@ static int wait_for_jobs(DBusConnection *bus, Set *s) {
                         return -ECONNREFUSED;
                 }
 
                         return -ECONNREFUSED;
                 }
 
-                if (!arg_quiet && d.result) {
+                if (!d.result)
+                        goto free_name;
+
+                if (!arg_quiet) {
                         if (streq(d.result, "timeout"))
                                 log_error("Job for %s timed out.", strna(d.name));
                         else if (streq(d.result, "canceled"))
                         if (streq(d.result, "timeout"))
                                 log_error("Job for %s timed out.", strna(d.name));
                         else if (streq(d.result, "canceled"))
@@ -1343,11 +1346,12 @@ static int wait_for_jobs(DBusConnection *bus, Set *s) {
                 free(d.result);
                 d.result = NULL;
 
                 free(d.result);
                 d.result = NULL;
 
+        free_name:
                 free(d.name);
                 d.name = NULL;
         }
 
                 free(d.name);
                 d.name = NULL;
         }
 
-        /* This is slightly dirty, since we don't undo the filter registration. */
+        dbus_connection_remove_filter(bus, wait_filter, &d);
         return r;
 }
 
         return r;
 }