From 422095668e94cee289825ec9cfbf9cb05bc5008a Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Wed, 1 Mar 2017 14:50:20 +0100 Subject: [PATCH] stream: optimize session pruning --- src/stream-tcp-list.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/stream-tcp-list.c b/src/stream-tcp-list.c index 2546c5d3d2..a532c3cb10 100644 --- a/src/stream-tcp-list.c +++ b/src/stream-tcp-list.c @@ -744,16 +744,27 @@ void StreamTcpPruneSession(Flow *f, uint8_t flags) SCReturn; } + if (stream->flags & STREAMTCP_STREAM_FLAG_NOREASSEMBLY) { + return; + } + if (stream->flags & STREAMTCP_STREAM_FLAG_DEPTH_REACHED) { stream->flags |= STREAMTCP_STREAM_FLAG_NOREASSEMBLY; SCLogDebug("ssn %p: reassembly depth reached, " "STREAMTCP_STREAM_FLAG_NOREASSEMBLY set", ssn); + StreamTcpReturnStreamSegments(stream); + StreamingBufferClear(&stream->sb); + return; + } else if ((ssn->flags & STREAMTCP_FLAG_APP_LAYER_DISABLED) && (stream->flags & STREAMTCP_STREAM_FLAG_DISABLE_RAW)) { SCLogDebug("ssn %p: both app and raw are done, " "STREAMTCP_STREAM_FLAG_NOREASSEMBLY set", ssn); stream->flags |= STREAMTCP_STREAM_FLAG_NOREASSEMBLY; + StreamTcpReturnStreamSegments(stream); + StreamingBufferClear(&stream->sb); + return; } uint64_t left_edge = GetLeftEdge(ssn, stream);