diff --git a/CHANGELOG.md b/CHANGELOG.md index a5fcd726b..ea2a70511 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,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 diff --git a/src/manage.c b/src/manage.c index 5e285bed7..69122ce90 100644 --- a/src/manage.c +++ b/src/manage.c @@ -6190,9 +6190,10 @@ 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); @@ -6200,7 +6201,15 @@ get_osp_performance_string (scanner_t scanner, int start, int end, 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); @@ -6215,7 +6224,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);