aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0156-revert-serverside-behavior-of-keepalives.patch
diff options
context:
space:
mode:
authorRiley Park <[email protected]>2024-05-15 17:06:59 -0700
committerGitHub <[email protected]>2024-05-15 17:06:59 -0700
commitf17519338bc589c045e0b32bfc37e048b23544d5 (patch)
treee50182ec698b4a9de8f366f485ee089b1901bbd9 /patches/server/0156-revert-serverside-behavior-of-keepalives.patch
parent3fc93581bb876e8149b2ca423375a98f5ca12d27 (diff)
downloadPaper-f17519338bc589c045e0b32bfc37e048b23544d5.tar.gz
Paper-f17519338bc589c045e0b32bfc37e048b23544d5.zip
Expose server build information (#10729)
* Expose server build information * squash patches * final tweaks --------- Co-authored-by: Jake Potrebic <[email protected]> Co-authored-by: masmc05 <[email protected]>
Diffstat (limited to 'patches/server/0156-revert-serverside-behavior-of-keepalives.patch')
-rw-r--r--patches/server/0156-revert-serverside-behavior-of-keepalives.patch68
1 files changed, 68 insertions, 0 deletions
diff --git a/patches/server/0156-revert-serverside-behavior-of-keepalives.patch b/patches/server/0156-revert-serverside-behavior-of-keepalives.patch
new file mode 100644
index 0000000000..167f18e6c9
--- /dev/null
+++ b/patches/server/0156-revert-serverside-behavior-of-keepalives.patch
@@ -0,0 +1,68 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Shane Freeder <[email protected]>
+Date: Sun, 15 Oct 2017 00:29:07 +0100
+Subject: [PATCH] revert serverside behavior of keepalives
+
+This patch intends to bump up the time that a client has to reply to the
+server back to 30 seconds as per pre 1.12.2, which allowed clients
+more than enough time to reply potentially allowing them to be less
+tempermental due to lag spikes on the network thread, e.g. that caused
+by plugins that are interacting with netty.
+
+We also add a system property to allow people to tweak how long the server
+will wait for a reply. There is a compromise here between lower and higher
+values, lower values will mean that dead connections can be closed sooner,
+whereas higher values will make this less sensitive to issues such as spikes
+from networking or during connections flood of chunk packets on slower clients,
+ at the cost of dead connections being kept open for longer.
+
+diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
+index 8cc454ad3f6b865253bdd4902fbf19fc4a3e4a7f..a0dc17702fb6c8c96f262bc917624a46a40920fa 100644
+--- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
++++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
+@@ -68,7 +68,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
+ protected final MinecraftServer server;
+ public final Connection connection; // Paper
+ private final boolean transferred;
+- private long keepAliveTime;
++ private long keepAliveTime = Util.getMillis(); // Paper
+ private boolean keepAlivePending;
+ private long keepAliveChallenge;
+ private long closedListenerTime;
+@@ -76,6 +76,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
+ private int latency;
+ private volatile boolean suspendFlushingOnServerThread = false;
+ public final java.util.Map<java.util.UUID, net.kyori.adventure.resource.ResourcePackCallback> packCallbacks = new java.util.concurrent.ConcurrentHashMap<>(); // Paper - adventure resource pack callbacks
++ private static final long KEEPALIVE_LIMIT = Long.getLong("paper.playerconnection.keepalive", 30) * 1000; // Paper - provide property to set keepalive limit
+
+ public ServerCommonPacketListenerImpl(MinecraftServer minecraftserver, Connection networkmanager, CommonListenerCookie commonlistenercookie, ServerPlayer player) { // CraftBukkit
+ this.server = minecraftserver;
+@@ -226,18 +227,22 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
+
+ protected void keepConnectionAlive() {
+ this.server.getProfiler().push("keepAlive");
+- long i = Util.getMillis();
++ // Paper start - give clients a longer time to respond to pings as per pre 1.12.2 timings
++ // This should effectively place the keepalive handling back to "as it was" before 1.12.2
++ long currentTime = Util.getMillis();
++ long elapsedTime = currentTime - this.keepAliveTime;
+
+- if (!this.isSingleplayerOwner() && i - this.keepAliveTime >= 25000L) { // CraftBukkit
+- if (this.keepAlivePending) {
++ if (!this.isSingleplayerOwner() && elapsedTime >= 15000L) { // Paper - use vanilla's 15000L between keep alive packets
++ if (this.keepAlivePending && !this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // Paper - check keepalive limit, don't fire if already disconnected
+ this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE);
+- } else if (this.checkIfClosed(i)) {
++ } else if (this.checkIfClosed(currentTime)) { // Paper
+ this.keepAlivePending = true;
+- this.keepAliveTime = i;
+- this.keepAliveChallenge = i;
++ this.keepAliveTime = currentTime;
++ this.keepAliveChallenge = currentTime;
+ this.send(new ClientboundKeepAlivePacket(this.keepAliveChallenge));
+ }
+ }
++ // Paper end - give clients a longer time to respond to pings as per pre 1.12.2 timings
+
+ this.server.getProfiler().pop();
+ }