From 8fc58bde75f775b25aa699e4dbf3b1a6049300f9 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Tue, 28 May 2019 21:02:57 +0200 Subject: [PATCH] Simplify server_connect_to() Only use 2 branches, using either forward or remote tunnel. --- app/src/server.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/src/server.c b/app/src/server.c index 0d92cabc..8760362b 100644 --- a/app/src/server.c +++ b/app/src/server.c @@ -223,20 +223,20 @@ bool server_connect_to(struct server *server) { if (!server->tunnel_forward) { 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 { uint32_t attempts = 100; uint32_t delay = 100; // ms server->device_socket = connect_to_server(server->local_port, attempts, delay); - } - - if (server->device_socket == INVALID_SOCKET) { - return false; - } - - if (!server->tunnel_forward) { - // we don't need the server socket anymore - close_socket(&server->server_socket); + if (server->device_socket == INVALID_SOCKET) { + return false; + } } // we don't need the adb tunnel anymore