summaryrefslogtreecommitdiffstats
path: root/adb
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2019-03-26 13:06:38 -0700
committerJosh Gao <jmgao@google.com>2019-03-26 13:06:38 -0700
commit63b52ec13b8b612b79d9c6884776b72bff6bebd0 (patch)
treef5dffddd2370e9fd8cad16315dd986eaeb9128c6 /adb
parent8a5a918ef836d6df353b6644f921ad81536b0c35 (diff)
downloadsystem_core-63b52ec13b8b612b79d9c6884776b72bff6bebd0.tar.gz
system_core-63b52ec13b8b612b79d9c6884776b72bff6bebd0.tar.bz2
system_core-63b52ec13b8b612b79d9c6884776b72bff6bebd0.zip
adbd: increment writes_submitted_ before submitting writes.
If we fail to submit writes for some reason (e.g. the USB cable was unplugged), another thread that's waiting on the write mutex can enter SubmitWrites and attempt to resubmit the writes that we already failed to submit, leading to a failed assertion of !IoBlock::pending. Increment writes_submitted_ before actually calling io_submit, so we skip over these writes and fall through to exit. Bug: http://b/129134256 Test: manually unplugged a blueline Change-Id: I2fd0034e45db22c8f637c81039ce686b7aa6a03b
Diffstat (limited to 'adb')
-rw-r--r--adb/daemon/usb.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/adb/daemon/usb.cpp b/adb/daemon/usb.cpp
index b42236ece..765357971 100644
--- a/adb/daemon/usb.cpp
+++ b/adb/daemon/usb.cpp
@@ -552,6 +552,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 +562,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) {