]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #962 in SNORT/snort3 from file_exit to master
authorTom Peters (thopeter) <thopeter@cisco.com>
Thu, 20 Jul 2017 14:24:35 +0000 (10:24 -0400)
committerTom Peters (thopeter) <thopeter@cisco.com>
Thu, 20 Jul 2017 14:24:35 +0000 (10:24 -0400)
Squashed commit of the following:

commit e98b26a5bff62e131c9a9552d70b14416006f0f5
Author: Tom Peters <thopeter@cisco.com>
Date:   Tue Jul 18 16:26:48 2017 -0400

    two fixes to file capture exit

src/file_api/file_capture.cc

index ec70481737aed927a5224797e064155795620efe..b6463a6ad835b72f1b29defb57a1eafaf69d46ce 100644 (file)
@@ -65,7 +65,10 @@ void FileCapture::writer_thread()
         std::unique_lock<std::mutex> lk(capture_mutex);
         capture_cv.wait(lk, [] { return !running or files_waiting.size(); });
 
-        if (!running)
+        // When !running we write out any remaining files before exiting.
+        // FIXIT-L should take dirty_pig into account. But this thread does not have convenient
+        // access to snort_conf.
+        if (!files_waiting.size())
             break;
 
         FileCapture* file = files_waiting.front();
@@ -136,7 +139,10 @@ void FileCapture::init(int64_t memcap, int64_t block_size)
  */
 void FileCapture::exit()
 {
-    running = false;
+    {
+        std::lock_guard<std::mutex> lk(capture_mutex);
+        running = false;
+    }
     capture_cv.notify_one();
 
     if (file_storer)