Skip to content

Commit

Permalink
Merge pull request #1634 from greenbone/mergify/bp/master/pr-1633
Browse files Browse the repository at this point in the history
Added retry of sensor connection for performance reports on failure. (backport #1633)
  • Loading branch information
timopollmeier authored Jul 19, 2021
2 parents cd71b1b + 563fb0b commit e7260f7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Solved a performance problem when filtering results by tags [#1579](https://github.com/greenbone/gvmd/pull/1579)
- Fix VTs hash check and add --dump-vt-verification [#1611](https://github.com/greenbone/gvmd/pull/1611) [#1629](https://github.com/greenbone/gvmd/pull/1629)
- Fix memory errors in modify_permission [#1613](https://github.com/greenbone/gvmd/pull/1613)
- Fix sensor connection for performance reports on failure [#1633](https://github.com/greenbone/gvmd/pull/1633)

[Unreleased]: https://github.com/greenbone/gvmd/compare/v20.8.2...gvmd-20.08

Expand Down
24 changes: 22 additions & 2 deletions src/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -4001,17 +4001,26 @@ get_osp_performance_string (scanner_t scanner, int start, int end,
{
char *host, *ca_pub, *key_pub, *key_priv;
int port;
osp_connection_t *connection;
osp_connection_t *connection = NULL;
osp_get_performance_opts_t opts;
gchar *error;
int connection_retry, return_value;

host = scanner_host (scanner);
port = scanner_port (scanner);
ca_pub = scanner_ca_pub (scanner);
key_pub = scanner_key_pub (scanner);
key_priv = scanner_key_priv (scanner);

connection_retry = get_scanner_connection_retry ();
connection = osp_connect_with_data (host, port, ca_pub, key_pub, key_priv);
while (connection == NULL && connection_retry > 0)
{
sleep(1);
connection = osp_connect_with_data (host, port,
ca_pub, key_pub, key_priv);
connection_retry--;
}

free (host);
free (ca_pub);
Expand All @@ -4026,7 +4035,18 @@ get_osp_performance_string (scanner_t scanner, int start, int end,
opts.titles = g_strdup (titles);
error = NULL;

if (osp_get_performance_ext (connection, opts, performance_str, &error))
connection_retry = get_scanner_connection_retry ();
return_value = osp_get_performance_ext (connection, opts,
performance_str, &error);
while (return_value != 0 && connection_retry > 0)
{
sleep(1);
return_value = osp_get_performance_ext (connection, opts,
performance_str, &error);
connection_retry--;
}

if (return_value)
{
osp_connection_close (connection);
g_warning ("Error getting OSP performance report: %s", error);
Expand Down

0 comments on commit e7260f7

Please sign in to comment.