]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Apply suggestions from Otto's code review (thanks!)
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 11 Jan 2023 11:27:23 +0000 (12:27 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 11 Jan 2023 11:28:23 +0000 (12:28 +0100)
pdns/dnsdist-idstate.hh
pdns/dnsdistdist/dnsdist-backend.cc

index 1fb8116be16af15016b9c326f5ecfef6e3905415..56547166479cc80b6f1d61338e57124d8e63b6d7 100644 (file)
@@ -160,14 +160,13 @@ struct IDState
   }
 
   IDState(const IDState& orig) = delete;
-  IDState(IDState&& rhs)
+  IDState(IDState&& rhs) noexcept: internal(std::move(rhs.internal))
   {
     inUse.store(rhs.inUse.load());
     age.store(rhs.age.load());
-    internal = std::move(rhs.internal);
   }
 
-  IDState& operator=(IDState&& rhs)
+  IDState& operator=(IDState&& rhs) noexcept
   {
     inUse.store(rhs.inUse.load());
     age.store(rhs.age.load());
@@ -177,7 +176,7 @@ struct IDState
 
   bool isInUse() const
   {
-    return inUse == true;
+    return inUse;
   }
 
   /* For performance reasons we don't want to use a lock here, but that means
index eea141e440509a02dd149d373910882b5bb788f7..f1183c2e5160bd6342124a0093a4d8ab1b5d28a2 100644 (file)
@@ -447,17 +447,16 @@ uint16_t DownstreamState::saveState(InternalQueryState&& state)
   }
 
   do {
-    IDState* ids = nullptr;
     uint16_t selectedID = (idOffset++) % idStates.size();
-    ids = &idStates[selectedID];
-    auto guard = ids->acquire();
+    IDState& ids = idStates[selectedID];
+    auto guard = ids.acquire();
     if (!guard) {
       continue;
     }
-    if (ids->isInUse()) {
+    if (ids.isInUse()) {
       /* we are reusing a state, no change in outstanding but if there was an existing DOHUnit we need
          to handle it because it's about to be overwritten. */
-      auto oldDU = std::move(ids->internal.du);
+      auto oldDU = std::move(ids.internal.du);
       ++reuseds;
       ++g_stats.downstreamTimeouts;
       handleDOHTimeout(std::move(oldDU));
@@ -465,9 +464,9 @@ uint16_t DownstreamState::saveState(InternalQueryState&& state)
     else {
       ++outstanding;
     }
-    ids->internal = std::move(state);
-    ids->age.store(0);
-    ids->inUse = true;
+    ids.internal = std::move(state);
+    ids.age.store(0);
+    ids.inUse = true;
     return selectedID;
   }
   while (true);