This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/master by this push:
     new 74f9a51  AVRO-2722 Move the 'random' variable to be local to the 
method where it is being used (#1365)
74f9a51 is described below

commit 74f9a51c354f986aae3efc8766d321a0939ec45f
Author: Martin Grigorov <[email protected]>
AuthorDate: Wed Jan 5 10:47:44 2022 +0200

    AVRO-2722 Move the 'random' variable to be local to the method where it is 
being used (#1365)
    
    This avoids thread-safety issues.
---
 lang/c++/impl/DataFile.cc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lang/c++/impl/DataFile.cc b/lang/c++/impl/DataFile.cc
index 18fb3f6..b0c5746 100644
--- a/lang/c++/impl/DataFile.cc
+++ b/lang/c++/impl/DataFile.cc
@@ -232,9 +232,8 @@ void DataFileWriterBase::flush() {
     sync();
 }
 
-boost::mt19937 random(static_cast<uint32_t>(time(nullptr)));
-
 DataFileSync DataFileWriterBase::makeSync() {
+    boost::mt19937 random(static_cast<uint32_t>(time(nullptr)));
     DataFileSync sync;
     std::generate(sync.begin(), sync.end(), random);
     return sync;

Reply via email to