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.
This commit is contained in:
Ruihan Li 2023-12-10 09:44:31 +08:00 committed by Tate, Hongliang Tian
parent 0cc9c5fb3a
commit bc771de494

View File

@ -105,7 +105,7 @@ impl ListenStream {
}
pub fn local_endpoint(&self) -> Result<IpEndpoint> {
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<AnyBoundSocket> {
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();