diff --git a/CHANGELOG.md b/CHANGELOG.md index bbabfc431..55ad8e41a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/manage.c b/src/manage.c index 2fd189174..f0e79b435 100644 --- a/src/manage.c +++ b/src/manage.c @@ -4001,9 +4001,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); @@ -4011,7 +4012,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); @@ -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);