Fix DDMS-JDWP race
DDMS would race against the JDWP-Handshake in some circumstances
causing clients to become confused as DDMS packets were recieved
before the handshake reply.
Test: atest CtsJdwpTunnelHostTestCases
Test: ./tools/dt_fds_forward.py
Bug: 178655046
Change-Id: Iabeb68829455ee4d2682f0a14591c8b7b0f4fc5f
diff --git a/tools/dt_fds_forward.py b/tools/dt_fds_forward.py
index 1f9c41f..2c6a84d 100755
--- a/tools/dt_fds_forward.py
+++ b/tools/dt_fds_forward.py
@@ -38,6 +38,7 @@
LISTEN_START_MESSAGE = b"dt_fd_forward:START-LISTEN\x00"
LISTEN_END_MESSAGE = b"dt_fd_forward:END-LISTEN\x00"
ACCEPTED_MESSAGE = b"dt_fd_forward:ACCEPTED\x00"
+HANDSHAKEN_MESSAGE = b"dt_fd_forward:HANDSHAKE-COMPLETE\x00"
CLOSE_MESSAGE = b"dt_fd_forward:CLOSING\x00"
libc = ctypes.cdll.LoadLibrary("libc.so.6")
@@ -105,6 +106,8 @@
listening = False
elif buf == ACCEPTED_MESSAGE:
print("Fds were accepted.")
+ elif buf == HANDSHAKEN_MESSAGE:
+ print("Handshake completed.")
elif buf == CLOSE_MESSAGE:
# TODO Dup the fds and send a fake DDMS message like the actual plugin would.
print("Fds were closed")