From 675ab9572d69ac3ea5b17258b5a291b1e7361eba Mon Sep 17 00:00:00 2001 From: Seiya Nuta Date: Sat, 18 Dec 2021 18:01:00 +0900 Subject: [PATCH] net: Fix a memory leak --- kernel/net/tcp_socket.rs | 6 ++++++ 1 file changed, 6 insertions(+) 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()