// for the same reason we need to update the state right away, nobody will do that for us
if (state->active()) {
- state->updateIO(state, iostate, now);
+ state->updateIO(iostate, now);
// if we have not finished reading every available byte, we _need_ to do an actual read
// attempt before waiting for the socket to become readable again, because if there is
// buffered data available the socket might never become readable again.
conn->d_ioState->update(IOState::Done, handleIOCallback, conn);
}
-void IncomingTCPConnectionState::updateIO(std::shared_ptr<IncomingTCPConnectionState>& state, IOState newState, const struct timeval& now)
+void IncomingTCPConnectionState::updateIO(IOState newState, const struct timeval& now)
{
+ auto sharedPtrToConn = shared_from_this();
if (newState == IOState::Async) {
- updateIOForAsync(state);
+ updateIOForAsync(sharedPtrToConn);
return;
}
- state->d_ioState->update(newState, handleIOCallback, state, newState == IOState::NeedWrite ? state->getClientWriteTTD(now) : state->getClientReadTTD(now));
+ d_ioState->update(newState, handleIOCallback, sharedPtrToConn, newState == IOState::NeedWrite ? getClientWriteTTD(now) : getClientReadTTD(now));
}
/* called from the backend code when a new response has been received */
return;
}
- auto state = shared_from_this();
+ auto sharedPtrToConn = shared_from_this();
if (iostate == IOState::Done) {
- d_ioState->update(iostate, handleIOCallback, state);
+ d_ioState->update(iostate, handleIOCallback, sharedPtrToConn);
}
else {
- updateIO(state, iostate, now);
+ updateIO(iostate, now);
}
ioGuard.release();
} while ((iostate == IOState::NeedRead || iostate == IOState::NeedWrite) && !d_lastIOBlocked);
return;
}
- std::shared_ptr<IncomingTCPConnectionState> state = shared_from_this();
- --state->d_currentQueriesCount;
- state->d_hadErrors = true;
+ auto sharedPtrToConn = shared_from_this();
+ --sharedPtrToConn->d_currentQueriesCount;
+ sharedPtrToConn->d_hadErrors = true;
- if (state->d_state == State::sendingResponse) {
+ if (sharedPtrToConn->d_state == State::sendingResponse) {
/* if we have responses to send, let's do that first */
}
- else if (!state->d_queuedResponses.empty()) {
+ else if (!sharedPtrToConn->d_queuedResponses.empty()) {
/* stop reading and send what we have */
try {
- auto iostate = sendQueuedResponses(state, now);
+ auto iostate = sendQueuedResponses(sharedPtrToConn, now);
- if (state->active() && iostate != IOState::Done) {
+ if (sharedPtrToConn->active() && iostate != IOState::Done) {
// we need to update the state right away, nobody will do that for us
- updateIO(state, iostate, now);
+ updateIO(iostate, now);
}
}
catch (const std::exception& e) {
}
else {
// the backend code already tried to reconnect if it was possible
- state->terminateClientConnection();
+ sharedPtrToConn->terminateClientConnection();
}
}