]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #2272 in SNORT/snort3 from ~MMATIRKO/snort3:reg_xtra_fix to master
authorMasud Hasan (mashasan) <mashasan@cisco.com>
Thu, 18 Jun 2020 18:51:45 +0000 (18:51 +0000)
committerMasud Hasan (mashasan) <mashasan@cisco.com>
Thu, 18 Jun 2020 18:51:45 +0000 (18:51 +0000)
Squashed commit of the following:

commit e914576493bee03e7170506519b0f8662f760b90
Author: Michael Matirko <mmatirko@cisco.com>
Date:   Wed Jun 17 12:02:31 2020 -0400

    stream: lock xtradata stream_impl to avoid data race on logging

src/stream/stream.cc

index f9e2284de6c4a6d6978ade8b5fc37224785f5365..06bace61095a91748067ed14bbc92ed037f38e5d 100644 (file)
@@ -24,6 +24,7 @@
 #include "stream.h"
 
 #include <cassert>
+#include <mutex>
 
 #include "detection/detection_engine.h"
 #include "flow/flow_control.h"
@@ -60,6 +61,7 @@ public:
 };
 
 static StreamImpl stream;
+static std::mutex stream_xtra_mutex;
 
 //-------------------------------------------------------------------------
 // session foo
@@ -542,6 +544,7 @@ uint32_t Stream::get_xtra_data_map(LogFunction*& f)
 
 void Stream::reg_xtra_data_log(LogExtraData f, void* config)
 {
+    const std::lock_guard<std::mutex> xtra_lock(stream_xtra_mutex);
     stream.extra_data_log = f;
     stream.extra_data_config = config;
 }