From 6bad7eca8d7943009353b31e0e9efd78eb13ba53 Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Tue, 18 Oct 2011 09:01:52 +0200 Subject: [PATCH] fix possible endless loops (100% CPU) in networking code --- mars_server.c | 5 +++-- sy_old/mars_light.c | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mars_server.c b/mars_server.c index fa3add33..ef98abba 100644 --- a/mars_server.c +++ b/mars_server.c @@ -418,7 +418,7 @@ static int server_switch(struct server_brick *brick) mars_power_led_off((void*)brick, false); - MARS_INF("starting....."); + MARS_INF("starting.....\n"); spin_lock(&server_lock); list_add(&brick->server_link, &server_list); @@ -566,7 +566,7 @@ static int _server_thread(void *data) MARS_INF("-------- server starting on host '%s' ----------\n", id); - while (!kthread_should_stop()) { + while (!kthread_should_stop() && mars_global && mars_global->global_power.button) { struct server_brick *brick; struct mars_socket *new_socket; @@ -607,6 +607,7 @@ static int _server_thread(void *data) goto err; } + msleep(1000); continue; err: diff --git a/sy_old/mars_light.c b/sy_old/mars_light.c index 7c873af1..17605bd9 100644 --- a/sy_old/mars_light.c +++ b/sy_old/mars_light.c @@ -928,6 +928,7 @@ int remote_thread(void *data) continue; } MARS_DBG("successfully opened socket to '%s'\n", real_peer); + msleep(1000); continue; } @@ -962,8 +963,9 @@ int remote_thread(void *data) mars_free_dent_all(NULL, &old_list); + msleep(1000); if (!kthread_should_stop()) - msleep(5 * 1000); + msleep(4000); } MARS_INF("-------- remote thread terminating\n");