adb: really make kill-server wait for server death

It doesn't seem like b3c14ec693 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: Spencer Low <CompareAndSwap@gmail.com>
This commit is contained in:
Spencer Low 2018-08-29 15:46:47 -07:00
parent 6d2ace3684
commit c8ad0ca69d

View file

@ -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;
}