MXS-1752: Fail if no connections were created

If no backend connections were created, the CatSession will not be
created.
This commit is contained in:
Markus Mäkelä
2018-04-07 08:00:03 +03:00
parent 6cd75cc31c
commit 88ae276dd6

View File

@ -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)