Commit ca4801fe authored by Stanislav Bohm's avatar Stanislav Bohm

FIX: Removed race condition in RawData

parent c6178620
......@@ -51,6 +51,7 @@ size_t RawData::get_size() const {
const char *RawData::get_raw_data() const
{
std::lock_guard<std::mutex> lock(mutex);
if (data == nullptr) {
open();
}
......
......@@ -4,6 +4,8 @@
#include "../data.h"
#include "../unpacking.h"
#include <mutex>
namespace loom {
class RawData : public Data {
......@@ -36,6 +38,7 @@ protected:
void map(int fd, bool write) const;
mutable char *data;
mutable std::mutex mutex;
size_t size;
std::string filename;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment