Tweak bad packet warning some. Makes it a bit more log friendly.
This commit is contained in:
parent
8e64a82423
commit
3084368af3
1 changed files with 18 additions and 3 deletions
|
@ -11,8 +11,12 @@ import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraft.network.play.client.C17PacketCustomPayload;
|
import net.minecraft.network.play.client.C17PacketCustomPayload;
|
||||||
import net.minecraft.network.play.server.S3FPacketCustomPayload;
|
import net.minecraft.network.play.server.S3FPacketCustomPayload;
|
||||||
import org.apache.logging.log4j.Level;
|
import org.apache.logging.log4j.Level;
|
||||||
|
import org.apache.logging.log4j.core.helpers.Integers;
|
||||||
|
import com.google.common.collect.ConcurrentHashMultiset;
|
||||||
|
import com.google.common.collect.Multiset;
|
||||||
|
import com.google.common.collect.Multiset.Entry;
|
||||||
|
import com.google.common.collect.Multisets;
|
||||||
import cpw.mods.fml.common.FMLLog;
|
import cpw.mods.fml.common.FMLLog;
|
||||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
|
||||||
import cpw.mods.fml.common.network.FMLNetworkException;
|
import cpw.mods.fml.common.network.FMLNetworkException;
|
||||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||||
import cpw.mods.fml.common.network.handshake.NetworkDispatcher;
|
import cpw.mods.fml.common.network.handshake.NetworkDispatcher;
|
||||||
|
@ -24,7 +28,8 @@ public class FMLProxyPacket extends Packet {
|
||||||
private final ByteBuf payload;
|
private final ByteBuf payload;
|
||||||
private INetHandler netHandler;
|
private INetHandler netHandler;
|
||||||
private NetworkDispatcher dispatcher;
|
private NetworkDispatcher dispatcher;
|
||||||
|
private static Multiset<String> badPackets = ConcurrentHashMultiset.create();
|
||||||
|
private static int packetCountWarning = Integers.parseInt(System.getProperty("fml.badPacketCounter", "100"), 100);
|
||||||
private FMLProxyPacket(byte[] payload, String channel)
|
private FMLProxyPacket(byte[] payload, String channel)
|
||||||
{
|
{
|
||||||
this(Unpooled.wrappedBuffer(payload), channel);
|
this(Unpooled.wrappedBuffer(payload), channel);
|
||||||
|
@ -71,7 +76,17 @@ public class FMLProxyPacket extends Packet {
|
||||||
{
|
{
|
||||||
if (internalChannel.writeInbound(this))
|
if (internalChannel.writeInbound(this))
|
||||||
{
|
{
|
||||||
FMLLog.severe("Messages for channel %s for side %s were not processed by the embedded channel %s.\n They have been dropped.\n%s", this.channel, this.target, internalChannel.inboundMessages(), ByteBufUtils.getContentDump(this.payload));
|
badPackets.add(this.channel);
|
||||||
|
if (badPackets.size() % packetCountWarning == 0)
|
||||||
|
{
|
||||||
|
FMLLog.severe("Detected ongoing potential memory leak. %d packets have leaked. Top offenders", badPackets.size());
|
||||||
|
int i = 0;
|
||||||
|
for (Entry<String> s : Multisets.copyHighestCountFirst(badPackets).entrySet())
|
||||||
|
{
|
||||||
|
if (i++ > 10) break;
|
||||||
|
FMLLog.severe("\t %s : %d", s.getElement(), s.getCount());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
internalChannel.inboundMessages().clear();
|
internalChannel.inboundMessages().clear();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue