From 1ac5fec1ee2be1664f2a6b7152fbdd0cfb00af6b Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 20 May 2014 12:37:19 +1000 Subject: [PATCH] Timeout in 5 seconds on the stratum read socket allowing us to detect closed connections sooner --- src/generator.c | 9 +++++++-- src/libckpool.c | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/generator.c b/src/generator.c index fced81d0..b4fff498 100644 --- a/src/generator.c +++ b/src/generator.c @@ -897,8 +897,8 @@ static void *proxy_recv(void *arg) while (42) { notify_instance_t *ni, *tmp; share_msg_t *share, *tmpshare; + int retries = 0, ret; time_t now; - int ret; now = time(NULL); @@ -923,7 +923,12 @@ static void *proxy_recv(void *arg) } mutex_unlock(&proxi->share_lock); - ret = read_socket_line(cs, 120); + /* If we don't get an update within 2 minutes the upstream pool + * has likely stopped responding. */ + do { + ret = read_socket_line(cs, 5); + } while (ret == 0 && ++retries < 24); + if (ret < 1) { LOGWARNING("Failed to read_socket_line in proxy_recv, attempting reconnect"); reconnect_stratum(cs, proxi); diff --git a/src/libckpool.c b/src/libckpool.c index 2d034d71..4dbdb4b1 100644 --- a/src/libckpool.c +++ b/src/libckpool.c @@ -492,7 +492,7 @@ int read_socket_line(connsock_t *cs, int timeout) continue; if (ret < 1) { if (!ret) - LOGNOTICE("Select timed out in read_socket_line"); + LOGDEBUG("Select timed out in read_socket_line"); else LOGERR("Select failed in read_socket_line"); goto out;