Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit b749a0a

Browse files
committed
avoid redundant CallStarted or CallReturned events
If we're returning `Status::Started` or `Status::Returned`, don't _also_ deliver redundant events. Fixes #103 Signed-off-by: Joel Dice <joel.dice@fermyon.com>
1 parent c406e58 commit b749a0a

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

crates/wasmtime/src/runtime/component/concurrent.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1675,8 +1675,12 @@ impl ComponentInstance {
16751675
let mut status = if task.lower_params.is_some() {
16761676
Status::Starting
16771677
} else if task.lift_result.is_some() {
1678+
let event = Waitable::Guest(guest_task).take_event(self)?;
1679+
assert!(matches!(event, Some(Event::CallStarted)));
16781680
Status::Started
16791681
} else {
1682+
let event = Waitable::Guest(guest_task).take_event(self)?;
1683+
assert!(matches!(event, Some(Event::CallReturned)));
16801684
Status::Returned
16811685
};
16821686

@@ -1689,7 +1693,7 @@ impl ComponentInstance {
16891693
self.waitable_tables()[caller_instance]
16901694
.insert(guest_task.rep(), WaitableState::GuestTask)?
16911695
} else {
1692-
let caller = if let Caller::Guest { task, .. } = &task.caller {
1696+
let caller = if let Caller::Guest { task, .. } = &self.get(guest_task)?.caller {
16931697
*task
16941698
} else {
16951699
unreachable!()
@@ -3108,6 +3112,15 @@ impl Waitable {
31083112
})
31093113
}
31103114

3115+
fn take_event(&self, instance: &mut ComponentInstance) -> Result<Option<Event>> {
3116+
let common = self.common(instance)?;
3117+
let event = common.event.take();
3118+
if let Some(set) = self.common(instance)?.set {
3119+
instance.get_mut(set)?.ready.remove(self);
3120+
}
3121+
Ok(event)
3122+
}
3123+
31113124
fn mark_ready(&self, instance: &mut ComponentInstance) -> Result<()> {
31123125
if let Some(set) = self.common(instance)?.set {
31133126
instance.get_mut(set)?.ready.insert(*self);

0 commit comments

Comments
 (0)