From 8fa21b0b647e3334a918eb457516bec6eee2e5d7 Mon Sep 17 00:00:00 2001 From: yinyanghuafa <1209451624@qq.com> Date: Thu, 18 Apr 2019 15:36:27 +0800 Subject: [PATCH] fix the 'ClosedChannelException' error when the client set useServerPrepStmts=true (#1133) * fix the 'ClosedChannelException' error when the client set useServerPrepStmts=true * other tweak other tweak --- .../dble/net/handler/FrontendCommandHandler.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/actiontech/dble/net/handler/FrontendCommandHandler.java b/src/main/java/com/actiontech/dble/net/handler/FrontendCommandHandler.java index 9d6ef619e4..7c2bc4eed2 100644 --- a/src/main/java/com/actiontech/dble/net/handler/FrontendCommandHandler.java +++ b/src/main/java/com/actiontech/dble/net/handler/FrontendCommandHandler.java @@ -30,9 +30,9 @@ public class FrontendCommandHandler implements NIOHandler { protected final FrontendConnection source; protected final CommandCount commands; private volatile byte[] dataTodo; - Queue blobDataQueue = new ConcurrentLinkedQueue(); + private Queue blobDataQueue = new ConcurrentLinkedQueue(); - public FrontendCommandHandler(FrontendConnection source) { + FrontendCommandHandler(FrontendConnection source) { this.source = source; this.commands = source.getProcessor().getCommands(); } @@ -49,8 +49,13 @@ public void handle(byte[] data) { } if (MySQLPacket.COM_STMT_SEND_LONG_DATA == data[4]) { + commands.doStmtSendLongData(); blobDataQueue.offer(data); return; + } else if (MySQLPacket.COM_STMT_CLOSE == data[4]) { + commands.doStmtClose(); + source.stmtClose(data); + return; } else { dataTodo = data; if (MySQLPacket.COM_STMT_RESET == data[4]) { @@ -113,10 +118,6 @@ protected void handleData(byte[] data) { commands.doStmtExecute(); source.stmtExecute(data, blobDataQueue); break; - case MySQLPacket.COM_STMT_CLOSE: - commands.doStmtClose(); - source.stmtClose(data); - break; case MySQLPacket.COM_HEARTBEAT: commands.doHeartbeat(); source.heartbeat(data);