mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-19 12:36:46 +00:00
Correct lock usages in UNIX sockets
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
14531cd99f
commit
1aa8b0abc6
@ -160,7 +160,7 @@ pub(super) struct Backlog {
|
|||||||
addr: UnixSocketAddrBound,
|
addr: UnixSocketAddrBound,
|
||||||
pollee: Pollee,
|
pollee: Pollee,
|
||||||
backlog: AtomicUsize,
|
backlog: AtomicUsize,
|
||||||
incoming_conns: Mutex<Option<VecDeque<Connected>>>,
|
incoming_conns: SpinLock<Option<VecDeque<Connected>>>,
|
||||||
wait_queue: WaitQueue,
|
wait_queue: WaitQueue,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ impl Backlog {
|
|||||||
addr,
|
addr,
|
||||||
pollee,
|
pollee,
|
||||||
backlog: AtomicUsize::new(backlog),
|
backlog: AtomicUsize::new(backlog),
|
||||||
incoming_conns: Mutex::new(incoming_sockets),
|
incoming_conns: SpinLock::new(incoming_sockets),
|
||||||
wait_queue: WaitQueue::new(),
|
wait_queue: WaitQueue::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,21 +24,21 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub struct UnixStreamSocket {
|
pub struct UnixStreamSocket {
|
||||||
state: RwLock<Takeable<State>>,
|
state: RwMutex<Takeable<State>>,
|
||||||
is_nonblocking: AtomicBool,
|
is_nonblocking: AtomicBool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UnixStreamSocket {
|
impl UnixStreamSocket {
|
||||||
pub(super) fn new_init(init: Init, is_nonblocking: bool) -> Arc<Self> {
|
pub(super) fn new_init(init: Init, is_nonblocking: bool) -> Arc<Self> {
|
||||||
Arc::new(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),
|
is_nonblocking: AtomicBool::new(is_nonblocking),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn new_connected(connected: Connected, is_nonblocking: bool) -> Arc<Self> {
|
pub(super) fn new_connected(connected: Connected, is_nonblocking: bool) -> Arc<Self> {
|
||||||
Arc::new(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),
|
is_nonblocking: AtomicBool::new(is_nonblocking),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user