Merge pull request #2112 from LeandroLP23/fix/agc-profile-output-shutdown

fix(agc): stop the profile output at shutdown only if it was created
This commit is contained in:
Dean 2026-10-09 23:46:21 +13:00 committed by GitHub
commit d70b899894
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 1 deletions

View File

@ -1,6 +1,7 @@
#pragma once
#include <array>
#include <atomic>
#include <condition_variable>
#include <cstdio>
#include <deque>
@ -135,14 +136,21 @@ private:
std::thread worker;
};
inline std::atomic<ProfileOutput*> createdProfileOutput{nullptr};
inline ProfileOutput& ProfileOutput_nid_no_patch() {
static ProfileOutput output([](std::string_view text) {
if (std::fwrite(text.data(), 1, text.size(), stderr) != text.size() || std::fflush(stderr) != 0)
throw std::runtime_error("profile output write failed");
});
createdProfileOutput.store(&output, std::memory_order_release);
return output;
}
inline void StopProfileOutput_nid_no_patch() {
if (auto* output = createdProfileOutput.load(std::memory_order_acquire)) output->Stop();
}
template<typename... TArgs>
void ProfilePrint_nid_no_patch(const char* format, TArgs... args) {
ProfileOutput_nid_no_patch().Print(format, args...);

View File

@ -45,7 +45,7 @@ void Driver::stop() {
device.Reset();
replacedDevices.clear();
Graphics::ShutdownGuestBufferWorkers();
ProfileOutput_nid_no_patch().Stop();
StopProfileOutput_nid_no_patch();
stopped = true;
}

View File

@ -48,6 +48,10 @@ if(BUILD_TESTING)
if(WIN32)
set_tests_properties(guest_video_out_wqhd_detection PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
add_test(NAME guest_video_out_wqhd_detection_no_vulkan COMMAND guest_video_out_wqhd_detection_tests)
set_tests_properties(guest_video_out_wqhd_detection_no_vulkan PROPERTIES TIMEOUT 20 SKIP_RETURN_CODE 77
ENVIRONMENT "VK_DRIVER_FILES=${CMAKE_CURRENT_BINARY_DIR}/missing_icd.json;VK_ICD_FILENAMES=${CMAKE_CURRENT_BINARY_DIR}/missing_icd.json"
ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
endif()