diff --git a/src/gfxstream/guest/connection-manager/GfxStreamConnectionManager.cpp b/src/gfxstream/guest/connection-manager/GfxStreamConnectionManager.cpp index c341318db30..7b440ccf657 100644 --- a/src/gfxstream/guest/connection-manager/GfxStreamConnectionManager.cpp +++ b/src/gfxstream/guest/connection-manager/GfxStreamConnectionManager.cpp @@ -67,6 +67,21 @@ GfxStreamConnectionManager* GfxStreamConnectionManager::getThreadLocalInstance( return tls; } +void GfxStreamConnectionManager::resetThreadLocalInstance() { + if (unlikely(!gfxstream_connection_manager_tls_key_valid)) { + return; + } + + GfxStreamConnectionManager* tls = + (GfxStreamConnectionManager*)tss_get(gfxstream_connection_manager_tls_key); + if (unlikely(!tls)) { + return; + } + + delete tls; + tss_set(gfxstream_connection_manager_tls_key, nullptr); +} + GfxStreamConnectionManager::GfxStreamConnectionManager(GfxStreamTransportType type, VirtGpuCapset capset) : mTransportType(type), mCapset(capset) {} diff --git a/src/gfxstream/guest/connection-manager/GfxStreamConnectionManager.h b/src/gfxstream/guest/connection-manager/GfxStreamConnectionManager.h index 0ed114eaebe..ae82aacbe99 100644 --- a/src/gfxstream/guest/connection-manager/GfxStreamConnectionManager.h +++ b/src/gfxstream/guest/connection-manager/GfxStreamConnectionManager.h @@ -31,6 +31,7 @@ class GfxStreamConnectionManager { public: static GfxStreamConnectionManager* getThreadLocalInstance(GfxStreamTransportType type, VirtGpuCapset capset); + static void resetThreadLocalInstance(); GfxStreamConnectionManager(GfxStreamTransportType type, VirtGpuCapset capset); ~GfxStreamConnectionManager(); diff --git a/src/gfxstream/guest/vulkan/gfxstream_vk_device.cpp b/src/gfxstream/guest/vulkan/gfxstream_vk_device.cpp index 16b7a829b2d..95824d074c9 100644 --- a/src/gfxstream/guest/vulkan/gfxstream_vk_device.cpp +++ b/src/gfxstream/guest/vulkan/gfxstream_vk_device.cpp @@ -417,6 +417,7 @@ void gfxstream_vk_DestroyInstance(VkInstance _instance, const VkAllocationCallba // To make End2EndTests happy, since now the host connection is statically linked to // libvulkan_ranchu.so [separate HostConnections now]. #if defined(END2END_TESTS) + GfxStreamConnectionManager::resetThreadLocalInstance(); VirtGpuDevice::resetInstance(); gSeqno = 0; #endif