summaryrefslogtreecommitdiffstats
path: root/adb
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2019-03-26 18:08:11 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-03-26 18:08:11 -0700
commit3d26a866769bc13938e0762518241f8067a7de38 (patch)
tree0c9aac10e0bd51855e7a99dc7ae1a76bf414a5d3 /adb
parentc45ba3e8bb9b83c05fe06a84124cb7faf0c910fa (diff)
parent448aed3c73c7b554a212d4723cf1d168d22fee4a (diff)
downloadsystem_core-3d26a866769bc13938e0762518241f8067a7de38.tar.gz
system_core-3d26a866769bc13938e0762518241f8067a7de38.tar.bz2
system_core-3d26a866769bc13938e0762518241f8067a7de38.zip
Merge changes I80af5f4b,I2fd0034e am: 2decb2fc3a am: c9a893c1eb
am: 448aed3c73 Change-Id: I783537a4b2ec10659c563b4461186d2230895e35
Diffstat (limited to 'adb')
-rw-r--r--adb/daemon/usb.cpp30
1 files changed, 23 insertions, 7 deletions
diff --git a/adb/daemon/usb.cpp b/adb/daemon/usb.cpp
index b42236ece..8a5000336 100644
--- a/adb/daemon/usb.cpp
+++ b/adb/daemon/usb.cpp
@@ -267,7 +267,7 @@ struct UsbFfsConnection : public Connection {
adb_thread_setname("UsbFfs-monitor");
bool bound = false;
- bool started = false;
+ bool enabled = false;
bool running = true;
while (running) {
adb_pollfd pfd[2] = {
@@ -298,16 +298,32 @@ struct UsbFfsConnection : public Connection {
switch (event.type) {
case FUNCTIONFS_BIND:
CHECK(!bound) << "received FUNCTIONFS_BIND while already bound?";
+ CHECK(!enabled) << "received FUNCTIONFS_BIND while already enabled?";
bound = true;
+
break;
case FUNCTIONFS_ENABLE:
- CHECK(!started) << "received FUNCTIONFS_ENABLE while already running?";
- started = true;
+ CHECK(bound) << "received FUNCTIONFS_ENABLE while not bound?";
+ CHECK(!enabled) << "received FUNCTIONFS_ENABLE while already enabled?";
+ enabled = true;
+
StartWorker();
break;
case FUNCTIONFS_DISABLE:
+ CHECK(bound) << "received FUNCTIONFS_DISABLE while not bound?";
+ CHECK(enabled) << "received FUNCTIONFS_DISABLE while not enabled?";
+ enabled = false;
+
+ running = false;
+ break;
+
+ case FUNCTIONFS_UNBIND:
+ CHECK(!enabled) << "received FUNCTIONFS_UNBIND while still enabled?";
+ CHECK(bound) << "received FUNCTIONFS_UNBIND when not bound?";
+ bound = false;
+
running = false;
break;
}
@@ -339,7 +355,7 @@ struct UsbFfsConnection : public Connection {
LOG(FATAL) << "hit EOF on eventfd";
}
- WaitForEvents();
+ ReadEvents();
}
});
}
@@ -389,7 +405,7 @@ struct UsbFfsConnection : public Connection {
return block;
}
- void WaitForEvents() {
+ void ReadEvents() {
static constexpr size_t kMaxEvents = kUsbReadQueueDepth + kUsbWriteQueueDepth;
struct io_event events[kMaxEvents];
struct timespec timeout = {.tv_sec = 0, .tv_nsec = 0};
@@ -552,6 +568,8 @@ struct UsbFfsConnection : public Connection {
LOG(VERBOSE) << "submitting write_request " << static_cast<void*>(iocbs[i]);
}
+ writes_submitted_ += writes_to_submit;
+
int rc = io_submit(aio_context_.get(), writes_to_submit, iocbs);
if (rc == -1) {
HandleError(StringPrintf("failed to submit write requests: %s", strerror(errno)));
@@ -560,8 +578,6 @@ struct UsbFfsConnection : public Connection {
LOG(FATAL) << "failed to submit all writes: wanted to submit " << writes_to_submit
<< ", actually submitted " << rc;
}
-
- writes_submitted_ += rc;
}
void HandleError(const std::string& error) {