Merge changes I6c6bf61b,I3fb0b3a8 am: 3160a25010 am: 9d7880fe96

am: 14f749c2c4

Change-Id: I626e726e1672da9cc1077677b0178e70dda1e923
This commit is contained in:
Josh Gao 2017-06-06 02:57:02 +00:00 committed by android-build-merger
commit 2d30a74181
2 changed files with 12 additions and 5 deletions

View file

@ -74,13 +74,18 @@ class BlockingQueue {
template <typename Fn>
void PopAll(Fn fn) {
std::unique_lock<std::mutex> lock(mutex);
cv.wait(lock, [this]() { return !queue.empty(); });
std::vector<T> popped;
for (const T& t : queue) {
{
std::unique_lock<std::mutex> lock(mutex);
cv.wait(lock, [this]() { return !queue.empty(); });
popped = std::move(queue);
queue.clear();
}
for (const T& t : popped) {
fn(t);
}
queue.clear();
}
};

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);
}
}