From 88ae276dd6887c285acbaabfbe8d3ae1293c9d28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Sat, 7 Apr 2018 08:00:03 +0300 Subject: [PATCH] MXS-1752: Fail if no connections were created If no backend connections were created, the CatSession will not be created. --- server/modules/routing/cat/cat.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/modules/routing/cat/cat.cc b/server/modules/routing/cat/cat.cc index 450bd25e9..5fd1b708e 100644 --- a/server/modules/routing/cat/cat.cc +++ b/server/modules/routing/cat/cat.cc @@ -33,13 +33,17 @@ Cat* Cat::create(SERVICE* pService, char** pzOptions) CatSession* Cat::newSession(MXS_SESSION* pSession) { auto backends = RWBackend::from_servers(pSession->service->dbref); + bool connected = false; for (auto a = backends.begin(); a != backends.end(); a++) { - (*a)->connect(pSession); + if ((*a)->can_connect() && (*a)->connect(pSession)) + { + connected = true; + } } - return new CatSession(pSession, this, backends); + return connected ? new CatSession(pSession, this, backends) : NULL; } void Cat::diagnostics(DCB* dcb)