Skip to content

Commit

Permalink
Added retry of sensor connection for performance reports on failure
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jhelmold committed Jul 15, 2021
1 parent d5b9fe4 commit ede0f95
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -4006,17 +4006,25 @@ 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);
ca_pub = scanner_ca_pub (scanner);
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);
Expand All @@ -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);
Expand Down

0 comments on commit ede0f95

Please sign in to comment.