]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon/worker: retransmit based on current score
authorMarek Vavrusa <marek@vavrusa.com>
Mon, 5 Sep 2016 00:42:03 +0000 (17:42 -0700)
committerMarek Vavrusa <marek@vavrusa.com>
Mon, 5 Sep 2016 00:42:03 +0000 (17:42 -0700)
if the score is known (and not glued), the retry
rate is <avg(rtt), 250ms>

if the NS score is unknown or worse than 250ms,
it is always retried at this rate

all other servers in the list use default rate

daemon/worker.c
lib/defines.h

index 0210ce6f6fec9e78fea397615ab5d58d52a895f0..82ddba909d571b17856cb4dee7aef545634e9274 100644 (file)
@@ -745,9 +745,21 @@ static int qr_task_step(struct qr_task *task, const struct sockaddr *packet_sour
                if (subreq_enqueue(task)) {
                        return kr_ok(); /* Will be notified when outgoing query finishes. */
                }
+               /* Check current query NSLIST */
+               struct kr_query *qry = array_tail(task->req.rplan.pending);
                /* Start transmitting */
                if (retransmit(task)) {
-                       ret = timer_start(task, on_retransmit, KR_CONN_RETRY, 0);
+                       assert(qry != NULL);
+                       /* Retransmit at default interval, or more frequently if the mean
+                        * RTT of the server is better. If the server is glued, use default rate. */
+                       size_t timeout = qry->ns.score;
+                       if (timeout > KR_NS_GLUED) {
+                               /* We don't have information about variance in RTT, expect +10ms */
+                               timeout = MIN(qry->ns.score + 10, KR_CONN_RETRY);
+                       } else {
+                               timeout = KR_CONN_RETRY;
+                       }
+                       ret = timer_start(task, on_retransmit, timeout, 0);
                } else {
                        return qr_task_step(task, NULL, NULL);
                }
index a9baf643bcf90ef7125667b5c85da817256bfa9b..2e64e564847fcfa8dc7bfd30b7a02938ac253365 100644 (file)
@@ -51,7 +51,7 @@ static inline int __attribute__((__cold__)) kr_error(int x) {
  * @cond internal
  */
 #define KR_CONN_RTT_MAX 3000 /* Timeout for network activity */
-#define KR_CONN_RETRY 300    /* Retry interval for network activity */
+#define KR_CONN_RETRY 250    /* Retry interval for network activity */
 #define KR_ITER_LIMIT 50     /* Built-in iterator limit */
 #define KR_CNAME_CHAIN_LIMIT 40 /* Built-in maximum CNAME chain length */
 #define KR_TIMEOUT_LIMIT 4   /* Maximum number of retries after timeout. */