diff options
| author | Stefan Boberg <[email protected]> | 2026-04-23 18:16:57 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2026-04-23 18:16:57 +0200 |
| commit | 0232b991cd7d8e3a2114ea30e4591dd3e7b65c36 (patch) | |
| tree | 94730e7594fd09ae1fa820391ce311f6daf13905 /src/zenserver/storage/cache/httpstructuredcache.cpp | |
| parent | Fix forward declaration order for s_GotSigWinch and SigWinchHandler (diff) | |
| parent | trace: declare Region event name fields as AnsiString (#1012) (diff) | |
| download | archived-zen-sb/zen-help.tar.xz archived-zen-sb/zen-help.zip | |
Merge branch 'main' into sb/zen-helpsb/zen-help
- Combine HelpCommand (this branch) with HistoryCommand (main) in zen CLI dispatcher
- Keep filter-aware TuiPickOne rewrite; adopt main's ASCII arrow glyphs in doc comment
Diffstat (limited to 'src/zenserver/storage/cache/httpstructuredcache.cpp')
| -rw-r--r-- | src/zenserver/storage/cache/httpstructuredcache.cpp | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/zenserver/storage/cache/httpstructuredcache.cpp b/src/zenserver/storage/cache/httpstructuredcache.cpp index 8ad48225b..4d3673e70 100644 --- a/src/zenserver/storage/cache/httpstructuredcache.cpp +++ b/src/zenserver/storage/cache/httpstructuredcache.cpp @@ -437,19 +437,22 @@ HttpStructuredCacheService::HandleRequest(HttpServerRequest& Request) std::string RecordPath = UrlDecode(Params.GetValue("path")); - uint32_t ThreadCount = GetHardwareConcurrency(); + const uint32_t HardwareConcurrency = GetHardwareConcurrency(); + const uint32_t MaxThreadCount = std::max<uint32_t>(HardwareConcurrency, 16u); + uint32_t ThreadCount = HardwareConcurrency; if (auto Param = Params.GetValue("thread_count"); Param.empty() == false) { if (auto Value = ParseInt<uint64_t>(Param)) { - ThreadCount = gsl::narrow<uint32_t>(Value.value()); + ThreadCount = gsl::narrow_cast<uint32_t>(std::min<uint64_t>(Value.value(), MaxThreadCount)); } } + ThreadCount = std::clamp<uint32_t>(ThreadCount, 1u, MaxThreadCount); ZEN_INFO("initiating cache RPC replay using {} threads, from '{}'", ThreadCount, RecordPath); std::unique_ptr<cache::IRpcRequestReplayer> Replayer(cache::MakeDiskRequestReplayer(RecordPath, false)); - ReplayRequestRecorder(RequestContext, *Replayer, ThreadCount < 1 ? 1 : ThreadCount); + ReplayRequestRecorder(RequestContext, *Replayer, ThreadCount); ZEN_INFO("cache RPC replay COMPLETED"); @@ -557,7 +560,7 @@ HttpStructuredCacheService::HandleCacheRequest(HttpServerRequest& Request) break; default: m_CacheStats.BadRequestCount++; - break; + return Request.WriteResponse(HttpResponseCode::MethodNotAllowed); } } @@ -707,7 +710,8 @@ HttpStructuredCacheService::HandleCacheNamespaceRequest(HttpServerRequest& Reque break; default: - break; + m_CacheStats.BadRequestCount++; + return Request.WriteResponse(HttpResponseCode::MethodNotAllowed); } } @@ -797,7 +801,8 @@ HttpStructuredCacheService::HandleCacheBucketRequest(HttpServerRequest& Request, break; default: - break; + m_CacheStats.BadRequestCount++; + return Request.WriteResponse(HttpResponseCode::MethodNotAllowed); } } @@ -816,7 +821,8 @@ HttpStructuredCacheService::HandleCacheRecordRequest(HttpServerRequest& Request, break; default: - break; + m_CacheStats.BadRequestCount++; + return Request.WriteResponse(HttpResponseCode::MethodNotAllowed); } } @@ -1216,8 +1222,6 @@ HttpStructuredCacheService::HandlePutCacheRecord(HttpServerRequest& Request, con } auto WriteFailureResponse = [&Request](const ZenCacheStore::PutResult& PutResult) { - ZEN_UNUSED(PutResult); - HttpResponseCode ResponseCode = HttpResponseCode::InternalServerError; switch (PutResult.Status) { @@ -1231,7 +1235,7 @@ HttpStructuredCacheService::HandlePutCacheRecord(HttpServerRequest& Request, con if (PutResult.Details) { - Request.WriteResponse(ResponseCode, PutResult.Details); + return Request.WriteResponse(ResponseCode, PutResult.Details); } return Request.WriteResponse(ResponseCode); }; @@ -1507,7 +1511,8 @@ HttpStructuredCacheService::HandleCacheChunkRequest(HttpServerRequest& Request, HandlePutCacheChunk(Request, Ref, PolicyFromUrl); break; default: - break; + m_CacheStats.BadRequestCount++; + return Request.WriteResponse(HttpResponseCode::MethodNotAllowed); } } |