From d3ff6f8e3398aa900350248437bebf9712b8fde6 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Wed, 4 Aug 2021 23:37:27 -0400 Subject: [PATCH] Make sure to issue a backpressure-solving flush on a future iteration of the event loop Thanks to @Spottedleaf for finding this issue. --- .../proxy/connection/client/ClientPlaySessionHandler.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java index 364ac5056..7042cb109 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java @@ -335,8 +335,11 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler { boolean writable = player.getConnection().getChannel().isWritable(); if (!writable) { - // We might have packets queued from the server, so flush them now to free up memory. - player.getConnection().flush(); + // We might have packets queued from the server, so flush them now to free up memory. Make + // sure to do it on a future invocation of the event loop, otherwise while the issue will + // fix itself, we'll still disable auto-reading and instead of backpressure resolution, we + // get client timeouts. + player.getConnection().eventLoop().execute(() -> player.getConnection().flush()); } VelocityServerConnection serverConn = player.getConnectedServer();