]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolved: add 'next_attempt_after' field to DnsTransaction
authorDaniel Mack <daniel@zonque.org>
Mon, 30 Nov 2015 21:35:51 +0000 (22:35 +0100)
committerDaniel Mack <daniel@zonque.org>
Tue, 8 Dec 2015 15:51:41 +0000 (16:51 +0100)
For each transaction, record when the earliest point in time when the
query packet may hit the wire. This is the same time stamp for which
the timer is scheduled in retries, except for the initial query packets
which are delayed by a random jitter. In this case, we denote that the
packet may actually be sent at the nominal time, without the jitter.

Transactions that share the same timestamp will also have identical
values in this field. It is used to coalesce pending queries in a later
patch.

src/resolve/resolved-dns-transaction.c
src/resolve/resolved-dns-transaction.h

index 6eec1446d71a5935d3f3db070f1ddd959ba44a4d..7924b24354912b4afb72a2c9e7d3dc009f857aa6 100644 (file)
@@ -814,6 +814,7 @@ int dns_transaction_go(DnsTransaction *t) {
                         return r;
 
                 t->n_attempts = 0;
+                t->next_attempt_after = ts;
                 t->state = DNS_TRANSACTION_PENDING;
 
                 log_debug("Delaying %s transaction for " USEC_FMT "us.", dns_protocol_to_string(t->scope->protocol), jitter);
@@ -863,16 +864,20 @@ int dns_transaction_go(DnsTransaction *t) {
                 return dns_transaction_go(t);
         }
 
+        ts += transaction_get_resend_timeout(t);
+
         r = sd_event_add_time(
                         t->scope->manager->event,
                         &t->timeout_event_source,
                         clock_boottime_or_monotonic(),
-                        ts + transaction_get_resend_timeout(t), 0,
+                        ts, 0,
                         on_transaction_timeout, t);
         if (r < 0)
                 return r;
 
         t->state = DNS_TRANSACTION_PENDING;
+        t->next_attempt_after = ts;
+
         return 1;
 }
 
index e3d4b861be5692bed6a3bdf2cf4f2814033c88d6..af08b20e44b381feef57143e3deeafbff242f69a 100644 (file)
@@ -73,6 +73,7 @@ struct DnsTransaction {
         bool answer_authenticated;
 
         usec_t start_usec;
+        usec_t next_attempt_after;
         sd_event_source *timeout_event_source;
         unsigned n_attempts;