Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pdns/dnsdistdist/dnsdist-kvs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ bool CDBKVStore::reload(const struct stat& st)
{
auto newCDB = std::make_unique<CDB>(d_fname);
{
*(d_cdb.write_lock()) = std::move(newCDB);
*(d_cdb.lock()) = std::move(newCDB);
}
d_mtime = st.st_mtime;
return true;
Expand Down Expand Up @@ -263,7 +263,7 @@ bool CDBKVStore::getValue(const std::string& key, std::string& value)
}

{
auto cdb = d_cdb.read_lock();
auto cdb = d_cdb.lock();
if (*cdb && (*cdb)->findOne(key, value)) {
return true;
}
Expand All @@ -286,7 +286,7 @@ bool CDBKVStore::keyExists(const std::string& key)
}

{
auto cdb = d_cdb.read_lock();
auto cdb = d_cdb.lock();
if (!*cdb) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion pdns/dnsdistdist/dnsdist-kvs.hh
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ private:
void refreshDBIfNeeded(time_t now);
bool reload(const struct stat& st);

SharedLockGuarded<std::unique_ptr<CDB>> d_cdb{nullptr};
LockGuarded<std::unique_ptr<CDB>> d_cdb{nullptr};
std::string d_fname;
time_t d_mtime{0};
time_t d_nextCheck{0};
Expand Down
6 changes: 2 additions & 4 deletions pdns/dnsdistdist/dnsdist-xsk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ void XskResponderThread(std::shared_ptr<DownstreamState> dss, std::shared_ptr<Xs
auto response = packet.clonePacketBuffer();
if (response.size() > packet.getCapacity()) {
/* fallback to sending the packet via normal socket */
VERBOSESLOG(infolog("XSK packet falling back because packet is too large"),
logger->info(Logr::Info, "XSK packet falling back because packet is too large"));
ids->xskPacketHeader.clear();
}
if (!processResponderPacket(dss, response, std::move(*ids))) {
Expand All @@ -79,10 +81,6 @@ void XskResponderThread(std::shared_ptr<DownstreamState> dss, std::shared_ptr<Xs
return;
}
if (response.size() > packet.getCapacity()) {
/* fallback to sending the packet via normal socket */
sendUDPResponse(ids->cs->udpFD, response, ids->delayMsec, ids->hopLocal, ids->hopRemote);
VERBOSESLOG(infolog("XSK packet falling back because packet is too large"),
logger->info(Logr::Info, "XSK packet falling back because packet is too large"));
xskInfo->markAsFree(packet);
return;
}
Expand Down
8 changes: 5 additions & 3 deletions pdns/dnsdistdist/xsk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -878,8 +878,10 @@ void XskWorker::notify(int desc)
{
uint64_t value = 1;
ssize_t res = 0;
while ((res = write(desc, &value, sizeof(value))) == EINTR) {
}
do {
res = write(desc, &value, sizeof(value));
} while (res == -1 && errno == EINTR);

if (res != sizeof(value)) {
throw runtime_error("Unable Wake Up XskSocket Failed");
}
Expand Down Expand Up @@ -1010,7 +1012,7 @@ void XskPacket::rewrite() noexcept
{
size_t position{0};
/* Main loop: 32 bits at a time */
for (position = 0; position < len; position += sizeof(uint32_t)) {
for (position = 0; position + sizeof(uint32_t) <= len; position += sizeof(uint32_t)) {
uint32_t value{};
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
memcpy(&value, static_cast<const uint8_t*>(ptr) + position, sizeof(value));
Expand Down
Loading