diff options
author | James M Snell <jasnell@gmail.com> | 2021-01-24 21:00:57 +0300 |
---|---|---|
committer | Myles Borins <mylesborins@github.com> | 2021-08-31 17:55:07 +0300 |
commit | 8484ab2a6c9f90ca3b1795fbe75bf32beabdffcb (patch) | |
tree | 8db54038a0632aa96e8218ba002df45d15c27684 /src | |
parent | bad990c934871c4a5e91dec7dc902741e580e415 (diff) |
buffer: avoid creating the backing store in the thread
Fixes: https://github.com/nodejs/node/issues/37030
PR-URL: https://github.com/nodejs/node/pull/37052
Backport-PR-URL: https://github.com/nodejs/node/pull/39704
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/node_blob.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/node_blob.cc b/src/node_blob.cc index d227ec58223..aaea61fb653 100644 --- a/src/node_blob.cc +++ b/src/node_blob.cc @@ -253,8 +253,6 @@ void FixedSizeBlobCopyJob::AfterThreadPoolWork(int status) { } void FixedSizeBlobCopyJob::DoThreadPoolWork() { - Environment* env = AsyncWrap::env(); - destination_ = ArrayBuffer::NewBackingStore(env->isolate(), length_); unsigned char* dest = static_cast<unsigned char*>(destination_->Data()); if (length_ > 0) { size_t total = 0; @@ -313,6 +311,8 @@ void FixedSizeBlobCopyJob::Run(const FunctionCallbackInfo<Value>& args) { Environment* env = Environment::GetCurrent(args); FixedSizeBlobCopyJob* job; ASSIGN_OR_RETURN_UNWRAP(&job, args.Holder()); + job->destination_ = + ArrayBuffer::NewBackingStore(env->isolate(), job->length_); if (job->mode() == FixedSizeBlobCopyJob::Mode::ASYNC) return job->ScheduleWork(); |