diff --git a/kernel/net/tcp_socket.rs b/kernel/net/tcp_socket.rs index e0677f91..b4faa23c 100644 --- a/kernel/net/tcp_socket.rs +++ b/kernel/net/tcp_socket.rs @@ -330,6 +330,12 @@ impl FileLike for TcpSocket { } } +impl Drop for TcpSocket { + fn drop(&mut self) { + SOCKETS.lock().remove(self.handle); + } +} + impl fmt::Debug for TcpSocket { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("TcpSocket").finish()