From f9155aa1218808f0b26816438e87c2f45b3a51cb Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Fri, 22 Nov 2019 15:33:27 +0100 Subject: [PATCH] files: simplify pruning logic Since ebcc4db84ac2c1957a6cc23b5154d7d6333f4cb8 the flow worker runs file pruning after parsing, detection and loging. This means we can simplify the pruning logic. If a file is in state >= CLOSED, we can prune it. Detection and outputs will have had a final chance to process it. Remove the calls to the pruning code from Rust. They are no longer needed. --- rust/src/filetracker.rs | 3 --- src/util-file.c | 5 +---- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/rust/src/filetracker.rs b/rust/src/filetracker.rs index 0dbfc90fd8..233eefbedf 100644 --- a/rust/src/filetracker.rs +++ b/rust/src/filetracker.rs @@ -110,7 +110,6 @@ impl FileTransferTracker { } self.file_open = false; self.tracked = 0; - files.files_prune(); } pub fn trunc (&mut self, files: &mut FileContainer, flags: u16) { @@ -120,7 +119,6 @@ impl FileTransferTracker { let myflags = flags | 1; // TODO util-file.c::FILE_TRUNCATED files.file_close(&self.track_id, myflags); SCLogDebug!("truncated file"); - files.files_prune(); self.file_is_truncated = true; } @@ -322,7 +320,6 @@ impl FileTransferTracker { consumed += data.len(); } } - files.files_prune(); consumed as u32 } diff --git a/src/util-file.c b/src/util-file.c index 88a086adce..0c1e228854 100644 --- a/src/util-file.c +++ b/src/util-file.c @@ -332,10 +332,7 @@ static int FilePruneFile(File *file) SCLogDebug("file->state %d. Is >= FILE_STATE_CLOSED: %s", file->state, (file->state >= FILE_STATE_CLOSED) ? "yes" : "no"); /* file is done when state is closed+, logging/storing is done (if any) */ - if (file->state >= FILE_STATE_CLOSED && - (!RunModeOutputFileEnabled() || (file->flags & FILE_LOGGED)) && - (!RunModeOutputFiledataEnabled() || (file->flags & (FILE_STORED|FILE_NOSTORE)))) - { + if (file->state >= FILE_STATE_CLOSED) { SCReturnInt(1); } else { SCReturnInt(0); -- 2.47.2