From 649ad7953f3550d218c1f46c0fec893ce7a528e1 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 28 Nov 2014 10:24:32 +1100 Subject: [PATCH] Fix potential socket leak in gen_loop --- src/generator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/generator.c b/src/generator.c index 6e00669e..c1804029 100644 --- a/src/generator.c +++ b/src/generator.c @@ -251,6 +251,7 @@ static int gen_loop(proc_instance_t *pi) char hash[68]; reconnect: + Close(sockd); if (si) { kill_server(si); reconnecting = true; @@ -267,6 +268,7 @@ reconnect: } retry: + Close(sockd); ckmsgq_add(gdata->srvchk, si); do { @@ -294,7 +296,6 @@ retry: buf = recv_unix_msg(sockd); if (!buf) { LOGWARNING("Failed to get message in gen_loop"); - Close(sockd); goto retry; } LOGDEBUG("Generator received request: %s", buf); @@ -374,7 +375,6 @@ retry: LOGDEBUG("Generator received ping request"); send_unix_msg(sockd, "pong"); } - Close(sockd); goto retry; out: