From cd97fa80f19b58234766963569c414601901f4af Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Sun, 14 May 2017 10:00:35 +0200 Subject: [PATCH] file: fix pruning for parallel files Allow pruning of random files, not just list head. --- src/util-file.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/util-file.c b/src/util-file.c index 6f9fdf0185..3998262db3 100644 --- a/src/util-file.c +++ b/src/util-file.c @@ -343,23 +343,26 @@ static int FilePruneFile(File *file) void FilePrune(FileContainer *ffc) { File *file = ffc->head; + File *prev = NULL; while (file) { if (FilePruneFile(file) == 0) { + prev = file; file = file->next; continue; } - BUG_ON(file != ffc->head); - SCLogDebug("removing file %p", file); File *file_next = file->next; + if (prev) + prev->next = file_next; /* update head and tail */ - ffc->head = file_next; + if (file == ffc->head) + ffc->head = file_next; if (file == ffc->tail) - ffc->tail = NULL; + ffc->tail = prev; FileFree(file); file = file_next;