summaryrefslogtreecommitdiff
path: root/src/components/transport_manager/src/usb/libusb/usb_handler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/transport_manager/src/usb/libusb/usb_handler.cc')
-rw-r--r--src/components/transport_manager/src/usb/libusb/usb_handler.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/components/transport_manager/src/usb/libusb/usb_handler.cc b/src/components/transport_manager/src/usb/libusb/usb_handler.cc
index df3b7e128e..975f71e84c 100644
--- a/src/components/transport_manager/src/usb/libusb/usb_handler.cc
+++ b/src/components/transport_manager/src/usb/libusb/usb_handler.cc
@@ -90,20 +90,20 @@ UsbHandler::UsbHandler()
UsbHandler::~UsbHandler() {
shutdown_requested_ = true;
- if (libusb_context_ != 0) {
+ thread_->stop();
+ LOG4CXX_INFO(logger_, "UsbHandler thread finished");
+ if (libusb_context_ != 0) { // This wakes up libusb_handle_events()
libusb_hotplug_deregister_callback(libusb_context_,
arrived_callback_handle_);
libusb_hotplug_deregister_callback(libusb_context_, left_callback_handle_);
}
- thread_->stop();
- LOG4CXX_INFO(logger_, "UsbHandler thread finished");
+ thread_->join();
+ delete thread_->delegate();
+ threads::DeleteThread(thread_);
if (libusb_context_) {
libusb_exit(libusb_context_);
libusb_context_ = 0;
}
- thread_->join();
- delete thread_->delegate();
- threads::DeleteThread(thread_);
}
void UsbHandler::DeviceArrived(libusb_device* device_libusb) {