diff --git a/crates/kumod/src/ready_queue.rs b/crates/kumod/src/ready_queue.rs index 1d96125c..0375349a 100644 --- a/crates/kumod/src/ready_queue.rs +++ b/crates/kumod/src/ready_queue.rs @@ -113,11 +113,14 @@ impl Fifo { } pub fn push(&self, msg: Message) -> Result<(), Message> { - let mut list = self.list.lock(); - if list.len() + 1 > self.capacity.load(Ordering::Relaxed) { - return Err(msg); + { + let mut list = self.list.lock(); + if list.len() + 1 > self.capacity.load(Ordering::Relaxed) { + return Err(msg); + } + list.push_back(msg); } - list.push_back(msg); + // Increment the count after we've dropped the mutexguard on the list self.count.inc(); Ok(()) }