diff options
author | Simon Rettberg | 2024-05-29 12:40:35 +0200 |
---|---|---|
committer | Simon Rettberg | 2024-05-29 12:40:35 +0200 |
commit | ab5ad2099860bd841003a973104dc819c74357e6 (patch) | |
tree | 8c7f8844e06deb61e4fcac1f3ba2618ca0d5e7f0 | |
parent | [*] Switch to new CascadedThreadPool (diff) | |
download | tutor-module-ab5ad2099860bd841003a973104dc819c74357e6.tar.gz tutor-module-ab5ad2099860bd841003a973104dc819c74357e6.tar.xz tutor-module-ab5ad2099860bd841003a973104dc819c74357e6.zip |
[server] CoW: Fix race condition generating invalid hashes
It's not too f'n bright to use a shared buffer in a multi-threaded
environment....
-rw-r--r-- | dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/cow/CowFinalizer.java | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/cow/CowFinalizer.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/cow/CowFinalizer.java index 9e4a7256..67f38634 100644 --- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/cow/CowFinalizer.java +++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/cow/CowFinalizer.java @@ -77,7 +77,6 @@ public class CowFinalizer { } private void calculateHashes() throws IOException { - byte[] buffer = new byte[FileChunk.CHUNK_SIZE]; HashChecker hc = IncomingTransferBase.getHashChecker(); if (hc == null) { LOGGER.info("No hash checker, skipping..."); @@ -96,7 +95,8 @@ public class CowFinalizer { } }; for (FileChunk chunk : chunks.getAll()) { - file.readFully(buffer, 0, chunk.range.getLength()); + byte[] buffer = new byte[chunk.range.getLength()]; + file.readFully(buffer); hc.queue(chunk, buffer, cb, HashChecker.BLOCKING | HashChecker.CALC_CRC32 | HashChecker.CALC_SHA1 | HashChecker.NO_SLOW_WARN); } |