Do not release TCP sockets while still in use
SDLNet_TCP_Close() not only closes, but also release the resources. Therefore, we must not close the socket if another thread attempts to read it. For that purpose, move socket closing from server_stop() to server_destroy().
This commit is contained in:
@@ -115,13 +115,6 @@ TCPsocket server_connect_to(struct server *server, const char *serial) {
|
||||
|
||||
void server_stop(struct server *server, const char *serial) {
|
||||
SDL_assert(server->process != PROCESS_NONE);
|
||||
if (server->server_socket) {
|
||||
SDLNet_TCP_Close(server->server_socket);
|
||||
}
|
||||
if (server->device_socket) {
|
||||
SDLNet_TCP_Close(server->device_socket);
|
||||
}
|
||||
|
||||
terminate_server(server->process);
|
||||
|
||||
if (server->adb_reverse_enabled) {
|
||||
@@ -129,3 +122,12 @@ void server_stop(struct server *server, const char *serial) {
|
||||
disable_tunnel(serial);
|
||||
}
|
||||
}
|
||||
|
||||
void server_destroy(struct server *server) {
|
||||
if (server->server_socket) {
|
||||
SDLNet_TCP_Close(server->server_socket);
|
||||
}
|
||||
if (server->device_socket) {
|
||||
SDLNet_TCP_Close(server->device_socket);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user