tcp_terminal: fix destruction of Open_socket

The socket API close() must be called within a libc context. Moreover,
the socket for listening needs to be closed as well.

Fixes #5270
This commit is contained in:
Johannes Schlatow 2024-07-04 22:25:03 +02:00 committed by Christian Helmuth
parent 7b8a2e77e4
commit 5bc6c9f2d0

View File

@ -455,8 +455,16 @@ Open_socket::Open_socket(char const * ip_addr, int tcp_port)
Open_socket::~Open_socket()
{
if (_sd != -1) close(_sd);
open_socket_pool()->remove(this);
Libc::with_libc([&] () {
if (_sd != -1)
close(_sd);
if (_listen_sd != -1)
close(_listen_sd);
open_socket_pool()->remove(this);
});
}