Browse Source

Don't leak memory on server reconnect

master
Con Kolivas 10 years ago
parent
commit
a40bbda19b
  1. 23
      src/generator.c
  2. 1
      src/libckpool.c

23
src/generator.c

@ -181,10 +181,18 @@ out:
static void kill_server(server_instance_t *si)
{
connsock_t *cs;
if (!si)
return;
close(si->cs.fd);
si->cs.fd = -1;
cs = &si->cs;
close(cs->fd);
cs->fd = -1;
dealloc(cs->url);
dealloc(cs->port);
dealloc(cs->auth);
dealloc(si->data);
dealloc(si);
}
static int gen_loop(proc_instance_t *pi)
@ -1304,14 +1312,9 @@ static int server_mode(ckpool_t *ckp, proc_instance_t *pi)
ret = gen_loop(pi);
for (i = 0; i < ckp->btcds; si = ckp->servers[i], i++) {
connsock_t *cs = &si->cs;
dealloc(cs->url);
dealloc(cs->port);
dealloc(cs->auth);
dealloc(si->data);
dealloc(si);
for (i = 0; i < ckp->btcds; i++) {
si = ckp->servers[i];
kill_server(si);
}
dealloc(ckp->servers);
return ret;

1
src/libckpool.c

@ -270,7 +270,6 @@ bool extract_sockaddr(char *url, char **sockaddr_url, char **sockaddr_port)
LOGWARNING("Null length url string passed to extract_sockaddr");
return false;
}
*sockaddr_url = url;
url_begin = strstr(url, "//");
if (!url_begin)
url_begin = url;

Loading…
Cancel
Save