diff options
| author | Dan Engelbrecht <[email protected]> | 2024-08-06 14:54:33 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-08-06 14:54:33 +0200 |
| commit | 1eaacecbdc540280d4ebd347c9f4b155799e6f89 (patch) | |
| tree | 9ea10ecf4e6c5d8f83f1eb78ced37d2f3622d2d6 /src/zenserver/projectstore/remoteprojectstore.cpp | |
| parent | validate cbobject before iterating for attachments to avoid crash on malforme... (diff) | |
| download | zen-1eaacecbdc540280d4ebd347c9f4b155799e6f89.tar.xz zen-1eaacecbdc540280d4ebd347c9f4b155799e6f89.zip | |
stop exceptions from leaking on threaded work (#102)
* catch exceptions in threaded work
* don't abort all project file/chunk info fetch for single failure
Diffstat (limited to 'src/zenserver/projectstore/remoteprojectstore.cpp')
| -rw-r--r-- | src/zenserver/projectstore/remoteprojectstore.cpp | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/src/zenserver/projectstore/remoteprojectstore.cpp b/src/zenserver/projectstore/remoteprojectstore.cpp index de6753a6b..15d329442 100644 --- a/src/zenserver/projectstore/remoteprojectstore.cpp +++ b/src/zenserver/projectstore/remoteprojectstore.cpp @@ -237,22 +237,31 @@ CreateBlock(WorkerThreadPool& WorkerPool, { return; } - ZEN_ASSERT(!Chunks.empty()); - size_t ChunkCount = Chunks.size(); - Stopwatch Timer; - CompressedBuffer CompressedBlock = GenerateBlock(std::move(Chunks)); - IoHash BlockHash = CompressedBlock.DecodeRawHash(); - { - // We can share the lock as we are not resizing the vector and only touch BlockHash at our own index - RwLock::SharedLockScope __(SectionsLock); - Blocks[BlockIndex].BlockHash = BlockHash; - } - uint64_t BlockSize = CompressedBlock.GetCompressedSize(); - AsyncOnBlock(std::move(CompressedBlock), BlockHash); - ZEN_INFO("Generated block with {} attachments in {} ({})", - ChunkCount, - NiceTimeSpanMs(Timer.GetElapsedTimeMs()), - NiceBytes(BlockSize)); + size_t ChunkCount = Chunks.size(); + try + { + ZEN_ASSERT(ChunkCount > 0); + Stopwatch Timer; + CompressedBuffer CompressedBlock = GenerateBlock(std::move(Chunks)); + IoHash BlockHash = CompressedBlock.DecodeRawHash(); + { + // We can share the lock as we are not resizing the vector and only touch BlockHash at our own index + RwLock::SharedLockScope __(SectionsLock); + Blocks[BlockIndex].BlockHash = BlockHash; + } + uint64_t BlockSize = CompressedBlock.GetCompressedSize(); + AsyncOnBlock(std::move(CompressedBlock), BlockHash); + ZEN_INFO("Generated block with {} attachments in {} ({})", + ChunkCount, + NiceTimeSpanMs(Timer.GetElapsedTimeMs()), + NiceBytes(BlockSize)); + } + catch (const std::exception& Ex) + { + RemoteResult.SetError(gsl::narrow<int>(HttpResponseCode::InternalServerError), + fmt::format("Failed creating block {} with {} chunks", BlockIndex, ChunkCount), + Ex.what()); + } }); } |