diff --git a/include/maxscale/server.h b/include/maxscale/server.h index e1c82b42c..93c624210 100644 --- a/include/maxscale/server.h +++ b/include/maxscale/server.h @@ -349,7 +349,7 @@ extern void server_transfer_status(SERVER *dest_server, const SERVER *source_ser extern void server_add_mon_user(SERVER *server, const char *user, const char *passwd); extern const char *server_get_parameter(const SERVER *server, const char *name); extern void server_update_credentials(SERVER *server, const char *user, const char *passwd); -extern DCB *server_get_persistent(SERVER *server, const char *user, const char *protocol, int id); +extern DCB* server_get_persistent(SERVER *server, const char *user, const char* ip, const char *protocol, int id); extern void server_update_address(SERVER *server, const char *address); extern void server_update_port(SERVER *server, unsigned short port); extern uint64_t server_map_status(const char *str); diff --git a/server/core/dcb.cc b/server/core/dcb.cc index 718f06853..f79806873 100644 --- a/server/core/dcb.cc +++ b/server/core/dcb.cc @@ -386,7 +386,8 @@ dcb_connect(SERVER *server, MXS_SESSION *session, const char *protocol) if (user && strlen(user)) { MXS_DEBUG("Looking for persistent connection DCB user %s protocol %s", user, protocol); - dcb = server_get_persistent(server, user, protocol, session->client_dcb->poll.thread.id); + dcb = server_get_persistent(server, user, session->client_dcb->remote, + protocol, session->client_dcb->thread.id); if (dcb) { /** @@ -423,6 +424,11 @@ dcb_connect(SERVER *server, MXS_SESSION *session, const char *protocol) memcpy(&(dcb->func), funcs, sizeof(MXS_PROTOCOL)); dcb->protoname = MXS_STRDUP_A(protocol); + if (session->client_dcb->remote) + { + dcb->remote = MXS_STRDUP_A(session->client_dcb->remote); + } + const char *authenticator = server->authenticator ? server->authenticator : dcb->func.auth_default ? dcb->func.auth_default() : "NullAuthDeny"; diff --git a/server/core/server.cc b/server/core/server.cc index 45336d6de..43fefe5c3 100644 --- a/server/core/server.cc +++ b/server/core/server.cc @@ -213,12 +213,15 @@ server_free(SERVER *tofreeserver) /** * Get a DCB from the persistent connection pool, if possible * - * @param server The server to set the name on - * @param user The name of the user needing the connection - * @param protocol The name of the protocol needed for the connection + * @param server The server to set the name on + * @param user The name of the user needing the connection + * @param ip Client IP address + * @param protocol The name of the protocol needed for the connection + * @param id Thread ID + * + * @return A DCB or NULL if no connection is found */ -DCB * -server_get_persistent(SERVER *server, const char *user, const char *protocol, int id) +DCB* server_get_persistent(SERVER *server, const char *user, const char* ip, const char *protocol, int id) { DCB *dcb, *previous = NULL; @@ -232,9 +235,12 @@ server_get_persistent(SERVER *server, const char *user, const char *protocol, in { if (dcb->user && dcb->protoname + && dcb->remote + && ip && !dcb-> dcb_errhandle_called && !(dcb->flags & DCBF_HUNG) && 0 == strcmp(dcb->user, user) + && 0 == strcmp(dcb->remote, ip) && 0 == strcmp(dcb->protoname, protocol)) { if (NULL == previous) diff --git a/server/modules/protocol/MySQL/mariadbclient/mysql_client.cc b/server/modules/protocol/MySQL/mariadbclient/mysql_client.cc index a1c1164b4..b7b663e90 100644 --- a/server/modules/protocol/MySQL/mariadbclient/mysql_client.cc +++ b/server/modules/protocol/MySQL/mariadbclient/mysql_client.cc @@ -334,8 +334,8 @@ int MySQLSendHandshake(DCB* dcb) mysql_server_capabilities_one[1] = (uint8_t)(GW_MYSQL_CAPABILITIES_SERVER >> 8); // Check that we match the old values - ss_dassert(mysql_server_capabilities_one[0] = 0xff); - ss_dassert(mysql_server_capabilities_one[1] = 0xf7); + ss_dassert(mysql_server_capabilities_one[0] == 0xff); + ss_dassert(mysql_server_capabilities_one[1] == 0xf7); if (is_maria) {