diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2022-12-05 08:10:22 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-05 21:40:22 +0530 |
commit | 55595ca1b74e07eb2365d5aec3861600e2266470 (patch) | |
tree | 3d32d362e60b8c2b6fbf9e57f939afb8f52f42db /ext/flash/lib.rs | |
parent | 715f35d635bf5a4e972238e6ac8d290c0e096083 (diff) |
fix(ops): disallow auto-borrowing OpState across potential await point (#16952)
Fixes https://github.com/denoland/deno/issues/16934
Example compiler error:
```
error: mutable opstate is not supported in async ops
--> core/ops_builtin.rs:122:1
|
122 | #[op]
| ^^^^^
|
= note: this error originates in the attribute macro `op` (in Nightly builds, run with -Z macro-backtrace for more info)
```
Diffstat (limited to 'ext/flash/lib.rs')
-rw-r--r-- | ext/flash/lib.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ext/flash/lib.rs b/ext/flash/lib.rs index d08cdbcdc..04ed54e1a 100644 --- a/ext/flash/lib.rs +++ b/ext/flash/lib.rs @@ -1290,10 +1290,11 @@ where #[op] fn op_flash_wait_for_listening( - state: &mut OpState, + state: Rc<RefCell<OpState>>, server_id: u32, ) -> Result<impl Future<Output = Result<u16, AnyError>> + 'static, AnyError> { let mut listening_rx = { + let mut state = state.borrow_mut(); let flash_ctx = state.borrow_mut::<FlashContext>(); let server_ctx = flash_ctx .servers @@ -1312,10 +1313,11 @@ fn op_flash_wait_for_listening( #[op] fn op_flash_drive_server( - state: &mut OpState, + state: Rc<RefCell<OpState>>, server_id: u32, ) -> Result<impl Future<Output = Result<(), AnyError>> + 'static, AnyError> { let join_handle = { + let mut state = state.borrow_mut(); let flash_ctx = state.borrow_mut::<FlashContext>(); flash_ctx .join_handles |