Refactor sock option implementations

This commit is contained in:
Jianfeng Jiang
2023-12-28 09:24:23 +00:00
committed by Tate, Hongliang Tian
parent 782cd05ade
commit f8eca84a99
36 changed files with 733 additions and 728 deletions

View File

@ -132,8 +132,9 @@ impl FileTable {
.ok_or(Error::with_message(Errno::EBADF, "fd not exits"))
}
pub fn get_socket(&self, sockfd: FileDescripter) -> Result<&dyn Socket> {
self.get_file(sockfd)?
pub fn get_socket(&self, sockfd: FileDescripter) -> Result<Arc<dyn Socket>> {
let file_like = self.get_file(sockfd)?.clone();
file_like
.as_socket()
.ok_or_else(|| Error::with_message(Errno::ENOTSOCK, "the fd is not a socket"))
}