From 12bf86c744a08aa443ea8cc13bab3a2c468824bb Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Tue, 11 Feb 2014 14:07:27 +0100 Subject: [PATCH] miraclectl: suppress useless error on scan-stop If we stop a scan in an async-manner and the object is no longer around, don't print an error. Only do that if the scan is stopped explicitly by the user. This allows us to correctly kill scans during link-removal in a follow-up patch. In such cases, the scan-stop may fail of the dbus object has already been removed. Signed-off-by: David Herrmann --- src/miraclectl.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/miraclectl.c b/src/miraclectl.c index 5f263ac..0c740cf 100644 --- a/src/miraclectl.c +++ b/src/miraclectl.c @@ -1307,7 +1307,7 @@ static int cmd_stop_scan(char **args, unsigned int n) static char *scan_link; -static int cmd_scan_stop(void) +static int cmd_scan_stop(bool async) { _cleanup_sd_bus_error_ sd_bus_error err = SD_BUS_ERROR_NULL; _shl_cleanup_free_ char *path = NULL, *name = NULL; @@ -1332,11 +1332,14 @@ static int cmd_scan_stop(void) &err, NULL, NULL); - if (r < 0) + if (r >= 0) + cli_printf("Scan stopped on link %s\n", scan_link); + else if (async && + sd_bus_error_has_name(&err, SD_BUS_ERROR_UNKNOWN_OBJECT)) + /* ignore */ ; + else cli_error("cannot stop scan on link %s: %s", scan_link, bus_error_message(&err, r)); - else - cli_printf("Scan stopped on link %s\n", scan_link); free(scan_link); scan_link = NULL; @@ -1374,7 +1377,7 @@ static int cmd_scan(char **args, unsigned int n) int r; if (n > 0 && !strcmp(args[0], "stop")) - return cmd_scan_stop(); + return cmd_scan_stop(false); if (scan_link) { log_error("another managed scan is already running on link %s", @@ -1693,7 +1696,7 @@ static int miraclectl_run(void) r = cli_run(); - cmd_scan_stop(); + cmd_scan_stop(true); filters_destroy(); return r;