diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-06-10 10:55:06 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-06-10 10:55:06 +1200 |
commit | 1dc1e06cfd4b7b23775984a254723b2d06b4f1dd (patch) | |
tree | 6dd89b120a7400ff3f08b2cb213cadc27112d0e7 /src/org/traccar/protocol/EgtsProtocolDecoder.java | |
parent | 58a222ba3d546dc2366586f2c904e70680a394bd (diff) | |
download | trackermap-server-1dc1e06cfd4b7b23775984a254723b2d06b4f1dd.tar.gz trackermap-server-1dc1e06cfd4b7b23775984a254723b2d06b4f1dd.tar.bz2 trackermap-server-1dc1e06cfd4b7b23775984a254723b2d06b4f1dd.zip |
Handle buffers reference count
Diffstat (limited to 'src/org/traccar/protocol/EgtsProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/EgtsProtocolDecoder.java | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/org/traccar/protocol/EgtsProtocolDecoder.java b/src/org/traccar/protocol/EgtsProtocolDecoder.java index 5b1b49370..45e191d1e 100644 --- a/src/org/traccar/protocol/EgtsProtocolDecoder.java +++ b/src/org/traccar/protocol/EgtsProtocolDecoder.java @@ -75,12 +75,13 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder { Channel channel, int packetType, int index, int serviceType, int type, ByteBuf content) { if (channel != null) { - ByteBuf data = Unpooled.buffer(); // TODO ref count + ByteBuf data = Unpooled.buffer(); data.writeByte(type); data.writeShortLE(content.readableBytes()); data.writeBytes(content); + content.release(); - ByteBuf record = Unpooled.buffer(); // TODO ref count + ByteBuf record = Unpooled.buffer(); if (packetType == PT_RESPONSE) { record.writeShortLE(index); record.writeByte(0); // success @@ -91,6 +92,7 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder { record.writeByte(serviceType); record.writeByte(serviceType); record.writeBytes(data); + data.release(); int recordChecksum = Checksum.crc16(Checksum.CRC16_CCITT_FALSE, record.nioBuffer()); ByteBuf response = Unpooled.buffer(); @@ -104,6 +106,7 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder { response.writeByte(packetType); response.writeByte(Checksum.crc8(Checksum.CRC8_EGTS, response.nioBuffer())); response.writeBytes(record); + record.release(); response.writeShortLE(recordChecksum); channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress())); @@ -150,7 +153,7 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(deviceSession.getDeviceId()); } - ByteBuf response = Unpooled.buffer(); // TODO ref count + ByteBuf response = Unpooled.buffer(); response.writeShortLE(recordIndex); response.writeByte(0); // success sendResponse(channel, PT_RESPONSE, index, serviceType, MSG_RECORD_RESPONSE, response); @@ -189,7 +192,7 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder { channel, remoteAddress, buf.readSlice(15).toString(StandardCharsets.US_ASCII).trim()); } - response = Unpooled.buffer(); // TODO ref count + response = Unpooled.buffer(); response.writeByte(0); // success sendResponse(channel, PT_APPDATA, 0, serviceType, MSG_RESULT_CODE, response); |