Add unit tests for local socket.
Add has_write_error flag in asocket, so it will not wait on local_socket_closing_list
to write pending packets in local_socket_close(). Although it doesn't fix any problem,
it helps to make the code more stable.
Add a missing put_apacket() in error handling.
Add a check when adding local socket in local_socket_closing_list.
Bug: 23314034
Change-Id: I75b07ba8ee59b7f277fba2fb919db63065b291be
diff --git a/adb/fdevent.cpp b/adb/fdevent.cpp
index dc03807..666a15f 100644
--- a/adb/fdevent.cpp
+++ b/adb/fdevent.cpp
@@ -119,10 +119,10 @@
fde->func = func;
fde->arg = arg;
if (fcntl(fd, F_SETFL, O_NONBLOCK) != 0) {
- // Here is not proper to handle the error. If it fails here, some error is
- // likely to be detected by poll(), then we can let the callback function
- // to handle it.
- LOG(ERROR) << "failed to fcntl(" << fd << ") to be nonblock";
+ // Here is not proper to handle the error. If it fails here, some error is
+ // likely to be detected by poll(), then we can let the callback function
+ // to handle it.
+ LOG(ERROR) << "failed to fcntl(" << fd << ") to be nonblock";
}
auto pair = g_poll_node_map.emplace(fde->fd, PollNode(fde));
CHECK(pair.second) << "install existing fd " << fd;
@@ -215,10 +215,13 @@
D("poll(), pollfds = %s", dump_pollfds(pollfds).c_str());
int ret = TEMP_FAILURE_RETRY(poll(&pollfds[0], pollfds.size(), -1));
if (ret == -1) {
- PLOG(ERROR) << "poll(), ret = " << ret;
- return;
+ PLOG(ERROR) << "poll(), ret = " << ret;
+ return;
}
for (auto& pollfd : pollfds) {
+ if (pollfd.revents != 0) {
+ D("for fd %d, revents = %x", pollfd.fd, pollfd.revents);
+ }
unsigned events = 0;
if (pollfd.revents & POLLIN) {
events |= FDE_READ;
@@ -337,3 +340,12 @@
}
}
}
+
+size_t fdevent_installed_count() {
+ return g_poll_node_map.size();
+}
+
+void fdevent_reset() {
+ g_poll_node_map.clear();
+ g_pending_list.clear();
+}