From 576ac8f71af07bba8f659b6bffa1b709edb99cc4 Mon Sep 17 00:00:00 2001 From: ckolivas Date: Wed, 25 Feb 2015 10:12:09 +1100 Subject: [PATCH] Check return value of subsequent read_socket_line, disabling a subproxy if it has failed and recruit more subproxies if required --- src/generator.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/generator.c b/src/generator.c index 629f4643..4fec657b 100644 --- a/src/generator.c +++ b/src/generator.c @@ -965,6 +965,9 @@ static void disable_subproxy(gdata_t *gdata, proxy_instance_t *proxi, proxy_inst if (parent_proxy(subproxy)) return; + if (proxi->alive && proxi->clients_per_proxy == 1 && HASH_CNT(sh, proxi->subproxies) < 42) + recruit_subproxies(proxi, 1); + mutex_lock(&proxi->proxy_lock); subproxy->disabled = true; /* Make sure subproxy is still in the list */ @@ -1993,7 +1996,12 @@ static void *proxy_recv(void *arg) /* If it's not a method it should be a share result */ if (!parse_share(subproxy, cs->buf)) LOGWARNING("Unhandled stratum message: %s", cs->buf); - } while (read_socket_line(cs, 0) > 0); + } while ((ret = read_socket_line(cs, 0)) > 0); + if (ret < 0) { + LOGNOTICE("Proxy %ld:%d %s failed to epoll/read_socket_line in proxy_recv", + proxi->id, subproxy->subid, subproxy->si->url); + disable_subproxy(gdata, proxi, subproxy); + } } return NULL;