Skip to content

Commit

Permalink
fix(ArchiveStrategy): data race #4309
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-f committed Nov 28, 2023
1 parent 61dae36 commit f72a808
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions Foundation/include/Poco/ArchiveStrategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "Poco/File.h"
#include "Poco/DateTimeFormatter.h"
#include "Poco/NumberFormatter.h"
#include <atomic>


namespace Poco {
Expand All @@ -44,7 +45,7 @@ class Foundation_API ArchiveStrategy

virtual LogFile* open(LogFile* pFile) = 0;
/// Open a new log file and return it.

virtual LogFile* archive(LogFile* pFile) = 0;
/// Renames the given log file for archiving
/// and creates and returns a new log file.
Expand All @@ -61,8 +62,8 @@ class Foundation_API ArchiveStrategy
ArchiveStrategy(const ArchiveStrategy&);
ArchiveStrategy& operator = (const ArchiveStrategy&);

bool _compress;
ArchiveCompressor* _pCompressor;
std::atomic<bool> _compress;
std::atomic<ArchiveCompressor*> _pCompressor;
};


Expand Down
2 changes: 1 addition & 1 deletion Foundation/src/ArchiveStrategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void ArchiveStrategy::moveFile(const std::string& oldPath, const std::string& ne
{
f.renameTo(newPath);
if (!_pCompressor) _pCompressor = new ArchiveCompressor;
_pCompressor->compress(newPath);
_pCompressor.load()->compress(newPath);
}
}

Expand Down

0 comments on commit f72a808

Please sign in to comment.