adb: improve race between device_connected and device_disconnected.
If a device is unplugged while it's being processed, we can be inside
register_usb_transport still when we call unregister_usb_transport,
leading to bad things happening. Move the call of
register_usb_transport into the scope guarded by usb_handles_mutex.
Bug: http://b/62200735
Test: manual
Merged-In: I2517dcb9d30d9a08cebbb5f715ae3fd30c510109
Change-Id: I2517dcb9d30d9a08cebbb5f715ae3fd30c510109
(cherry picked from commit 7dd382ded9
)
This commit is contained in:
parent
435baf5d00
commit
f74dd42e4e
|
@ -377,9 +377,10 @@ static void process_device(libusb_device* device) {
|
|||
{
|
||||
std::unique_lock<std::mutex> lock(usb_handles_mutex);
|
||||
usb_handles[device_address] = std::move(result);
|
||||
}
|
||||
|
||||
register_usb_transport(usb_handle_raw, device_serial.c_str(), device_address.c_str(), writable);
|
||||
register_usb_transport(usb_handle_raw, device_serial.c_str(), device_address.c_str(),
|
||||
writable);
|
||||
}
|
||||
LOG(INFO) << "registered new usb device '" << device_serial << "'";
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue