MXS-2196: Fix use of DCBs in binlogrouter
The binlogrouter now handles the DCB creation a bit more correctly but it still breaks a few of the rules.
This commit is contained in:
@ -187,28 +187,29 @@ static void blr_start_master(void* data)
|
|||||||
|
|
||||||
pthread_mutex_unlock(&router->lock);
|
pthread_mutex_unlock(&router->lock);
|
||||||
|
|
||||||
// TODO: Fix this
|
// Create a temporary listener so we can create a session originating from it
|
||||||
DCB* client = dcb_alloc(DCB::Role::INTERNAL, NULL);
|
auto listener = Listener::create(router->service, "binlogrouter_listener", "mariadbclient",
|
||||||
|
"127.0.0.1", 9999, "", "", nullptr);
|
||||||
/* Create fake 'client' DCB */
|
router->session = new mxs::Session(listener);
|
||||||
if (client == NULL)
|
Listener::destroy(listener);
|
||||||
{
|
router->client = dcb_alloc(DCB::Role::INTERNAL, router->session);
|
||||||
MXS_ERROR("failed to create DCB for dummy client");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
router->client = client;
|
|
||||||
|
|
||||||
/* Fake the client is reading */
|
/* Fake the client is reading */
|
||||||
client->state = DCB_STATE_POLLING; /* Fake the client is reading */
|
router->client->state = DCB_STATE_POLLING; /* Fake the client is reading */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This prevents the actual protocol level closing code from being called that expects
|
||||||
|
* the dcb->protocol pointer to not be NULL.
|
||||||
|
*/
|
||||||
|
router->client->func.close = nullptr;
|
||||||
|
|
||||||
/* Create MySQL Athentication from configured user/passwd */
|
/* Create MySQL Athentication from configured user/passwd */
|
||||||
client->data = CreateMySQLAuthData(router->user, router->password, "");
|
router->client->data = CreateMySQLAuthData(router->user, router->password, "");
|
||||||
// TODO: Fix this
|
router->client->user = MXS_STRDUP(router->user);
|
||||||
client->session = new mxs::Session(nullptr);
|
router->session->client_dcb = router->client;
|
||||||
router->session = client->session;
|
|
||||||
|
|
||||||
/* Create a session for dummy client DCB */
|
/* Create a session for dummy client DCB */
|
||||||
if (router->session == NULL || session_start(router->session))
|
if (router->session == NULL || !session_start(router->session))
|
||||||
{
|
{
|
||||||
MXS_ERROR("failed to create session for connection to master");
|
MXS_ERROR("failed to create session for connection to master");
|
||||||
return;
|
return;
|
||||||
@ -218,7 +219,7 @@ static void blr_start_master(void* data)
|
|||||||
* 'client' is the fake DCB that emulates a client session:
|
* 'client' is the fake DCB that emulates a client session:
|
||||||
* we need to set the poll.thread.id for the "dummy client"
|
* we need to set the poll.thread.id for the "dummy client"
|
||||||
*/
|
*/
|
||||||
client->session->client_dcb->owner = mxs_rworker_get_current();
|
router->client->owner = mxs_rworker_get_current();
|
||||||
|
|
||||||
/* Connect to configured master server */
|
/* Connect to configured master server */
|
||||||
if ((router->master = dcb_connect(router->service->dbref->server,
|
if ((router->master = dcb_connect(router->service->dbref->server,
|
||||||
|
Reference in New Issue
Block a user