Skip to content
Snippets Groups Projects
Commit c8ad0ca6 authored by Spencer Low's avatar Spencer Low
Browse files

adb: really make kill-server wait for server death


It doesn't seem like b3c14ec6 was really
waiting for adb server death because the server would write OKAY to the
socket, causing the client to return from ReadOrderlyShutdown() before
the socket was actually closed.

The fix is to read the OKAY and then call ReadOrderlyShutdown() which
will then wait for the socket to be closed.

Test: Made the server hang in adb_server_cleanup() during kill-server
and kill-server would hang (as desired).
Test: To test resilience, tried preventing the server from sending OKAY and
adb kill-server still worked properly.

Change-Id: I4f0f11b86bbdc983670273ef5d3bb1dff7ab3697
Signed-off-by: default avatarSpencer Low <CompareAndSwap@gmail.com>
parent 6d2ace36
No related branches found
No related tags found
No related merge requests found
......@@ -185,6 +185,11 @@ bool adb_kill_server() {
return false;
}
// The server might send OKAY, so consume that.
char buf[4];
ReadFdExactly(fd, buf, 4);
// Now that no more data is expected, wait for socket orderly shutdown or error, indicating
// server death.
ReadOrderlyShutdown(fd);
return true;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment