]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Skip the no-op code in adjustsrtt()
authorOndřej Surý <ondrej@isc.org>
Thu, 12 Oct 2023 07:17:40 +0000 (09:17 +0200)
committerOndřej Surý <ondrej@isc.org>
Thu, 12 Oct 2023 10:35:00 +0000 (12:35 +0200)
If factor == DNS_ADB_RTTADJAGE and addr->entry->lastage == now we would
load value into new_srtt and then immediatelly store it back which
triggers the synchronization between threads using .srtt values.

lib/dns/adb.c

index 26f9885ba34ac5c2c9cef63322331c8f1594b41a..a589519f6eec7574368a1a078b93a11123a32f66 100644 (file)
@@ -3057,18 +3057,17 @@ adjustsrtt(dns_adbaddrinfo_t *addr, unsigned int rtt, unsigned int factor,
                        new_srtt -= addr->entry->srtt;
                        new_srtt >>= 9;
                        atomic_store(&addr->entry->lastage, now);
-               } else {
-                       new_srtt = atomic_load(&addr->entry->srtt)
+                       atomic_store(&addr->entry->srtt, new_srtt);
+                       addr->srtt = new_srtt;
                }
        } else {
                new_srtt = ((uint64_t)atomic_load(&addr->entry->srtt) / 10 *
                            factor) +
                           ((uint64_t)rtt / 10 * (10 - factor));
+               atomic_store(&addr->entry->srtt, new_srtt);
+               addr->srtt = new_srtt;
        }
 
-       atomic_store(&addr->entry->srtt, new_srtt);
-       addr->srtt = new_srtt;
-
        (void)atomic_compare_exchange_strong(&addr->entry->expires,
                                             &(isc_stdtime_t){ 0 },
                                             now + ADB_ENTRY_WINDOW);