Waterfall/BungeeCord-Patches/0022-Use-a-worker-and-a-boss-event-loop-group.patch
Shane Freeder cca83dfaf6
Updated Upstream (BungeeCord)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

BungeeCord Changes:
a3ab2bf5 Update checkstyle
adee7bd2 Source jar does not need to fork build
7bd8a027 Always print remote IP in InitialHandler
0cf27a09 Update scriptus
bf673c5d Add pretty colours to console log levels
2235a323 Optimize ColouredWriter slightly
1dee0490 Don't send/construct redundant kick messages
e9ba95b9 Don't log full CorruptedFrameException
d3bd7852 #2762: Work correctly with disabled timeout
3ce4132c Switch keepalive queue to ArrayDeque
ce2dcaf7 #2763: Fix .DS_Store entry in .gitignore
cf72c3a7 Show slow event times in milliseconds
cd7a3ab2 #2758: Improve server list ping response where remote ping failed
0a4b9b49 #2752: Configurable connect and ping timeouts
2020-02-01 15:39:53 +00:00

88 lines
4.5 KiB
Diff

From 61eb721efb50a13bb3de793753cf74764d54850c Mon Sep 17 00:00:00 2001
From: kamcio96 <k.nadworski@icloud.com>
Date: Mon, 14 Mar 2016 16:07:20 -0700
Subject: [PATCH] Use a worker and a boss event loop group.
Merges the rest of https://github.com/SpigotMC/BungeeCord/pull/1706 by @kamcio96 along with b8845c4edbae46bb66f6adda338330a1d4032057
This is proper practice for netty.
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
index 5643684c..b18027e2 100644
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
@@ -117,7 +117,7 @@ public class BungeeCord extends ProxyServer
*/
private ResourceBundle baseBundle;
private ResourceBundle customBundle;
- public EventLoopGroup eventLoops;
+ public EventLoopGroup bossEventLoopGroup, workerEventLoopGroup;
/**
* locations.yml save thread.
*/
@@ -253,7 +253,8 @@ public class BungeeCord extends ProxyServer
ResourceLeakDetector.setLevel( ResourceLeakDetector.Level.DISABLED ); // Eats performance
}
- eventLoops = PipelineUtils.newEventLoopGroup( 0, new ThreadFactoryBuilder().setNameFormat( "Netty IO Thread #%1$d" ).build() );
+ bossEventLoopGroup = PipelineUtils.newEventLoopGroup( 0, new ThreadFactoryBuilder().setNameFormat( "Netty Boss IO Thread #%1$d" ).build() );
+ workerEventLoopGroup = PipelineUtils.newEventLoopGroup( 0, new ThreadFactoryBuilder().setNameFormat( "Netty Worker IO Thread #%1$d" ).build() );
File moduleDirectory = new File( "modules" );
moduleManager.load( this, moduleDirectory );
@@ -333,7 +334,7 @@ public class BungeeCord extends ProxyServer
.option( ChannelOption.SO_REUSEADDR, true ) // TODO: Move this elsewhere!
.childAttr( PipelineUtils.LISTENER, info )
.childHandler( PipelineUtils.SERVER_CHILD )
- .group( eventLoops )
+ .group( bossEventLoopGroup, workerEventLoopGroup )
.localAddress( info.getSocketAddress() )
.bind().addListener( listener );
@@ -356,7 +357,7 @@ public class BungeeCord extends ProxyServer
}
}
};
- new RemoteQuery( this, info ).start( PipelineUtils.getDatagramChannel(), new InetSocketAddress( info.getHost().getAddress(), info.getQueryPort() ), eventLoops, bindListener );
+ new RemoteQuery( this, info ).start( PipelineUtils.getDatagramChannel(), new InetSocketAddress( info.getHost().getAddress(), info.getQueryPort() ), workerEventLoopGroup, bindListener );
}
}
}
@@ -451,12 +452,14 @@ public class BungeeCord extends ProxyServer
}
getLogger().info( "Closing IO threads" );
- eventLoops.shutdownGracefully();
- try
- {
- eventLoops.awaitTermination( Long.MAX_VALUE, TimeUnit.NANOSECONDS );
- } catch ( InterruptedException ex )
- {
+ bossEventLoopGroup.shutdownGracefully();
+ workerEventLoopGroup.shutdownGracefully();
+ while (true) {
+ try {
+ bossEventLoopGroup.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
+ workerEventLoopGroup.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
+ break;
+ } catch (InterruptedException ignored) {}
}
getLogger().info( "Thank you and goodbye" );
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java b/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java
index 9d581d9a..7b002089 100644
--- a/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java
@@ -184,7 +184,7 @@ public class BungeeServerInfo implements ServerInfo
};
new Bootstrap()
.channel( PipelineUtils.getChannel( socketAddress ) )
- .group( BungeeCord.getInstance().eventLoops )
+ .group( BungeeCord.getInstance().workerEventLoopGroup )
.handler( PipelineUtils.BASE )
.option( ChannelOption.CONNECT_TIMEOUT_MILLIS, BungeeCord.getInstance().getConfig().getRemotePingTimeout() )
.remoteAddress( socketAddress )
--
2.25.0