Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix finish_signal_on_queue (bp #464) #465

Merged
merged 2 commits into from
Mar 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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