aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/librdns
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-11-08 17:12:44 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-11-08 17:12:44 +0000
commit16bb4d5c1efe0e45f1ad6dddac20f954ea8d0778 (patch)
tree9840a5f59ab3807c155a176461585c34f58d6c7b /contrib/librdns
parentcdf45ced6793f066bd965336cf8d2f443807bcbd (diff)
downloadrspamd-16bb4d5c1efe0e45f1ad6dddac20f954ea8d0778.tar.gz
rspamd-16bb4d5c1efe0e45f1ad6dddac20f954ea8d0778.zip
[Fix] Fail DNS upstream on each retransmit attempt
Diffstat (limited to 'contrib/librdns')
-rw-r--r--contrib/librdns/rdns.h5
-rw-r--r--contrib/librdns/resolver.c22
2 files changed, 16 insertions, 11 deletions
diff --git a/contrib/librdns/rdns.h b/contrib/librdns/rdns.h
index b563c7ea3..1b2f63b7a 100644
--- a/contrib/librdns/rdns.h
+++ b/contrib/librdns/rdns.h
@@ -164,8 +164,9 @@ struct rdns_upstream_context {
void *data;
struct rdns_upstream_elt* (*select)(const char *name,
size_t len, void *ups_data);
- struct rdns_upstream_elt* (*select_retransmit)(const char *name,
- size_t len, void *ups_data);
+ struct rdns_upstream_elt* (*select_retransmit)(const char *name, size_t len,
+ struct rdns_upstream_elt* prev_elt,
+ void *ups_data);
unsigned int (*count)(void *ups_data);
void (*ok)(struct rdns_upstream_elt *elt, void *ups_data);
void (*fail)(struct rdns_upstream_elt *elt, void *ups_data);
diff --git a/contrib/librdns/resolver.c b/contrib/librdns/resolver.c
index 2cc3695a7..6c4f29d8c 100644
--- a/contrib/librdns/resolver.c
+++ b/contrib/librdns/resolver.c
@@ -332,14 +332,15 @@ rdns_process_timer (void *arg)
req->retransmits --;
resolver = req->resolver;
+ if (req->resolver->ups && req->io->srv->ups_elt) {
+ req->resolver->ups->fail (req->io->srv->ups_elt,
+ req->resolver->ups->data);
+ }
+ else {
+ UPSTREAM_FAIL (req->io->srv, time (NULL));
+ }
+
if (req->retransmits == 0) {
- if (req->resolver->ups && req->io->srv->ups_elt) {
- req->resolver->ups->fail (req->io->srv->ups_elt,
- req->resolver->ups->data);
- }
- else {
- UPSTREAM_FAIL (req->io->srv, time (NULL));
- }
rep = rdns_make_reply (req, RDNS_RC_TIMEOUT);
rdns_request_unschedule (req);
@@ -371,8 +372,11 @@ rdns_process_timer (void *arg)
if (resolver->ups) {
struct rdns_upstream_elt *elt;
- elt = resolver->ups->select_retransmit (req->requested_names[0].name,
- req->requested_names[0].len, resolver->ups->data);
+ elt = resolver->ups->select_retransmit (
+ req->requested_names[0].name,
+ req->requested_names[0].len,
+ req->io->srv->ups_elt,
+ resolver->ups->data);
if (elt) {
serv = elt->server;