diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-11-08 17:12:44 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-11-08 17:12:44 +0000 |
commit | 16bb4d5c1efe0e45f1ad6dddac20f954ea8d0778 (patch) | |
tree | 9840a5f59ab3807c155a176461585c34f58d6c7b | |
parent | cdf45ced6793f066bd965336cf8d2f443807bcbd (diff) | |
download | rspamd-16bb4d5c1efe0e45f1ad6dddac20f954ea8d0778.tar.gz rspamd-16bb4d5c1efe0e45f1ad6dddac20f954ea8d0778.zip |
[Fix] Fail DNS upstream on each retransmit attempt
-rw-r--r-- | contrib/librdns/rdns.h | 5 | ||||
-rw-r--r-- | contrib/librdns/resolver.c | 22 | ||||
-rw-r--r-- | src/libserver/dns.c | 8 |
3 files changed, 22 insertions, 13 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; diff --git a/src/libserver/dns.c b/src/libserver/dns.c index 710f96b3a..f5b35eab7 100644 --- a/src/libserver/dns.c +++ b/src/libserver/dns.c @@ -30,7 +30,9 @@ static struct rdns_upstream_elt* rspamd_dns_select_upstream (const char *name, size_t len, void *ups_data); static struct rdns_upstream_elt* rspamd_dns_select_upstream_retransmit ( const char *name, - size_t len, void *ups_data); + size_t len, + struct rdns_upstream_elt *prev_elt, + void *ups_data); static void rspamd_dns_upstream_ok (struct rdns_upstream_elt *elt, void *ups_data); static void rspamd_dns_upstream_fail (struct rdns_upstream_elt *elt, @@ -815,7 +817,9 @@ rspamd_dns_select_upstream (const char *name, static struct rdns_upstream_elt* rspamd_dns_select_upstream_retransmit ( const char *name, - size_t len, void *ups_data) + size_t len, + struct rdns_upstream_elt *prev_elt, + void *ups_data) { struct upstream_list *ups = ups_data; struct upstream *up; |