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.
This commit is contained in:
parent
f3f67b7919
commit
285adc8acd
17
src/client.c
17
src/client.c
|
@ -1714,6 +1714,8 @@ read_server_setup(gint fd)
|
||||||
{
|
{
|
||||||
gchar buf[4097]; /* TODO: Use dynamic receive buffer */
|
gchar buf[4097]; /* TODO: Use dynamic receive buffer */
|
||||||
gint table_size;
|
gint table_size;
|
||||||
|
gint rs;
|
||||||
|
gint retries = 10;
|
||||||
|
|
||||||
gkrellm_debug(DEBUG_CLIENT, "read_server_setup()\n");
|
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);
|
gkrellm_free_glist_and_data(&client_plugin_setup_line_list);
|
||||||
|
|
||||||
gint rs;
|
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
rs = gkrellm_getline(fd, buf, sizeof(buf));
|
rs = gkrellm_getline(fd, buf, sizeof(buf));
|
||||||
if (rs < 0)
|
if (rs < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
if (rs == 0)
|
||||||
|
{
|
||||||
|
if (--retries)
|
||||||
|
usleep(10000);
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
if (!strcmp(buf, "</gkrellmd_setup>"))
|
if (!strcmp(buf, "</gkrellmd_setup>"))
|
||||||
break;
|
break;
|
||||||
process_server_line(&setup_table[0], table_size, buf);
|
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));
|
rs = gkrellm_getline(fd, buf, sizeof(buf));
|
||||||
if (rs < 0)
|
if (rs < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
if (rs==0){
|
||||||
|
if(--retries)
|
||||||
|
usleep(10000);
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
if (!strcmp(buf, "</initial_update>"))
|
if (!strcmp(buf, "</initial_update>"))
|
||||||
break;
|
break;
|
||||||
process_server_line(&update_table[0], table_size, buf);
|
process_server_line(&update_table[0], table_size, buf);
|
||||||
|
|
Loading…
Reference in New Issue