Skip to content

Commit

Permalink
Merge pull request #465 from greenbone/mergify/bp/master/pr-464
Browse files Browse the repository at this point in the history
Fix finish_signal_on_queue (bp #464)
  • Loading branch information
ArnoStiefvater authored Mar 22, 2021
2 parents afab992 + 7b1e949 commit b578b0b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
34 changes: 23 additions & 11 deletions boreas/boreas_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,26 +240,38 @@ 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.
*/
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;
}

Expand Down

0 comments on commit b578b0b

Please sign in to comment.