adb: libusb: don't try to delete a usb_handle twice.

Previously, we would attempt to delete a usb_handle in both
device_disconnected and usb_close. If the one in device_disconnected
happened to happen first, usb_close would abort when it failed to find
the handle it was supposed to own.

Bug: http://b/62020217
Test: unplugging device on darwin
Change-Id: I6c6bf61bf89a4d9a23458c00b457080d3d6cc744
This commit is contained in:
Josh Gao 2017-06-05 15:08:13 -07:00
parent 664a618c06
commit 60b8c26520
1 changed files with 3 additions and 1 deletions

View File

@ -422,8 +422,10 @@ static void device_disconnected(libusb_device* device) {
if (!it->second->device_handle) {
// If the handle is null, we were never able to open the device.
unregister_usb_transport(it->second.get());
usb_handles.erase(it);
} else {
// Closure of the transport will erase the usb_handle.
}
usb_handles.erase(it);
}
}