diff options
author | Yabin Cui <yabinc@google.com> | 2015-09-29 12:25:33 -0700 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2015-09-30 15:03:26 -0700 |
commit | aa77e22d7384a97757e2d2194f4e265f7ad3b71a (patch) | |
tree | 9fbcc3dbd66c1cdae1a50656b0e15e831eb6fc99 /adb/adb.cpp | |
parent | d490db9824cdb4974da22ba80399f39a8b44ec08 (diff) | |
download | system_core-aa77e22d7384a97757e2d2194f4e265f7ad3b71a.tar.gz system_core-aa77e22d7384a97757e2d2194f4e265f7ad3b71a.tar.bz2 system_core-aa77e22d7384a97757e2d2194f4e265f7ad3b71a.zip |
adb: detect sockets in CLOSE_WAIT state to prevent socket leak on linux.
It is possible that the adb server on host has many sockets in
CLOSE_WAIT state. To prevent socket leak, always enable POLLRDHUP
in fdevent.cpp to detect sockets in CLOSE_WAIT state.
Update LocalSocketTest unit tests:
Change half_close_with_packet to read_from_closing_socket, as reading
from a SHUT_WR socket is not needed in adb.
Change close_with_no_events_installed to close_socket_in_CLOSE_WAIT_state,
as the latter is more close to the real situation in use.
Bug: 23314034
Change-Id: Ice4f4036624e5584eab6ba5848e7f169c92f037f
Diffstat (limited to 'adb/adb.cpp')
-rw-r--r-- | adb/adb.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/adb/adb.cpp b/adb/adb.cpp index 0e1859cdd..1c1683e73 100644 --- a/adb/adb.cpp +++ b/adb/adb.cpp @@ -395,6 +395,11 @@ void handle_packet(apacket *p, atransport *t) D("Invalid A_OKAY(%d,%d), expected A_OKAY(%d,%d) on transport %s", p->msg.arg0, p->msg.arg1, s->peer->id, p->msg.arg1, t->serial); } + } else { + // When receiving A_OKAY from device for A_OPEN request, the host server may + // have closed the local socket because of client disconnection. Then we need + // to send A_CLSE back to device to close the service on device. + send_close(p->msg.arg1, p->msg.arg0, t); } } break; |