Combine tcp_connect and socket_spec_connect.
This will make it easier to add new types of transports by combining the
logic the adb server and adb daemon use to connect to things.
Bug:121166534
Test: adb connect against a cuttlefish instance over the shm proxy.
Change-Id: Ic7fc848c60a85eef968c3735838c87cb7fdaf38b
diff --git a/adb/services.cpp b/adb/services.cpp
index 8636657..73fed09 100644
--- a/adb/services.cpp
+++ b/adb/services.cpp
@@ -72,24 +72,23 @@
}
int service_to_fd(std::string_view name, atransport* transport) {
- int ret = -1;
+ unique_fd ret;
if (is_socket_spec(name)) {
std::string error;
- ret = socket_spec_connect(name, &error);
- if (ret < 0) {
+ if (!socket_spec_connect(&ret, name, nullptr, nullptr, &error)) {
LOG(ERROR) << "failed to connect to socket '" << name << "': " << error;
}
} else {
#if !ADB_HOST
- ret = daemon_service_to_fd(name, transport).release();
+ ret = daemon_service_to_fd(name, transport);
#endif
}
if (ret >= 0) {
close_on_exec(ret);
}
- return ret;
+ return ret.release();
}
#if ADB_HOST