Added blr_cache_read_master_data and dcb checks
Added blr_cache_read_master_data() Added dcb checks before calling db_close Forced initialisation values of some parameters
This commit is contained in:
@ -183,7 +183,11 @@ unsigned char *defuuid;
|
||||
spinlock_init(&inst->binlog_lock);
|
||||
|
||||
inst->binlog_fd = -1;
|
||||
inst->master_chksum = true;
|
||||
|
||||
inst->master_state = BLRM_UNCONNECTED;
|
||||
inst->master = NULL;
|
||||
inst->client = NULL;
|
||||
|
||||
inst->master_uuid = NULL;
|
||||
|
||||
inst->low_water = DEF_LOW_WATER;
|
||||
@ -374,23 +378,13 @@ unsigned char *defuuid;
|
||||
inst->next = NULL;
|
||||
inst->lastEventTimestamp = 0;
|
||||
|
||||
inst->binlog_position = 0;
|
||||
strcpy(inst->binlog_name, "");
|
||||
|
||||
/*
|
||||
* Read any cached response messages
|
||||
*/
|
||||
inst->saved_master.server_id = blr_cache_read_response(inst, "serverid");
|
||||
inst->saved_master.heartbeat = blr_cache_read_response(inst, "heartbeat");
|
||||
inst->saved_master.chksum1 = blr_cache_read_response(inst, "chksum1");
|
||||
inst->saved_master.chksum2 = blr_cache_read_response(inst, "chksum2");
|
||||
inst->saved_master.gtid_mode = blr_cache_read_response(inst, "gtidmode");
|
||||
inst->saved_master.uuid = blr_cache_read_response(inst, "uuid");
|
||||
inst->saved_master.setslaveuuid = blr_cache_read_response(inst, "ssuuid");
|
||||
inst->saved_master.setnames = blr_cache_read_response(inst, "setnames");
|
||||
inst->saved_master.utf8 = blr_cache_read_response(inst, "utf8");
|
||||
inst->saved_master.select1 = blr_cache_read_response(inst, "select1");
|
||||
inst->saved_master.selectver = blr_cache_read_response(inst, "selectver");
|
||||
inst->saved_master.selectvercom = blr_cache_read_response(inst, "selectvercom");
|
||||
inst->saved_master.selecthostname = blr_cache_read_response(inst, "selecthostname");
|
||||
inst->saved_master.map = blr_cache_read_response(inst, "map");
|
||||
blr_cache_read_master_data(inst);
|
||||
|
||||
/*
|
||||
* Initialise the binlog file and position
|
||||
@ -1060,7 +1054,7 @@ unsigned long mysql_errno;
|
||||
blrm_states[router->master_state], msg)));
|
||||
|
||||
if (router->master_state < BLRM_BINLOGDUMP || router->master_state != BLRM_SLAVE_STOPPED) {
|
||||
/* set mysql_errno */
|
||||
/* set mysql_errno */
|
||||
router->m_errno = mysql_errno;
|
||||
|
||||
/* set io error message */
|
||||
|
@ -23,8 +23,9 @@
|
||||
* @verbatim
|
||||
* Revision History
|
||||
*
|
||||
* Date Who Description
|
||||
* Date Who Description
|
||||
* 14/04/2014 Mark Riddoch Initial implementation
|
||||
* 08/06/2015 Massimiliano Pinto Addition of blr_cache_read_master_data()
|
||||
*
|
||||
* @endverbatim
|
||||
*/
|
||||
@ -59,6 +60,7 @@ static int blr_file_create(ROUTER_INSTANCE *router, char *file);
|
||||
static void blr_file_append(ROUTER_INSTANCE *router, char *file);
|
||||
static uint32_t extract_field(uint8_t *src, int bits);
|
||||
static void blr_log_header(logfile_id_t file, char *msg, uint8_t *ptr);
|
||||
void blr_cache_read_master_data(ROUTER_INSTANCE *router);
|
||||
|
||||
/**
|
||||
* Initialise the binlog file for this instance. MaxScale will look
|
||||
@ -752,3 +754,27 @@ int filenum;
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read any previously saved master data
|
||||
*
|
||||
* @param router The router instance
|
||||
*/
|
||||
void
|
||||
blr_cache_read_master_data(ROUTER_INSTANCE *router)
|
||||
{
|
||||
router->saved_master.server_id = blr_cache_read_response(router, "serverid");
|
||||
router->saved_master.heartbeat = blr_cache_read_response(router, "heartbeat");
|
||||
router->saved_master.chksum1 = blr_cache_read_response(router, "chksum1");
|
||||
router->saved_master.chksum2 = blr_cache_read_response(router, "chksum2");
|
||||
router->saved_master.gtid_mode = blr_cache_read_response(router, "gtidmode");
|
||||
router->saved_master.uuid = blr_cache_read_response(router, "uuid");
|
||||
router->saved_master.setslaveuuid = blr_cache_read_response(router, "ssuuid");
|
||||
router->saved_master.setnames = blr_cache_read_response(router, "setnames");
|
||||
router->saved_master.utf8 = blr_cache_read_response(router, "utf8");
|
||||
router->saved_master.select1 = blr_cache_read_response(router, "select1");
|
||||
router->saved_master.selectver = blr_cache_read_response(router, "selectver");
|
||||
router->saved_master.selectvercom = blr_cache_read_response(router, "selectvercom");
|
||||
router->saved_master.selecthostname = blr_cache_read_response(router, "selecthostname");
|
||||
router->saved_master.map = blr_cache_read_response(router, "map");
|
||||
}
|
||||
|
@ -2211,8 +2211,9 @@ blr_stop_slave(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave)
|
||||
|
||||
if (router->master_state != BLRM_SLAVE_STOPPED) {
|
||||
|
||||
if (router->master->fd != -1 && router->master->state == DCB_STATE_POLLING)
|
||||
blr_master_close(router);
|
||||
if (router->master)
|
||||
if (router->master->fd != -1 && router->master->state == DCB_STATE_POLLING)
|
||||
blr_master_close(router);
|
||||
|
||||
spinlock_acquire(&router->lock);
|
||||
|
||||
@ -2220,8 +2221,9 @@ blr_stop_slave(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave)
|
||||
|
||||
spinlock_release(&router->lock);
|
||||
|
||||
if (router->client->fd != -1 && router->client->state == DCB_STATE_POLLING)
|
||||
dcb_close(router->client);
|
||||
if (router->client)
|
||||
if (router->client->fd != -1 && router->client->state == DCB_STATE_POLLING)
|
||||
dcb_close(router->client);
|
||||
|
||||
/* Discard the queued residual data */
|
||||
ptr = router->residual;
|
||||
|
Reference in New Issue
Block a user