diff options
author | Jason Macnak <natsu@google.com> | 2024-03-15 16:08:31 -0700 |
---|---|---|
committer | Jason Macnak <natsu@google.com> | 2024-03-15 16:08:31 -0700 |
commit | 3dc9050f12b0ed4a450ffc7658b34009543ad451 (patch) | |
tree | 8dc26aa11cfadf4a3b6601d7bedb6e1f66c07cb4 | |
parent | c63f29e5f3a86f07b8575c31b444dffa9bbfb50b (diff) | |
download | aemu-3dc9050f12b0ed4a450ffc7658b34009543ad451.tar.gz |
Avoid holding device lock while destroying specific context
Bug: b/329287602
Test: GfxstreamEnd2EndVkTest.MultiThreadedShutdown with 50000 iterations
Change-Id: I923ef0f99f12cd273278aadf7059541f7312eab7
-rw-r--r-- | host-common/address_space_device.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/host-common/address_space_device.cpp b/host-common/address_space_device.cpp index c7951be..73d7f63 100644 --- a/host-common/address_space_device.cpp +++ b/host-common/address_space_device.cpp @@ -69,8 +69,22 @@ public: void destroyHandle(uint32_t handle) { AS_DEVICE_DPRINT("erase handle: %u", handle); - AutoLock lock(mContextsLock); - mContexts.erase(handle); + + std::unique_ptr<AddressSpaceDeviceContext> context; + + { + AutoLock lock(mContextsLock); + + auto contextDescriptionIt = mContexts.find(handle); + if (contextDescriptionIt == mContexts.end()) return; + auto& contextDescription = contextDescriptionIt->second; + + context = std::move(contextDescription.device_context); + + mContexts.erase(contextDescriptionIt); + } + + // Destroy `context` without holding the lock. } void tellPingInfo(uint32_t handle, uint64_t gpa) { |