MXS-1503: Make sure backend is in use before using it

The get_backend_from_dcb function needs to check that the backend is in
use before comparing the pointer. This prevents stale pointers from being
used and is logically more sound than relying on raw DCB matches.
This commit is contained in:
Markus Mäkelä 2018-03-31 10:08:48 +03:00
parent be0ab82283
commit caa5fe89bb
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
2 changed files with 3 additions and 1 deletions

View File

@ -207,6 +207,7 @@ bool Backend::connect(MXS_SESSION* session, SessionCommandList* sescmd)
bool Backend::write(GWBUF* buffer, response_type type)
{
ss_dassert(in_use());
bool rval = m_dcb->func.write(m_dcb, buffer) != 0;
if (rval && type == EXPECT_RESPONSE)

View File

@ -118,7 +118,7 @@ static inline SRWBackend& get_backend_from_dcb(RWSplitSession *rses, DCB *dcb)
{
SRWBackend& backend = *it;
if (backend->dcb() == dcb)
if (backend->in_use() && backend->dcb() == dcb)
{
return backend;
}
@ -1178,6 +1178,7 @@ static void handleError(MXS_ROUTER *instance,
ss_dassert(session);
SRWBackend& backend = get_backend_from_dcb(rses, problem_dcb);
ss_dassert(backend->in_use());
switch (action)
{