From 869325e00a7876341b665da9d1cb2fa606ea8bc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 16 Jun 2017 01:27:21 +0300 Subject: [PATCH] Make execute_session_command virtual Making the function allows higher level checking to be done by the derived class. The readwritesplit does some of the reply bookkeeping for session commands in the function. This makes their execution less prone for errors as the states are always updated correctly whenever a session command is executed. --- include/maxscale/backend.hh | 2 +- .../modules/routing/readwritesplit/readwritesplit.hh | 12 ++++++++++++ .../routing/readwritesplit/rwsplit_route_stmt.cc | 1 - 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/maxscale/backend.hh b/include/maxscale/backend.hh index 5e8c01c69..8b0ce8c01 100644 --- a/include/maxscale/backend.hh +++ b/include/maxscale/backend.hh @@ -63,7 +63,7 @@ public: * * @return True if the command was executed successfully */ - bool execute_session_command(); + virtual bool execute_session_command(); /** * @brief Add a new session command to the tail of the command queue diff --git a/server/modules/routing/readwritesplit/readwritesplit.hh b/server/modules/routing/readwritesplit/readwritesplit.hh index 973154213..3e13b8656 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.hh +++ b/server/modules/routing/readwritesplit/readwritesplit.hh @@ -178,6 +178,18 @@ public: m_reply_state = state; } + bool execute_session_command() + { + bool rval = mxs::Backend::execute_session_command(); + + if (rval) + { + set_reply_state(REPLY_STATE_START); + } + + return rval; + } + private: reply_state_t m_reply_state; }; diff --git a/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc b/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc index fab24401d..ca2f7420f 100644 --- a/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc +++ b/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc @@ -263,7 +263,6 @@ bool route_session_write(ROUTER_CLIENT_SES *rses, GWBUF *querybuf, uint8_t comma if (expecting_response) { - bref->set_reply_state(REPLY_STATE_START); rses->expected_responses++; }