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) {
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;
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;
}
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());
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)
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);
}
*/
#pragma once
#include <boost/utility.hpp>
-#include <boost/shared_array.hpp>
#include "iputils.hh"
#include "dnsname.hh"
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;
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
};
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) {
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());
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) {
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
};
} kQueueDoIt;
KqueueFDMultiplexer::KqueueFDMultiplexer() :
- d_kevents(new struct kevent[s_maxevents])
+ d_kevents(s_maxevents)
{
d_kqueuefd = kqueue();
if (d_kqueuefd < 0) {
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());
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) {
#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>
#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
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
};
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) {
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
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