From ede0f95e515977db0980955f46da8c3fb4dd3df3 Mon Sep 17 00:00:00 2001 From: Johannes Helmold Date: Thu, 15 Jul 2021 15:07:28 +0200 Subject: [PATCH] Added retry of sensor connection for performance reports on failure In manage.c in function get_osp_performance_string (..): The installation of the connection to the sensor via osp_connect_with_data (..) and the access to the performance data via osp_get_performance_ext (..) are now retried several times on failure. --- src/manage.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/manage.c b/src/manage.c index 94d333fa8..0c53d78ae 100644 --- a/src/manage.c +++ b/src/manage.c @@ -4006,9 +4006,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; host = scanner_host (scanner); port = scanner_port (scanner); @@ -4016,7 +4017,14 @@ get_osp_performance_string (scanner_t scanner, int start, int end, key_pub = scanner_key_pub (scanner); key_priv = scanner_key_priv (scanner); - connection = osp_connect_with_data (host, port, ca_pub, key_pub, key_priv); + connection_retry = SCANNER_CONNECTION_RETRY_DEFAULT; + while(connection == NULL && connection_retry > 0) + { + connection = osp_connect_with_data (host, port, + ca_pub, key_pub, key_priv); + connection_retry--; + sleep(1); + } free (host); free (ca_pub); @@ -4031,7 +4039,17 @@ 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 = SCANNER_CONNECTION_RETRY_DEFAULT; + int return_value = 1; + while (return_value > 0 && connection_retry > 0) + { + return_value = osp_get_performance_ext (connection, opts, + performance_str, &error); + connection_retry--; + sleep(1); + } + + if (return_value) { osp_connection_close (connection); g_warning ("Error getting OSP performance report: %s", error);