summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app-admin/gkrellm/files/gkrellm-2.3.6_rc1-avoid_possible_busy_loop.patch')
-rw-r--r--app-admin/gkrellm/files/gkrellm-2.3.6_rc1-avoid_possible_busy_loop.patch65
1 files changed, 65 insertions, 0 deletions
diff --git a/app-admin/gkrellm/files/gkrellm-2.3.6_rc1-avoid_possible_busy_loop.patch b/app-admin/gkrellm/files/gkrellm-2.3.6_rc1-avoid_possible_busy_loop.patch
new file mode 100644
index 000000000000..b6843b64e923
--- /dev/null
+++ b/app-admin/gkrellm/files/gkrellm-2.3.6_rc1-avoid_possible_busy_loop.patch
@@ -0,0 +1,65 @@
+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
+