Skip to content

Commit 0e65003

Browse files
committed
Fixed #84 - keep alive thread interfering with non-blocking mode
1 parent a921459 commit 0e65003

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/java/com/github/shyiko/mysql/binlog/BinaryLogClient.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ private void confirmSupportOfChecksum(ChecksumType checksumType) throws IOExcept
610610

611611
private void listenForEventPackets() throws IOException {
612612
ByteArrayInputStream inputStream = channel.getInputStream();
613+
boolean completeShutdown = false;
613614
try {
614615
while (inputStream.peek() != -1) {
615616
int packetLength = inputStream.readInteger(3);
@@ -621,6 +622,7 @@ private void listenForEventPackets() throws IOException {
621622
errorPacket.getSqlState());
622623
}
623624
if (marker == (byte) 0xFE && !blocking) {
625+
completeShutdown = true;
624626
break;
625627
}
626628
Event event;
@@ -658,7 +660,11 @@ private void listenForEventPackets() throws IOException {
658660
}
659661
} finally {
660662
if (isConnected()) {
661-
disconnectChannel();
663+
if (completeShutdown) {
664+
disconnect(); // initiate complete shutdown sequence (which includes keep alive thread)
665+
} else {
666+
disconnectChannel();
667+
}
662668
}
663669
}
664670
}

0 commit comments

Comments
 (0)