From 5b73a10f64712e27429836210d665afac2f12e11 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 2 Oct 2015 19:49:10 -0700 Subject: [PATCH] Explain adb client/server version mismatch better. "Out of date" is only probably true. You might equally well have an older client talking to a newer server. So tell the truth and include the actual version numbers. Change-Id: I821de88f5baf65bf2623363129c60c496b407bff --- adb/adb_client.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/adb/adb_client.cpp b/adb/adb_client.cpp index 63cb3c3af..984910d39 100644 --- a/adb/adb_client.cpp +++ b/adb/adb_client.cpp @@ -195,14 +195,15 @@ int adb_connect(const std::string& service, std::string* error) { adb_sleep_ms(3000); // fall through to _adb_connect } else { - // if server was running, check its version to make sure it is not out of date + // If a server is already running, check its version matches. int version = ADB_SERVER_VERSION - 1; - // if we have a file descriptor, then parse version result + // If we have a file descriptor, then parse version result. if (fd >= 0) { std::string version_string; if (!ReadProtocolString(fd, &version_string, error)) { - goto error; + adb_close(fd); + return -1; } adb_close(fd); @@ -214,8 +215,8 @@ int adb_connect(const std::string& service, std::string* error) { return -1; } } else { - // if fd is -1, then check for "unknown host service", - // which would indicate a version of adb that does not support the + // If fd is -1 check for "unknown host service" which would + // indicate a version of adb that does not support the // version command, in which case we should fall-through to kill it. if (*error != "unknown host service") { return fd; @@ -223,7 +224,8 @@ int adb_connect(const std::string& service, std::string* error) { } if (version != ADB_SERVER_VERSION) { - printf("adb server is out of date. killing...\n"); + printf("adb server version (%d) doesn't match this client (%d); killing...\n", + version, ADB_SERVER_VERSION); fd = _adb_connect("host:kill", error); if (fd >= 0) { adb_close(fd); @@ -253,9 +255,6 @@ int adb_connect(const std::string& service, std::string* error) { D("adb_connect: return fd %d", fd); return fd; -error: - adb_close(fd); - return -1; }