Skip to content

Commit

Permalink
fix(net): deallocate network buffers
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kröning <[email protected]>
  • Loading branch information
mkroening committed Oct 7, 2023
1 parent 2cd6dc6 commit d7b50ce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/executor/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ impl<'a> NetworkInterface<'a> {
) -> (&mut T, &mut smoltcp::iface::Context) {
(self.sockets.get_mut(handle), self.iface.context())
}

pub(crate) fn destroy_socket(&mut self, handle: Handle) {
// This deallocates the socket's buffers
self.sockets.remove(handle);
}
}

#[inline]
Expand Down
1 change: 1 addition & 0 deletions src/fd/socket/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ impl<T> Clone for Socket<T> {
impl<T> Drop for Socket<T> {
fn drop(&mut self) {
let _ = block_on(self.async_close(), None);
NIC.lock().as_nic_mut().unwrap().destroy_socket(self.handle);
}
}

Expand Down

0 comments on commit d7b50ce

Please sign in to comment.