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
This commit is contained in:
Prathmesh Prabhu 2016-03-09 13:51:30 -08:00
parent a996c2963a
commit 251d46e68a
1 changed files with 2 additions and 1 deletions

View File

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