Lower WaitQueue incoming lock level
This commit is contained in:
@@ -2,7 +2,7 @@ use alloc::collections::VecDeque;
|
|||||||
use syscall::{EAGAIN, EINTR};
|
use syscall::{EAGAIN, EINTR};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
sync::{CleanLockToken, LockToken, Mutex, MutexGuard, WaitCondition, L1, L2},
|
sync::{CleanLockToken, LockToken, Mutex, MutexGuard, WaitCondition, L1, L2, L3},
|
||||||
syscall::{
|
syscall::{
|
||||||
error::{Error, Result, EINVAL},
|
error::{Error, Result, EINVAL},
|
||||||
usercopy::UserSliceWo,
|
usercopy::UserSliceWo,
|
||||||
@@ -11,7 +11,7 @@ use crate::{
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct WaitQueue<T> {
|
pub struct WaitQueue<T> {
|
||||||
incoming: Mutex<L2, VecDeque<T>>,
|
incoming: Mutex<L3, VecDeque<T>>,
|
||||||
outgoing: Mutex<L2, VecDeque<T>>,
|
outgoing: Mutex<L2, VecDeque<T>>,
|
||||||
pub condition: WaitCondition,
|
pub condition: WaitCondition,
|
||||||
}
|
}
|
||||||
@@ -58,17 +58,16 @@ impl<T> WaitQueue<T> {
|
|||||||
return Ok(bytes_copied);
|
return Ok(bytes_copied);
|
||||||
}
|
}
|
||||||
|
|
||||||
let incoming_guard = unsafe { self.incoming.relock(token.token()) };
|
let mut incoming = self.incoming.lock(token.token());
|
||||||
let (mut incoming, mut split_token) = incoming_guard.into_split();
|
|
||||||
|
|
||||||
if incoming.is_empty() {
|
if incoming.is_empty() {
|
||||||
if block {
|
if block {
|
||||||
drop(outgoing);
|
drop(incoming);
|
||||||
// SAFETY: Uses wait_inner because this inner is L2. It's guaranteed there's no other
|
// SAFETY: Uses wait_inner because this inner is L2. It's guaranteed there's no other
|
||||||
// lock held at this point because clean token is provided from caller.
|
// lock held at this point because clean token is provided from caller.
|
||||||
if !self
|
if !self
|
||||||
.condition
|
.condition
|
||||||
.wait_inner(incoming, reason, &mut split_token)
|
.wait_inner(outgoing, reason, &mut token.token())
|
||||||
{
|
{
|
||||||
return Err(Error::new(EINTR));
|
return Err(Error::new(EINTR));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user