From 12828623d82ca36bcf75642196cd4c3ff75d14b6 Mon Sep 17 00:00:00 2001 From: wxx Date: Thu, 4 Sep 2025 20:27:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=87=8D=E8=AF=95=E9=99=90?= =?UTF-8?q?=E5=88=B6=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wxx Change-Id: I6541fd87f85b0bfab8741a6ff1d2a5fded4671dc --- .../photo_processor/deferred_photo_result.h | 9 ++++++++- .../photo_processor/deferred_photo_result.cpp | 16 +++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/services/deferred_processing_service/include/schedule/photo_processor/deferred_photo_result.h b/services/deferred_processing_service/include/schedule/photo_processor/deferred_photo_result.h index b2670d9c5..3d0316c39 100644 --- a/services/deferred_processing_service/include/schedule/photo_processor/deferred_photo_result.h +++ b/services/deferred_processing_service/include/schedule/photo_processor/deferred_photo_result.h @@ -47,13 +47,18 @@ public: bool IsFatalError(DpsError error) const; bool IsNeedReset(); void OnSuccess(const std::string& imageId); - ErrorType OnError(const std::string& imageId, DpsError error, bool isHighJob); + ErrorType OnError(const std::string& imageId, DpsError& error, bool isHighJob); inline void ResetTimeoutCount() { processTimeoutCount_.store(DEFAULT_COUNT); } + inline void ResetCrashCount(const std::string& imageId) + { + imageId2CrashCount_.erase(imageId); + } + protected: DeferredPhotoResult(); @@ -62,11 +67,13 @@ private: void RecordResult(const std::string& imageId, const std::shared_ptr& result); void DeRecordResult(const std::string& imageId); std::shared_ptr GetCacheResult(const std::string& imageId); + void CheckCrashCount(const std::string& imageId, DpsError& error); std::atomic_int32_t processTimeoutCount_ {DEFAULT_COUNT}; std::set fatalStatusCodes_ {}; std::set highImages_ {}; std::unordered_map> cacheMap_ {}; + std::unordered_map imageId2CrashCount_ {}; }; } // namespace DeferredProcessing } // namespace CameraStandard diff --git a/services/deferred_processing_service/src/schedule/photo_processor/deferred_photo_result.cpp b/services/deferred_processing_service/src/schedule/photo_processor/deferred_photo_result.cpp index 2f8fbfc6d..140e3c5f8 100644 --- a/services/deferred_processing_service/src/schedule/photo_processor/deferred_photo_result.cpp +++ b/services/deferred_processing_service/src/schedule/photo_processor/deferred_photo_result.cpp @@ -23,6 +23,7 @@ namespace CameraStandard { namespace DeferredProcessing { namespace { constexpr int32_t DEFAULT_TIMEOUT_COUNT = 3; + constexpr uint32_t MAX_CONSECUTIVE_CRASH_COUNT = 3; } DeferredPhotoResult::DeferredPhotoResult() { @@ -33,6 +34,7 @@ DeferredPhotoResult::~DeferredPhotoResult() { DP_INFO_LOG("entered."); fatalStatusCodes_.clear(); + imageId2CrashCount_.clear(); } int32_t DeferredPhotoResult::Initialize() @@ -62,10 +64,11 @@ void DeferredPhotoResult::OnSuccess(const std::string& imageId) ResetTimeoutCount(); } -ErrorType DeferredPhotoResult::OnError(const std::string& imageId, DpsError error, bool isHighJob) +ErrorType DeferredPhotoResult::OnError(const std::string& imageId, DpsError& error, bool isHighJob) { DP_INFO_LOG("entered imageId: %{public}s, error: %{public}d, isHighJob: %{public}d", imageId.c_str(), error, isHighJob); + DP_CHECK_EXECUTE(error == DpsError::DPS_ERROR_SESSION_NOT_READY_TEMPORARILY, CheckCrashCount(imageId, error)); DP_CHECK_EXECUTE(error != DpsError::DPS_ERROR_IMAGE_PROC_TIMEOUT, ResetTimeoutCount()); DP_CHECK_RETURN_RET(IsFatalError(error), ErrorType::FATAL_NOTIFY); @@ -100,6 +103,17 @@ std::shared_ptr DeferredPhotoResult::GetCacheResult(const std::string return nullptr; } +void DeferredPhotoResult::CheckCrashCount(const std::string& imageId, DpsError& error) +{ + auto image = imageId2CrashCount_.find(imageId); + if (image == imageId2CrashCount_.end()) { + imageId2CrashCount_.emplace(imageId, 1); + return; + } + image->second += 1; + DP_CHECK_EXECUTE(image->second >= MAX_CONSECUTIVE_CRASH_COUNT, error = DPS_ERROR_IMAGE_PROC_FAILED); +} + bool DeferredPhotoResult::IsFatalError(DpsError error) const { return fatalStatusCodes_.count(error) != 0; -- Gitee