From 0574a545543f776eed99fcc15131ef1f9ee5eb3d Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 18 Dec 2015 19:10:39 +1100 Subject: [PATCH] Don't disable parent proxies in disable_subproxy for failover to work --- src/generator.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/generator.c b/src/generator.c index e40b920d..666484c8 100644 --- a/src/generator.c +++ b/src/generator.c @@ -1015,7 +1015,8 @@ static void send_stratifier_deadproxy(ckpool_t *ckp, const int id, const int sub /* Remove the subproxy from the proxi list and put it on the dead list. * Further use of the subproxy pointer may point to a new proxy but will not - * dereference */ + * dereference. This will only disable subproxies so parent proxies need to + * have their disabled bool set manually. */ static void disable_subproxy(gdata_t *gdata, proxy_instance_t *proxi, proxy_instance_t *subproxy) { subproxy->alive = false; @@ -1024,10 +1025,11 @@ static void disable_subproxy(gdata_t *gdata, proxy_instance_t *proxi, proxy_inst epoll_ctl(proxi->epfd, EPOLL_CTL_DEL, subproxy->cs.fd, NULL); Close(subproxy->cs.fd); } - subproxy->disabled = true; if (parent_proxy(subproxy)) return; + subproxy->disabled = true; + mutex_lock(&proxi->proxy_lock); /* Make sure subproxy is still in the list */ subproxy = __subproxy_by_id(proxi, subproxy->subid); @@ -2488,9 +2490,11 @@ static void parse_ableproxy(gdata_t *gdata, const int sockd, const char *buf, bo proxy->disabled = disable; LOGNOTICE("%sabling proxy %d:%s", disable ? "Dis" : "En", id, proxy->url); } - if (disable) + if (disable) { + /* Set disabled bool here in case this is a parent proxy */ + proxy->disabled = true; disable_subproxy(gdata, proxy, proxy); - else + } else reconnect_proxy(proxy); out: send_api_response(val, sockd);