Skip to content

Commit

Permalink
Merge pull request PowerDNS#12639 from rgacogne/ddist-fix-race-ioerrors
Browse files Browse the repository at this point in the history
dnsdist: Fix a race when a cross-protocol query triggers an IO error
  • Loading branch information
rgacogne authored Mar 15, 2023
2 parents 2848820 + 9083693 commit 48126e3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pdns/dnsdist-tcp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1084,8 +1084,14 @@ void IncomingTCPConnectionState::handleIO(std::shared_ptr<IncomingTCPConnectionS

void IncomingTCPConnectionState::notifyIOError(InternalQueryState&& query, const struct timeval& now)
{
std::shared_ptr<IncomingTCPConnectionState> state = shared_from_this();
if (std::this_thread::get_id() != d_creatorThreadID) {
/* empty buffer will signal an IO error */
TCPResponse response(PacketBuffer(), std::move(query), nullptr, nullptr);
handleCrossProtocolResponse(now, std::move(response));
return;
}

std::shared_ptr<IncomingTCPConnectionState> state = shared_from_this();
--state->d_currentQueriesCount;
state->d_hadErrors = true;

Expand Down Expand Up @@ -1114,6 +1120,11 @@ void IncomingTCPConnectionState::notifyIOError(InternalQueryState&& query, const

void IncomingTCPConnectionState::handleXFRResponse(const struct timeval& now, TCPResponse&& response)
{
if (std::this_thread::get_id() != d_creatorThreadID) {
handleCrossProtocolResponse(now, std::move(response));
return;
}

std::shared_ptr<IncomingTCPConnectionState> state = shared_from_this();
queueResponse(state, now, std::move(response));
}
Expand Down

0 comments on commit 48126e3

Please sign in to comment.