From 453dd642730bfac7c865830693b555de2e6c251f Mon Sep 17 00:00:00 2001 From: MassimilianoPinto Date: Wed, 27 May 2015 15:29:38 +0200 Subject: [PATCH] Added dcb_close for router->client session Added dcb_close for router->client session and queue residual cleanup --- server/modules/routing/binlog/blr_slave.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/server/modules/routing/binlog/blr_slave.c b/server/modules/routing/binlog/blr_slave.c index d56070639..0e37ed08a 100644 --- a/server/modules/routing/binlog/blr_slave.c +++ b/server/modules/routing/binlog/blr_slave.c @@ -2160,6 +2160,8 @@ uint8_t *ptr; static int 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", router->service->name, slave->dcb->user, @@ -2178,6 +2180,22 @@ blr_stop_slave(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave) 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); } else { blr_slave_send_error(router, slave, "Slave connection is not running");