From ea550a8281fd0febabf9006fec009ffb6541a7d2 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Mon, 2 Feb 2015 16:47:57 +0100 Subject: [PATCH] actually make calidns work with sendmmsg --- pdns/calidns.cc | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/pdns/calidns.cc b/pdns/calidns.cc index 0932c9f43..7384ec9b8 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(); -- 2.40.0