From e6b79715cb590b953ad22be8223bebac16168aa1 Mon Sep 17 00:00:00 2001 From: ckolivas Date: Wed, 25 Feb 2015 09:57:26 +1100 Subject: [PATCH] Abstract out recruit_subproxies function --- src/generator.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/generator.c b/src/generator.c index 32824ef5..bea23bf2 100644 --- a/src/generator.c +++ b/src/generator.c @@ -1735,15 +1735,11 @@ retry: return NULL; } -/* Queue up to the requested amount */ -static void recruit_subproxy(proxy_instance_t *proxi, const char *buf) +static void recruit_subproxies(proxy_instance_t *proxi, const int recruits) { bool recruit = false; - int recruits = 1; pthread_t pth; - sscanf(buf, "recruit=%d", &recruits); - mutex_lock(&proxi->proxy_lock); if (!proxi->recruit) recruit = true; @@ -1755,6 +1751,15 @@ static void recruit_subproxy(proxy_instance_t *proxi, const char *buf) create_pthread(&pth, proxy_recruit, proxi); } +/* Queue up to the requested amount */ +static void recruit_subproxy(proxy_instance_t *proxi, const char *buf) +{ + int recruits = 1; + + sscanf(buf, "recruit=%d", &recruits); + recruit_subproxies(proxi, recruits); +} + static void *proxy_reconnect(void *arg) { proxy_instance_t *proxy = (proxy_instance_t *)arg;