Skip to content

Commit b4d1f5d

Browse files
committed
scheduling: fix atomicity issues
1 parent 2c213e9 commit b4d1f5d

File tree

2 files changed

+160
-129
lines changed

2 files changed

+160
-129
lines changed

crates/core/src/host/module_host.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,13 +1427,14 @@ impl ModuleHost {
14271427
pub async fn call_reducer_with_params(
14281428
&self,
14291429
reducer_name: &str,
1430+
tx: Option<MutTxId>,
14301431
params: CallReducerParams,
14311432
) -> Result<ReducerCallResult, NoSuchModule> {
14321433
self.call(
14331434
reducer_name,
1434-
params,
1435-
|p, inst| inst.call_reducer(None, p),
1436-
|p, inst| inst.call_reducer(None, p),
1435+
(tx, params),
1436+
|(tx, p), inst| inst.call_reducer(tx, p),
1437+
|(tx, p), inst| inst.call_reducer(tx, p),
14371438
)
14381439
.await
14391440
}
@@ -1465,7 +1466,7 @@ impl ModuleHost {
14651466
};
14661467

14671468
Ok(self
1468-
.call_reducer_with_params(&reducer_def.name, call_reducer_params)
1469+
.call_reducer_with_params(&reducer_def.name, None, call_reducer_params)
14691470
.await?)
14701471
}
14711472

@@ -1583,15 +1584,9 @@ impl ModuleHost {
15831584
procedure_id,
15841585
args,
15851586
};
1586-
self.call_async_with_instance(&procedure_def.name, async move |inst| match inst {
1587-
Instance::Wasm(mut inst) => (inst.call_procedure(params).await, Instance::Wasm(inst)),
1588-
Instance::Js(inst) => {
1589-
let (r, s) = inst.call_procedure(params).await;
1590-
(r, Instance::Js(s))
1591-
}
1592-
})
1593-
.await
1594-
.map_err(Into::into)
1587+
self.call_procedure_with_params(&procedure_def.name, params)
1588+
.await
1589+
.map_err(Into::into)
15951590
}
15961591

15971592
// This is not reused in `call_procedure_inner`
@@ -1601,9 +1596,12 @@ impl ModuleHost {
16011596
name: &str,
16021597
params: CallProcedureParams,
16031598
) -> Result<CallProcedureReturn, NoSuchModule> {
1604-
self.call_async_with_instance(name, async move |mut inst| {
1605-
let res = inst.call_procedure(params).await;
1606-
(res, inst)
1599+
self.call_async_with_instance(name, async move |inst| match inst {
1600+
Instance::Wasm(mut inst) => (inst.call_procedure(params).await, Instance::Wasm(inst)),
1601+
Instance::Js(inst) => {
1602+
let (r, s) = inst.call_procedure(params).await;
1603+
(r, Instance::Js(s))
1604+
}
16071605
})
16081606
.await
16091607
}

0 commit comments

Comments
 (0)