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:
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
Reference in New Issue
Block a user