From f6470c580a1f89d742ca2ea19ac38db65fa11af1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Mon, 27 Mar 2017 23:37:34 +0300 Subject: [PATCH] Fix minor problems Use correct value in initialization, return correct return value on success, do a equals comparison on route target. --- .../routing/schemarouter/schemaroutersession.cc | 14 +++++++------- .../routing/schemarouter/schemaroutersession.hh | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/server/modules/routing/schemarouter/schemaroutersession.cc b/server/modules/routing/schemarouter/schemaroutersession.cc index 117f9e52e..ae1b86055 100644 --- a/server/modules/routing/schemarouter/schemaroutersession.cc +++ b/server/modules/routing/schemarouter/schemaroutersession.cc @@ -123,7 +123,7 @@ SchemaRouterSession::SchemaRouterSession(MXS_SESSION* session, SchemaRouter* rou m_closed(false), m_client(session->client_dcb), m_mysql_session((MYSQL_session*)session->client_dcb->data), - m_config(&m_router->m_config), + m_config(&router->m_config), m_router(router), m_shard(m_router->m_shard_manager.get_shard(m_client->user, m_config->refresh_min_interval)), m_state(0), @@ -394,6 +394,7 @@ int32_t SchemaRouterSession::routeQuery(GWBUF* pPacket) if (m_state & (INIT_MAPPING | INIT_USE_DB)) { m_queue.push_back(pPacket); + ret = 1; if (m_state == (INIT_READY | INIT_USE_DB)) { @@ -401,12 +402,11 @@ int32_t SchemaRouterSession::routeQuery(GWBUF* pPacket) * This state is possible if a client connects with a default database * and the shard map was found from the router cache */ - if (handle_default_db()) + if (!handle_default_db()) { - ret = 1; + ret = 0; } } - return ret; } @@ -543,9 +543,9 @@ int32_t SchemaRouterSession::routeQuery(GWBUF* pPacket) gwbuf_free(pPacket); return ret; } -void SchemaRouterSession::handle_mapping_reply(Backend* bref, GWBUF* pPacket) +void SchemaRouterSession::handle_mapping_reply(Backend* bref, GWBUF** pPacket) { - int rc = inspect_backend_mapping_states(bref, &pPacket); + int rc = inspect_backend_mapping_states(bref, pPacket); if (rc == 1) { @@ -634,7 +634,7 @@ void SchemaRouterSession::clientReply(GWBUF* pPacket, DCB* pDcb) if (m_state & INIT_MAPPING) { - handle_mapping_reply(bref, pPacket); + handle_mapping_reply(bref, &pPacket); } else if (m_state & INIT_USE_DB) { diff --git a/server/modules/routing/schemarouter/schemaroutersession.hh b/server/modules/routing/schemarouter/schemaroutersession.hh index 87682ed81..676ce6c8b 100644 --- a/server/modules/routing/schemarouter/schemaroutersession.hh +++ b/server/modules/routing/schemarouter/schemaroutersession.hh @@ -79,9 +79,9 @@ enum route_target /** Helper macros for route target type */ #define TARGET_IS_UNDEFINED(t) (t == TARGET_UNDEFINED) -#define TARGET_IS_NAMED_SERVER(t) (t & TARGET_NAMED_SERVER) -#define TARGET_IS_ALL(t) (t & TARGET_ALL) -#define TARGET_IS_ANY(t) (t & TARGET_ANY) +#define TARGET_IS_NAMED_SERVER(t) (t == TARGET_NAMED_SERVER) +#define TARGET_IS_ALL(t) (t == TARGET_ALL) +#define TARGET_IS_ANY(t) (t == TARGET_ANY) /** * Reference to BACKEND. @@ -186,7 +186,7 @@ private: void handle_error_reply_client(DCB* backend_dcb, GWBUF* errmsg); void route_queued_query(); void synchronize_shard_map(); - void handle_mapping_reply(Backend* bref, GWBUF* pPacket); + void handle_mapping_reply(Backend* bref, GWBUF** pPacket); void process_response(Backend* bref, GWBUF** ppPacket); SERVER* resolve_query_target(GWBUF* pPacket, uint32_t type, uint8_t command, enum route_target& route_target);