diff options
| author | Stefan Boberg <[email protected]> | 2021-05-27 18:49:20 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-05-27 18:49:20 +0200 |
| commit | 8697ef327dac7cc50f90b889a483fc4e9006149b (patch) | |
| tree | 217ce443e84064d579bd4b74b9198d7081703233 | |
| parent | Added locks to protect against races in parallel oplog updates (diff) | |
| download | zen-8697ef327dac7cc50f90b889a483fc4e9006149b.tar.xz zen-8697ef327dac7cc50f90b889a483fc4e9006149b.zip | |
Fixed logic to avoid a race condition which could cause a sharing violation when two threads try to write the same chunk
| -rw-r--r-- | zenstore/filecas.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/zenstore/filecas.cpp b/zenstore/filecas.cpp index 4f5cf370e..64fcb2ffe 100644 --- a/zenstore/filecas.cpp +++ b/zenstore/filecas.cpp @@ -242,6 +242,10 @@ FileCasStrategy::InsertChunk(const void* const ChunkData, const size_t ChunkSize ChunkRemain -= ByteCount; } + // We cannot rely on RAII to close the file handle since it would be closed + // *after* the lock is released due to the initialization order. + PayloadFile.Close(); + AtomicIncrement(m_Stats.PutCount); AtomicAdd(m_Stats.PutBytes, ChunkSize); |