Added dcb_close for router->client session

Added dcb_close for router->client session and queue residual cleanup
This commit is contained in:
MassimilianoPinto
2015-05-27 15:29:38 +02:00
parent 7634f22a94
commit 453dd64273

View File

@ -2160,6 +2160,8 @@ uint8_t *ptr;
static int static int
blr_stop_slave(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave) blr_stop_slave(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave)
{ {
GWBUF *ptr;
LOGIF(LM, (skygw_log_write(LOGFILE_MESSAGE, "%s: STOP SLAVE received by %s@%s. Disconnecting from master %s:%d", LOGIF(LM, (skygw_log_write(LOGFILE_MESSAGE, "%s: STOP SLAVE received by %s@%s. Disconnecting from master %s:%d",
router->service->name, router->service->name,
slave->dcb->user, slave->dcb->user,
@ -2178,6 +2180,22 @@ blr_stop_slave(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave)
spinlock_release(&router->lock); spinlock_release(&router->lock);
dcb_close(router->client);
/* Discard the queued residual data */
ptr = router->residual;
while (ptr)
{
ptr = gwbuf_consume(ptr, GWBUF_LENGTH(ptr));
}
router->residual = NULL;
/* Now it is safe to unleash other threads on this router instance */
spinlock_acquire(&router->lock);
router->reconnect_pending = 0;
router->active_logs = 0;
spinlock_release(&router->lock);
return blr_slave_send_ok(router, slave); return blr_slave_send_ok(router, slave);
} else { } else {
blr_slave_send_error(router, slave, "Slave connection is not running"); blr_slave_send_error(router, slave, "Slave connection is not running");