From 4d25a197e78644ee25dae1178e103263e1b5d902 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 23 Feb 2015 18:04:45 +1100 Subject: [PATCH] Only have one thread trying to reconnect a proxy at a time --- src/generator.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/generator.c b/src/generator.c index c9fa76b9..19dcb47f 100644 --- a/src/generator.c +++ b/src/generator.c @@ -107,6 +107,7 @@ struct proxy_instance { bool disabled; /* Subproxy no longer to be used */ bool reconnect; /* We need to drop and reconnect */ + bool reconnecting; /* Testing in progress */ bool alive; mutex_t notify_lock; @@ -1712,6 +1713,7 @@ static void *proxy_reconnect(void *arg) pthread_detach(pthread_self()); proxy_alive(ckp, si, proxy, cs, true, proxy->epfd); + proxy->reconnecting = false; return NULL; } @@ -1720,6 +1722,9 @@ static void reconnect_proxy(proxy_instance_t *proxi) { pthread_t pth; + if (proxi->reconnecting) + return; + proxi->reconnecting = true; create_pthread(&pth, proxy_reconnect, proxi); }