Browse Source

Use generic workqueues for the proxy reconnect function

master
Con Kolivas 10 years ago
parent
commit
e6ce49d2ef
  1. 14
      src/generator.c

14
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); 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; server_instance_t *si = proxy->si;
connsock_t *cs = proxy->cs; connsock_t *cs = proxy->cs;
ckpool_t *ckp = proxy->ckp;
pthread_detach(pthread_self());
proxy_alive(ckp, si, proxy, cs, true, proxy->epfd); proxy_alive(ckp, si, proxy, cs, true, proxy->epfd);
return NULL;
} }
/* For reconnecting the parent proxy instance async */ /* 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; ckwq_add(gdata->ckwqs, &proxy_reconnect, proxi);
create_pthread(&pth, proxy_reconnect, proxi);
} }
static void reconnect_generator(ckpool_t *ckp) static void reconnect_generator(ckpool_t *ckp)
@ -1845,7 +1839,7 @@ static void *proxy_recv(void *arg)
if (!proxi->alive) { if (!proxi->alive) {
while (!subproxies_alive(proxi)) { while (!subproxies_alive(proxi)) {
reconnect_proxy(proxi); reconnect_proxy(gdata, proxi);
if (alive) { if (alive) {
LOGWARNING("Proxy %d:%s failed, attempting reconnect", LOGWARNING("Proxy %d:%s failed, attempting reconnect",
proxi->id, proxi->si->url); proxi->id, proxi->si->url);

Loading…
Cancel
Save