#2420: Cap forge packet queue size

This commit is contained in:
md_5 2018-05-12 21:14:44 +10:00
parent e93323ddbc
commit 88bacf12a3

View File

@ -1,5 +1,6 @@
package net.md_5.bungee.forge; package net.md_5.bungee.forge;
import com.google.common.base.Preconditions;
import java.util.ArrayDeque; import java.util.ArrayDeque;
import java.util.Map; import java.util.Map;
import lombok.AccessLevel; import lombok.AccessLevel;
@ -58,6 +59,7 @@ public class ForgeClientHandler
message.setAllowExtendedPacket( true ); // FML allows extended packets so this must be enabled message.setAllowExtendedPacket( true ); // FML allows extended packets so this must be enabled
ForgeClientHandshakeState prevState = state; ForgeClientHandshakeState prevState = state;
Preconditions.checkState( packetQueue.size() < 128, "Forge packet queue too big!" );
packetQueue.add( message ); packetQueue.add( message );
state = state.send( message, con ); state = state.send( message, con );
if ( state != prevState ) // state finished, send packets if ( state != prevState ) // state finished, send packets