diff --git a/server/modules/routing/readwritesplit/readwritesplit.cc b/server/modules/routing/readwritesplit/readwritesplit.cc index 086a89266..8b520add1 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.cc +++ b/server/modules/routing/readwritesplit/readwritesplit.cc @@ -59,22 +59,19 @@ using namespace maxscale; */ static bool rwsplit_process_router_options(Config& config, char **options) { - int i; - char *value; - select_criteria_t c; - if (options == NULL) { return true; } MXS_WARNING("Router options for readwritesplit are deprecated."); - 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]); success = false; @@ -85,7 +82,7 @@ static bool rwsplit_process_router_options(Config& config, char **options) value++; 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 || c == LEAST_ROUTER_CONNECTIONS || c == LEAST_BEHIND_MASTER || c == LEAST_CURRENT_OPERATIONS || c == UNDEFINED_CRITERIA); @@ -155,7 +152,7 @@ static bool rwsplit_process_router_options(Config& config, char **options) success = false; } } - } /*< for */ + } return success; } diff --git a/server/modules/routing/readwritesplit/rwbackend.cc b/server/modules/routing/readwritesplit/rwbackend.cc index 051870e38..4dad84b74 100644 --- a/server/modules/routing/readwritesplit/rwbackend.cc +++ b/server/modules/routing/readwritesplit/rwbackend.cc @@ -10,7 +10,8 @@ namespace maxscale RWBackend::RWBackend(SERVER_REF* ref): mxs::Backend(ref), m_reply_state(REPLY_STATE_DONE), - m_large_packet(false) + m_large_packet(false), + m_command(0) { } diff --git a/server/modules/routing/readwritesplit/rwsplit_mysql.cc b/server/modules/routing/readwritesplit/rwsplit_mysql.cc index d8a1b9c68..32906365d 100644 --- a/server/modules/routing/readwritesplit/rwsplit_mysql.cc +++ b/server/modules/routing/readwritesplit/rwsplit_mysql.cc @@ -121,31 +121,6 @@ bool RWSplitSession::handle_target_is_all(route_target_t route_target, GWBUF *qu 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 * diff --git a/server/modules/routing/readwritesplit/rwsplit_select_backends.cc b/server/modules/routing/readwritesplit/rwsplit_select_backends.cc index d01042007..d70b75c4c 100644 --- a/server/modules/routing/readwritesplit/rwsplit_select_backends.cc +++ b/server/modules/routing/readwritesplit/rwsplit_select_backends.cc @@ -312,7 +312,7 @@ bool RWSplit::select_connect_backend_servers(MXS_SESSION *session, /** Check slave selection criteria and set compare function */ 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); if (MXS_LOG_PRIORITY_IS_ENABLED(LOG_INFO)) diff --git a/server/modules/routing/readwritesplit/rwsplitsession.cc b/server/modules/routing/readwritesplit/rwsplitsession.cc index cb744c27e..bcc4cb966 100644 --- a/server/modules/routing/readwritesplit/rwsplitsession.cc +++ b/server/modules/routing/readwritesplit/rwsplitsession.cc @@ -222,9 +222,6 @@ bool RWSplitSession::route_stored_query() GWBUF* RWSplitSession::discard_master_wait_gtid_result(GWBUF *buffer) { 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); /* ignore error packet */ @@ -236,7 +233,7 @@ GWBUF* RWSplitSession::discard_master_wait_gtid_result(GWBUF *buffer) /* this packet must be an ok packet now */ 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_next_seq = 1; @@ -284,14 +281,14 @@ SRWBackend& RWSplitSession::get_backend_from_dcb(DCB *dcb) */ 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) { + uint8_t header[3]; + uint32_t offset = 0; + 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); *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(); } - int max_nslaves = m_router->max_slave_count(); bool succp; /** * Try to get replacement slave or at least the minimum