You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.7 KiB
66 lines
1.7 KiB
9 years ago
|
From 285adc8acd22892f86435edd84bf9b22c915b349 Mon Sep 17 00:00:00 2001
|
||
|
From: Bill Wilson
|
||
|
Date: Wed, 5 Nov 2014 17:46:37 -0600
|
||
|
Subject: Avoid possible busy loop in read_server_setup()
|
||
|
|
||
|
A patch from Joe Garcia. A ssh tunnel can be up but possibly not
|
||
|
connected to anything in which case gkrellm_getline() can return 0.
|
||
|
This patch prevents a busy loop by limiting the 0 return retries.
|
||
|
|
||
|
diff --git a/src/client.c b/src/client.c
|
||
|
index e7c5116..0eb2924 100644
|
||
|
--- a/src/client.c
|
||
|
+++ b/src/client.c
|
||
|
@@ -1712,8 +1712,10 @@ process_server_line(KeyTable *table, gint table_size, gchar *line)
|
||
|
static gboolean
|
||
|
read_server_setup(gint fd)
|
||
|
{
|
||
|
- gchar buf[4097]; /* TODO: Use dynamic receive buffer */
|
||
|
- gint table_size;
|
||
|
+ gchar buf[4097]; /* TODO: Use dynamic receive buffer */
|
||
|
+ gint table_size;
|
||
|
+ gint rs;
|
||
|
+ gint retries = 10;
|
||
|
|
||
|
gkrellm_debug(DEBUG_CLIENT, "read_server_setup()\n");
|
||
|
|
||
|
@@ -1726,13 +1728,18 @@ read_server_setup(gint fd)
|
||
|
|
||
|
gkrellm_free_glist_and_data(&client_plugin_setup_line_list);
|
||
|
|
||
|
- gint rs;
|
||
|
-
|
||
|
while (1)
|
||
|
{
|
||
|
rs = gkrellm_getline(fd, buf, sizeof(buf));
|
||
|
- if (rs < 0)
|
||
|
- return FALSE;
|
||
|
+ if (rs < 0)
|
||
|
+ return FALSE;
|
||
|
+ if (rs == 0)
|
||
|
+ {
|
||
|
+ if (--retries)
|
||
|
+ usleep(10000);
|
||
|
+ else
|
||
|
+ return FALSE;
|
||
|
+ }
|
||
|
if (!strcmp(buf, "</gkrellmd_setup>"))
|
||
|
break;
|
||
|
process_server_line(&setup_table[0], table_size, buf);
|
||
|
@@ -1751,6 +1758,12 @@ read_server_setup(gint fd)
|
||
|
rs = gkrellm_getline(fd, buf, sizeof(buf));
|
||
|
if (rs < 0)
|
||
|
return FALSE;
|
||
|
+ if (rs==0){
|
||
|
+ if(--retries)
|
||
|
+ usleep(10000);
|
||
|
+ else
|
||
|
+ return FALSE;
|
||
|
+ }
|
||
|
if (!strcmp(buf, "</initial_update>"))
|
||
|
break;
|
||
|
process_server_line(&update_table[0], table_size, buf);
|
||
|
--
|
||
|
cgit v0.10.2-6-g49f6
|
||
|
|