unit_control: Reply with an error if no unit was matched 50/208050/1
authorPaweł Szewczyk <p.szewczyk@samsung.com>
Mon, 17 Jun 2019 14:07:04 +0000 (16:07 +0200)
committerPaweł Szewczyk <p.szewczyk@samsung.com>
Mon, 17 Jun 2019 15:07:19 +0000 (17:07 +0200)
Change-Id: I0a78a7d7830d88d26e0eff8d0b01401f85842af3
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
src/decision_makers/unit_control_dm.c

index 149770f475e13c8c8e282b6da894d122752b6863..959277a537b33286a30282c89b29415a97c77731 100644 (file)
@@ -290,6 +290,8 @@ static int unit_control_query_and_execute(const char *pattern, const char *comma
        int ret, error_code = 0;
        struct list_head unit_list;
        struct unit_info *u, *next;
+       struct unit_control_event *event = to_unit_control_event(ev);
+       _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
 
        INIT_LIST_HEAD(&unit_list);
 
@@ -308,9 +310,16 @@ static int unit_control_query_and_execute(const char *pattern, const char *comma
                free(u->unit);
                list_del(&u->node);
        }
+
        if (error_code != 0)
                return error_code;
 
+       /* nothing more to do */
+       if (event->jobs_cnt == 0) {
+               sd_bus_error_set_errno(&error, ENOENT);
+               return sd_bus_reply_method_error(event->m, &error);
+       }
+
        return 0;
 cleanup:
        list_for_each_entry_safe(u, next, &unit_list, node) {