From 803f9c5fdbbc6b088e0f6fd0757893efa2e06517 Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 14 Feb 2018 20:33:52 +0100 Subject: [PATCH] Fixed channel shutdown order --- src/dorkbox/network/connection/Shutdownable.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/dorkbox/network/connection/Shutdownable.java b/src/dorkbox/network/connection/Shutdownable.java index 2db2f4f3..a309f6cb 100644 --- a/src/dorkbox/network/connection/Shutdownable.java +++ b/src/dorkbox/network/connection/Shutdownable.java @@ -148,7 +148,7 @@ class Shutdownable { // server only does this on stop. Client does this on closeConnections void shutdownChannels() { synchronized (shutdownChannelList) { - // now we stop all of our channels + // now we stop all of our channels. For the server, this will close the server manager for UDP sessions for (ChannelFuture f : shutdownChannelList) { Channel channel = f.channel(); if (channel.isOpen()) { @@ -275,6 +275,9 @@ class Shutdownable { // make sure we are not trying to stop during a startup procedure. // This will wait until we have finished starting up/shutting down. synchronized (shutdownInProgress) { + shutdownChannelsPre(); + shutdownChannels(); + // we want to WAIT until after the event executors have completed shutting down. List> shutdownThreadList = new LinkedList>(); @@ -298,9 +301,7 @@ class Shutdownable { Thread.yield(); } - shutdownChannelsPre(); - shutdownChannels(); logger.info("Stopping endpoint.");