summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2019-03-24 16:07:10 +0100
committerRyan Dahl <ry@tinyclouds.org>2019-03-24 11:07:10 -0400
commit129eae0265e3bd93c26c272d253ae9cbc6b88991 (patch)
treefd73a20f04e7a39e0d2b57144b1b8ffefd5b05ac
parentefe9c18b459dbec71b213e8dc87e2e1b02477139 (diff)
Handle overflown shared queue (#1992)
Fixes #1988
-rw-r--r--core/isolate.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/core/isolate.rs b/core/isolate.rs
index 6bf134536..43fa4854a 100644
--- a/core/isolate.rs
+++ b/core/isolate.rs
@@ -430,6 +430,9 @@ impl<B: Behavior> Future for Isolate<B> {
// there wasn't enough size, we will return the buffer via the
// legacy route, using the argument of deno_respond.
overflow_response = Some(buf);
+ // reset `polled_recently` so pending ops can be
+ // done even if shared space overflows
+ self.polled_recently = false;
break;
}
@@ -896,6 +899,35 @@ mod tests {
}
#[test]
+ fn overflow_res_multiple_dispatch_async() {
+ // TODO(ry) This test is quite slow due to memcpy-ing 100MB into JS. We
+ // should optimize this.
+ let mut isolate = TestBehavior::setup(TestBehaviorMode::OverflowResAsync);
+ js_check(isolate.execute(
+ "overflow_res_multiple_dispatch_async.js",
+ r#"
+ let asyncRecv = 0;
+ DenoCore.setAsyncHandler((buf) => {
+ assert(buf.byteLength === 100 * 1024 * 1024);
+ assert(buf[0] === 4);
+ asyncRecv++;
+ });
+ // Large message that will overflow the shared space.
+ let control = new Uint8Array([42]);
+ let response = DenoCore.dispatch(control);
+ assert(response == null);
+ assert(asyncRecv == 0);
+ // Dispatch another message to verify that pending ops
+ // are done even if shared space overflows
+ DenoCore.dispatch(control);
+ "#,
+ ));
+ assert_eq!(isolate.behavior.dispatch_count, 2);
+ assert_eq!(Ok(Async::Ready(())), isolate.poll());
+ js_check(isolate.execute("check.js", "assert(asyncRecv == 2);"));
+ }
+
+ #[test]
fn test_js() {
let mut isolate = TestBehavior::setup(TestBehaviorMode::AsyncImmediate);
js_check(