| Index: device/usb/usb_device_handle_impl.cc
|
| diff --git a/device/usb/usb_device_handle_impl.cc b/device/usb/usb_device_handle_impl.cc
|
| index 716c6c196611213a625c5ce329cb0945e1c835a0..cf6ebfb13efd51c91b81f4ca69934e00a132a617 100644
|
| --- a/device/usb/usb_device_handle_impl.cc
|
| +++ b/device/usb/usb_device_handle_impl.cc
|
| @@ -782,8 +782,14 @@ UsbDeviceHandleImpl::UsbDeviceHandleImpl(
|
|
|
| UsbDeviceHandleImpl::~UsbDeviceHandleImpl() {
|
| // This class is RefCountedThreadSafe and so the destructor may be called on
|
| - // any thread.
|
| - libusb_close(handle_);
|
| + // any thread. libusb is not safe to reentrancy so be sure not to try to close
|
| + // the device from inside a transfer completion callback.
|
| + if (blocking_task_runner_->RunsTasksOnCurrentThread()) {
|
| + libusb_close(handle_);
|
| + } else {
|
| + blocking_task_runner_->PostTask(FROM_HERE,
|
| + base::Bind(&libusb_close, handle_));
|
| + }
|
| }
|
|
|
| void UsbDeviceHandleImpl::SetConfigurationOnBlockingThread(
|
|
|