Skip to content

Commit

Permalink
fix(tasks): never yield expired tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Threated committed Oct 22, 2024
1 parent 08ae06f commit 165fc18
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion broker/src/task_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,14 @@ impl<T: HasWaitId<MsgId> + Task + Msg + Send + Sync + 'static> TaskManager<T> {
impl<T: HasWaitId<MsgId> + Task + Msg> TaskManager<T> {

pub fn get(&self, task_id: &MsgId) -> Result<impl Deref<Target = MsgSigned<T>> + '_, TaskManagerError> {
self.tasks.get(task_id).ok_or(TaskManagerError::NotFound)
self.tasks
.get(task_id)
.ok_or(TaskManagerError::NotFound)
.and_then(|entry| if entry.msg.is_expired() {
Err(TaskManagerError::Gone)
} else {
Ok(entry)
})
}

pub fn remove(&self, task_id: &MsgId) -> Result<MsgSigned<T>, TaskManagerError> {
Expand Down

0 comments on commit 165fc18

Please sign in to comment.