From 36aed068eb869c6816d3fd28c862fc5d05da6cee Mon Sep 17 00:00:00 2001 From: Juan Jose Nicola Date: Fri, 19 Mar 2021 10:04:25 -0500 Subject: [PATCH 1/2] Fix finish_signal_on_queue Check for the signal in the whole items under the key, instead of just checking the the last item. (cherry picked from commit 8b8f088d2ee6581f1f33f49a967ef7b7bba6c305) --- CHANGELOG.md | 3 +++ boreas/boreas_io.c | 34 +++++++++++++++++++++++----------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d14aa415b..000a7aea8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). [#451](https://github.com/greenbone/gvm-libs/pull/451) - Fix openvas preference name. The option was rename to "allow_simultaneous_ips". [#461](https://github.com/greenbone/gvm-libs/pull/461) +### Fixed +- Fix finish_signal_on_queue for boreas. [#464](https://github.com/greenbone/gvm-libs/pull/464) + ### Removed - Remove handling of severity class from auth [#402](https://github.com/greenbone/gvm-libs/pull/402) - Remove version from the nvticache name. [#386](https://github.com/greenbone/gvm-libs/pull/386) diff --git a/boreas/boreas_io.c b/boreas/boreas_io.c index 5e36b825a..be2ee9424 100644 --- a/boreas/boreas_io.c +++ b/boreas/boreas_io.c @@ -240,7 +240,7 @@ put_host_on_queue (kb_t kb, char *addr_str) } /** - * @brief Checks if the finish signal is already set as last item in the queue. + * @brief Checks if the finish signal is already set. * * @param main_kb kb to use * @return 1 if it is already set. 0 otherwise. @@ -248,18 +248,30 @@ put_host_on_queue (kb_t kb, char *addr_str) int finish_signal_on_queue (kb_t main_kb) { - struct kb_item *last_queue_item; - int ret; - - ret = 0; - last_queue_item = - kb_item_get_single (main_kb, ALIVE_DETECTION_QUEUE, KB_TYPE_STR); + static gboolean fin_msg_already_on_queue = FALSE; + struct kb_item *queue_items = NULL; + int ret = 0; - if (last_queue_item && (last_queue_item->type == KB_TYPE_STR) - && (!g_strcmp0 (last_queue_item->v_str, ALIVE_DETECTION_FINISHED))) - ret = 1; + if (fin_msg_already_on_queue) + return 1; - kb_item_free (last_queue_item); + /* Check if it was already set throught the whole items under the key. + If so, set the static variable to avoid quering redis unnecessarily. */ + queue_items = + kb_item_get_all (main_kb, ALIVE_DETECTION_QUEUE); + if (queue_items) + { + while (queue_items) + { + if (!g_strcmp0 (queue_items->v_str, ALIVE_DETECTION_FINISHED)) + { + fin_msg_already_on_queue = TRUE; + ret = 1; + } + queue_items = queue_items->next; + } + kb_item_free (queue_items); + } return ret; } From 7b1e949e44c3a975e2f57978cf803dfa8e47358a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9=20Nicola?= Date: Mon, 22 Mar 2021 08:35:45 +0100 Subject: [PATCH 2/2] Update boreas/boreas_io.c Co-authored-by: ArnoStiefvater (cherry picked from commit 72cc3c0dabc76aecbdfaad8960edcceeb060e082) --- boreas/boreas_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boreas/boreas_io.c b/boreas/boreas_io.c index be2ee9424..3831ce57a 100644 --- a/boreas/boreas_io.c +++ b/boreas/boreas_io.c @@ -256,7 +256,7 @@ finish_signal_on_queue (kb_t main_kb) return 1; /* Check if it was already set throught the whole items under the key. - If so, set the static variable to avoid quering redis unnecessarily. */ + If so, set the static variable to avoid querying redis unnecessarily. */ queue_items = kb_item_get_all (main_kb, ALIVE_DETECTION_QUEUE); if (queue_items)