Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable explicit flushing by default #262

Merged
merged 1 commit into from
Nov 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
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
Subject: [PATCH] Allow Disabling Explicit Network Manager Flushing

This seems completely pointless, as packet dispatch uses .writeAndFlush.
This seems completely useless since sending packets 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.
The logic has been improved to do the
flushing in the netty event loop, so it doesn't flush on the main
thread.

Renable flushing by passing -Dpaper.explicit-flush=true
Disable flushing by passing -Dpaper.explicit-flush=false

diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
index fcf54e3a138f8408d7b85f087be03ca8cedb45f9..9ece4582635db8d9547302421b44f67e262fd0f7 100644
index fcf54e3a138f8408d7b85f087be03ca8cedb45f9..37f81913c8bfabb7337282f54f30d023f7584c43 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> {
Expand All @@ -28,7 +28,7 @@ index fcf54e3a138f8408d7b85f087be03ca8cedb45f9..9ece4582635db8d9547302421b44f67e
}

- 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
+ if (!enableExplicitFlush) this.channel.eventLoop().execute(() -> this.channel.flush()); // PandaSpigot - Allow Disabling Explicit Network Manager Flushing
}

public SocketAddress getSocketAddress() {