From: Remi Gacogne Date: Tue, 23 Nov 2021 14:36:12 +0000 (+0100) Subject: dnsdist: Cleaner TCPCrossProtocolQuerySender() constructor X-Git-Tag: auth-4.8.0-alpha0~146^2~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=38edba8994edd9a9326b8f3909b7b5f801bb45b0;p=thirdparty%2Fpdns.git dnsdist: Cleaner TCPCrossProtocolQuerySender() constructor --- 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);