forked from hpfxd/PandaSpigot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0014-Disable-Explicit-Network-Manager-Flushing.patch
34 lines (28 loc) · 1.76 KB
/
0014-Disable-Explicit-Network-Manager-Flushing.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <[email protected]>
Date: Fri, 29 Oct 2021 05:24:16 -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 ae7c6e289c8a6d9f8bdd4911e90e2ef9840069a2..d547fe7b3a1e2355043a82cec9d40b69b2e410b0 100644
--- a/src/main/java/net/minecraft/server/NetworkManager.java
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
@@ -74,6 +74,7 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet> {
private IChatBaseComponent n;
private boolean o;
private boolean p;
+ private static boolean enableExplicitFlush = Boolean.getBoolean("paper.explicit-flush"); // PandaSpigot - Disable explicit flushing
// PandaSpigot start - Optimize network
public boolean isPending = true;
public boolean queueImmunity = false;
@@ -406,7 +407,7 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet> {
((IUpdatePlayerListBox) this.m).c();
}
- this.channel.flush();
+ if (enableExplicitFlush) this.channel.eventLoop().execute(() -> this.channel.flush()); // PandaSpigot - we don't need to explicit flush here, but allow opt-in in case issues are found to a better version
}
public SocketAddress getSocketAddress() {