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..3831ce57a 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 querying 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; }