mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-18 12:48:53 +01:00
da9d110d5b
This patch does not appear to be doing anything useful, and may hide errors. Currently, the save logic does not run through this path either so it did not do anything. Additionally, properly implement support for handling RegionFileSizeException in Moonrise.
68 lines
4.2 KiB
Diff
68 lines
4.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Shane Freeder <theboyetronic@gmail.com>
|
|
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 6fd8204a8d66d26c3011d197c004398d320dc469..b36528ad18c8603994c6a821b19b99581717b44c 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
|
@@ -75,7 +75,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;
|
|
@@ -83,6 +83,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;
|
|
@@ -239,18 +240,22 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
|
|
|
protected void keepConnectionAlive() {
|
|
Profiler.get().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
|
|
|
|
Profiler.get().pop();
|
|
}
|