diff options
author | Yurii Postolov <32772773+Ypostolov@users.noreply.github.com> | 2021-04-26 21:44:44 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-26 14:44:44 -0400 |
commit | b8bb4ae8947c74bde887b1148aa116ac19b8020b (patch) | |
tree | 7ba6d5fc704580a24bd1632831ef90852329d92a | |
parent | cd037d934d44c23e1d77b47b10e319b063f8150a (diff) | |
download | sdl_core-b8bb4ae8947c74bde887b1148aa116ac19b8020b.tar.gz |
fix crash in libusb callback handling (#2505)
* fix crash in libusb callback handling
* Answer review; removing redundant logger
* Respond review comment, fixed logger.
* Removed usb_connection.cc.orig
* Update src/components/transport_manager/src/usb/libusb/usb_connection.cc
Co-authored-by: Collin <iCollin@users.noreply.github.com>
* Update src/components/transport_manager/src/usb/libusb/usb_connection.cc
Co-authored-by: Collin <iCollin@users.noreply.github.com>
Co-authored-by: yurii <ypostolov>
Co-authored-by: Collin <iCollin@users.noreply.github.com>
-rw-r--r-- | src/components/transport_manager/src/usb/libusb/usb_connection.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/components/transport_manager/src/usb/libusb/usb_connection.cc b/src/components/transport_manager/src/usb/libusb/usb_connection.cc index 278a1b1f05..44e037e2b5 100644 --- a/src/components/transport_manager/src/usb/libusb/usb_connection.cc +++ b/src/components/transport_manager/src/usb/libusb/usb_connection.cc @@ -128,6 +128,13 @@ std::string hex_data(const unsigned char* const buffer, } void UsbConnection::OnInTransfer(libusb_transfer* transfer) { + SDL_LOG_AUTO_TRACE(); + if (transfer->status == LIBUSB_TRANSFER_CANCELLED) { + SDL_LOG_DEBUG("Free already canceled transfer."); + libusb_free_transfer(transfer); + return; + } + SDL_LOG_TRACE("enter with Libusb_transfer*: " << transfer); if (transfer->status == LIBUSB_TRANSFER_COMPLETED) { SDL_LOG_DEBUG("USB incoming transfer, size:" @@ -200,6 +207,13 @@ TransportAdapter::Error UsbConnection::PostOutTransfer() { } void UsbConnection::OnOutTransfer(libusb_transfer* transfer) { + SDL_LOG_AUTO_TRACE(); + if (transfer->status == LIBUSB_TRANSFER_CANCELLED) { + SDL_LOG_DEBUG("Free already canceled transfer."); + libusb_free_transfer(transfer); + return; + } + SDL_LOG_TRACE("enter with Libusb_transfer*: " << transfer); auto error_code = TransportAdapter::OK; { |