mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 11:06:29 +01:00
5c7081fecc
* Updated Upstream (Bukkit/CraftBukkit) 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 Bukkit Changes: 45690fe9 SPIGOT-5047: Correct slot types for 1.14 inventories CraftBukkit Changes:4090d01f
SPIGOT-5047: Correct slot types for 1.14 inventoriese8c08362
SPIGOT-5046: World#getLoadedChunks returning inaccessible cached chunks.d445af3b
SPIGOT-5067: Add item meta for 1.14 spawn eggs * Bring Chunk load checks in-line with spigot As of the last upstream merge spigot now checks ticket level status when returning loaded chunks for a world from api. Now our checks will respect that decision. * Fix spawn ticket levels Vanilla would keep the inner chunks of spawn available for ticking, however my changes made all chunks non-ticking. Resolve by changing ticket levels for spawn chunks inside the border to respect this behavior. * Make World#getChunkIfLoadedImmediately return only entity ticking chunks Mojang appears to be using chunks with level > 33 (non-ticking chunks) as cached chunks and not actually loaded chunks. * Bring all loaded checks in line with spigot Loaded chunks must be at least border chunks, or level <= 33
79 lines
4.4 KiB
Diff
79 lines
4.4 KiB
Diff
From e40d8b0493dbaac80cddf8a09ed5c731c2581c39 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 a7275e7ef8..22dca3fe68 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
@@ -70,7 +70,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
|
private final MinecraftServer minecraftServer;
|
|
public EntityPlayer player;
|
|
private int e;
|
|
- private long lastKeepAlive; private void setLastPing(long lastPing) { this.lastKeepAlive = lastPing;}; private long getLastPing() { return this.lastKeepAlive;}; // Paper - OBFHELPER
|
|
+ private long lastKeepAlive = SystemUtils.getMonotonicMillis(); private void setLastPing(long lastPing) { this.lastKeepAlive = lastPing;}; private long getLastPing() { return this.lastKeepAlive;}; // Paper - OBFHELPER
|
|
private boolean awaitingKeepAlive; private void setPendingPing(boolean isPending) { this.awaitingKeepAlive = isPending;}; private boolean isPendingPing() { return this.awaitingKeepAlive;}; // 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
|
|
@@ -101,6 +101,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
|
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;
|
|
@@ -179,18 +180,26 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
|
}
|
|
|
|
this.minecraftServer.getMethodProfiler().enter("keepAlive");
|
|
- long i = SystemUtils.getMonotonicMillis();
|
|
-
|
|
- if (i - this.lastKeepAlive >= 25000L) { // CraftBukkit
|
|
- if (this.awaitingKeepAlive) {
|
|
+ // 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.getMonotonicMillis();
|
|
+ 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.awaitingKeepAlive = true;
|
|
- this.lastKeepAlive = 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.getMethodProfiler().exit();
|
|
// CraftBukkit start
|
|
--
|
|
2.21.0
|
|
|