Browse Source

Fix potential socket leak in gen_loop

master
Con Kolivas 10 years ago
parent
commit
649ad7953f
  1. 4
      src/generator.c

4
src/generator.c

@ -251,6 +251,7 @@ static int gen_loop(proc_instance_t *pi)
char hash[68]; char hash[68];
reconnect: reconnect:
Close(sockd);
if (si) { if (si) {
kill_server(si); kill_server(si);
reconnecting = true; reconnecting = true;
@ -267,6 +268,7 @@ reconnect:
} }
retry: retry:
Close(sockd);
ckmsgq_add(gdata->srvchk, si); ckmsgq_add(gdata->srvchk, si);
do { do {
@ -294,7 +296,6 @@ retry:
buf = recv_unix_msg(sockd); buf = recv_unix_msg(sockd);
if (!buf) { if (!buf) {
LOGWARNING("Failed to get message in gen_loop"); LOGWARNING("Failed to get message in gen_loop");
Close(sockd);
goto retry; goto retry;
} }
LOGDEBUG("Generator received request: %s", buf); LOGDEBUG("Generator received request: %s", buf);
@ -374,7 +375,6 @@ retry:
LOGDEBUG("Generator received ping request"); LOGDEBUG("Generator received ping request");
send_unix_msg(sockd, "pong"); send_unix_msg(sockd, "pong");
} }
Close(sockd);
goto retry; goto retry;
out: out:

Loading…
Cancel
Save