From 251d46e68a279df2eb359e87a24b0e47fdfe4b78 Mon Sep 17 00:00:00 2001 From: Prathmesh Prabhu Date: Wed, 9 Mar 2016 13:51:30 -0800 Subject: [PATCH] emulator: Use distinct serial names for simultaneous qemu pipes. ADB local transport for the emulator based on qemu pipes uses a socket transport. Before this CL, multiple connection requests accepted by the qemu pipe device would result in ADB transport with the same serial. The register function would fail as a result, and all subsequent connections would fail. Test: while true; do adb kill-server; adb devices; done Doesn't fail for > 10 minutes. This CL replaces an earlier CL (I0fdcf2694516151c5f8f8e1580648b940679c981) that was unsafe for real devices. BUG=27441661 Change-Id: I7d801b175f3bee10fc7e0ab1b12d5623984371b9 --- adb/transport_local.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adb/transport_local.cpp b/adb/transport_local.cpp index 372bedf7c..f6c9df4e8 100644 --- a/adb/transport_local.cpp +++ b/adb/transport_local.cpp @@ -260,7 +260,8 @@ static void qemu_socket_thread(void* arg) { } else { /* Host is connected. Register the transport, and start the * exchange. */ - register_socket_transport(fd, "host", port, 1); + std::string serial = android::base::StringPrintf("host-%d", fd); + register_socket_transport(fd, serial.c_str(), port, 1); if (!WriteFdExactly(fd, _start_req, strlen(_start_req))) { adb_close(fd); }