MXS-2196: Make DCB a C++ struct

Allocating DCB with new allows the use of C++ objects in the DCB
struct. Also the explicit poll field can be replaced by inheriting from
MXB_POLL_DATA.
This commit is contained in:
Markus Mäkelä
2018-11-30 15:37:40 +02:00
parent e365b97c6e
commit 694d4a4003
9 changed files with 153 additions and 206 deletions

View File

@ -174,9 +174,9 @@ class ResultSetDCB : public DCB
{
public:
ResultSetDCB()
: DCB(DCB_ROLE_CLIENT_HANDLER, nullptr, nullptr)
{
DCB* pDcb = this;
memset(pDcb, 0, sizeof(*pDcb));
pDcb->func.write = &ResultSetDCB::write;
}

View File

@ -18,8 +18,6 @@ namespace
void initialize_dcb(DCB* pDcb)
{
memset(pDcb, 0, sizeof(DCB));
pDcb->fd = DCBFD_CLOSED;
pDcb->state = DCB_STATE_ALLOC;
pDcb->ssl_state = SSL_HANDSHAKE_UNKNOWN;
@ -36,7 +34,8 @@ Dcb::Dcb(MXS_SESSION* pSession,
const char* zUser,
const char* zHost,
Handler* pHandler)
: m_user(zUser)
: DCB(DCB_ROLE_CLIENT_HANDLER, nullptr, nullptr)
, m_user(zUser)
, m_host(zHost)
, m_pHandler(pHandler)
{

View File

@ -1434,7 +1434,7 @@ static void gw_process_one_new_client(DCB* client_dcb)
else
{
// Move the rest of the initialization process to the owning worker
mxs::RoutingWorker* worker = static_cast<mxs::RoutingWorker*>(client_dcb->poll.owner);
mxs::RoutingWorker* worker = static_cast<mxs::RoutingWorker*>(client_dcb->owner);
worker->execute([=]() {
client_dcb->protocol = mysql_protocol_init(client_dcb, client_dcb->fd);

View File

@ -215,7 +215,7 @@ static void blr_start_master(void* data)
* 'client' is the fake DCB that emulates a client session:
* we need to set the poll.thread.id for the "dummy client"
*/
client->session->client_dcb->poll.owner = mxs_rworker_get_current();
client->session->client_dcb->owner = mxs_rworker_get_current();
/* Connect to configured master server */
if ((router->master = dcb_connect(router->service->dbref->server,