added checks in blr_stop_slave()
errorReply sets mysql_errno into router struct blr_slave_send_slave_status displays mysql errno added checks in blr_stop_slave()
This commit is contained in:
@ -199,6 +199,9 @@ unsigned char *defuuid;
|
||||
inst->user = strdup(service->credentials.name);
|
||||
inst->password = strdup(service->credentials.authdata);
|
||||
|
||||
inst->m_errno = 0;
|
||||
inst->m_errmsg = NULL
|
||||
|
||||
my_uuid_init((ulong)rand()*12345,12345);
|
||||
if ((defuuid = (char *)malloc(20)) != NULL)
|
||||
{
|
||||
@ -1018,6 +1021,7 @@ errorReply(ROUTER *instance, void *router_session, GWBUF *message, DCB *backend_
|
||||
ROUTER_INSTANCE *router = (ROUTER_INSTANCE *)instance;
|
||||
int error, len;
|
||||
char msg[85], *errmsg;
|
||||
unsigned long mysql_errno;
|
||||
|
||||
if (action == ERRACT_RESET)
|
||||
{
|
||||
@ -1046,12 +1050,25 @@ char msg[85], *errmsg;
|
||||
else
|
||||
strcpy(msg, "");
|
||||
|
||||
mysql_errno = (unsigned long) extract_field((uint8_t *)(GWBUF_DATA(message) + 5), 16);
|
||||
errmsg = extract_message(message);
|
||||
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR, "%s: Master connection error '%s' in state '%s', "
|
||||
"%sattempting reconnect to master",
|
||||
router->service->name, errmsg,
|
||||
blrm_states[router->master_state], msg)));
|
||||
|
||||
if (router->master_state < BLRM_BINLOGDUMP || router->master_state != BLRM_SLAVE_STOPPED) {
|
||||
/* set mysql_errno */
|
||||
router->m_errno = mysql_errno;
|
||||
|
||||
/* set io error message */
|
||||
if (router->m_errmsg)
|
||||
free(router->m_errmsg);
|
||||
router->m_errmsg = strdup(errmsg);
|
||||
}
|
||||
|
||||
if (errmsg)
|
||||
free(errmsg);
|
||||
*succp = true;
|
||||
|
@ -472,7 +472,17 @@ char query[128];
|
||||
break;
|
||||
case BLRM_MUUID:
|
||||
{
|
||||
char *val = blr_extract_column(buf, 2);
|
||||
char *key;
|
||||
char *val = NULL;
|
||||
|
||||
key = blr_extract_column(buf, 1);
|
||||
if (key && strlen(key))
|
||||
val = blr_extract_column(buf, 2);
|
||||
if (key)
|
||||
free(key);
|
||||
|
||||
if (router->master_uuid)
|
||||
free(router->master_uuid);
|
||||
router->master_uuid = val;
|
||||
|
||||
// Response to the SERVER_UUID, should be stored
|
||||
@ -907,6 +917,9 @@ static REP_HEADER phdr;
|
||||
phdr = hdr;
|
||||
if (hdr.ok == 0)
|
||||
{
|
||||
/* set mysql errno to 0 */
|
||||
router->m_errno = 0;
|
||||
|
||||
/*
|
||||
* First check that the checksum we calculate matches the
|
||||
* checksum in the packet we received.
|
||||
@ -1080,6 +1093,11 @@ static REP_HEADER phdr;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned long mysql_errno = extract_field(ptr+5, 16);
|
||||
|
||||
/* set mysql_errno */
|
||||
router->m_errno = mysql_errno;
|
||||
|
||||
LOGIF(LE,(skygw_log_write(LOGFILE_ERROR,
|
||||
"Error packet in binlog stream.%s @ %d.",
|
||||
router->binlog_name,
|
||||
|
@ -39,6 +39,8 @@
|
||||
* 25/05/2015 Massimiliano Pinto Addition of BLRM_SLAVE_STOPPED state and blr_start/stop_slave.
|
||||
* New commands STOP SLAVE, START SLAVE added.
|
||||
* 29/05/2015 Massimiliano Pinto Addition of CHANGE MASTER TO ...
|
||||
* 05/06/2015 Massimiliano Pinto router->service->dbref->sever->name instead of master->remote
|
||||
* in blr_slave_send_slave_status()
|
||||
*
|
||||
* @endverbatim
|
||||
*/
|
||||
@ -848,7 +850,7 @@ int len, actual_len, col_len, seqno, ncols, i;
|
||||
strncpy((char *)ptr, column, col_len); // Result string
|
||||
ptr += col_len;
|
||||
|
||||
sprintf(column, "%s", router->master->remote ? router->master->remote : "");
|
||||
sprintf(column, "%s", router->service->dbref->server->name ? router->service->dbref->server->name : "");
|
||||
col_len = strlen(column);
|
||||
*ptr++ = col_len; // Length of result string
|
||||
strncpy((char *)ptr, column, col_len); // Result string
|
||||
@ -924,7 +926,7 @@ int len, actual_len, col_len, seqno, ncols, i;
|
||||
*ptr++ = 0;
|
||||
|
||||
/* Last error information */
|
||||
sprintf(column, "%d", 0);
|
||||
sprintf(column, "%lu", router->m_errno);
|
||||
col_len = strlen(column);
|
||||
*ptr++ = col_len; // Length of result string
|
||||
strncpy((char *)ptr, column, col_len); // Result string
|
||||
@ -2209,7 +2211,7 @@ blr_stop_slave(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave)
|
||||
|
||||
if (router->master_state != BLRM_SLAVE_STOPPED) {
|
||||
|
||||
if (router->master->fd != -1)
|
||||
if (router->master->fd != -1 && router->master->state == DCB_STATE_POLLING)
|
||||
blr_master_close(router);
|
||||
|
||||
spinlock_acquire(&router->lock);
|
||||
@ -2218,7 +2220,8 @@ blr_stop_slave(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave)
|
||||
|
||||
spinlock_release(&router->lock);
|
||||
|
||||
dcb_close(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