No description
Find a file
Yabin Cui 005bf1e05b adb: fix adb usb operations on device.
Problem: For devices using /dev/usb-ffs/adb, Run
`while true; do adb reconnect device; sleep 1; done`. And the
device soon becomes offline. The adbd log shows that calling
adb_read(h->bulk_out) in usb_ffs_read() gets EOVERFLOW error.

Reason: When kicking a transport using usb-ffs, /dev/usb-ffs/adb/ep0
is not closed, and the device will not notify a usb connection reset
to host. So the host will continue to send unfinished packets even
if a new transport is started on device. The unfinished packets may
not have the same size as what is expected on device, so adbd on
device gets EOVERFLOW error. At the worst case, adbd has to create new
transports for each unfinished packet.

Fixes:
The direct fix is to make the usb connection reset when kicking transports,
as in https://android-review.googlesource.com/#/c/211267/1. And I think
we can make following improvements beside that.
1. Close a file that is used in other threads isn't safe. Because the file
descriptor may be reused to open other files, and other threads may operate
on the wrong file. So use dup2(dummy_fd) to replace close() in kick function,
and really close the file descriptor after the read/write threads exit.

2. Open new usb connection after usb_close() instead of after
usb_kick(). After usb_kick(), the transport may still exist and
reader/writer for the transport may be still running. But after
usb_close(), the previous transport is guaranteed to be destroyed.

Bug: 25935458
Change-Id: I1eff99662d1bf1cba66af7e7142f4c0c4d82c01b
2016-04-15 18:18:16 -07:00
adb adb: fix adb usb operations on device. 2016-04-15 18:18:16 -07:00
adf Adf: Remove unused variable 2015-07-27 22:08:16 -07:00
base Add operator int() to unique_fd. 2016-03-28 12:15:36 -07:00
bootstat bootstat: Calculate and log the time_since_last_boot metric. 2016-04-15 08:44:01 -07:00
cpio fs_config: replace getenv('OUT') by new fs_config parameter 2015-07-09 21:47:07 -07:00
crash_reporter crash_reporter: Mark the euid parameter as __unused. 2016-02-26 15:44:46 -08:00
debuggerd debuggerd: set the name of the signal sender. 2016-03-29 17:56:47 -07:00
fastboot fastboot: Minor fix to help text. 2016-03-24 19:51:05 -07:00
fingerprintd Fingerprint: Add HAL close() code 2015-07-10 16:26:32 -07:00
fs_mgr Merge "Add nofail fstab option" 2016-04-14 00:12:44 +00:00
gatekeeperd Cleanup uses of sprintf so we can deprecate it. 2016-03-07 18:40:40 -08:00
healthd healthd: Explicitly reference headers from libbinder 2016-04-12 13:07:18 -07:00
include Remove libmincrypt. 2016-04-12 16:20:23 -07:00
init Remove undocumented functionality from init. 2016-04-13 07:56:51 -07:00
libbacktrace libbacktrace: only build libbacktrace_offline static library. 2016-04-14 10:31:08 -07:00
libbinderwrapper binderwrapper: Resolve ambiguous base::Closure reference 2016-04-12 13:19:29 -07:00
libcrypto_utils Add libcrypto_utils. 2016-04-12 15:08:01 -07:00
libcutils Merge "system/core/lib[c]utils: Fix signedness comparison warnings." 2016-03-01 20:28:13 +00:00
libdiskconfig Move libdiskconfig headers into libdiskconfig. 2016-02-13 12:48:23 -08:00
libion Use unique_ptr to free objects when ASSERT* fail. 2016-03-04 11:30:50 -08:00
liblog liblog: remove android_ids and replace with getpwuid 2016-04-11 14:55:56 +00:00
libmemtrack Remove unnecessary #include from <memtrack/memtrack.h>. 2016-02-16 10:32:30 -08:00
libmemunreachable Add operator int() to unique_fd. 2016-03-28 12:15:36 -07:00
libnativebridge Add Mips64 Runtime ISA type. 2016-02-08 14:02:47 -08:00
libnativeloader Allow vendors to extend the list of public libs 2016-04-06 18:24:08 -07:00
libnetutils Set IFA_BROADCAST during IPv4 RTM_NEWADDRs 2016-03-30 20:06:36 +09:00
libpackagelistparser Remove two bogus libutils dependencies. 2016-02-17 11:54:47 -08:00
libpixelflinger libpixelflinger: Fix -Woverloaded-virtual warnings. 2016-02-25 10:59:30 -08:00
libprocessgroup system/core: Cleanup direct calls to opendir by containing in a 2016-02-18 14:52:46 -08:00
libsparse Fix static analyzer issues caught by clang 2016-02-01 11:19:26 -08:00
libsuspend Adds a parameter to the wakeup_callback to report sucessful wakeup or suspend aborts. 2015-06-25 13:15:22 -07:00
libsync Cleanup uses of sprintf so we can deprecate it. 2016-03-07 18:40:40 -08:00
libsysutils Clean up CLOEXEC in SocketListener. 2016-02-19 18:14:22 -08:00
libusbhost libusbhost: Fix problem reading USB string descriptors on some quirky devices 2015-06-18 13:38:31 -07:00
libutils Remove debugging code for a fixed 3.6 kernel bug. 2016-04-04 16:06:53 -07:00
libziparchive libziparchive: port unit tests to darwin and windows. 2016-02-08 16:52:55 -08:00
lmkd more O_CLOEXEC 2015-12-18 20:57:25 -08:00
logcat logcat: expand -n, -r and -b 2016-04-13 11:43:03 -07:00
logd logd: switch from android_ids to getpwuid 2016-04-14 15:14:46 +00:00
logwrapper Don't go busy loop when waiting child process. 2016-02-16 10:13:48 -08:00
metricsd metricsd: Remove release/aquire semantic from scoped_ptr/unique_ptr 2016-04-08 09:59:05 -07:00
mkbootimg mkbootimg: use int for os_version and os_patch_level 2016-03-29 16:06:37 -07:00
reboot reboot: Turn on -Werror 2014-05-21 12:58:38 -07:00
rootdir Move list of public libraries to a config file 2016-03-17 10:54:19 -07:00
run-as Fix the run-as environment to better match su. 2015-11-03 14:31:46 -08:00
sdcard Merge commit '4352ee87fd74b931d4b58192fb8974e91aa899d0' into HEAD 2016-02-17 11:37:00 -08:00
toolbox Fix toolbox failure return to match similar tools. 2016-04-12 08:40:43 -07:00
trusty Merge "[core][trusty] Implement Trusty NVRAM HAL module." 2016-03-15 14:43:29 +00:00
tzdatacheck Track rename of base/ to android-base/. 2015-12-04 22:00:26 -08:00
.gitignore Ignore adb/*.pyc files 2015-08-11 12:59:58 -07:00
Android.mk Remove the simulator target from all makefiles. 2011-07-11 22:12:32 -07:00
CleanSpec.mk Add a CleanSpec for grep/toolbox. 2015-03-22 18:04:54 -07:00
MODULE_LICENSE_APACHE2 auto import from //depot/cupcake/@135843 2013-07-30 13:56:49 -07:00
NOTICE Fix omission in NOTICE file. 2013-07-30 13:56:55 -07:00