some fixes
This commit is contained in:
@@ -157,8 +157,19 @@ class USBTransport:
|
||||
logger.debug("USB disconnect requested")
|
||||
self._stop_event.set()
|
||||
|
||||
if self._rx_thread is not None and self._rx_thread.is_alive():
|
||||
self._rx_thread.join(timeout=1.0)
|
||||
rx_thread = self._rx_thread
|
||||
if rx_thread is not None and rx_thread.is_alive():
|
||||
rx_thread.join(timeout=1.0)
|
||||
if rx_thread.is_alive():
|
||||
# The RX thread is wedged inside libusb; closing the handle or
|
||||
# context now would risk a use-after-free in the still-running
|
||||
# bulkRead. Deliberately leak both rather than crash the process.
|
||||
logger.error(
|
||||
"USB RX thread did not stop within timeout; leaking USB handle/context "
|
||||
"to avoid use-after-free (serial=%s)",
|
||||
self.connected_serial,
|
||||
)
|
||||
return
|
||||
self._rx_thread = None
|
||||
|
||||
if self._handle is not None:
|
||||
|
||||
Reference in New Issue
Block a user