MXS-2582: Deep-copy PS buffers in RWBackend::write

Deep-copying prevents subsequent modifications done by the caller from
affecting the data that can be potentially stored in the write queue of
the backend's DCB.
This commit is contained in:
Markus Mäkelä 2019-06-28 09:13:11 +03:00
parent e927366995
commit 5ab5e914e7
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19

View File

@ -88,6 +88,14 @@ bool RWBackend::write(GWBUF* buffer, response_type type)
if (mxs_mysql_is_ps_command(cmd))
{
// We need to completely separate the buffer this backend owns and the one that the caller owns to
// prevent any modifications from affecting the one that was written through this backend. If the
// buffer gets placed into the write queue of the DCB, subsequent modifications to the original buffer
// would be propagated to the one this backend owns.
GWBUF* tmp = gwbuf_deep_clone(buffer);
gwbuf_free(buffer);
buffer = tmp;
uint32_t id = mxs_mysql_extract_ps_id(buffer);
BackendHandleMap::iterator it = m_ps_handles.find(id);