summaryrefslogtreecommitdiffstats
path: root/adb
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2019-03-11 13:03:08 -0700
committerJosh Gao <jmgao@google.com>2019-03-11 13:06:17 -0700
commit007a4dc7a6b8ad6ec206f2c70be7f66d59287ecb (patch)
treebca1d66b39fca1a635aeaf2f77c277dad9d15bff /adb
parentfdfb9a0113abc4b91859f2e4dfd05b1c0ca018b0 (diff)
downloadsystem_core-007a4dc7a6b8ad6ec206f2c70be7f66d59287ecb.tar.gz
system_core-007a4dc7a6b8ad6ec206f2c70be7f66d59287ecb.tar.bz2
system_core-007a4dc7a6b8ad6ec206f2c70be7f66d59287ecb.zip
adbd: properly handle FUNCTIONFS_BIND without ENABLE.
If a device is unplugged, a BIND will happen without an ENABLE until the device is plugged in, which would previously result in adbd crashing every 5 seconds due to an attempt to join a thread that hadn't been started. Bug: http://b/128255355 Test: manually observed adbd via serial cable while unplugged Change-Id: I90d6384e7e829df1ffaf73a95f2418a2ff97fb03
Diffstat (limited to 'adb')
-rw-r--r--adb/daemon/usb.cpp18
1 files changed, 2 insertions, 16 deletions
diff --git a/adb/daemon/usb.cpp b/adb/daemon/usb.cpp
index a44ff43b6..f4458a2c8 100644
--- a/adb/daemon/usb.cpp
+++ b/adb/daemon/usb.cpp
@@ -270,29 +270,15 @@ struct UsbFfsConnection : public Connection {
bool started = false;
bool running = true;
while (running) {
- int timeout = -1;
- if (!bound || !started) {
- timeout = 5000 /*ms*/;
- }
-
adb_pollfd pfd[2] = {
{ .fd = control_fd_.get(), .events = POLLIN, .revents = 0 },
{ .fd = monitor_event_fd_.get(), .events = POLLIN, .revents = 0 },
};
- int rc = TEMP_FAILURE_RETRY(adb_poll(pfd, 2, timeout));
+ int rc = TEMP_FAILURE_RETRY(adb_poll(pfd, 2, -1));
if (rc == -1) {
PLOG(FATAL) << "poll on USB control fd failed";
} else if (rc == 0) {
- // Something in the kernel presumably went wrong.
- // Close our endpoints, wait for a bit, and then try again.
- StopWorker();
- aio_context_.reset();
- read_fd_.reset();
- write_fd_.reset();
- control_fd_.reset();
- std::this_thread::sleep_for(5s);
- HandleError("didn't receive FUNCTIONFS_ENABLE, retrying");
- return;
+ LOG(FATAL) << "poll on USB control fd returned 0";
}
if (pfd[1].revents) {