aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-03-14 18:45:06 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-03-14 18:45:06 +0000
commit48208dfdc5f94d4f7a2668d52d679841a7c0ce92 (patch)
tree113e0bc8f2506d90ae2b6d43ba6a5495c124e46f /src/libutil
parent3740caa96e5a3d930db98564f59b00a104e499fa (diff)
downloadrspamd-48208dfdc5f94d4f7a2668d52d679841a7c0ce92.tar.gz
rspamd-48208dfdc5f94d4f7a2668d52d679841a7c0ce92.zip
[Fix] More fixes to maps resources management
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/map.c55
1 files changed, 30 insertions, 25 deletions
diff --git a/src/libutil/map.c b/src/libutil/map.c
index 972cae2d2..e6f185a39 100644
--- a/src/libutil/map.c
+++ b/src/libutil/map.c
@@ -65,6 +65,9 @@ write_http_request (struct http_callback_data *cbd)
msg->url = rspamd_fstring_new_init (cbd->data->path, strlen (cbd->data->path));
msg->url = rspamd_fstring_append (msg->url, ".sig", 4);
}
+ else {
+ g_assert_not_reached ();
+ }
rspamd_http_connection_write_message (cbd->conn, msg, cbd->data->host,
NULL, cbd, cbd->fd, &cbd->tv, cbd->ev_base);
@@ -73,7 +76,6 @@ write_http_request (struct http_callback_data *cbd)
else {
msg_err_pool ("cannot connect to %s: %s", cbd->data->host,
strerror (errno));
- REF_RELEASE (cbd);
}
}
@@ -225,6 +227,10 @@ free_http_cbdata (struct http_callback_data *cbd)
close (cbd->fd);
}
+ if (cbd->addr) {
+ rspamd_inet_address_destroy (cbd->addr);
+ }
+
g_slice_free1 (sizeof (struct http_callback_data), cbd);
}
@@ -563,11 +569,6 @@ rspamd_map_dns_callback (struct rdns_reply *reply, void *arg)
struct http_callback_data *cbd = arg;
rspamd_mempool_t *pool;
- if (cbd->stage >= map_load_file) {
- /* No need in further corrections */
- return;
- }
-
pool = cbd->map->pool;
if (reply->code == RDNS_RC_NOERROR) {
@@ -575,28 +576,32 @@ rspamd_map_dns_callback (struct rdns_reply *reply, void *arg)
* We just get the first address hoping that a resolver performs
* round-robin rotation well
*/
- cbd->addr = rspamd_inet_address_from_rnds (reply->entries);
-
-
- if (cbd->addr != NULL) {
- rspamd_inet_address_set_port (cbd->addr, cbd->data->port);
- /* Try to open a socket */
-
- cbd->fd = rspamd_inet_address_connect (cbd->addr, SOCK_STREAM, TRUE);
-
- if (cbd->fd != -1) {
- cbd->stage = map_load_file;
- cbd->conn = rspamd_http_connection_new (http_map_read,
- http_map_error, http_map_finish,
- RSPAMD_HTTP_BODY_PARTIAL|RSPAMD_HTTP_CLIENT_SIMPLE,
- RSPAMD_HTTP_CLIENT, NULL);
-
- write_http_request (cbd);
+ if (cbd->addr == NULL) {
+ cbd->addr = rspamd_inet_address_from_rnds (reply->entries);
+
+ if (cbd->addr != NULL) {
+ rspamd_inet_address_set_port (cbd->addr, cbd->data->port);
+ /* Try to open a socket */
+ cbd->fd = rspamd_inet_address_connect (cbd->addr, SOCK_STREAM,
+ TRUE);
+
+ if (cbd->fd != -1) {
+ cbd->stage = map_load_file;
+ cbd->conn = rspamd_http_connection_new (http_map_read,
+ http_map_error, http_map_finish,
+ RSPAMD_HTTP_BODY_PARTIAL|RSPAMD_HTTP_CLIENT_SIMPLE,
+ RSPAMD_HTTP_CLIENT, NULL);
+
+ write_http_request (cbd);
+ }
+ else {
+ rspamd_inet_address_destroy (cbd->addr);
+ cbd->addr = NULL;
+ }
}
}
}
-
- if (cbd->stage < map_load_file) {
+ else if (cbd->stage < map_load_file) {
if (cbd->stage == map_resolve_host2) {
/* We have still one request pending */
cbd->stage = map_resolve_host1;