{
IOState result = IOState::Done;
- while (!state->d_queuedResponses.empty()) {
+ while (state->active() && !state->d_queuedResponses.empty()) {
DEBUGLOG("queue size is "<<state->d_queuedResponses.size()<<", sending the next one");
TCPResponse resp = std::move(state->d_queuedResponses.front());
state->d_queuedResponses.pop_front();
state->d_state == IncomingTCPConnectionState::State::waitingForQuery) {
auto iostate = sendQueuedResponses(state, now);
- if (iostate == IOState::Done) {
+ if (iostate == IOState::Done && state->active()) {
if (state->canAcceptNewQueries(now)) {
state->resetForNewQuery();
state->d_state = IncomingTCPConnectionState::State::waitingForQuery;
}
// for the same reason we need to update the state right away, nobody will do that for us
- state->d_ioState->update(iostate, handleIOCallback, state, iostate == IOState::NeedWrite ? state->getClientWriteTTD(now) : state->getClientReadTTD(now));
+ if (state->active()) {
+ state->d_ioState->update(iostate, handleIOCallback, state, iostate == IOState::NeedWrite ? state->getClientWriteTTD(now) : state->getClientReadTTD(now));
+ }
}
}
state->d_querySize = state->d_buffer.at(0) * 256 + state->d_buffer.at(1);
if (state->d_querySize < sizeof(dnsheader)) {
/* go away */
+ state->terminateClientConnection();
return;
}
DEBUGLOG("send responses, if any");
iostate = sendQueuedResponses(state, now);
- if (!state->d_lastIOBlocked && iostate == IOState::Done) {
+ if (!state->d_lastIOBlocked && state->active() && iostate == IOState::Done) {
// if the query has been passed to a backend, or dropped, and the responses have been sent,
// we can start reading again
if (!state->d_isXFR) {
else {
DEBUGLOG("Going idle");
/* we still have some queries in flight, let's just stop reading for now */
- state->d_hadErrors = true;
state->d_state = IncomingTCPConnectionState::State::idle;
state->d_ioState->update(IOState::Done, handleIOCallback, state);