diff options
author | Jason Macnak <natsu@google.com> | 2024-03-21 15:02:43 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-03-21 15:02:43 +0000 |
commit | 1ed9bf08399146945d12c75b0571f9168cca6085 (patch) | |
tree | f993610ae68d71da597b6c62a4dc6d010b2edb9b | |
parent | 7546235e6055fddb9cac780190071f515059849d (diff) | |
parent | 3dc9050f12b0ed4a450ffc7658b34009543ad451 (diff) | |
download | aemu-1ed9bf08399146945d12c75b0571f9168cca6085.tar.gz |
Merge "Avoid holding device lock while destroying specific context" into main
-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) { |