]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
file: fix pruning for parallel files
authorVictor Julien <victor@inliniac.net>
Sun, 14 May 2017 08:00:35 +0000 (10:00 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 15 May 2017 12:11:33 +0000 (14:11 +0200)
Allow pruning of random files, not just list head.

src/util-file.c

index 6f9fdf0185d9438b274981ea6febac225684f18d..3998262db35d0ac0407f80681860f0c542c7658b 100644 (file)
@@ -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;