Set the destroyed flag at the correct time and fix a the httpupload example to release all resources

This commit is contained in:
Norman Maurer 2013-07-11 13:48:37 +02:00
parent 10097bf881
commit e85ae721b2
2 changed files with 7 additions and 4 deletions

View File

@ -1204,9 +1204,9 @@ public class HttpPostRequestDecoder {
*/ */
public void destroy() { public void destroy() {
checkDestroyed(); checkDestroyed();
cleanFiles();
destroyed = true; destroyed = true;
cleanFiles();
if (undecodedChunk != null && undecodedChunk.refCnt() > 0) { if (undecodedChunk != null && undecodedChunk.refCnt() > 0) {
undecodedChunk.release(); undecodedChunk.release();
undecodedChunk = null; undecodedChunk = null;

View File

@ -216,8 +216,12 @@ public class HttpUploadServerHandler extends SimpleChannelInboundHandler<HttpObj
while (decoder.hasNext()) { while (decoder.hasNext()) {
InterfaceHttpData data = decoder.next(); InterfaceHttpData data = decoder.next();
if (data != null) { if (data != null) {
// new value try {
writeHttpData(data); // new value
writeHttpData(data);
} finally {
data.release();
}
} }
} }
} catch (EndOfDataDecoderException e1) { } catch (EndOfDataDecoderException e1) {
@ -275,7 +279,6 @@ public class HttpUploadServerHandler extends SimpleChannelInboundHandler<HttpObj
} }
} }
} }
//BufUtil.release(data);
} }
private void writeResponse(Channel channel) { private void writeResponse(Channel channel) {