From e6ce49d2effd23e0a4fde24d55444548b03a21ea Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 23 Feb 2015 12:24:07 +1100 Subject: [PATCH] Use generic workqueues for the proxy reconnect function --- src/generator.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/generator.c b/src/generator.c index 851d8697..f5a6f4c5 100644 --- a/src/generator.c +++ b/src/generator.c @@ -1696,24 +1696,18 @@ static void recruit_subproxy(gdata_t *gdata, proxy_instance_t *proxi) ckwq_add(gdata->ckwqs, &proxy_recruit, proxi); } -static void *proxy_reconnect(void *arg) +static void proxy_reconnect(ckpool_t *ckp, proxy_instance_t *proxy) { - proxy_instance_t *proxy = (proxy_instance_t *)arg; server_instance_t *si = proxy->si; connsock_t *cs = proxy->cs; - ckpool_t *ckp = proxy->ckp; - pthread_detach(pthread_self()); proxy_alive(ckp, si, proxy, cs, true, proxy->epfd); - return NULL; } /* For reconnecting the parent proxy instance async */ -static void reconnect_proxy(proxy_instance_t *proxi) +static void reconnect_proxy(gdata_t *gdata, proxy_instance_t *proxi) { - pthread_t pth; - - create_pthread(&pth, proxy_reconnect, proxi); + ckwq_add(gdata->ckwqs, &proxy_reconnect, proxi); } static void reconnect_generator(ckpool_t *ckp) @@ -1845,7 +1839,7 @@ static void *proxy_recv(void *arg) if (!proxi->alive) { while (!subproxies_alive(proxi)) { - reconnect_proxy(proxi); + reconnect_proxy(gdata, proxi); if (alive) { LOGWARNING("Proxy %d:%s failed, attempting reconnect", proxi->id, proxi->si->url);