chiark / gitweb /
systemctl: process only signals for jobs we really wait for
authorMichal Sekletar <msekleta@redhat.com>
Thu, 12 Sep 2013 13:42:24 +0000 (15:42 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 12 Sep 2013 16:09:08 +0000 (18:09 +0200)
wait_filter() callback shouldn't process JobRemove signals for arbitrary
jobs. It should only deal with signals for jobs which are included in
set of jobs we wait for.

src/systemctl/systemctl.c

index a305c3d..dc3e41b 100644 (file)
@@ -1494,7 +1494,7 @@ static DBusHandlerResult wait_filter(DBusConnection *connection, DBusMessage *me
 
         } else if (dbus_message_is_signal(message, "org.freedesktop.systemd1.Manager", "JobRemoved")) {
                 uint32_t id;
-                const char *path, *result, *unit;
+                const char *path, *result, *unit, *r;
 
                 if (dbus_message_get_args(message, &error,
                                           DBUS_TYPE_UINT32, &id,
@@ -1503,7 +1503,11 @@ static DBusHandlerResult wait_filter(DBusConnection *connection, DBusMessage *me
                                           DBUS_TYPE_STRING, &result,
                                           DBUS_TYPE_INVALID)) {
 
-                        free(set_remove(d->set, (char*) path));
+                        r = set_remove(d->set, (char*) path);
+                        if (!r)
+                                return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+                        free(r);
 
                         if (!isempty(result))
                                 d->result = strdup(result);
@@ -1523,7 +1527,11 @@ static DBusHandlerResult wait_filter(DBusConnection *connection, DBusMessage *me
                         /* Compatibility with older systemd versions <
                          * 183 during upgrades. This should be dropped
                          * one day. */
-                        free(set_remove(d->set, (char*) path));
+                        r = set_remove(d->set, (char*) path);
+                        if (!r)
+                                return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+                        free(r);
 
                         if (*result)
                                 d->result = strdup(result);