responseBuffer = std::move(response.d_buffer);
}
+ auto sent = responseBuffer.size();
sendResponse(response.d_idstate.d_streamID, context, statusCode, d_ci.cs->dohFrontend->d_customResponseHeaders, contentType, sendContentType);
- handleResponseSent(response);
+ handleResponseSent(response, sent);
return hasPendingWrite() ? IOState::NeedWrite : IOState::Done;
}
void handleXFRResponse(const struct timeval& now, TCPResponse&& response) override;
virtual IOState sendResponse(const struct timeval& now, TCPResponse&& response);
- void handleResponseSent(TCPResponse& currentResponse);
+ void handleResponseSent(TCPResponse& currentResponse, size_t sentBytes);
virtual IOState handleHandshake(const struct timeval& now);
void handleHandshakeDone(const struct timeval& now);
ProxyProtocolResult handleProxyProtocolPayload();
return IOState::Done;
}
-void IncomingTCPConnectionState::handleResponseSent(TCPResponse& currentResponse)
+void IncomingTCPConnectionState::handleResponseSent(TCPResponse& currentResponse, size_t sentBytes)
{
if (currentResponse.d_idstate.qtype == QType::AXFR || currentResponse.d_idstate.qtype == QType::IXFR) {
return;
if (!currentResponse.d_idstate.selfGenerated && backend) {
const auto& ids = currentResponse.d_idstate;
double udiff = ids.queryRealTime.udiff();
- vinfolog("Got answer from %s, relayed to %s (%s, %d bytes), took %f us", backend->d_config.remote.toStringWithPort(), ids.origRemote.toStringWithPort(), getProtocol().toString(), currentResponse.d_buffer.size(), udiff);
+ vinfolog("Got answer from %s, relayed to %s (%s, %d bytes), took %f us", backend->d_config.remote.toStringWithPort(), ids.origRemote.toStringWithPort(), getProtocol().toString(), sentBytes, udiff);
auto backendProtocol = backend->getProtocol();
if (backendProtocol == dnsdist::Protocol::DoUDP && !currentResponse.d_idstate.forwardedOverUDP) {
backendProtocol = dnsdist::Protocol::DoTCP;
}
- ::handleResponseSent(ids, udiff, d_ci.remote, backend->d_config.remote, static_cast<unsigned int>(currentResponse.d_buffer.size()), currentResponse.d_cleartextDH, backendProtocol, true);
+ ::handleResponseSent(ids, udiff, d_ci.remote, backend->d_config.remote, static_cast<unsigned int>(sentBytes), currentResponse.d_cleartextDH, backendProtocol, true);
}
else {
const auto& ids = currentResponse.d_idstate;
auto iostate = d_handler.tryWrite(d_currentResponse.d_buffer, d_currentPos, d_currentResponse.d_buffer.size());
if (iostate == IOState::Done) {
DEBUGLOG("response sent from " << __PRETTY_FUNCTION__);
- handleResponseSent(d_currentResponse);
+ handleResponseSent(d_currentResponse, d_currentResponse.d_buffer.size());
return iostate;
}
d_lastIOBlocked = true;
iostate = d_handler.tryWrite(d_currentResponse.d_buffer, d_currentPos, d_currentResponse.d_buffer.size());
if (iostate == IOState::Done) {
DEBUGLOG("response sent from " << __PRETTY_FUNCTION__);
- handleResponseSent(d_currentResponse);
+ handleResponseSent(d_currentResponse, d_currentResponse.d_buffer.size());
d_state = State::idle;
}
else {