From 2a31da75524198cb7cddc2d812e327f9d0582ccd Mon Sep 17 00:00:00 2001 From: lzj Date: Mon, 9 Nov 2020 20:45:26 +0800 Subject: [PATCH] =?UTF-8?q?1=20UdpBootstrap=20=E4=B8=AD=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E9=85=8D=E7=BD=AE=E7=9B=91=E6=8E=A7=EF=BC=8C?= =?UTF-8?q?=E6=9C=AA=E9=85=8D=E7=BD=AE=E5=88=99=E8=B7=B3=E8=BF=87=20NetMon?= =?UTF-8?q?itor=20netMonitor=20=3D=20config.getMonitor();=20if(netMonitor?= =?UTF-8?q?=20!=3D=20null){=20=20=20=20netMonitor.beforeRead(aioSession);?= =?UTF-8?q?=20=20=20=20netMonitor.afterRead(aioSession,=20buffer.remaining?= =?UTF-8?q?());=20}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2 UdpDispatcher 当业务执行报错时,while 循环退出 while (true) { try { RequestTask unit = taskQueue.take(); if (unit == EXECUTE_TASK_OR_SHUTDOWN) { LOGGER.info("shutdown thread:{}", Thread.currentThread()); break; } processor.process(unit.session, unit.request); unit.session.writeBuffer().flush(); } catch (InterruptedException e) { LOGGER.info("InterruptedException", e); } catch (Exception e) { LOGGER.error(e.getClass().getName(), e); } } --- aio-core/pom.xml | 2 +- .../org/smartboot/socket/transport/IoServerConfig.java | 2 +- aio-pro/pom.xml | 2 +- .../org/smartboot/socket/transport/UdpBootstrap.java | 8 ++++++-- .../org/smartboot/socket/transport/UdpDispatcher.java | 10 ++++++---- example/pom.xml | 6 +++--- pom.xml | 2 +- smart-socket-parent/pom.xml | 4 ++-- 8 files changed, 21 insertions(+), 15 deletions(-) diff --git a/aio-core/pom.xml b/aio-core/pom.xml index e1cfc917..43030ecf 100644 --- a/aio-core/pom.xml +++ b/aio-core/pom.xml @@ -20,7 +20,7 @@ org.smartboot.socket smart-socket-parent - 1.5.0 + 1.5.1 ../smart-socket-parent 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 b53c905f..c19c8e90 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.5.0"; + public static final String VERSION = "v1.5.1"; /** * 消息体缓存大小,字节 diff --git a/aio-pro/pom.xml b/aio-pro/pom.xml index 157b35d8..7f6fba40 100644 --- a/aio-pro/pom.xml +++ b/aio-pro/pom.xml @@ -20,7 +20,7 @@ org.smartboot.socket smart-socket-parent - 1.5.0 + 1.5.1 ../smart-socket-parent diff --git a/aio-pro/src/main/java/org/smartboot/socket/transport/UdpBootstrap.java b/aio-pro/src/main/java/org/smartboot/socket/transport/UdpBootstrap.java index 6a6aea4c..2fb4a9ed 100644 --- a/aio-pro/src/main/java/org/smartboot/socket/transport/UdpBootstrap.java +++ b/aio-pro/src/main/java/org/smartboot/socket/transport/UdpBootstrap.java @@ -12,6 +12,7 @@ package org.smartboot.socket.transport; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.smartboot.socket.MessageProcessor; +import org.smartboot.socket.NetMonitor; import org.smartboot.socket.Protocol; import org.smartboot.socket.StateMachineEnum; import org.smartboot.socket.buffer.BufferPage; @@ -201,8 +202,11 @@ public class UdpBootstrap { buffer.flip(); UdpAioSession aioSession = channel.createAndCacheSession(remote); - config.getMonitor().beforeRead(aioSession); - config.getMonitor().afterRead(aioSession, buffer.remaining()); + NetMonitor netMonitor = config.getMonitor(); + if(netMonitor != null){ + netMonitor.beforeRead(aioSession); + netMonitor.afterRead(aioSession, buffer.remaining()); + } Request request; //解码 try { diff --git a/aio-pro/src/main/java/org/smartboot/socket/transport/UdpDispatcher.java b/aio-pro/src/main/java/org/smartboot/socket/transport/UdpDispatcher.java index bc1f893d..133fe1a3 100644 --- a/aio-pro/src/main/java/org/smartboot/socket/transport/UdpDispatcher.java +++ b/aio-pro/src/main/java/org/smartboot/socket/transport/UdpDispatcher.java @@ -34,8 +34,8 @@ class UdpDispatcher implements Runnable { @Override public void run() { - try { - while (true) { + while (true) { + try { RequestTask unit = taskQueue.take(); if (unit == EXECUTE_TASK_OR_SHUTDOWN) { LOGGER.info("shutdown thread:{}", Thread.currentThread()); @@ -43,9 +43,11 @@ class UdpDispatcher implements Runnable { } processor.process(unit.session, unit.request); unit.session.writeBuffer().flush(); + } catch (InterruptedException e) { + LOGGER.info("InterruptedException", e); + } catch (Exception e) { + LOGGER.error(e.getClass().getName(), e); } - } catch (InterruptedException e) { - LOGGER.info("InterruptedException", e); } } diff --git a/example/pom.xml b/example/pom.xml index 3fc28166..dc970388 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -32,12 +32,12 @@ org.smartboot.socket aio-pro - 1.5.0 + 1.5.1 org.smartboot.socket aio-core - 1.5.0 + 1.5.1 org.apache.commons @@ -52,7 +52,7 @@ org.smartboot.aio aio-enhance - 1.0.1-SNAPSHOT + 1.0.2 diff --git a/pom.xml b/pom.xml index fd3aadf9..3f3278e8 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.smartboot.socket smart-socket-parent - 1.5.0 + 1.5.1 2.6 diff --git a/smart-socket-parent/pom.xml b/smart-socket-parent/pom.xml index 690a4a05..569c26e6 100644 --- a/smart-socket-parent/pom.xml +++ b/smart-socket-parent/pom.xml @@ -15,14 +15,14 @@ 4.0.0 org.smartboot.socket smart-socket-parent - 1.5.0 + 1.5.1 pom UTF-8 1.7.29 - 1.5.0 + 1.5.1 -- Gitee