Limit size of Authenticator Cache Thread Pool (#8360)

This commit is contained in:
Peter Crawley 2022-09-17 22:58:51 +01:00 committed by GitHub
parent f5f84ff476
commit 05f6a5c005
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 33 additions and 43 deletions

View File

@ -5,29 +5,19 @@ Subject: [PATCH] Cache user authenticator threads
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index bcf189d0ae917b99fff62167740ddb0012082138..6e315a2e87bbc4b03e4e0f38ba0b0f6b592a433e 100644
index bcf189d0ae917b99fff62167740ddb0012082138..71581c619d369d443908ed475d9a4d2d6ef07e5c 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -118,6 +118,18 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
@@ -118,6 +118,8 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
}
+ // Paper start - Cache authenticator threads
+ private static final AtomicInteger threadId = new AtomicInteger(0);
+ private static final java.util.concurrent.ExecutorService authenticatorPool = java.util.concurrent.Executors.newCachedThreadPool(
+ r -> {
+ Thread ret = new Thread(r, "User Authenticator #" + threadId.incrementAndGet());
+ private static final java.util.concurrent.ExecutorService authenticatorPool = new java.util.concurrent.ThreadPoolExecutor(0, 16, 60L, java.util.concurrent.TimeUnit.SECONDS, new java.util.concurrent.SynchronousQueue<>(), new com.google.common.util.concurrent.ThreadFactoryBuilder().setNameFormat("User Authenticator #%d").setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER)).build()); // Paper - Cache authenticator threads
+
+ ret.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER));
+
+ return ret;
+ }
+ );
+ // Paper end
// Spigot start
public void initUUID()
{
@@ -242,8 +254,8 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
@@ -242,8 +244,8 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
this.connection.send(new ClientboundHelloPacket("", this.server.getKeyPair().getPublic().getEncoded(), this.nonce));
} else {
// Spigot start
@ -38,7 +28,7 @@ index bcf189d0ae917b99fff62167740ddb0012082138..6e315a2e87bbc4b03e4e0f38ba0b0f6b
@Override
public void run() {
try {
@@ -254,7 +266,8 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
@@ -254,7 +256,8 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
server.server.getLogger().log(java.util.logging.Level.WARNING, "Exception verifying " + ServerLoginPacketListenerImpl.this.gameProfile.getName(), ex);
}
}
@ -48,7 +38,7 @@ index bcf189d0ae917b99fff62167740ddb0012082138..6e315a2e87bbc4b03e4e0f38ba0b0f6b
// Spigot end
}
@@ -297,7 +310,8 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
@@ -297,7 +300,8 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
throw new IllegalStateException("Protocol error", cryptographyexception);
}
@ -58,7 +48,7 @@ index bcf189d0ae917b99fff62167740ddb0012082138..6e315a2e87bbc4b03e4e0f38ba0b0f6b
public void run() {
GameProfile gameprofile = ServerLoginPacketListenerImpl.this.gameProfile;
@@ -342,10 +356,8 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
@@ -342,10 +346,8 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
return ServerLoginPacketListenerImpl.this.server.getPreventProxyConnections() && socketaddress instanceof InetSocketAddress ? ((InetSocketAddress) socketaddress).getAddress() : null;
}

View File

