From 38edba8994edd9a9326b8f3909b7b5f801bb45b0 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Tue, 23 Nov 2021 15:36:12 +0100 Subject: [PATCH] dnsdist: Cleaner TCPCrossProtocolQuerySender() constructor --- pdns/dnsdist-tcp.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pdns/dnsdist-tcp.cc b/pdns/dnsdist-tcp.cc index ada447c3de..7acf6909e3 100644 --- a/pdns/dnsdist-tcp.cc +++ b/pdns/dnsdist-tcp.cc @@ -565,7 +565,7 @@ struct TCPCrossProtocolResponse class TCPCrossProtocolQuerySender : public TCPQuerySender { public: - TCPCrossProtocolQuerySender(std::shared_ptr& state, int responseDescriptor): d_state(state), d_responseDesc(responseDescriptor) + TCPCrossProtocolQuerySender(std::shared_ptr& state): d_state(state) { } @@ -581,13 +581,13 @@ public: void handleResponse(const struct timeval& now, TCPResponse&& response) override { - if (d_responseDesc == -1) { + if (d_state->d_threadData.crossProtocolResponsesPipe == -1) { throw std::runtime_error("Invalid pipe descriptor in TCP Cross Protocol Query Sender"); } auto ptr = new TCPCrossProtocolResponse(std::move(response), d_state, now); static_assert(sizeof(ptr) <= PIPE_BUF, "Writes up to PIPE_BUF are guaranteed not to be interleaved and to either fully succeed or fail"); - ssize_t sent = write(d_responseDesc, &ptr, sizeof(ptr)); + ssize_t sent = write(d_state->d_threadData.crossProtocolResponsesPipe, &ptr, sizeof(ptr)); if (sent != sizeof(ptr)) { if (errno == EAGAIN || errno == EWOULDBLOCK) { ++g_stats.tcpCrossProtocolResponsePipeFull; @@ -613,7 +613,6 @@ public: private: std::shared_ptr d_state; - int d_responseDesc{-1}; }; class TCPCrossProtocolQuery : public CrossProtocolQuery @@ -774,7 +773,7 @@ static void handleQuery(std::shared_ptr& state, cons proxyProtocolPayload = getProxyProtocolPayload(dq); } - auto incoming = std::make_shared(state, state->d_threadData.crossProtocolResponsesPipe); + auto incoming = std::make_shared(state); auto cpq = std::make_unique(std::move(state->d_buffer), std::move(ids), ds, incoming); cpq->query.d_proxyProtocolPayload = std::move(proxyProtocolPayload); -- 2.47.2