]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fail DNS upstream on each retransmit attempt
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 8 Nov 2019 17:12:44 +0000 (17:12 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 8 Nov 2019 17:12:44 +0000 (17:12 +0000)
contrib/librdns/rdns.h
contrib/librdns/resolver.c
src/libserver/dns.c

index b563c7ea3fc20e6ceca83d58cbf579dee1923f4c..1b2f63b7a480657630a7e4178394fe8f2ea9a01a 100644 (file)
@@ -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);
index 2cc3695a747bc5d120da3aa9d389429c25f1d857..6c4f29d8c3c6bcb274a761af4bdbe18201c7f1ab 100644 (file)
@@ -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;
index 710f96b3adbed0a0a075e794250b9e5ce7f936d2..f5b35eab7b78caa4207df52f61903a442d72efec 100644 (file)
@@ -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;