Paper/Spigot-Server-Patches/0197-Disable-Explicit-Netwo...

35 lines
1.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 11 Mar 2018 14:13:33 -0400
Subject: [PATCH] Disable Explicit Network Manager Flushing
This seems completely pointless, as packet dispatch uses .writeAndFlush.
Things seem to work fine without explicit flushing, but incase issues arise,
provide a System property to re-enable it using improved logic of doing the
flushing on the netty event loop, so it won't do the flush on the main thread.
Renable flushing by passing -Dpaper.explicit-flush=true
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
index aeee6bfbc1c0113beef35bf33e8c6928a1db2844..2fda6f6965916e99e603ff87af4226b5ab8417ee 100644
--- a/src/main/java/net/minecraft/server/NetworkManager.java
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
@@ -63,6 +63,7 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
// Paper start - NetworkClient implementation
public int protocolVersion;
public java.net.InetSocketAddress virtualHost;
+ private static boolean enableExplicitFlush = Boolean.getBoolean("paper.explicit-flush");
// Paper end
public NetworkManager(EnumProtocolDirection enumprotocoldirection) {
@@ -230,7 +231,7 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
}
if (this.channel != null) {
- this.channel.flush();
+ if (enableExplicitFlush) this.channel.eventLoop().execute(() -> this.channel.flush()); // Paper - we don't need to explicit flush here, but allow opt in incase issues are found to a better version
}
if (this.t++ % 20 == 0) {