Skip to content

Commit

Permalink
Merge pull request #1633 from jhelmold/retry_sensor_connection_perfor…
Browse files Browse the repository at this point in the history
…mance_report

Added retry of sensor connection for performance reports on failure.
  • Loading branch information
timopollmeier authored Jul 19, 2021
2 parents d5b9fe4 + 0d06084 commit a8a9bbd
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 @@ -101,6 +101,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed
- 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 @@ -4006,17 +4006,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 @@ -4031,7 +4040,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 a8a9bbd

Please sign in to comment.