From df5377f1357b44aefe8ea53a86d006a51e3ba6a9 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Tue, 11 Jun 2019 10:48:42 +0300 Subject: [PATCH] MXS-2556 Check if TCP/IP socket is used and warn about it If the server (a real one or a service exposed as a server) is on the same machine as MaxScale, then for performance reasons a Unix domain socket and not a TCP/IP socket should be used. --- .../routing/smartrouter/smartrouter.cc | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/server/modules/routing/smartrouter/smartrouter.cc b/server/modules/routing/smartrouter/smartrouter.cc index ed9598222..2c2d2e56f 100644 --- a/server/modules/routing/smartrouter/smartrouter.cc +++ b/server/modules/routing/smartrouter/smartrouter.cc @@ -86,11 +86,29 @@ bool SmartRouter::Config::post_configure(const MXS_CONFIG_PARAMETER& params) bool rv = true; auto servers = params.get_server_list(CN_SERVERS); - // TODO: Check that the servers are local ones. - auto it = std::find(servers.begin(), servers.end(), m_master.get()); + bool master_found = false; - if (it == servers.end()) + for (SERVER* pServer : servers) + { + if (pServer == m_master.get()) + { + master_found = true; + } + + if (pServer->address[0] != '/') + { + if (strcmp(pServer->address, "127.0.0.1") == 0 || strcmp(pServer->address, "localhost")) + { + MXS_WARNING("The server %s, used by the smartrouter, is currently accessed " + "using a TCP/IP socket (%s:%d). For better performance, a Unix " + "domain socket should be used. See the 'socket' argument.", + pServer->name(), pServer->address, pServer->port); + } + } + } + + if (rv && !master_found) { rv = false;