diff options
author | Robert Godfrey <rgodfrey@apache.org> | 2015-01-28 21:57:48 +0000 |
---|---|---|
committer | Robert Godfrey <rgodfrey@apache.org> | 2015-01-28 21:57:48 +0000 |
commit | 5a0dbe989ab6da2085496013bb8bd13a81d12e9d (patch) | |
tree | 2cf89c880b3557a4e5aac3e6860d73b1533adf66 /qpid/java/common | |
parent | 0900a59cebb72b3446ce8eb1b06e36935cc815ac (diff) | |
download | qpid-python-5a0dbe989ab6da2085496013bb8bd13a81d12e9d.tar.gz |
Close the selector thread
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/QPID-6262-JavaBrokerNIO@1655482 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/common')
2 files changed, 14 insertions, 4 deletions
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/NonBlockingNetworkTransport.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/NonBlockingNetworkTransport.java index 0b06a95717..2344872580 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/NonBlockingNetworkTransport.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/NonBlockingNetworkTransport.java @@ -49,7 +49,7 @@ public class NonBlockingNetworkTransport implements IncomingNetworkTransport private static final int HANDSHAKE_TIMEOUT = Integer.getInteger(CommonProperties.HANDSHAKE_TIMEOUT_PROP_NAME , CommonProperties.HANDSHAKE_TIMEOUT_DEFAULT); private AcceptingThread _acceptor; - private SelectorThread _selector = new SelectorThread(); + private SelectorThread _selector; protected NonBlockingConnection createNetworkConnection(final SocketChannel socketChannel, final ServerProtocolEngine engine, @@ -72,6 +72,10 @@ public class NonBlockingNetworkTransport implements IncomingNetworkTransport { _acceptor.close(); } + if(_selector != null) + { + _selector.close(); + } } public void accept(NetworkTransportConfiguration config, @@ -85,7 +89,7 @@ public class NonBlockingNetworkTransport implements IncomingNetworkTransport _acceptor.setDaemon(false); _acceptor.start(); - + _selector = new SelectorThread(config.getAddress().toString()); _selector.start(); } catch (IOException e) diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/SelectorThread.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/SelectorThread.java index 65707eb4c2..10d21f8f94 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/SelectorThread.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/SelectorThread.java @@ -43,10 +43,10 @@ public class SelectorThread extends Thread private final AtomicBoolean _closed = new AtomicBoolean(); private final NetworkConnectionScheduler _scheduler = new NetworkConnectionScheduler(); - SelectorThread() + SelectorThread(final String name) { - + super("SelectorThread-"+name); try { _selector = Selector.open(); @@ -147,6 +147,12 @@ public class SelectorThread extends Thread _selector.wakeup(); } + public void close() + { + _closed.set(true); + _selector.wakeup(); + } + private class NetworkConnectionScheduler { public void schedule(final NonBlockingConnection connection) |