adbd: don't abort on EOF on functionfs control fd.
Also, improve the logging in the cases where we do abort.
Bug: http://b/131867920
Test: treehugger
Change-Id: If8ec9f4614ce146e6dbd21cc77587ea81658199b
(cherry picked from commit 2916e148d9c333be253533968f407b73ebc017c2)
diff --git a/adb/daemon/usb.cpp b/adb/daemon/usb.cpp
index 3b29ab5..0fc4512 100644
--- a/adb/daemon/usb.cpp
+++ b/adb/daemon/usb.cpp
@@ -295,9 +295,15 @@
}
struct usb_functionfs_event event;
- if (TEMP_FAILURE_RETRY(adb_read(control_fd_.get(), &event, sizeof(event))) !=
- sizeof(event)) {
+ rc = TEMP_FAILURE_RETRY(adb_read(control_fd_.get(), &event, sizeof(event)));
+ if (rc == -1) {
PLOG(FATAL) << "failed to read functionfs event";
+ } else if (rc == 0) {
+ LOG(WARNING) << "hit EOF on functionfs control fd";
+ break;
+ } else if (rc != sizeof(event)) {
+ LOG(FATAL) << "read functionfs event of unexpected size, expected "
+ << sizeof(event) << ", got " << rc;
}
LOG(INFO) << "USB event: "