]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Move internal DoQ structures to doq.cc
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 22 Sep 2023 08:22:12 +0000 (10:22 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 9 Oct 2023 11:37:55 +0000 (13:37 +0200)
pdns/dnsdistdist/doq.cc
pdns/dnsdistdist/doq.hh

index 2df6b6a40405f388cc8233047072589ba759c80b..0617ffcd862796f8d80f7a3ba37a8481e88c227b 100644 (file)
 
 static std::string s_quicRetryTokenKey = newKey(false);
 
+#ifdef HAVE_DNS_OVER_QUIC
+
+#include <quiche.h>
+
+using QuicheConnection = std::unique_ptr<quiche_conn, decltype(&quiche_conn_free)>;
+using QuicheConfig = std::unique_ptr<quiche_config, decltype(&quiche_config_free)>;
+
+class Connection
+{
+public:
+  Connection(const ComboAddress& peer, std::unique_ptr<quiche_conn, decltype(&quiche_conn_free)>&& conn) :
+    d_peer(peer), d_conn(std::move(conn))
+  {
+  }
+  Connection(const Connection&) = delete;
+  Connection(Connection&&) = default;
+  Connection& operator=(const Connection&) = delete;
+  Connection& operator=(Connection&&) = default;
+  ~Connection() = default;
+
+  ComboAddress d_peer;
+  QuicheConnection d_conn;
+};
+
+#endif
+
 static void sendBackDOQUnit(DOQUnitUniquePtr&& du, const char* description);
 struct DOQServerConfig
 {
@@ -94,7 +120,7 @@ public:
     }
 
     auto du = std::move(response.d_idstate.doqu);
-    if (du->responseSender == nullptr) {
+    if (du->dsc == nullptr) {
       return;
     }
 
@@ -407,11 +433,11 @@ static std::optional<std::reference_wrapper<Connection>> getConnection(const Pac
 
 static void sendBackDOQUnit(DOQUnitUniquePtr&& du, const char* description)
 {
-  if (du->responseSender == nullptr) {
+  if (du->dsc == nullptr) {
     return;
   }
   try {
-    if (!du->responseSender->send(std::move(du))) {
+    if (!du->dsc->d_responseSender.send(std::move(du))) {
       vinfolog("Unable to pass a %s to the DoQ worker thread because the pipe is full", description);
     }
   } catch (const std::exception& e) {
@@ -640,7 +666,6 @@ static void doq_dispatch_query(DOQServerConfig& dsc, PacketBuffer&& query, const
     du->ids.protocol = dnsdist::Protocol::DoQ;
     du->serverConnID = serverConnID;
     du->streamID = streamID;
-    du->responseSender = &dsc.d_responseSender;
 
     processDOQQuery(std::move(du));
   }
index a45110411a35e155e43c0038057fd7fb6585700e..112fa09751c190eaf0855a510fc25023640c19af 100644 (file)
 #include "stat_t.hh"
 #include "dnsdist-idstate.hh"
 
-#ifdef HAVE_DNS_OVER_QUIC
-
-#include <quiche.h>
-
-using QuicheConnection = std::unique_ptr<quiche_conn, decltype(&quiche_conn_free)>;
-using QuicheConfig = std::unique_ptr<quiche_config, decltype(&quiche_config_free)>;
-
-class Connection
-{
-public:
-  Connection(const ComboAddress& peer, std::unique_ptr<quiche_conn, decltype(&quiche_conn_free)>&& conn) :
-    d_peer(peer), d_conn(std::move(conn))
-  {
-  }
-  Connection(const Connection&) = delete;
-  Connection(Connection&&) = default;
-  Connection& operator=(const Connection&) = delete;
-  Connection& operator=(Connection&&) = default;
-  ~Connection() = default;
-
-  ComboAddress d_peer;
-  QuicheConnection d_conn;
-};
-
-#endif
-
 struct DOQServerConfig;
 struct DownstreamState;
 
@@ -94,16 +68,14 @@ struct DOQUnit
   InternalQueryState ids;
   PacketBuffer query;
   PacketBuffer response;
+  PacketBuffer serverConnID;
   std::shared_ptr<DownstreamState> downstream{nullptr};
   DOQServerConfig* dsc{nullptr};
-  pdns::channel::Sender<DOQUnit>* responseSender{nullptr};
-  size_t proxyProtocolPayloadSize{0};
   uint64_t streamID{0};
-  PacketBuffer serverConnID;
+  size_t proxyProtocolPayloadSize{0};
   /* whether the query was re-sent to the backend over
      TCP after receiving a truncated answer over UDP */
   bool tcp{false};
-  bool truncated{false};
 };
 
 using DOQUnitUniquePtr = std::unique_ptr<DOQUnit>;