diff --git a/device/plugins/native_daemon/include/stack_data_repeater.h b/device/plugins/native_daemon/include/stack_data_repeater.h index f24e6766f..ddb7c021a 100644 --- a/device/plugins/native_daemon/include/stack_data_repeater.h +++ b/device/plugins/native_daemon/include/stack_data_repeater.h @@ -69,6 +69,11 @@ public: std::shared_ptr GetRawStack(); void ReturnRawStack(std::shared_ptr rawStack); size_t Size(); + void ClearCache() + { + std::unique_lock lock(cacheMutex_); + rawDataCacheQueue_.clear(); + } private: std::mutex mutex_; diff --git a/device/plugins/native_daemon/src/hook_manager.cpp b/device/plugins/native_daemon/src/hook_manager.cpp index 8eca3d921..3b9749d47 100644 --- a/device/plugins/native_daemon/src/hook_manager.cpp +++ b/device/plugins/native_daemon/src/hook_manager.cpp @@ -536,6 +536,7 @@ void HookManager::ReadShareMemory(const std::shared_ptr& hookCtx reinterpret_cast(rawStack->data)); continue; } else if (rawStack->stackConext->type == END_MSG) { + hookCtx->FlushStackArray(); if (!hookCtx->stackData->PutRawStack(rawStack, hookCtx->isRecordAccurately)) { break; } @@ -569,6 +570,9 @@ bool HookManager::DestroyPluginSession(const std::vector& pluginIds) if (item->shareMemoryBlock != nullptr) { ShareMemoryAllocator::GetInstance().ReleaseMemoryBlockLocal(item->smbName); } + if (item->stackData != nullptr) { + item->stackData->ClearCache(); + } } if (fpHookData_) { fclose(fpHookData_); @@ -615,7 +619,6 @@ bool HookManager::StopPluginSession(const std::vector& pluginIds) } else { PROFILER_LOG_INFO(LOG_CORE, "StopPluginSession: pid(%d) is less or equal zero.", item->pid); } - item->FlushStackArray(); CHECK_TRUE(item->stackPreprocess != nullptr, false, "stop StackPreprocess FAIL"); item->stackPreprocess->StopTakeResults(); PROFILER_LOG_INFO(LOG_CORE, "StopTakeResults success"); diff --git a/device/plugins/native_daemon/src/stack_data_repeater.cpp b/device/plugins/native_daemon/src/stack_data_repeater.cpp index dd56d0d06..e0a861189 100644 --- a/device/plugins/native_daemon/src/stack_data_repeater.cpp +++ b/device/plugins/native_daemon/src/stack_data_repeater.cpp @@ -49,7 +49,6 @@ void StackDataRepeater::Close() { std::unique_lock lock(mutex_); rawDataQueue_.clear(); - rawDataCacheQueue_.clear(); closed_ = true; } PROFILER_LOG_INFO(LOG_CORE, "StackDataRepeater Close, reducedStackCount_ : %" PRIx64 " ", reducedStackCount_);