Correct lock usages in UNIX sockets

This commit is contained in:
Ruihan Li
2024-09-23 10:22:28 +08:00
committed by Tate, Hongliang Tian
parent 14531cd99f
commit 1aa8b0abc6
2 changed files with 5 additions and 5 deletions

View File

@ -160,7 +160,7 @@ pub(super) struct Backlog {
addr: UnixSocketAddrBound,
pollee: Pollee,
backlog: AtomicUsize,
incoming_conns: Mutex<Option<VecDeque<Connected>>>,
incoming_conns: SpinLock<Option<VecDeque<Connected>>>,
wait_queue: WaitQueue,
}
@ -176,7 +176,7 @@ impl Backlog {
addr,
pollee,
backlog: AtomicUsize::new(backlog),
incoming_conns: Mutex::new(incoming_sockets),
incoming_conns: SpinLock::new(incoming_sockets),
wait_queue: WaitQueue::new(),
}
}

View File

@ -24,21 +24,21 @@ use crate::{
};
pub struct UnixStreamSocket {
state: RwLock<Takeable<State>>,
state: RwMutex<Takeable<State>>,
is_nonblocking: AtomicBool,
}
impl UnixStreamSocket {
pub(super) fn new_init(init: Init, is_nonblocking: bool) -> Arc<Self> {
Arc::new(Self {
state: RwLock::new(Takeable::new(State::Init(init))),
state: RwMutex::new(Takeable::new(State::Init(init))),
is_nonblocking: AtomicBool::new(is_nonblocking),
})
}
pub(super) fn new_connected(connected: Connected, is_nonblocking: bool) -> Arc<Self> {
Arc::new(Self {
state: RwLock::new(Takeable::new(State::Connected(connected))),
state: RwMutex::new(Takeable::new(State::Connected(connected))),
is_nonblocking: AtomicBool::new(is_nonblocking),
})
}