From fefe13e929588ef133473a486fb869c91d70afdc Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 28 Apr 2014 21:37:49 +1000 Subject: [PATCH] Check for no response in the listener thread and allow 1 minute timeouts for receiving messages --- src/ckpool.c | 5 +++++ src/libckpool.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ckpool.c b/src/ckpool.c index dbd4c7ec..010f4a2a 100644 --- a/src/ckpool.c +++ b/src/ckpool.c @@ -45,6 +45,11 @@ retry: } /* Insert parsing and repeat code here */ buf = recv_unix_msg(sockd); + if (!buf) { + LOGWARNING("Failed to get message in listener"); + close(sockd); + goto retry; + } if (!strncasecmp(buf, "shutdown", 8)) { LOGWARNING("Listener received shutdown message, terminating ckpool"); close(sockd); diff --git a/src/libckpool.c b/src/libckpool.c index c3fde1f4..31df220e 100644 --- a/src/libckpool.c +++ b/src/libckpool.c @@ -701,7 +701,7 @@ out: * string.*/ char *recv_unix_msg(int sockd) { - tv_t tv_timeout = {1, 0}; + tv_t tv_timeout = {60, 0}; char *buf = NULL; uint32_t msglen; fd_set readfs; @@ -729,7 +729,7 @@ char *recv_unix_msg(int sockd) buf[msglen] = 0; ofs = 0; while (msglen) { - tv_timeout.tv_sec = 1; + tv_timeout.tv_sec = 60; tv_timeout.tv_usec = 0; FD_ZERO(&readfs);