mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-30 01:50:50 +01:00
Merge branch 'fix/netty-illegalreferencecount' into 'dev'
Fixes issue #588, netty IllegalReferenceCount See merge request morningstar/Arcturus-Community!136
This commit is contained in:
commit
fe533a17c9
@ -89,7 +89,7 @@ public class GameClient {
|
||||
public void sendResponse(MessageComposer composer) {
|
||||
if (this.channel.isOpen()) {
|
||||
try {
|
||||
this.channel.write(composer.compose(), this.channel.voidPromise());
|
||||
this.channel.write(composer.compose().retain(), this.channel.voidPromise());
|
||||
this.channel.flush();
|
||||
} catch (Exception e) {
|
||||
Emulator.getLogging().logPacketError(e);
|
||||
@ -103,7 +103,7 @@ public class GameClient {
|
||||
return;
|
||||
}
|
||||
|
||||
this.channel.write(response, this.channel.voidPromise());
|
||||
this.channel.write(response.retain(), this.channel.voidPromise());
|
||||
this.channel.flush();
|
||||
}
|
||||
}
|
||||
@ -115,7 +115,7 @@ public class GameClient {
|
||||
return;
|
||||
}
|
||||
|
||||
this.channel.write(response);
|
||||
this.channel.write(response.retain());
|
||||
}
|
||||
|
||||
this.channel.flush();
|
||||
|
@ -4,11 +4,14 @@ import com.eu.habbo.Emulator;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufOutputStream;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.util.IllegalReferenceCountException;
|
||||
import io.netty.util.ReferenceCounted;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public class ServerMessage {
|
||||
public class ServerMessage implements ReferenceCounted {
|
||||
|
||||
private int header;
|
||||
private ByteBufOutputStream stream;
|
||||
private ByteBuf channelBuffer;
|
||||
@ -192,8 +195,42 @@ public class ServerMessage {
|
||||
return this.channelBuffer.copy();
|
||||
}
|
||||
|
||||
public void release() {
|
||||
this.channelBuffer.release();
|
||||
@Override
|
||||
public int refCnt() {
|
||||
return this.channelBuffer.refCnt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReferenceCounted retain() {
|
||||
this.channelBuffer.retain();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReferenceCounted retain(int i) {
|
||||
this.channelBuffer.retain(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReferenceCounted touch() {
|
||||
this.channelBuffer.touch();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReferenceCounted touch(Object o) {
|
||||
this.channelBuffer.touch(o);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean release() {
|
||||
return this.channelBuffer.release();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean release(int i) {
|
||||
return this.channelBuffer.release(i);
|
||||
}
|
||||
|
||||
}
|
@ -54,6 +54,8 @@ public class GameMessageHandler extends ChannelInboundHandlerAdapter {
|
||||
if (cause instanceof TooLongFrameException) {
|
||||
Emulator.getLogging().logErrorLine("Disconnecting client, reason: \"" + cause.getMessage() + "\".");
|
||||
} else {
|
||||
cause.printStackTrace();
|
||||
|
||||
Emulator.getLogging().logErrorLine("Disconnecting client, exception in GameMessageHander:");
|
||||
Emulator.getLogging().logErrorLine(cause.toString());
|
||||
|
||||
|
@ -14,7 +14,7 @@ public class GameServerMessageLogger extends MessageToMessageEncoder<ServerMessa
|
||||
protected void encode(ChannelHandlerContext ctx, ServerMessage message, List<Object> out) throws Exception {
|
||||
Emulator.getLogging().logPacketLine("[" + Logging.ANSI_PURPLE + "SERVER" + Logging.ANSI_RESET + "] => [" + message.getHeader() + "] -> " + message.getBodyString());
|
||||
|
||||
out.add(message);
|
||||
out.add(message.retain());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.eu.habbo.messages.ServerMessage;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
import io.netty.util.IllegalReferenceCountException;
|
||||
|
||||
public class ServerMessageEncoder extends MessageToByteEncoder<ServerMessage> {
|
||||
|
||||
@ -15,7 +16,6 @@ public class ServerMessageEncoder extends MessageToByteEncoder<ServerMessage> {
|
||||
out.writeBytes(buf);
|
||||
} finally {
|
||||
buf.release();
|
||||
message.release();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user