From 0ecd5b5098c076d57f58f46df963b946e87eb063 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 23 Feb 2015 12:22:21 +1100 Subject: [PATCH] Use generic workqueues for the recruit subproxy function --- src/generator.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/generator.c b/src/generator.c index bcf7ab78..851d8697 100644 --- a/src/generator.c +++ b/src/generator.c @@ -1678,13 +1678,10 @@ static proxy_instance_t *create_subproxy(gdata_t *gdata, proxy_instance_t *proxi return subproxy; } -static void *proxy_recruit(void *arg) +static void proxy_recruit(ckpool_t *ckp, proxy_instance_t *parent) { - proxy_instance_t *proxy, *parent = (proxy_instance_t *)arg; - ckpool_t *ckp = parent->ckp; gdata_t *gdata = ckp->data; - - pthread_detach(pthread_self()); + proxy_instance_t *proxy; proxy = create_subproxy(gdata, parent); if (!proxy_alive(ckp, proxy->si, proxy, proxy->cs, false, parent->epfd)) { @@ -1692,14 +1689,11 @@ static void *proxy_recruit(void *arg) store_proxy(gdata, proxy); } else add_subproxy(parent, proxy); - return NULL; } -static void recruit_subproxy(proxy_instance_t *proxi) +static void recruit_subproxy(gdata_t *gdata, proxy_instance_t *proxi) { - pthread_t pth; - - create_pthread(&pth, proxy_recruit, proxi); + ckwq_add(gdata->ckwqs, &proxy_recruit, proxi); } static void *proxy_reconnect(void *arg) @@ -1920,7 +1914,7 @@ static void *proxy_recv(void *arg) subproxy->id, subproxy->si->url); break; } else - recruit_subproxy(proxi); + recruit_subproxy(gdata, proxi); } continue; } @@ -2058,7 +2052,7 @@ retry: LOGDEBUG("Proxy received ping request"); send_unix_msg(sockd, "pong"); } else if (cmdmatch(buf, "recruit")) { - recruit_subproxy(proxi); + recruit_subproxy(gdata, proxi); } else if (cmdmatch(buf, "dropproxy")) { drop_proxy(gdata, buf); } else if (ckp->passthrough) {