Simplify server_connect_to()

Only use 2 branches, using either forward or remote tunnel.
This commit is contained in:
Romain Vimont 2019-05-28 21:02:57 +02:00
parent 5a431cdf9b
commit 8fc58bde75

View file

@ -223,20 +223,20 @@ bool
server_connect_to(struct server *server) { server_connect_to(struct server *server) {
if (!server->tunnel_forward) { if (!server->tunnel_forward) {
server->device_socket = net_accept(server->server_socket); server->device_socket = net_accept(server->server_socket);
if (server->device_socket == INVALID_SOCKET) {
return false;
}
// we don't need the server socket anymore
close_socket(&server->server_socket);
} else { } else {
uint32_t attempts = 100; uint32_t attempts = 100;
uint32_t delay = 100; // ms uint32_t delay = 100; // ms
server->device_socket = connect_to_server(server->local_port, attempts, server->device_socket = connect_to_server(server->local_port, attempts,
delay); delay);
}
if (server->device_socket == INVALID_SOCKET) { if (server->device_socket == INVALID_SOCKET) {
return false; return false;
} }
if (!server->tunnel_forward) {
// we don't need the server socket anymore
close_socket(&server->server_socket);
} }
// we don't need the adb tunnel anymore // we don't need the adb tunnel anymore