@ -6,10 +6,10 @@ Subject: [PATCH] Allow specifying a custom "authentication servers down" kick
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index a00636626e2ef2975a3506fd6cfb7e4444d41e3f..552b7d612d0f833f3280a2a60839e2ef93b59271 100644
index 0b6cca9dae24aaa18e64c9238f7eb2042402db84..20b8c415834018ff7e6151b5345f91a0190d294c 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -344,7 +344,7 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
@@ -334,7 +334,7 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
ServerLoginPacketListenerImpl.this.gameProfile = gameprofile;
ServerLoginPacketListenerImpl.this.state = ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT;
} else {

View File

@ -6,10 +6,10 @@ Subject: [PATCH] Ability to change PlayerProfile in AsyncPreLoginEvent
This will allow you to change the players name or skin on login.
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index 158862d2ea50a34dea10e074f3776bc5ed5a327f..fa949d01da7b6c1a489d17955108f7082f959c66 100644
index 8245a9ce591f4613fc165e9c0d413b0bc7fa09fe..9246eb35d42bafcef32da8619e5b1ce5557a3aab 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -379,8 +379,16 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
@@ -369,8 +369,16 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
java.util.UUID uniqueId = ServerLoginPacketListenerImpl.this.gameProfile.getId();
final org.bukkit.craftbukkit.CraftServer server = ServerLoginPacketListenerImpl.this.server.server;

View File

@ -6,10 +6,10 @@ Subject: [PATCH] Player.setPlayerProfile API
This can be useful for changing name or skins after a player has logged in.
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index fa949d01da7b6c1a489d17955108f7082f959c66..c83395364edb4f2ba8515326b19c4f1a436a0502 100644
index 9246eb35d42bafcef32da8619e5b1ce5557a3aab..b72dc9c19f512c3f07390e440f2f0f0aab20d6c2 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -380,11 +380,11 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
@@ -370,11 +370,11 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
final org.bukkit.craftbukkit.CraftServer server = ServerLoginPacketListenerImpl.this.server.server;
// Paper start

View File

@ -81,7 +81,7 @@ index 3af9f2d86cf2a9566e22865689101245647d05a5..fe722106e20e199eb914a09f8dbc1409
this.server.getProfiler().push("keepAlive");
// Paper Start - give clients a longer time to respond to pings as per pre 1.12.2 timings
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index c83395364edb4f2ba8515326b19c4f1a436a0502..c99266d4782c5d58339e63f7564c28b4b5b7ac1d 100644
index b72dc9c19f512c3f07390e440f2f0f0aab20d6c2..0aa5dc11567cc388d2fcd843faf0aff792892966 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -90,7 +90,7 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
@ -93,7 +93,7 @@ index c83395364edb4f2ba8515326b19c4f1a436a0502..c99266d4782c5d58339e63f7564c28b4
if (entityplayer == null) {
this.state = ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT;
@@ -199,7 +199,7 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
@@ -189,7 +189,7 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
}
this.connection.send(new ClientboundGameProfilePacket(this.gameProfile));

View File

@ -58,10 +58,10 @@ index 3a4222f78a02e10ecccc03df3c580895fbb8059d..ff94b07246b5e17be53f4e7294557c67
this.running = false;
if (flag) {
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index c99266d4782c5d58339e63f7564c28b4b5b7ac1d..d477e9fbe6ffb600d08f8ba49741067d14348968 100644
index 0aa5dc11567cc388d2fcd843faf0aff792892966..5d661c5d9d2f8133445a603db91b729ca36bf44b 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -213,6 +213,11 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
@@ -203,6 +203,11 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
} catch (Exception exception) {
ServerLoginPacketListenerImpl.LOGGER.error("Couldn't place player in world", exception);
MutableComponent ichatmutablecomponent = Component.translatable("multiplayer.disconnect.invalid_player_data");

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Add raw address to AsyncPlayerPreLoginEvent
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index 2f0a70bc9cc8cda9e9beef00421078c036d6287c..f6efd220d7f78f3f763bf1983d20c636eb4923b6 100644
index 92781fc6d0ebce082cb43353b1dcaf0c70dc4cec..cb8b1375e1c26c8b7e53f18db8d526874089a0b2 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -381,12 +381,13 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
@@ -371,12 +371,13 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
public void fireEvents() throws Exception {
String playerName = ServerLoginPacketListenerImpl.this.gameProfile.getName();
java.net.InetAddress address = ((java.net.InetSocketAddress) ServerLoginPacketListenerImpl.this.connection.getRemoteAddress()).getAddress();

View File

@ -341,10 +341,10 @@ index b80aedd2002959b4026c27ce76b3ed17f0acfb5b..2985271132c9ae822dcb0d7a7e6f0c26
protected void initChannel(Channel channel) {
try {
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index f6efd220d7f78f3f763bf1983d20c636eb4923b6..77cb18da4f89bb89aea7d1ef5ebe3dd7acfe000d 100644
index cb8b1375e1c26c8b7e53f18db8d526874089a0b2..c8d34d4d9173d2c7c44cc922abe6b5f6c6bea879 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -315,12 +315,14 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
@@ -305,12 +305,14 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
}
SecretKey secretkey = packet.getSecretKey(privatekey);

View File

@ -49,10 +49,10 @@ index 2985271132c9ae822dcb0d7a7e6f0c268d1736cc..cfdbcd024de6ad0f9d4e83b2f912b36e
networkmanager.send(new ClientboundDisconnectPacket(ichatmutablecomponent), PacketSendListener.thenRun(() -> {
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index 77cb18da4f89bb89aea7d1ef5ebe3dd7acfe000d..acd581d14e0ef1fe5a6545ee67be00deff589879 100644
index c8d34d4d9173d2c7c44cc922abe6b5f6c6bea879..4ac2a2584fcfce36cbaeccae45ce082c1c37fa12 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -236,7 +236,10 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
@@ -226,7 +226,10 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
}
public String getUserName() {

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Validate usernames
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index acd581d14e0ef1fe5a6545ee67be00deff589879..553eb8e437b07376dbfc54b0018bcc3ff93e4461 100644
index 4ac2a2584fcfce36cbaeccae45ce082c1c37fa12..b62208300433bef59789243e484a34650a9edeab 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -66,6 +66,7 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
@ -16,7 +16,7 @@ index acd581d14e0ef1fe5a6545ee67be00deff589879..553eb8e437b07376dbfc54b0018bcc3f
public ServerLoginPacketListenerImpl(MinecraftServer server, Connection connection) {
this.state = ServerLoginPacketListenerImpl.State.HELLO;
@@ -255,10 +256,38 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
@@ -245,10 +246,38 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
}
}

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Added getHostname to AsyncPlayerPreLoginEvent
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index 553eb8e437b07376dbfc54b0018bcc3ff93e4461..51ff7ab5d8740e755cc893723f659c8481c1ec89 100644
index b62208300433bef59789243e484a34650a9edeab..7ce626369535219e1918a2e652a501e6835dce41 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -421,7 +421,7 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
@@ -411,7 +411,7 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
// Paper start
com.destroystokyo.paper.profile.PlayerProfile profile = com.destroystokyo.paper.profile.CraftPlayerProfile.asBukkitMirror(ServerLoginPacketListenerImpl.this.gameProfile);

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Remove invalid signature login stacktrace
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index 51ff7ab5d8740e755cc893723f659c8481c1ec89..2f0b2d0f3a3dc02076cee9ab5e6dd6ab931143e3 100644
index 7ce626369535219e1918a2e652a501e6835dce41..4c37a225aad960d50cec3f998bcc935b5c7dfe7a 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -177,7 +177,7 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
@@ -167,7 +167,7 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
profilepublickey = ServerLoginPacketListenerImpl.validatePublicKey(this.profilePublicKeyData, this.gameProfile.getId(), signaturevalidator, this.server.enforceSecureProfile());
} catch (ProfilePublicKey.ValidationException profilepublickey_b) {

View File

@ -94,7 +94,7 @@ index 0000000000000000000000000000000000000000..5de2dabbc076a9482b1d6c299f1cff74
+ }
+}
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index 2f0b2d0f3a3dc02076cee9ab5e6dd6ab931143e3..bf488013e45b9ab97568e587f4dad899498b2f73 100644
index 4c37a225aad960d50cec3f998bcc935b5c7dfe7a..94211a2927352ae468a19939958eb41c8a1d7429 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -67,6 +67,7 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
@ -105,7 +105,7 @@ index 2f0b2d0f3a3dc02076cee9ab5e6dd6ab931143e3..bf488013e45b9ab97568e587f4dad899
public ServerLoginPacketListenerImpl(MinecraftServer server, Connection connection) {
this.state = ServerLoginPacketListenerImpl.State.HELLO;
@@ -300,6 +301,16 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
@@ -290,6 +291,16 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
this.state = ServerLoginPacketListenerImpl.State.KEY;
this.connection.send(new ClientboundHelloPacket("", this.server.getKeyPair().getPublic().getEncoded(), this.nonce));
} else {
@ -122,7 +122,7 @@ index 2f0b2d0f3a3dc02076cee9ab5e6dd6ab931143e3..bf488013e45b9ab97568e587f4dad899
// Spigot start
// Paper start - Cache authenticator threads
authenticatorPool.execute(new Runnable() {
@@ -413,6 +424,12 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
@@ -403,6 +414,12 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
public class LoginHandler {
public void fireEvents() throws Exception {
@ -135,7 +135,7 @@ index 2f0b2d0f3a3dc02076cee9ab5e6dd6ab931143e3..bf488013e45b9ab97568e587f4dad899
String playerName = ServerLoginPacketListenerImpl.this.gameProfile.getName();
java.net.InetAddress address = ((java.net.InetSocketAddress) ServerLoginPacketListenerImpl.this.connection.getRemoteAddress()).getAddress();
java.net.InetAddress rawAddress = ((java.net.InetSocketAddress) connection.getRawAddress()).getAddress(); // Paper
@@ -461,6 +478,60 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
@@ -451,6 +468,60 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
// Spigot end
public void handleCustomQueryPacket(ServerboundCustomQueryPacket packet) {