Ensure packet hooks are called sync - thanks @aadnk for pointing this out

This commit is contained in:
md_5 2013-07-07 09:02:13 +10:00
parent cd02250065
commit a59da621da

View File

@ -1,4 +1,4 @@
From ee8dd3943261014e8444bbfb06a3aeeb3bd587e9 Mon Sep 17 00:00:00 2001 From ebb81f5f718e2f23a77bae13b3cae39330f65e22 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au> From: md_5 <md_5@live.com.au>
Date: Tue, 2 Jul 2013 09:06:29 +1000 Date: Tue, 2 Jul 2013 09:06:29 +1000
Subject: [PATCH] Netty Subject: [PATCH] Netty
@ -375,10 +375,10 @@ index 0000000..2eb1dcb
+} +}
diff --git a/src/main/java/org/spigotmc/netty/NettyNetworkManager.java b/src/main/java/org/spigotmc/netty/NettyNetworkManager.java diff --git a/src/main/java/org/spigotmc/netty/NettyNetworkManager.java b/src/main/java/org/spigotmc/netty/NettyNetworkManager.java
new file mode 100644 new file mode 100644
index 0000000..7340f5a index 0000000..c73d70c
--- /dev/null --- /dev/null
+++ b/src/main/java/org/spigotmc/netty/NettyNetworkManager.java +++ b/src/main/java/org/spigotmc/netty/NettyNetworkManager.java
@@ -0,0 +1,314 @@ @@ -0,0 +1,313 @@
+package org.spigotmc.netty; +package org.spigotmc.netty;
+ +
+import com.google.common.util.concurrent.ThreadFactoryBuilder; +import com.google.common.util.concurrent.ThreadFactoryBuilder;
@ -551,31 +551,31 @@ index 0000000..7340f5a
+ // Only send if channel is still connected + // Only send if channel is still connected
+ if ( connected ) + if ( connected )
+ { + {
+ // Process packet via handler
+ final Packet packet0 = PacketListener.callQueued( this, connection, packet );
+ highPriorityQueue.add( packet0 );
+ // If handler indicates packet send
+ if ( packet0 != null )
+ {
+ if ( channel.eventLoop().inEventLoop() ) + if ( channel.eventLoop().inEventLoop() )
+ { + {
+ queue0( packet ); + queue0( packet0 );
+ } else + } else
+ { + {
+ channel.eventLoop().execute( new Runnable() + channel.eventLoop().execute( new Runnable()
+ { + {
+ public void run() + public void run()
+ { + {
+ queue0( packet ); + queue0( packet0 );
+ } + }
+ } ); + } );
+ } + }
+ } + }
+ } + }
+ }
+ +
+ private void queue0(Packet packet) + private void queue0(Packet packet)
+ { + {
+ // Process packet via handler
+ packet = PacketListener.callQueued( this, connection, packet );
+ // If handler indicates packet send
+ if ( packet != null )
+ {
+ highPriorityQueue.add( packet );
+
+ if ( packet instanceof Packet255KickDisconnect ) + if ( packet instanceof Packet255KickDisconnect )
+ { + {
+ writer.lastFlush = 0; + writer.lastFlush = 0;
@ -588,7 +588,6 @@ index 0000000..7340f5a
+ channel.pipeline().addBefore( "decoder", "encrypt", new CipherEncoder( encrypt ) ); + channel.pipeline().addBefore( "decoder", "encrypt", new CipherEncoder( encrypt ) );
+ } + }
+ } + }
+ }
+ +
+ /** + /**
+ * wakeThreads. In Vanilla this method will interrupt the network read and + * wakeThreads. In Vanilla this method will interrupt the network read and