Pass modutil function state as a struct

This allows the type to change without changing it at the call sites.
This commit is contained in:
Markus Mäkelä
2017-08-29 22:46:35 +03:00
parent 2a346fd061
commit e6f78bfcb3
5 changed files with 36 additions and 24 deletions

View File

@ -523,10 +523,10 @@ bool reply_is_complete(SRWBackend backend, GWBUF *buffer)
else
{
bool more = false;
bool skip = backend->get_skip_packet();
modutil_state state = backend->get_modutil_state();
int old_eof = backend->get_reply_state() == REPLY_STATE_RSET_ROWS ? 1 : 0;
int n_eof = modutil_count_signal_packets(buffer, old_eof, &more, &skip);
backend->set_skip_packet(skip);
int n_eof = modutil_count_signal_packets(buffer, old_eof, &more, &state);
backend->set_modutil_state(state);
if (n_eof == 0)
{

View File

@ -17,7 +17,7 @@
RWBackend::RWBackend(SERVER_REF* ref):
mxs::Backend(ref),
m_reply_state(REPLY_STATE_DONE),
m_skip(false)
m_modutil_state(MODUTIL_STATE_INIT)
{
}
@ -35,14 +35,14 @@ void RWBackend::set_reply_state(reply_state_t state)
m_reply_state = state;
}
void RWBackend::set_skip_packet(bool state)
void RWBackend::set_modutil_state(const modutil_state& state)
{
m_skip = state;
m_modutil_state = state;
}
bool RWBackend::get_skip_packet() const
modutil_state RWBackend::get_modutil_state() const
{
return m_skip;
return m_modutil_state;
}
bool RWBackend::execute_session_command()

View File

@ -15,6 +15,8 @@
#include "readwritesplit.hh"
#include "rwsplit_ps.hh"
#include <maxscale/modutil.h>
/** Enum for tracking client reply state */
enum reply_state_t
@ -50,15 +52,15 @@ public:
bool execute_session_command();
bool write(GWBUF* buffer, response_type type = EXPECT_RESPONSE);
void set_skip_packet(bool state);
bool get_skip_packet() const;
void set_modutil_state(const modutil_state& state);
modutil_state get_modutil_state() const;
private:
reply_state_t m_reply_state;
BackendHandleMap m_ps_handles; /**< Internal ID to backend PS handle mapping */
bool m_skip; /**< Used to store the state of the EOF packet
* calculation for result sets when the result
* contains very large rows */
modutil_state m_modutil_state; /**< Used to store the state of the EOF packet
* calculation for result sets when the result
* contains very large rows */
};
typedef std::tr1::shared_ptr<RWBackend> SRWBackend;