aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/upstream.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-01-18 18:54:31 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-01-18 18:54:31 +0000
commitf3164efecab37a350abd79ad350840caaf6eb8f1 (patch)
tree441ace3b44712ff77db62da90c01154520f12b27 /src/libutil/upstream.c
parent87be736a89369f4c746e5a97352000eceaabac3a (diff)
downloadrspamd-f3164efecab37a350abd79ad350840caaf6eb8f1.tar.gz
rspamd-f3164efecab37a350abd79ad350840caaf6eb8f1.zip
[Fix] Further memory leaks fixes
Diffstat (limited to 'src/libutil/upstream.c')
-rw-r--r--src/libutil/upstream.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/libutil/upstream.c b/src/libutil/upstream.c
index 4e437d416..48ef08329 100644
--- a/src/libutil/upstream.c
+++ b/src/libutil/upstream.c
@@ -80,6 +80,7 @@ struct upstream_ctx {
guint dns_retransmits;
GQueue *upstreams;
gboolean configured;
+ rspamd_mempool_t *pool;
ref_entry_t ref;
};
@@ -144,6 +145,7 @@ rspamd_upstream_ctx_dtor (struct upstream_ctx *ctx)
}
g_queue_free (ctx->upstreams);
+ rspamd_mempool_delete (ctx->pool);
g_slice_free1 (sizeof (*ctx), ctx);
}
@@ -165,6 +167,8 @@ rspamd_upstreams_library_init (void)
ctx->dns_timeout = default_dns_timeout;
ctx->revive_jitter = default_revive_jitter;
ctx->revive_time = default_revive_time;
+ ctx->pool = rspamd_mempool_new (rspamd_mempool_suggest_size (),
+ "upstreams");
ctx->upstreams = g_queue_new ();
REF_INIT_RETAIN (ctx, rspamd_upstream_ctx_dtor);
@@ -549,7 +553,8 @@ rspamd_upstreams_add_upstream (struct upstream_list *ups,
if (!rspamd_parse_host_port_priority (str, &addrs,
&up->weight,
- &up->name, def_port, NULL)) {
+ &up->name, def_port, ups->ctx->pool)) {
+
g_slice_free1 (sizeof (*up), up);
return FALSE;
}
@@ -558,8 +563,6 @@ rspamd_upstreams_add_upstream (struct upstream_list *ups,
addr = g_ptr_array_index (addrs, i);
rspamd_upstream_add_addr (up, rspamd_inet_address_copy (addr));
}
-
- g_ptr_array_free (addrs, TRUE);
}
if (up->weight == 0 && ups->rot_alg == RSPAMD_UPSTREAM_MASTER_SLAVE) {