Refactor server_start() error handling
This avoids cleanup duplication.
This commit is contained in:
parent
4150eedcdf
commit
64d5edce92
1 changed files with 12 additions and 11 deletions
|
@ -345,30 +345,31 @@ server_start(struct server *server, const char *serial,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!push_server(serial)) {
|
if (!push_server(serial)) {
|
||||||
SDL_free(server->serial);
|
goto error1;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!enable_tunnel_any_port(server, params->port_range)) {
|
if (!enable_tunnel_any_port(server, params->port_range)) {
|
||||||
SDL_free(server->serial);
|
goto error1;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// server will connect to our server socket
|
// server will connect to our server socket
|
||||||
server->process = execute_server(server, params);
|
server->process = execute_server(server, params);
|
||||||
|
|
||||||
if (server->process == PROCESS_NONE) {
|
if (server->process == PROCESS_NONE) {
|
||||||
if (!server->tunnel_forward) {
|
goto error2;
|
||||||
close_socket(&server->server_socket);
|
|
||||||
}
|
|
||||||
disable_tunnel(server);
|
|
||||||
SDL_free(server->serial);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
server->tunnel_enabled = true;
|
server->tunnel_enabled = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
error2:
|
||||||
|
if (!server->tunnel_forward) {
|
||||||
|
close_socket(&server->server_socket);
|
||||||
|
}
|
||||||
|
disable_tunnel(server);
|
||||||
|
error1:
|
||||||
|
SDL_free(server->serial);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
Loading…
Reference in a new issue