feat(socket): 实现shutdown系统调用的基础结构并启用相关方法

This commit is contained in:
xiaolin2004 2024-11-28 14:38:54 +08:00
parent 14c21430a5
commit 57e0b2e96a
2 changed files with 14 additions and 12 deletions

View File

@ -118,6 +118,8 @@ pub trait Socket: Sync + Send + Debug + Any {
}
/// # `shutdown`
fn shutdown(&self, how: ShutdownTemp) -> Result<(), SystemError> {
// TODO 构建shutdown系统调用
// set shutdown bit
Err(ENOSYS)
}
// sockatmark

View File

@ -53,21 +53,21 @@ impl Shutdown {
.fetch_or(SEND_SHUTDOWN, core::sync::atomic::Ordering::SeqCst);
}
// pub fn is_recv_shutdown(&self) -> bool {
// self.bit.load(core::sync::atomic::Ordering::SeqCst) & RCV_SHUTDOWN != 0
// }
pub fn is_recv_shutdown(&self) -> bool {
self.bit.load(core::sync::atomic::Ordering::SeqCst) & RCV_SHUTDOWN != 0
}
// pub fn is_send_shutdown(&self) -> bool {
// self.bit.load(core::sync::atomic::Ordering::SeqCst) & SEND_SHUTDOWN != 0
// }
pub fn is_send_shutdown(&self) -> bool {
self.bit.load(core::sync::atomic::Ordering::SeqCst) & SEND_SHUTDOWN != 0
}
// pub fn is_both_shutdown(&self) -> bool {
// self.bit.load(core::sync::atomic::Ordering::SeqCst) & SHUTDOWN_MASK == SHUTDOWN_MASK
// }
pub fn is_both_shutdown(&self) -> bool {
self.bit.load(core::sync::atomic::Ordering::SeqCst) & SHUTDOWN_MASK == SHUTDOWN_MASK
}
// pub fn is_empty(&self) -> bool {
// self.bit.load(core::sync::atomic::Ordering::SeqCst) == 0
// }
pub fn is_empty(&self) -> bool {
self.bit.load(core::sync::atomic::Ordering::SeqCst) == 0
}
pub fn from_how(how: usize) -> Self {
Self::from(ShutdownBit::from_bits_truncate(how as u8))