Set internal DCB to NULL on close

The Backend::dcb() method gives the raw pointer to the internal DCB. This
pointer is used by at least readwritesplit to map raw DCB pointers to
backends. To prevent stale pointers from being returned, m_dcb needs to be
set to NULL after it has been closed.
This commit is contained in:
Markus Mäkelä 2018-03-31 10:04:29 +03:00
parent 177e3251ad
commit f743e99795
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
2 changed files with 2 additions and 1 deletions

View File

@ -158,7 +158,7 @@ public:
/**
* @brief Get a pointer to the internal DCB
*
* @return Pointer to internal DCB
* @return Pointer to DCB or NULL if not connected
*/
inline DCB* dcb() const
{

View File

@ -66,6 +66,7 @@ void Backend::close(close_type type)
}
dcb_close(m_dcb);
m_dcb = NULL;
/** decrease server current connection counters */
atomic_add(&m_backend->connections, -1);