From be238f6ac6c701487e3d46c1f5a97f146af67e93 Mon Sep 17 00:00:00 2001 From: "Kristian S. Stangeland" Date: Wed, 9 Apr 2014 02:57:52 +0200 Subject: [PATCH] Don't remove channel handlers in the main thread - can case deadlock. --- .../com/comphenix/tinyprotocol/TinyProtocol.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Examples/TinyProtocol/src/main/java/com/comphenix/tinyprotocol/TinyProtocol.java b/Examples/TinyProtocol/src/main/java/com/comphenix/tinyprotocol/TinyProtocol.java index 12e4bc8c..91835ad6 100644 --- a/Examples/TinyProtocol/src/main/java/com/comphenix/tinyprotocol/TinyProtocol.java +++ b/Examples/TinyProtocol/src/main/java/com/comphenix/tinyprotocol/TinyProtocol.java @@ -187,10 +187,20 @@ public abstract class TinyProtocol { public final void close() { if (!closed) { closed = true; - + // Compute this once + final String handlerName = getHandlerName(); + // Remove our handlers for (Player player : plugin.getServer().getOnlinePlayers()) { - getChannel(player).pipeline().remove(getHandlerName()); + final Channel channel = getChannel(player); + + // See ChannelInjector in ProtocolLib, line 590 + channel.eventLoop().execute(new Runnable() { + @Override + public void run() { + channel.pipeline().remove(handlerName); + } + }); } // Clean up Bukkit