mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 19:15:32 +01:00
835bc39b03
Updated Upstream (Bukkit/CraftBukkit/Spigot) Bukkit Changes: 2dcc44dc SPIGOT-4307: Fix hacky API for banners on shields e0fc6572 SPIGOT-4309: Add "forced" display of particles efeeab2f Add index to README.md for easier navigation f502bc6f Update to Minecraft 1.13.1 CraftBukkit Changes:d0bb0a1d
Fix some tests randomly failing997d378d
Fix client stall in specific teleportation scenariosb3dc2366
SPIGOT-4307: Fix hacky API for banners on shields2a271162
SPIGOT-4301: Fix more invalid enchants5d0d83bb
SPIGOT-4309: Add "forced" display of particlesa6772578
Add additional tests for CraftBlockDatace1af0c3
Update to Minecraft 1.13.1 Spigot Changes: 2440e189 Rebuild patches 4ecffced Update to Minecraft 1.13.1
79 lines
4.3 KiB
Diff
79 lines
4.3 KiB
Diff
From c0478436a87952e21925c9a7429ce1b242e7648a 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/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
index 66d7d76d41..5ffe4b374e 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
@@ -71,7 +71,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
|
private final MinecraftServer minecraftServer;
|
|
public EntityPlayer player;
|
|
private int e;
|
|
- private long f; private void setLastPing(long lastPing) { this.f = lastPing;}; private long getLastPing() { return this.f;}; // Paper - OBFHELPER
|
|
+ private long f = SystemUtils.b(); private void setLastPing(long lastPing) { this.f = lastPing;}; private long getLastPing() { return this.f;}; // Paper - OBFHELPER - set ping to delay initial
|
|
private boolean g; private void setPendingPing(boolean isPending) { this.g = isPending;}; private boolean isPendingPing() { return this.g;}; // Paper - OBFHELPER
|
|
private long h; private void setKeepAliveID(long keepAliveID) { this.h = keepAliveID;}; private long getKeepAliveID() {return this.h; }; // Paper - OBFHELPER
|
|
// CraftBukkit start - multithreaded fields
|
|
@@ -102,6 +102,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
|
private int E;
|
|
private int receivedMovePackets;
|
|
private int processedMovePackets;
|
|
+ private static final long KEEPALIVE_LIMIT = Long.getLong("paper.playerconnection.keepalive", 30) * 1000; // Paper - provide property to set keepalive limit
|
|
|
|
public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) {
|
|
this.minecraftServer = minecraftserver;
|
|
@@ -181,18 +182,26 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
|
}
|
|
|
|
this.minecraftServer.methodProfiler.a("keepAlive");
|
|
- long i = SystemUtils.b();
|
|
-
|
|
- if (i - this.f >= 25000L) { // CraftBukkit
|
|
- if (this.g) {
|
|
+ // 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 = SystemUtils.b();
|
|
+ long elapsedTime = currentTime - this.getLastPing();
|
|
+
|
|
+ if (this.isPendingPing()) {
|
|
+ if (!this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected
|
|
+ PlayerConnection.LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getName()); // more info
|
|
this.disconnect(new ChatMessage("disconnect.timeout", new Object[0]));
|
|
- } else {
|
|
- this.g = true;
|
|
- this.f = i;
|
|
- this.h = i;
|
|
- this.sendPacket(new PacketPlayOutKeepAlive(this.h));
|
|
+ }
|
|
+ } else {
|
|
+ if (elapsedTime >= 15000L) { // 15 seconds
|
|
+ this.setPendingPing(true);
|
|
+ this.setLastPing(currentTime);
|
|
+ this.setKeepAliveID(currentTime);
|
|
+ this.sendPacket(new PacketPlayOutKeepAlive(this.getKeepAliveID()));
|
|
+
|
|
}
|
|
}
|
|
+ // Paper end
|
|
|
|
this.minecraftServer.methodProfiler.e();
|
|
// CraftBukkit start
|
|
--
|
|
2.18.0
|
|
|