diff options
author | Jack Pham <jackp@codeaurora.org> | 2020-05-19 00:31:10 -0700 |
---|---|---|
committer | Jack Pham <jackp@codeaurora.org> | 2020-05-21 09:52:38 -0700 |
commit | 9fbb2ff864b8d2b9ae5e33286c537a46cfa4aca0 (patch) | |
tree | 38a0af55cd95f94fb27a3733a16f695974a2bcfc /libsparse/sparse.cpp | |
parent | ffa67fac3b959acae77889381eae5ed8dfed262b (diff) |
adbd: Avoid stuck write when offline
The USB transport can go offline for various reasons, such as
disconnection or ConfigFS configuration change, and is usually
handled as part of the transport's error callback after an I/O
failure. However, the main thread may still be running queued
fdevents prior to the offline event, any of which might have
been trying to send a packet to the now-offline transport.
Since the underlying USB FunctionFS endpoints are disabled, the
AIO write via io_submit() ends up waiting until the endpoints
are re-enabled, thus blocking the main thread from progressing.
Unlike the "UsbFfs-worker" thread which, even if blocked on I/O,
can be cancelled by sending a signal from the monitor thread,
there is no such recourse on the main thread.
On devices where USB Gadget HAL is not used, this can cause the
ConfigFS gadget to get silently unbound from the UDC, and without
a monitor for the FFS file nodes the init .rc rules do not get
triggered to re-bind the config leaving the USB device inoperable.
To address this, clear the atransport::offline flag immediately
instead of waiting for the queued handle_offline(), and check
this flag in send_packet() to avoid calling Write().
Also while there, move the nullptr check to the very beginning
of send_packet() before any of the dereferences of the "t" pointer.
CRs-Fixed: 2686499
Bug: 157078255
Change-Id: Iea499ff2ba4db7f61b03b3cee16b8a27d2973c0b
Diffstat (limited to 'libsparse/sparse.cpp')
0 files changed, 0 insertions, 0 deletions