From eed7df18262f5e8894ad0042b2b4c9599e84a4d6 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 17 Feb 2015 13:30:36 +1100 Subject: [PATCH] Do all the proxy recruitment within the new thread --- src/generator.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/generator.c b/src/generator.c index 6cb4ab2d..12925be0 100644 --- a/src/generator.c +++ b/src/generator.c @@ -1634,12 +1634,13 @@ static proxy_instance_t *create_subproxy(gdata_t *gdata, proxy_instance_t *proxi static void *proxy_recruit(void *arg) { - proxy_instance_t *proxy = (proxy_instance_t *)arg, *parent = proxy->parent; - ckpool_t *ckp = proxy->ckp; + proxy_instance_t *proxy, *parent = (proxy_instance_t *)arg; + ckpool_t *ckp = parent->ckp; gdata_t *gdata = ckp->data; pthread_detach(pthread_self()); + proxy = create_subproxy(gdata, parent); if (!proxy_alive(ckp, proxy->si, proxy, proxy->cs, false, parent->epfd)) { LOGNOTICE("Subproxy failed proxy_alive testing"); store_proxy(gdata, proxy); @@ -1648,12 +1649,11 @@ static void *proxy_recruit(void *arg) return NULL; } -static void recruit_subproxy(gdata_t *gdata, proxy_instance_t *proxi) +static void recruit_subproxy(proxy_instance_t *proxi) { - proxy_instance_t *subproxy = create_subproxy(gdata, proxi); pthread_t pth; - create_pthread(&pth, proxy_recruit, subproxy); + create_pthread(&pth, proxy_recruit, proxi); } /* For receiving messages from an upstream pool to pass downstream. Responsible @@ -1831,7 +1831,7 @@ static void *proxy_recv(void *arg) subproxy->id, subproxy->si->url); break; } else - recruit_subproxy(gdata, proxi); + recruit_subproxy(proxi); } continue; } @@ -1976,7 +1976,7 @@ retry: LOGDEBUG("Proxy received ping request"); send_unix_msg(sockd, "pong"); } else if (cmdmatch(buf, "recruit")) { - recruit_subproxy(gdata, proxi); + recruit_subproxy(proxi); } else if (ckp->passthrough) { /* Anything remaining should be stratum messages */ passthrough_add_send(proxi, buf);