MXS-1506: Clean up various functions
Reduced variable scopes and removed unused code.
This commit is contained in:
@ -59,22 +59,19 @@ using namespace maxscale;
|
|||||||
*/
|
*/
|
||||||
static bool rwsplit_process_router_options(Config& config, char **options)
|
static bool rwsplit_process_router_options(Config& config, char **options)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
char *value;
|
|
||||||
select_criteria_t c;
|
|
||||||
|
|
||||||
if (options == NULL)
|
if (options == NULL)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
MXS_WARNING("Router options for readwritesplit are deprecated.");
|
MXS_WARNING("Router options for readwritesplit are deprecated.");
|
||||||
|
|
||||||
bool success = true;
|
bool success = true;
|
||||||
|
|
||||||
for (i = 0; options[i]; i++)
|
for (int i = 0; options[i]; i++)
|
||||||
{
|
{
|
||||||
if ((value = strchr(options[i], '=')) == NULL)
|
char* value = strchr(options[i], '=');
|
||||||
|
|
||||||
|
if (value == NULL)
|
||||||
{
|
{
|
||||||
MXS_ERROR("Unsupported router option \"%s\" for readwritesplit router.", options[i]);
|
MXS_ERROR("Unsupported router option \"%s\" for readwritesplit router.", options[i]);
|
||||||
success = false;
|
success = false;
|
||||||
@ -85,7 +82,7 @@ static bool rwsplit_process_router_options(Config& config, char **options)
|
|||||||
value++;
|
value++;
|
||||||
if (strcmp(options[i], "slave_selection_criteria") == 0)
|
if (strcmp(options[i], "slave_selection_criteria") == 0)
|
||||||
{
|
{
|
||||||
c = GET_SELECT_CRITERIA(value);
|
select_criteria_t c = GET_SELECT_CRITERIA(value);
|
||||||
ss_dassert(c == LEAST_GLOBAL_CONNECTIONS ||
|
ss_dassert(c == LEAST_GLOBAL_CONNECTIONS ||
|
||||||
c == LEAST_ROUTER_CONNECTIONS || c == LEAST_BEHIND_MASTER ||
|
c == LEAST_ROUTER_CONNECTIONS || c == LEAST_BEHIND_MASTER ||
|
||||||
c == LEAST_CURRENT_OPERATIONS || c == UNDEFINED_CRITERIA);
|
c == LEAST_CURRENT_OPERATIONS || c == UNDEFINED_CRITERIA);
|
||||||
@ -155,7 +152,7 @@ static bool rwsplit_process_router_options(Config& config, char **options)
|
|||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /*< for */
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,8 @@ namespace maxscale
|
|||||||
RWBackend::RWBackend(SERVER_REF* ref):
|
RWBackend::RWBackend(SERVER_REF* ref):
|
||||||
mxs::Backend(ref),
|
mxs::Backend(ref),
|
||||||
m_reply_state(REPLY_STATE_DONE),
|
m_reply_state(REPLY_STATE_DONE),
|
||||||
m_large_packet(false)
|
m_large_packet(false),
|
||||||
|
m_command(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,31 +121,6 @@ bool RWSplitSession::handle_target_is_all(route_target_t route_target, GWBUF *qu
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Probably MySQL specific because of modutil function
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @brief Write an error message to the log for closed session
|
|
||||||
*
|
|
||||||
* This happens if a request is received for a session that is already
|
|
||||||
* closing down.
|
|
||||||
*
|
|
||||||
* @param querybuf Query buffer containing packet
|
|
||||||
*/
|
|
||||||
void closed_session_reply(GWBUF *querybuf)
|
|
||||||
{
|
|
||||||
uint8_t* data = GWBUF_DATA(querybuf);
|
|
||||||
|
|
||||||
if (GWBUF_LENGTH(querybuf) >= 5 && !MYSQL_IS_COM_QUIT(data))
|
|
||||||
{
|
|
||||||
/* Note that most modutil functions are MySQL specific */
|
|
||||||
char *query_str = modutil_get_query(querybuf);
|
|
||||||
MXS_ERROR("Can't route %s:\"%s\" to backend server. Router is closed.",
|
|
||||||
STRPACKETTYPE(data[4]), query_str ? query_str : "(empty)");
|
|
||||||
MXS_FREE(query_str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Send an error message to the client telling that the server is in read only mode
|
* @brief Send an error message to the client telling that the server is in read only mode
|
||||||
*
|
*
|
||||||
|
@ -312,7 +312,7 @@ bool RWSplit::select_connect_backend_servers(MXS_SESSION *session,
|
|||||||
|
|
||||||
/** Check slave selection criteria and set compare function */
|
/** Check slave selection criteria and set compare function */
|
||||||
select_criteria_t select_criteria = config().slave_selection_criteria;
|
select_criteria_t select_criteria = config().slave_selection_criteria;
|
||||||
int (*cmpfun)(const SRWBackend&, const SRWBackend&) = criteria_cmpfun[select_criteria];
|
auto cmpfun = criteria_cmpfun[select_criteria];
|
||||||
ss_dassert(cmpfun);
|
ss_dassert(cmpfun);
|
||||||
|
|
||||||
if (MXS_LOG_PRIORITY_IS_ENABLED(LOG_INFO))
|
if (MXS_LOG_PRIORITY_IS_ENABLED(LOG_INFO))
|
||||||
|
@ -222,9 +222,6 @@ bool RWSplitSession::route_stored_query()
|
|||||||
GWBUF* RWSplitSession::discard_master_wait_gtid_result(GWBUF *buffer)
|
GWBUF* RWSplitSession::discard_master_wait_gtid_result(GWBUF *buffer)
|
||||||
{
|
{
|
||||||
uint8_t header_and_command[MYSQL_HEADER_LEN + 1];
|
uint8_t header_and_command[MYSQL_HEADER_LEN + 1];
|
||||||
uint8_t packet_len = 0;
|
|
||||||
uint8_t offset = 0;
|
|
||||||
mxs_mysql_cmd_t com;
|
|
||||||
|
|
||||||
gwbuf_copy_data(buffer, 0, MYSQL_HEADER_LEN + 1, header_and_command);
|
gwbuf_copy_data(buffer, 0, MYSQL_HEADER_LEN + 1, header_and_command);
|
||||||
/* ignore error packet */
|
/* ignore error packet */
|
||||||
@ -236,7 +233,7 @@ GWBUF* RWSplitSession::discard_master_wait_gtid_result(GWBUF *buffer)
|
|||||||
|
|
||||||
/* this packet must be an ok packet now */
|
/* this packet must be an ok packet now */
|
||||||
ss_dassert(MYSQL_GET_COMMAND(header_and_command) == MYSQL_REPLY_OK);
|
ss_dassert(MYSQL_GET_COMMAND(header_and_command) == MYSQL_REPLY_OK);
|
||||||
packet_len = MYSQL_GET_PAYLOAD_LEN(header_and_command) + MYSQL_HEADER_LEN;
|
uint8_t packet_len = MYSQL_GET_PAYLOAD_LEN(header_and_command) + MYSQL_HEADER_LEN;
|
||||||
m_wait_gtid_state = EXPECTING_REAL_RESULT;
|
m_wait_gtid_state = EXPECTING_REAL_RESULT;
|
||||||
m_next_seq = 1;
|
m_next_seq = 1;
|
||||||
|
|
||||||
@ -284,14 +281,14 @@ SRWBackend& RWSplitSession::get_backend_from_dcb(DCB *dcb)
|
|||||||
*/
|
*/
|
||||||
void RWSplitSession::correct_packet_sequence(GWBUF *buffer)
|
void RWSplitSession::correct_packet_sequence(GWBUF *buffer)
|
||||||
{
|
{
|
||||||
uint8_t header[3];
|
|
||||||
uint32_t offset = 0;
|
|
||||||
uint32_t packet_len = 0;
|
|
||||||
if (m_wait_gtid_state == EXPECTING_REAL_RESULT)
|
if (m_wait_gtid_state == EXPECTING_REAL_RESULT)
|
||||||
{
|
{
|
||||||
|
uint8_t header[3];
|
||||||
|
uint32_t offset = 0;
|
||||||
|
|
||||||
while (gwbuf_copy_data(buffer, offset, 3, header) == 3)
|
while (gwbuf_copy_data(buffer, offset, 3, header) == 3)
|
||||||
{
|
{
|
||||||
packet_len = MYSQL_GET_PAYLOAD_LEN(header) + MYSQL_HEADER_LEN;
|
uint32_t packet_len = MYSQL_GET_PAYLOAD_LEN(header) + MYSQL_HEADER_LEN;
|
||||||
uint8_t *seq = gwbuf_byte_pointer(buffer, offset + MYSQL_SEQ_OFFSET);
|
uint8_t *seq = gwbuf_byte_pointer(buffer, offset + MYSQL_SEQ_OFFSET);
|
||||||
*seq = m_next_seq;
|
*seq = m_next_seq;
|
||||||
m_next_seq++;
|
m_next_seq++;
|
||||||
@ -647,7 +644,6 @@ bool RWSplitSession::handle_error_new_connection(DCB *backend_dcb, GWBUF *errmsg
|
|||||||
route_stored_query();
|
route_stored_query();
|
||||||
}
|
}
|
||||||
|
|
||||||
int max_nslaves = m_router->max_slave_count();
|
|
||||||
bool succp;
|
bool succp;
|
||||||
/**
|
/**
|
||||||
* Try to get replacement slave or at least the minimum
|
* Try to get replacement slave or at least the minimum
|
||||||
|
Reference in New Issue
Block a user