aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2022-01-02 10:34:05 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2022-01-02 10:34:05 +0000
commitaf3994ae7d27e935228fb866103d94310de974c3 (patch)
tree411ed8316857549d8f9f5d4cd08fcc5aa750af11 /contrib
parent02e027d0c0a5ffed16e3d387c3893ce9ff5a2521 (diff)
downloadrspamd-af3994ae7d27e935228fb866103d94310de974c3.tar.gz
rspamd-af3994ae7d27e935228fb866103d94310de974c3.zip
[Project] Rdns: Do not treat TCP channels failure as fatal
Diffstat (limited to 'contrib')
-rw-r--r--contrib/librdns/resolver.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/contrib/librdns/resolver.c b/contrib/librdns/resolver.c
index 6ef6d4558..05d838317 100644
--- a/contrib/librdns/resolver.c
+++ b/contrib/librdns/resolver.c
@@ -935,28 +935,46 @@ rdns_resolver_init (struct rdns_resolver *resolver)
/* Now init io channels to all servers */
UPSTREAM_FOREACH (resolver->servers, serv) {
serv->io_channels = calloc (serv->io_cnt, sizeof (struct rdns_io_channel *));
+
+ if (serv->io_channels == NULL) {
+ rdns_err ("cannot allocate memory for the resolver IO channels");
+ return false;
+ }
+
for (i = 0; i < serv->io_cnt; i ++) {
ioc = rdns_ioc_new(serv, resolver, false);
if (ioc == NULL) {
- rdns_err ("cannot allocate memory for the resolver IO channels");
+ rdns_err ("cannot allocate memory or init the IO channel");
return false;
}
serv->io_channels[i] = ioc;
}
+ int ntcp_channels = 0;
+
+ /*
+ * We are more forgiving for TCP IO channels: we can have zero of them
+ * if DNS is misconfigured and still be able to resolve stuff
+ */
serv->tcp_io_channels = calloc (serv->tcp_io_cnt, sizeof (struct rdns_io_channel *));
+ if (serv->tcp_io_channels == NULL) {
+ rdns_err ("cannot allocate memory for the resolver TCP IO channels");
+ return false;
+ }
for (i = 0; i < serv->tcp_io_cnt; i ++) {
ioc = rdns_ioc_new (serv, resolver, true);
if (ioc == NULL) {
- rdns_err ("cannot allocate memory for the resolver IO channels");
- return false;
+ rdns_err ("cannot allocate memory or init the TCP IO channel");
+ continue;
}
- serv->tcp_io_channels[i] = ioc;
+ serv->tcp_io_channels[ntcp_channels++] = ioc;
}
+
+ serv->tcp_io_cnt = ntcp_channels;
}
if (resolver->async->add_periodic) {