From: bert hubert Date: Mon, 2 Feb 2015 15:47:57 +0000 (+0100) Subject: actually make calidns work with sendmmsg X-Git-Tag: dnsdist-1.0.0-alpha1~307 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ea550a8281fd0febabf9006fec009ffb6541a7d2;p=thirdparty%2Fpdns.git actually make calidns work with sendmmsg --- diff --git a/pdns/calidns.cc b/pdns/calidns.cc index 0932c9f43d..7384ec9b82 100644 --- a/pdns/calidns.cc +++ b/pdns/calidns.cc @@ -99,31 +99,33 @@ void sendThread(const vector* sockets, const vector >* int count=0; struct Unit { - Unit(){} - Unit(const Unit&) = delete; - Unit(Unit&&) = default; struct msghdr msgh; struct iovec iov; char cbuf[256]; - struct mmsghdr mmh; }; - vector units; + vector > units; + int ret; for(const auto& p : *packets) { count++; - Unit u; + unique_ptr u{new Unit()}; - fillMSGHdr(&u.msgh, &u.iov, u.cbuf, 0, (char*)&p[0], p.size(), &dest); + fillMSGHdr(&u->msgh, &u->iov, u->cbuf, 0, (char*)&p[0], p.size(), &dest); units.emplace_back(std::move(u)); - + if(units.size()==burst) { vector job; for(auto& u : units) { - job.push_back({u.msgh, 0}); + job.push_back({u->msgh, 0}); + } + if((ret=sendmmsg((*sockets)[count % sockets->size()]->getHandle(), + &job[0], job.size(), 0)) != job.size()) { + if(ret < 0) + unixDie("sendmmsg"); + else + cerr<<"Sent out partial number of packets: "<size()]->getHandle(), - &job[0], job.size(), 0); nanosleep(&nsec, 0); units.clear();