Browse Source

Use generic workqueues for the recruit subproxy function

master
Con Kolivas 10 years ago
parent
commit
0ecd5b5098
  1. 18
      src/generator.c

18
src/generator.c

@ -1678,13 +1678,10 @@ static proxy_instance_t *create_subproxy(gdata_t *gdata, proxy_instance_t *proxi
return subproxy; 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; gdata_t *gdata = ckp->data;
proxy_instance_t *proxy;
pthread_detach(pthread_self());
proxy = create_subproxy(gdata, parent); proxy = create_subproxy(gdata, parent);
if (!proxy_alive(ckp, proxy->si, proxy, proxy->cs, false, parent->epfd)) { 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); store_proxy(gdata, proxy);
} else } else
add_subproxy(parent, proxy); 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; ckwq_add(gdata->ckwqs, &proxy_recruit, proxi);
create_pthread(&pth, proxy_recruit, proxi);
} }
static void *proxy_reconnect(void *arg) static void *proxy_reconnect(void *arg)
@ -1920,7 +1914,7 @@ static void *proxy_recv(void *arg)
subproxy->id, subproxy->si->url); subproxy->id, subproxy->si->url);
break; break;
} else } else
recruit_subproxy(proxi); recruit_subproxy(gdata, proxi);
} }
continue; continue;
} }
@ -2058,7 +2052,7 @@ retry:
LOGDEBUG("Proxy received ping request"); LOGDEBUG("Proxy received ping request");
send_unix_msg(sockd, "pong"); send_unix_msg(sockd, "pong");
} else if (cmdmatch(buf, "recruit")) { } else if (cmdmatch(buf, "recruit")) {
recruit_subproxy(proxi); recruit_subproxy(gdata, proxi);
} else if (cmdmatch(buf, "dropproxy")) { } else if (cmdmatch(buf, "dropproxy")) {
drop_proxy(gdata, buf); drop_proxy(gdata, buf);
} else if (ckp->passthrough) { } else if (ckp->passthrough) {

Loading…
Cancel
Save