From 67643e1c2ecc380a0d92550eb7ce2d283c8c6184 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sun, 13 Dec 2020 21:43:40 +0100 Subject: worker: fix broadcast channel SharedArrayBuffer passing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make sure that `SharedArrayBuffer`s can be deserialized on multiple receiving ends. As a drive-by, also fix the condition of the internal assertion that should occur if there are transferables passed to multiple destinations. PR-URL: https://github.com/nodejs/node/pull/36501 Reviewed-By: Michaƫl Zasso Reviewed-By: Gus Caplan Reviewed-By: James M Snell --- src/node_messaging.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/node_messaging.cc') diff --git a/src/node_messaging.cc b/src/node_messaging.cc index 03c6d5aaa76..5f054c41c8e 100644 --- a/src/node_messaging.cc +++ b/src/node_messaging.cc @@ -157,8 +157,7 @@ MaybeLocal Message::Deserialize(Environment* env, // Attach all transferred SharedArrayBuffers to their new Isolate. for (uint32_t i = 0; i < shared_array_buffers_.size(); ++i) { Local sab = - SharedArrayBuffer::New(env->isolate(), - std::move(shared_array_buffers_[i])); + SharedArrayBuffer::New(env->isolate(), shared_array_buffers_[i]); shared_array_buffers.push_back(sab); } @@ -1309,7 +1308,7 @@ Maybe SiblingGroup::Dispatch( // Transferables cannot be used when there is more // than a single destination. - if (size() > 2 && message->transferables().size()) { + if (size() > 2 && message->has_transferables()) { if (error != nullptr) *error = "Transferables cannot be used with multiple destinations."; return Nothing(); -- cgit v1.2.3