Added error message of DISCONNECT
Added error message of DISCONNECT when gwbuf_alloc may fail
This commit is contained in:
@ -1885,6 +1885,11 @@ char serverid[40];
|
|||||||
uint8_t *ptr;
|
uint8_t *ptr;
|
||||||
int len, id_len, seqno = 2;
|
int len, id_len, seqno = 2;
|
||||||
|
|
||||||
|
len = 5 + id_len + strlen(state) + 1;
|
||||||
|
|
||||||
|
if ((pkt = gwbuf_alloc(len)) == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
blr_slave_send_fieldcount(router, slave, 2);
|
blr_slave_send_fieldcount(router, slave, 2);
|
||||||
blr_slave_send_columndef(router, slave, "server_id", 0x03, 40, seqno++);
|
blr_slave_send_columndef(router, slave, "server_id", 0x03, 40, seqno++);
|
||||||
blr_slave_send_columndef(router, slave, "state", 0xf, 40, seqno++);
|
blr_slave_send_columndef(router, slave, "state", 0xf, 40, seqno++);
|
||||||
@ -1897,11 +1902,6 @@ int len, id_len, seqno = 2;
|
|||||||
else
|
else
|
||||||
strcpy(state, "not found");
|
strcpy(state, "not found");
|
||||||
|
|
||||||
len = 5 + id_len + strlen(state) + 1;
|
|
||||||
|
|
||||||
if ((pkt = gwbuf_alloc(len)) == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
ptr = GWBUF_DATA(pkt);
|
ptr = GWBUF_DATA(pkt);
|
||||||
encode_value(ptr, id_len + 2 + strlen(state), 24); // Add length of data packet
|
encode_value(ptr, id_len + 2 + strlen(state), 24); // Add length of data packet
|
||||||
ptr += 3;
|
ptr += 3;
|
||||||
@ -1949,7 +1949,6 @@ blr_slave_disconnect_server(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, int se
|
|||||||
{
|
{
|
||||||
/* server_id found */
|
/* server_id found */
|
||||||
server_found = 1;
|
server_found = 1;
|
||||||
|
|
||||||
LOGIF(LT, (skygw_log_write(LOGFILE_TRACE, "%s: Slave %s, server id %d, disconnected by %s@%s",
|
LOGIF(LT, (skygw_log_write(LOGFILE_TRACE, "%s: Slave %s, server id %d, disconnected by %s@%s",
|
||||||
router->service->name,
|
router->service->name,
|
||||||
sptr->dcb->remote,
|
sptr->dcb->remote,
|
||||||
@ -1981,8 +1980,10 @@ blr_slave_disconnect_server(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, int se
|
|||||||
|
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, "Error: gwbuf memory allocation in "
|
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, "Error: gwbuf memory allocation in "
|
||||||
"DISCONNECT SERVER for [%s], server_id [%d]",
|
"DISCONNECT SERVER server_id [%d]",
|
||||||
sptr->dcb->remote, sptr->serverid)));
|
sptr->serverid)));
|
||||||
|
|
||||||
|
blr_slave_send_error(router, slave, "Memory allocation error for DISCONNECT SERVER");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -2027,6 +2028,7 @@ blr_slave_disconnect_all(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave)
|
|||||||
sprintf(state, "disconnected");
|
sprintf(state, "disconnected");
|
||||||
|
|
||||||
len = 5 + strlen(server_id) + strlen(state) + 1;
|
len = 5 + strlen(server_id) + strlen(state) + 1;
|
||||||
|
|
||||||
if ((pkt = gwbuf_alloc(len)) == NULL) {
|
if ((pkt = gwbuf_alloc(len)) == NULL) {
|
||||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, "Error: gwbuf memory allocation in "
|
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, "Error: gwbuf memory allocation in "
|
||||||
"DISCONNECT ALL for [%s], server_id [%d]",
|
"DISCONNECT ALL for [%s], server_id [%d]",
|
||||||
@ -2034,6 +2036,8 @@ blr_slave_disconnect_all(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave)
|
|||||||
|
|
||||||
spinlock_release(&router->lock);
|
spinlock_release(&router->lock);
|
||||||
|
|
||||||
|
blr_slave_send_error(router, slave, "Memory allocation error for DISCONNECT ALL");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user