diff options
Diffstat (limited to 'adb/adb.cpp')
-rw-r--r-- | adb/adb.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/adb/adb.cpp b/adb/adb.cpp index c4df5c4b9..70e083b5f 100644 --- a/adb/adb.cpp +++ b/adb/adb.cpp @@ -934,8 +934,7 @@ int launch_server(const std::string& socket_spec) { // Try to handle a network forwarding request. // This returns 1 on success, 0 on failure, and -1 to indicate this is not // a forwarding-related request. -int handle_forward_request(const char* service, TransportType type, const char* serial, - TransportId transport_id, int reply_fd) { +int handle_forward_request(const char* service, atransport* transport, int reply_fd) { if (!strcmp(service, "list-forward")) { // Create the list of forward redirections. std::string listeners = format_listeners(); @@ -987,14 +986,6 @@ int handle_forward_request(const char* service, TransportType type, const char* } } - std::string error_msg; - atransport* transport = - acquire_one_transport(type, serial, transport_id, nullptr, &error_msg); - if (!transport) { - SendFail(reply_fd, error_msg); - return 1; - } - std::string error; InstallStatus r; int resolved_tcp_port = 0; @@ -1228,7 +1219,13 @@ int handle_host_request(const char* service, TransportType type, const char* ser return SendOkay(reply_fd, response); } - int ret = handle_forward_request(service, type, serial, transport_id, reply_fd); + std::string error; + atransport* t = acquire_one_transport(type, serial, transport_id, nullptr, &error); + if (!t) { + return SendFail(reply_fd, error); + } + + int ret = handle_forward_request(service, t, reply_fd); if (ret >= 0) return ret - 1; return -1; |