Browse Source

Make subproxy recruiting asynchronous to not delay other proxy loop functions

master
Con Kolivas 10 years ago
parent
commit
c33362c8ad
  1. 28
      src/generator.c

28
src/generator.c

@ -906,7 +906,6 @@ static bool send_pong(proxy_instance_t *proxi, json_t *val)
static void prepare_proxy(proxy_instance_t *proxi);
static proxy_instance_t *create_subproxy(gdata_t *gdata, proxy_instance_t *proxi);
static bool recruit_subproxy(gdata_t *gdata, proxy_instance_t *proxi);
static void add_subproxy(proxy_instance_t *proxi, proxy_instance_t *subproxy)
{
@ -1633,20 +1632,28 @@ static proxy_instance_t *create_subproxy(gdata_t *gdata, proxy_instance_t *proxi
return subproxy;
}
static bool recruit_subproxy(gdata_t *gdata, proxy_instance_t *proxi)
static void *proxy_recruit(void *arg)
{
proxy_instance_t *subproxy = create_subproxy(gdata, proxi);
int epfd = proxi->epfd;
proxy_instance_t *proxy = (proxy_instance_t *)arg, *parent = proxy->parent;
ckpool_t *ckp = proxy->ckp;
gdata_t *gdata = ckp->data;
if (!proxy_alive(subproxy->ckp, subproxy->si, subproxy, subproxy->cs, false, epfd)) {
pthread_detach(pthread_self());
if (!proxy_alive(ckp, proxy->si, proxy, proxy->cs, false, parent->epfd)) {
LOGNOTICE("Subproxy failed proxy_alive testing");
store_proxy(gdata, subproxy);
return false;
store_proxy(gdata, proxy);
} else
add_subproxy(parent, proxy);
return NULL;
}
add_subproxy(proxi, subproxy);
static void recruit_subproxy(gdata_t *gdata, proxy_instance_t *proxi)
{
proxy_instance_t *subproxy = create_subproxy(gdata, proxi);
pthread_t pth;
return true;
create_pthread(&pth, proxy_recruit, subproxy);
}
/* For receiving messages from an upstream pool to pass downstream. Responsible
@ -1823,7 +1830,8 @@ static void *proxy_recv(void *arg)
LOGWARNING("Proxy %d:%s reconnect issue, dropping existing connection",
subproxy->id, subproxy->si->url);
break;
}
} else
recruit_subproxy(gdata, proxi);
}
continue;
}

Loading…
Cancel
Save