]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Stop using the deprecated boost::shared_array 11141/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 4 Jan 2022 10:22:27 +0000 (11:22 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 4 Jan 2022 10:22:27 +0000 (11:22 +0100)
It was deprecated in 1.65.0: `This facility is deprecated because a shared_ptr
to T[] or T[N] is now available, and is superior in every regard`.

As far as I can tell we never actually used the reference counting 'shared'
feature anyway.

pdns/axfr-retriever.cc
pdns/axfr-retriever.hh
pdns/epollmplexer.cc
pdns/kqueuemplexer.cc
pdns/mplexer.hh
pdns/pdns_recursor.cc
pdns/portsmplexer.cc

index 99f386bc148bec366f8653a95c14bbb253d53f5a..c206306eeb05ad32f0b7da97c77901bff734fc3f 100644 (file)
@@ -35,7 +35,7 @@ AXFRRetriever::AXFRRetriever(const ComboAddress& remote,
                              const ComboAddress* laddr,
                              size_t maxReceivedBytes,
                              uint16_t timeout)
-  : d_tsigVerifier(tt, remote, d_trc), d_receivedBytes(0), d_maxReceivedBytes(maxReceivedBytes)
+  : d_buf(65536), d_tsigVerifier(tt, remote, d_trc), d_receivedBytes(0), d_maxReceivedBytes(maxReceivedBytes)
 {
   ComboAddress local;
   if (laddr != nullptr) {
@@ -51,7 +51,7 @@ AXFRRetriever::AXFRRetriever(const ComboAddress& remote,
     d_sock = makeQuerySocket(local, false); // make a TCP socket
     if (d_sock < 0)
       throw ResolverException("Error creating socket for AXFR request to "+d_remote.toStringWithPort());
-    d_buf = boost::shared_array<char>(new char[65536]);
+
     d_remote = remote; // mostly for error reporting
     this->connect(timeout);
     d_soacount = 0;
@@ -125,7 +125,7 @@ int AXFRRetriever::getChunk(Resolver::res_t &res, vector<DNSRecord>* records, ui
 
   d_receivedBytes += (uint16_t) len;
 
-  MOADNSParser mdp(false, d_buf.get(), len);
+  MOADNSParser mdp(false, d_buf.data(), len);
 
   int err = mdp.d_header.rcode;
 
@@ -134,7 +134,7 @@ int AXFRRetriever::getChunk(Resolver::res_t &res, vector<DNSRecord>* records, ui
   }
 
   try {
-    d_tsigVerifier.check(std::string(d_buf.get(), len), mdp);
+    d_tsigVerifier.check(std::string(d_buf.data(), len), mdp);
   }
   catch(const std::runtime_error& re) {
     throw ResolverException(re.what());
@@ -177,7 +177,7 @@ void AXFRRetriever::timeoutReadn(uint16_t bytes, uint16_t timeoutsec)
     if(!res)
       throw ResolverException("Timeout while reading data from remote nameserver over TCP");
 
-    numread=recv(d_sock, d_buf.get()+n, bytes-n, 0);
+    numread=recv(d_sock, &d_buf.at(n), bytes-n, 0);
     if(numread<0)
       throw ResolverException("Reading data from remote nameserver over TCP: "+stringerror());
     if(numread==0)
@@ -243,6 +243,6 @@ void AXFRRetriever::connect(uint16_t timeout)
 int AXFRRetriever::getLength(uint16_t timeout)
 {
   timeoutReadn(2, timeout);
-  return (unsigned char)d_buf[0]*256+(unsigned char)d_buf[1];
+  return (unsigned char)d_buf.at(0)*256+(unsigned char)d_buf.at(1);
 }
 
index f3e5c2bb88d9eca1638848ada33674a91be2af69..81362b754b5aa8fd8a21e56640cc376ab11677c1 100644 (file)
@@ -21,7 +21,6 @@
  */
 #pragma once
 #include <boost/utility.hpp>
-#include <boost/shared_array.hpp>
 
 #include "iputils.hh"
 #include "dnsname.hh"
@@ -44,7 +43,7 @@ class AXFRRetriever : public boost::noncopyable
     int getLength(uint16_t timeout);
     void timeoutReadn(uint16_t bytes, uint16_t timeoutsec=10);
 
-    boost::shared_array<char> d_buf;
+    std::vector<char> d_buf;
     string d_domain;
     int d_sock;
     int d_soacount;
index d0cbf548851e2fdeb3298cd83ae3eb2df732f414..85158d246f6879a4c2e9d3f3057c418e7090ed89 100644 (file)
@@ -58,7 +58,7 @@ public:
 
 private:
   int d_epollfd;
-  boost::shared_array<epoll_event> d_eevents;
+  std::vector<epoll_event> d_eevents;
   static int s_maxevents; // not a hard maximum
 };
 
@@ -78,7 +78,7 @@ static struct EpollRegisterOurselves
 int EpollFDMultiplexer::s_maxevents = 1024;
 
 EpollFDMultiplexer::EpollFDMultiplexer() :
-  d_eevents(new epoll_event[s_maxevents])
+  d_eevents(s_maxevents)
 {
   d_epollfd = epoll_create(s_maxevents); // not hard max
   if (d_epollfd < 0) {
@@ -156,7 +156,7 @@ void EpollFDMultiplexer::alterFD(int fd, FDMultiplexer::EventKind, FDMultiplexer
 
 void EpollFDMultiplexer::getAvailableFDs(std::vector<int>& fds, int timeout)
 {
-  int ret = epoll_wait(d_epollfd, d_eevents.get(), s_maxevents, timeout);
+  int ret = epoll_wait(d_epollfd, d_eevents.data(), s_maxevents, timeout);
 
   if (ret < 0 && errno != EINTR) {
     throw FDMultiplexerException("epoll returned error: " + stringerror());
@@ -173,7 +173,7 @@ int EpollFDMultiplexer::run(struct timeval* now, int timeout)
     throw FDMultiplexerException("FDMultiplexer::run() is not reentrant!\n");
   }
 
-  int ret = epoll_wait(d_epollfd, d_eevents.get(), s_maxevents, timeout);
+  int ret = epoll_wait(d_epollfd, d_eevents.data(), s_maxevents, timeout);
   gettimeofday(now, nullptr); // MANDATORY
 
   if (ret < 0 && errno != EINTR) {
index a81487c090891cb242c0c199c45ec4a6db42bf75..f777b8080819a63b1941dead3506cdddb92c8f15 100644 (file)
@@ -59,7 +59,7 @@ public:
 
 private:
   int d_kqueuefd;
-  boost::shared_array<struct kevent> d_kevents;
+  std::vector<struct kevent> d_kevents;
   static unsigned int s_maxevents; // not a hard maximum
 };
 
@@ -79,7 +79,7 @@ static struct KqueueRegisterOurselves
 } kQueueDoIt;
 
 KqueueFDMultiplexer::KqueueFDMultiplexer() :
-  d_kevents(new struct kevent[s_maxevents])
+  d_kevents(s_maxevents)
 {
   d_kqueuefd = kqueue();
   if (d_kqueuefd < 0) {
@@ -148,7 +148,7 @@ void KqueueFDMultiplexer::getAvailableFDs(std::vector<int>& fds, int timeout)
   ts.tv_sec = timeout / 1000;
   ts.tv_nsec = (timeout % 1000) * 1000000;
 
-  int ret = kevent(d_kqueuefd, 0, 0, d_kevents.get(), s_maxevents, &ts);
+  int ret = kevent(d_kqueuefd, 0, 0, d_kevents.data(), s_maxevents, &ts);
 
   if (ret < 0 && errno != EINTR) {
     throw FDMultiplexerException("kqueue returned error: " + stringerror());
@@ -177,7 +177,7 @@ int KqueueFDMultiplexer::run(struct timeval* now, int timeout)
   ts.tv_sec = timeout / 1000;
   ts.tv_nsec = (timeout % 1000) * 1000000;
 
-  int ret = kevent(d_kqueuefd, 0, 0, d_kevents.get(), s_maxevents, &ts);
+  int ret = kevent(d_kqueuefd, 0, 0, d_kevents.data(), s_maxevents, &ts);
   gettimeofday(now, nullptr); // MANDATORY!
 
   if (ret < 0 && errno != EINTR) {
index d85efe91fe54487b650221966a956cea8b0376bc..474ea89067ba1d8589174c6ed9f181a4d991a3f6 100644 (file)
@@ -22,7 +22,6 @@
 #pragma once
 #include <boost/function.hpp>
 #include <boost/any.hpp>
-#include <boost/shared_array.hpp>
 #include <boost/tuple/tuple.hpp>
 #include <boost/tuple/tuple_comparison.hpp>
 #include <boost/multi_index_container.hpp>
index c22e43419bf6f0a1c8e421df9915e47f6d206741..a021544453373dcbb55d0d79eb8ae4d95d54df7a 100644 (file)
@@ -61,7 +61,6 @@
 #include <boost/any.hpp>
 #include <boost/tuple/tuple.hpp>
 #include <boost/tuple/tuple_comparison.hpp>
-#include <boost/shared_array.hpp>
 #include <boost/function.hpp>
 #include <boost/algorithm/string.hpp>
 #ifdef MALLOC_TRACE
index d4f36591b149b432e5779e6a6bcc9410f043fcbf..f5e151043cee874ca8b427014bbfc86bbde61668 100644 (file)
@@ -36,7 +36,7 @@ public:
 
 private:
   int d_portfd;
-  boost::shared_array<port_event_t> d_pevents;
+  std::vector<port_event_t> d_pevents;
   static int s_maxevents; // not a hard maximum
 };
 
@@ -56,7 +56,7 @@ static struct PortsRegisterOurselves
 int PortsFDMultiplexer::s_maxevents = 1024;
 
 PortsFDMultiplexer::PortsFDMultiplexer() :
-  d_pevents(new port_event_t[s_maxevents])
+  d_pevents(s_maxevents)
 {
   d_portfd = port_create(); // not hard max
   if (d_portfd < 0) {
@@ -97,7 +97,7 @@ void PortsFDMultiplexer::getAvailableFDs(std::vector<int>& fds, int timeout)
   timeoutspec.tv_sec = timeout / 1000;
   timeoutspec.tv_nsec = (timeout % 1000) * 1000000;
   unsigned int numevents = 1;
-  int ret = port_getn(d_portfd, d_pevents.get(), min(PORT_MAX_LIST, s_maxevents), &numevents, &timeoutspec);
+  int ret = port_getn(d_portfd, d_pevents.data(), min(PORT_MAX_LIST, s_maxevents), &numevents, &timeoutspec);
 
   /* port_getn has an unusual API - (ret == -1, errno == ETIME) can
      mean partial success; you must check (*numevents) in this case
@@ -158,7 +158,7 @@ int PortsFDMultiplexer::run(struct timeval* now, int timeout)
   timeoutspec.tv_sec = timeout / 1000;
   timeoutspec.tv_nsec = (timeout % 1000) * 1000000;
   unsigned int numevents = 1;
-  int ret = port_getn(d_portfd, d_pevents.get(), min(PORT_MAX_LIST, s_maxevents), &numevents, &timeoutspec);
+  int ret = port_getn(d_portfd, d_pevents.data(), min(PORT_MAX_LIST, s_maxevents), &numevents, &timeoutspec);
 
   /* port_getn has an unusual API - (ret == -1, errno == ETIME) can
      mean partial success; you must check (*numevents) in this case