From bc771de4948c389a7d55d4dfa7c7f77e4ce43802 Mon Sep 17 00:00:00 2001 From: Ruihan Li Date: Sun, 10 Dec 2023 09:44:31 +0800 Subject: [PATCH] Remove the redundant `bound_socket()` from `ListenStream` There is no need to get the bound socket by cloning the first element from `self.backlog_sockets`. If we want a bound socket, we can always use `self.bound_socket` directly. --- services/libs/jinux-std/src/net/socket/ip/stream/listen.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/services/libs/jinux-std/src/net/socket/ip/stream/listen.rs b/services/libs/jinux-std/src/net/socket/ip/stream/listen.rs index 20b3f114f..bc3d23800 100644 --- a/services/libs/jinux-std/src/net/socket/ip/stream/listen.rs +++ b/services/libs/jinux-std/src/net/socket/ip/stream/listen.rs @@ -105,7 +105,7 @@ impl ListenStream { } pub fn local_endpoint(&self) -> Result { - self.bound_socket() + self.bound_socket .local_endpoint() .ok_or_else(|| Error::with_message(Errno::EINVAL, "does not has remote endpoint")) } @@ -114,10 +114,6 @@ impl ListenStream { self.pollee.poll(mask, poller) } - fn bound_socket(&self) -> Arc { - self.backlog_sockets.read()[0].bound_socket.clone() - } - fn update_io_events(&self) { // The lock should be held to avoid data races let backlog_sockets = self.backlog_sockets.read();