Skip to content

Commit acae9ec

Browse files
committed
whb04b: Comments / Cleanup
1 parent 8252750 commit acae9ec

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

  • src/hal/user_comps/xhc-whb04b-6

src/hal/user_comps/xhc-whb04b-6/usb.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,9 @@ void Usb::onUsbDataReceived(struct libusb_transfer* transfer)
444444
{
445445
assert(mHal.isInitialized());
446446

447+
//DO NOT call close from here, it is a callback from libusb
448+
//and will deadlock!!
449+
447450
int expectedPackageSize = static_cast<int>(sizeof(UsbInPackage));
448451
std::ios init(NULL);
449452
init.copyfmt(*verboseTxOut);
@@ -547,11 +550,15 @@ void Usb::onUsbDataReceived(struct libusb_transfer* transfer)
547550
transferFailed = true;
548551
break;
549552
}
550-
//libusb_free_transfer(transfer);
551553
}
552554
// ----------------------------------------------------------------------
553555
Usb::~Usb()
554556
{
557+
if(deviceHandle != nullptr){
558+
close();
559+
}
560+
libusb_free_transfer(inTransfer);
561+
libusb_free_transfer(outTransfer);
555562
}
556563
// ----------------------------------------------------------------------
557564
void Usb::enableVerboseTx(bool enable)

0 commit comments

Comments
 (0)