MXS-1502: Add have_session_commands helper function
The function conveys the meaning of the call better than using session_command_count to check whether there are session commands to be executed.
This commit is contained in:
parent
7d4f37d25b
commit
319122e621
@ -87,12 +87,22 @@ public:
|
||||
uint64_t complete_session_command();
|
||||
|
||||
/**
|
||||
* @brief Check if backend has session commands
|
||||
* @brief Get number of session commands
|
||||
*
|
||||
* @return Number of session commands
|
||||
*/
|
||||
size_t session_command_count() const;
|
||||
|
||||
/**
|
||||
* @brief Check if there are session commands waiting to be executed
|
||||
*
|
||||
* @return True if there are session commands waiting to be executed
|
||||
*/
|
||||
inline bool have_session_commands() const
|
||||
{
|
||||
return !m_session_commands.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the first session command
|
||||
*
|
||||
|
@ -80,7 +80,7 @@ void Backend::close(close_type type)
|
||||
|
||||
bool Backend::execute_session_command()
|
||||
{
|
||||
if (is_closed() || !session_command_count())
|
||||
if (is_closed() || !have_session_commands())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -150,7 +150,7 @@ size_t Backend::session_command_count() const
|
||||
|
||||
const SSessionCommand& Backend::next_session_command() const
|
||||
{
|
||||
ss_dassert(session_command_count() > 0);
|
||||
ss_dassert(have_session_commands());
|
||||
return m_session_commands.front();
|
||||
}
|
||||
|
||||
|
@ -398,7 +398,7 @@ static bool handle_error_new_connection(RWSplit *inst,
|
||||
*/
|
||||
gwbuf_free(stored);
|
||||
|
||||
if (backend->session_command_count() == 0)
|
||||
if (!backend->have_session_commands())
|
||||
{
|
||||
/**
|
||||
* The backend was executing a command that requires a reply.
|
||||
@ -1104,13 +1104,13 @@ static void clientReply(MXS_ROUTER *instance,
|
||||
rses->expected_responses, backend->name());
|
||||
}
|
||||
|
||||
if (backend->session_command_count())
|
||||
if (backend->have_session_commands())
|
||||
{
|
||||
/** Reply to an executed session command */
|
||||
process_sescmd_response(rses, backend, &writebuf);
|
||||
}
|
||||
|
||||
if (backend->session_command_count())
|
||||
if (backend->have_session_commands())
|
||||
{
|
||||
if (backend->execute_session_command())
|
||||
{
|
||||
|
@ -219,7 +219,7 @@ bool route_single_stmt(RWSplit *inst, RWSplitSession *rses, GWBUF *querybuf, con
|
||||
// The connection to target was down and we failed to reconnect
|
||||
succp = false;
|
||||
}
|
||||
else if (target->session_command_count())
|
||||
else if (target->have_session_commands())
|
||||
{
|
||||
// We need to wait until the session commands are executed
|
||||
rses->expected_responses++;
|
||||
@ -921,7 +921,7 @@ bool handle_got_target(RWSplit *inst, RWSplitSession *rses,
|
||||
target->uri());
|
||||
|
||||
/** The session command cursor must not be active */
|
||||
ss_dassert(target->session_command_count() == 0);
|
||||
ss_dassert(!target->have_session_commands());
|
||||
|
||||
mxs::Backend::response_type response = mxs::Backend::NO_RESPONSE;
|
||||
rses->wait_gtid_state = EXPECTING_NOTHING;
|
||||
|
@ -69,7 +69,7 @@ static void discard_if_response_differs(SRWBackend backend, uint8_t master_cmd,
|
||||
|
||||
void process_sescmd_response(RWSplitSession* rses, SRWBackend& backend, GWBUF** ppPacket)
|
||||
{
|
||||
if (backend->session_command_count())
|
||||
if (backend->have_session_commands())
|
||||
{
|
||||
/** We are executing a session command */
|
||||
if (GWBUF_IS_TYPE_SESCMD_RESPONSE((*ppPacket)))
|
||||
|
@ -431,7 +431,7 @@ int32_t SchemaRouterSession::routeQuery(GWBUF* pPacket)
|
||||
|
||||
MXS_INFO("Route query to \t%s:%d <", bref->backend()->server->name, bref->backend()->server->port);
|
||||
|
||||
if (bref->session_command_count())
|
||||
if (bref->have_session_commands())
|
||||
{
|
||||
/** Store current statement if execution of the previous
|
||||
* session command hasn't been completed. */
|
||||
@ -490,7 +490,7 @@ void SchemaRouterSession::handle_mapping_reply(SSRBackend& bref, GWBUF** pPacket
|
||||
|
||||
void SchemaRouterSession::process_sescmd_response(SSRBackend& bref, GWBUF** ppPacket)
|
||||
{
|
||||
if (bref->session_command_count())
|
||||
if (bref->have_session_commands())
|
||||
{
|
||||
/** We are executing a session command */
|
||||
if (GWBUF_IS_TYPE_SESCMD_RESPONSE((*ppPacket)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user