diff --git a/aio-core/pom.xml b/aio-core/pom.xml
index 58718d171835ad88c72f9beafb2191db004d3782..91e240782d64c04e10c54777c48c0d84f059a5c8 100644
--- a/aio-core/pom.xml
+++ b/aio-core/pom.xml
@@ -19,13 +19,7 @@
org.smartboot.socket
smart-socket-parent
- 1.6.4
+ 1.6.5
../smart-socket-parent
-
-
- org.smartboot.socket
- aio-enhance
-
-
diff --git a/aio-core/src/main/java/org/smartboot/socket/buffer/BufferPage.java b/aio-core/src/main/java/org/smartboot/socket/buffer/BufferPage.java
index 238e1296eb3cc113554d04914337c23ee2350fe3..3d3c5e395f685e19325eab58c4d51a489e9aeae3 100644
--- a/aio-core/src/main/java/org/smartboot/socket/buffer/BufferPage.java
+++ b/aio-core/src/main/java/org/smartboot/socket/buffer/BufferPage.java
@@ -82,6 +82,9 @@ public final class BufferPage {
* @return 虚拟内存对象
*/
public VirtualBuffer allocate(final int size) {
+ if (size == 0) {
+ throw new UnsupportedOperationException("cannot allocate zero bytes");
+ }
VirtualBuffer virtualBuffer;
Thread thread = Thread.currentThread();
if (thread instanceof FastBufferThread) {
diff --git a/aio-enhance/src/main/java/org/smartboot/socket/enhance/EnhanceAsynchronousChannelGroup.java b/aio-core/src/main/java/org/smartboot/socket/enhance/EnhanceAsynchronousChannelGroup.java
similarity index 94%
rename from aio-enhance/src/main/java/org/smartboot/socket/enhance/EnhanceAsynchronousChannelGroup.java
rename to aio-core/src/main/java/org/smartboot/socket/enhance/EnhanceAsynchronousChannelGroup.java
index 6dddae16d857a3d0a555fc3eaae49fe77d1b3fb8..0dd537f3d9e2c7bc023d6af6baf8b868edc10344 100644
--- a/aio-enhance/src/main/java/org/smartboot/socket/enhance/EnhanceAsynchronousChannelGroup.java
+++ b/aio-core/src/main/java/org/smartboot/socket/enhance/EnhanceAsynchronousChannelGroup.java
@@ -14,6 +14,7 @@ import java.nio.channels.AsynchronousChannelGroup;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.spi.AsynchronousChannelProvider;
+import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
@@ -202,17 +203,22 @@ class EnhanceAsynchronousChannelGroup extends AsynchronousChannelGroup {
public final void run() {
workerThread = Thread.currentThread();
// 优先获取SelectionKey,若无关注事件触发则阻塞在selector.select(),减少select被调用次数
- Consumer action = selectionKey -> {
- invoker = 0;
- consumer.accept(selectionKey);
- };
+ // 优先获取SelectionKey,若无关注事件触发则阻塞在selector.select(),减少select被调用次数
+ Set keySet = selector.selectedKeys();
try {
while (running) {
Consumer selectorConsumer;
while ((selectorConsumer = consumers.poll()) != null) {
selectorConsumer.accept(selector);
}
- selector.select(action);
+ selector.select();
+
+ // 执行本次已触发待处理的事件
+ for (SelectionKey key : keySet) {
+ invoker = 0;
+ consumer.accept(key);
+ }
+ keySet.clear();
}
} catch (Exception e) {
e.printStackTrace();
diff --git a/aio-enhance/src/main/java/org/smartboot/socket/enhance/EnhanceAsynchronousChannelProvider.java b/aio-core/src/main/java/org/smartboot/socket/enhance/EnhanceAsynchronousChannelProvider.java
similarity index 100%
rename from aio-enhance/src/main/java/org/smartboot/socket/enhance/EnhanceAsynchronousChannelProvider.java
rename to aio-core/src/main/java/org/smartboot/socket/enhance/EnhanceAsynchronousChannelProvider.java
diff --git a/aio-enhance/src/main/java/org/smartboot/socket/enhance/EnhanceAsynchronousServerSocketChannel.java b/aio-core/src/main/java/org/smartboot/socket/enhance/EnhanceAsynchronousServerSocketChannel.java
similarity index 100%
rename from aio-enhance/src/main/java/org/smartboot/socket/enhance/EnhanceAsynchronousServerSocketChannel.java
rename to aio-core/src/main/java/org/smartboot/socket/enhance/EnhanceAsynchronousServerSocketChannel.java
diff --git a/aio-enhance/src/main/java/org/smartboot/socket/enhance/EnhanceAsynchronousSocketChannel.java b/aio-core/src/main/java/org/smartboot/socket/enhance/EnhanceAsynchronousSocketChannel.java
similarity index 100%
rename from aio-enhance/src/main/java/org/smartboot/socket/enhance/EnhanceAsynchronousSocketChannel.java
rename to aio-core/src/main/java/org/smartboot/socket/enhance/EnhanceAsynchronousSocketChannel.java
diff --git a/aio-enhance/src/main/java/org/smartboot/socket/enhance/FutureCompletionHandler.java b/aio-core/src/main/java/org/smartboot/socket/enhance/FutureCompletionHandler.java
similarity index 100%
rename from aio-enhance/src/main/java/org/smartboot/socket/enhance/FutureCompletionHandler.java
rename to aio-core/src/main/java/org/smartboot/socket/enhance/FutureCompletionHandler.java
diff --git a/aio-core/src/main/java/org/smartboot/socket/transport/IoServerConfig.java b/aio-core/src/main/java/org/smartboot/socket/transport/IoServerConfig.java
index a5e4f431213927eca3306e62967f98ee682f16e0..4d80ad3697054134b7a858777b21c171a75e12d8 100644
--- a/aio-core/src/main/java/org/smartboot/socket/transport/IoServerConfig.java
+++ b/aio-core/src/main/java/org/smartboot/socket/transport/IoServerConfig.java
@@ -39,7 +39,7 @@ final class IoServerConfig {
/**
* 当前smart-socket版本号
*/
- public static final String VERSION = "v1.6.4";
+ public static final String VERSION = "v1.6.5";
/**
* 消息体缓存大小,字节
diff --git a/aio-core/src/main/java/org/smartboot/socket/transport/TcpAioSession.java b/aio-core/src/main/java/org/smartboot/socket/transport/TcpAioSession.java
index 11e200e87ad56e8e18a160adba9ffb1bacd64e86..2ad0c4ca8ee355399d862a1d9917ef2cd9336e09 100644
--- a/aio-core/src/main/java/org/smartboot/socket/transport/TcpAioSession.java
+++ b/aio-core/src/main/java/org/smartboot/socket/transport/TcpAioSession.java
@@ -184,10 +184,10 @@ final class TcpAioSession extends AioSession {
monitor.afterWrite(this, result);
}
if (writeBuffer == null) {
- writeBuffer = byteBuf.pollItem();
+ writeBuffer = byteBuf.poll();
} else if (!writeBuffer.buffer().hasRemaining()) {
writeBuffer.clean();
- writeBuffer = byteBuf.pollItem();
+ writeBuffer = byteBuf.poll();
}
if (writeBuffer != null) {
@@ -292,8 +292,10 @@ final class TcpAioSession extends AioSession {
monitor.afterRead(this, result);
}
this.eof = result == -1;
- this.readBuffer.buffer().flip();
- signalRead();
+ if (SESSION_STATUS_CLOSED != status) {
+ this.readBuffer.buffer().flip();
+ signalRead();
+ }
}
/**
diff --git a/aio-core/src/main/java/org/smartboot/socket/transport/WriteBuffer.java b/aio-core/src/main/java/org/smartboot/socket/transport/WriteBuffer.java
index d79e464293f425d058053c9c71323dea5400b7a6..36d47f2390fdefd981b24b11cdd27668b87ba87e 100644
--- a/aio-core/src/main/java/org/smartboot/socket/transport/WriteBuffer.java
+++ b/aio-core/src/main/java/org/smartboot/socket/transport/WriteBuffer.java
@@ -179,6 +179,9 @@ public final class WriteBuffer extends OutputStream {
@Override
public synchronized void write(byte[] b, int off, int len) throws IOException {
+ if (len == 0) {
+ return;
+ }
if (writeInBuf == null) {
writeInBuf = bufferPage.allocate(Math.max(chunkSize, len));
}
@@ -290,7 +293,7 @@ public final class WriteBuffer extends OutputStream {
return count == 0 && (writeInBuf == null || writeInBuf.buffer().position() == 0);
}
- VirtualBuffer pollItem() {
+ private VirtualBuffer pollItem() {
if (count == 0) {
return null;
}
@@ -299,10 +302,8 @@ public final class WriteBuffer extends OutputStream {
if (++takeIndex == items.length) {
takeIndex = 0;
}
- synchronized (this) {
- if (count-- == items.length) {
- this.notifyAll();
- }
+ if (count-- == items.length) {
+ this.notifyAll();
}
return x;
}
diff --git a/aio-enhance/pom.xml b/aio-enhance/pom.xml
deleted file mode 100644
index 24d3c3701ef46ed997737dbd102af2a48ee55b7f..0000000000000000000000000000000000000000
--- a/aio-enhance/pom.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
- smart-socket-parent
- org.smartboot.socket
- 1.6.4
- ../smart-socket-parent
-
- 4.0.0
-
- aio-enhance
-
-
\ No newline at end of file
diff --git a/aio-pro/pom.xml b/aio-pro/pom.xml
index 18c6cca85721146b938301bad5c461148ffdcbad..e0eb35a3521f305ee24ebb939e1b7cb6dbfcf4fa 100644
--- a/aio-pro/pom.xml
+++ b/aio-pro/pom.xml
@@ -19,7 +19,7 @@
org.smartboot.socket
smart-socket-parent
- 1.6.4
+ 1.6.5
../smart-socket-parent
diff --git a/benchmark/pom.xml b/benchmark/pom.xml
index 86acbfaea861574b02495fd963a496eafb832b76..39e292a6dd1d61354d7f6a02b8a0594c2e231870 100644
--- a/benchmark/pom.xml
+++ b/benchmark/pom.xml
@@ -18,7 +18,7 @@
org.smartboot.socket
aio-pro
- 1.6.4
+ 1.6.5
org.slf4j
diff --git a/example/pom.xml b/example/pom.xml
index 5cafdfdfd716d9b7ec840f9c2d7f77d4f5381b4d..0cbfd9bc916e1fb4fcb2ef04589c982fc106b2d5 100644
--- a/example/pom.xml
+++ b/example/pom.xml
@@ -23,7 +23,7 @@
org.smartboot.socket
aio-pro
- 1.6.4
+ 1.6.5
org.apache.commons
diff --git a/pom.xml b/pom.xml
index 00b48f2a66bde1ecc48b0651324b0b4abc806c8d..eb1bd73012b4794c18432aef3905260999412994 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
org.smartboot.socket
smart-socket-parent
- 1.6.4
+ 1.6.5
2.6
diff --git a/smart-socket-parent/pom.xml b/smart-socket-parent/pom.xml
index 59544ffc4cbd9b9d9d1876ce88ef55b1e180aff5..5cf4c4a2578356e5f35a18ae9e0ccbc8cbc80e26 100644
--- a/smart-socket-parent/pom.xml
+++ b/smart-socket-parent/pom.xml
@@ -15,23 +15,18 @@
4.0.0
org.smartboot.socket
smart-socket-parent
- 1.6.4
+ 1.6.5
pom
UTF-8
1.7.36
- 1.6.4
+ 1.6.5
4.13.2
-
- org.smartboot.socket
- aio-enhance
- ${aio.version}
-
org.smartboot.socket
aio-core
@@ -272,6 +267,5 @@
../aio-core
../aio-pro
- ../aio-enhance
\ No newline at end of file