diff --git a/src/manage.c b/src/manage.c index f9225674e..696010e64 100644 --- a/src/manage.c +++ b/src/manage.c @@ -7647,7 +7647,7 @@ delete_resource (const char *type, const char *resource_id, int ultimate) static int stop_openvasd_task (task_t task) { - int ret = -1; + int ret = 0; report_t scan_report; char *scan_id; task_t previous_task; @@ -7659,15 +7659,20 @@ stop_openvasd_task (task_t task) previous_task = current_scanner_task; previous_report = global_current_report; - scan_report = task_running_report (task); scan_id = report_uuid (scan_report); if (!scan_id) - goto end_stop_openvasd; + { + ret = -1; + goto end_stop_openvasd; + } scanner = task_scanner (task); connector = openvasd_scanner_connect (scanner, scan_id); if (!connector) - goto end_stop_openvasd; + { + ret = -1; + goto end_stop_openvasd; + } current_scanner_task = task; global_current_report = task_running_report (task); @@ -7675,13 +7680,12 @@ stop_openvasd_task (task_t task) response = openvasd_stop_scan (&connector); if (response->code < 0) { + ret = -1; g_free (scan_id); goto end_stop_openvasd; } - response = openvasd_delete_scan (&connector); g_free (scan_id); - end_stop_openvasd: openvasd_connector_free(&connector); set_task_end_time_epoch (task, time (NULL)); @@ -7693,9 +7697,8 @@ stop_openvasd_task (task_t task) } current_scanner_task = previous_task; global_current_report = previous_report; - if (ret) - return -1; - return 0; + + return ret; } /**