MXS-2068: Split reply_is_complete into two functions

By splitting the processing and state querying into two separate
functions, the result can be inspected multiple times without triggering
the result processing.
This commit is contained in:
Markus Mäkelä 2018-09-25 12:49:02 +03:00
parent 60cb8127a0
commit 24b438c9b6
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
4 changed files with 21 additions and 15 deletions

View File

@ -104,7 +104,17 @@ public:
return m_local_infile_requested;
}
bool reply_is_complete(GWBUF* buffer);
void process_reply(GWBUF* buffer);
/**
* Check whether the response from the server is complete
*
* @return True if no more results are expected from this server
*/
bool reply_is_complete() const
{
return m_reply_state == REPLY_STATE_DONE;
}
// Controlled by the session
ResponseStat& response_stat();

View File

@ -137,14 +137,11 @@ static inline bool have_next_packet(GWBUF* buffer)
}
/**
* @brief Check if we have received a complete reply from the backend
* @brief Process a possibly partial response from the backend
*
* @param backend Backend reference
* @param buffer Buffer containing the response
*
* @return True if the complete response has been received
*/
bool RWBackend::reply_is_complete(GWBUF* buffer)
void RWBackend::process_reply(GWBUF* buffer)
{
if (current_command() == MXS_COM_STMT_FETCH)
{
@ -191,9 +188,9 @@ bool RWBackend::reply_is_complete(GWBUF* buffer)
// TODO: Don't clone the buffer
GWBUF* tmp = gwbuf_clone(buffer);
tmp = gwbuf_consume(tmp, mxs_mysql_get_packet_len(tmp));
bool rval = reply_is_complete(tmp);
process_reply(tmp);
gwbuf_free(tmp);
return rval;
return;
}
}
}
@ -245,15 +242,10 @@ bool RWBackend::reply_is_complete(GWBUF* buffer)
}
}
bool rval = false;
if (get_reply_state() == REPLY_STATE_DONE)
{
ack_write();
rval = true;
}
return rval;
}
ResponseStat& RWBackend::response_stat()

View File

@ -72,7 +72,9 @@ void CatSession::clientReply(GWBUF* pPacket, DCB* pDcb)
mxb_assert(backend->dcb() == pDcb);
bool send = false;
if (backend->reply_is_complete(pPacket))
backend->process_reply(pPacket);
if (backend->reply_is_complete())
{
m_completed++;
m_current++;

View File

@ -560,7 +560,9 @@ void RWSplitSession::clientReply(GWBUF* writebuf, DCB* backend_dcb)
m_current_query.reset();
}
if (backend->reply_is_complete(writebuf))
backend->process_reply(writebuf);
if (backend->reply_is_complete())
{
/** Got a complete reply, decrement expected response count */
m_expected_responses--;