From: Victor Julien Date: Wed, 1 Mar 2017 13:50:20 +0000 (+0100) Subject: stream: optimize session pruning X-Git-Tag: suricata-4.0.0-beta1~151 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=422095668e94cee289825ec9cfbf9cb05bc5008a;p=thirdparty%2Fsuricata.git stream: optimize session pruning --- 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);