Skip to content

Commit

Permalink
buffer: avoid creating the backing store in the thread
Browse files Browse the repository at this point in the history
Fixes: #37030

PR-URL: #37052
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
jasnell authored and targos committed Feb 2, 2021
1 parent 55407b8 commit e4b88b5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/node_blob.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,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;
Expand Down Expand Up @@ -314,6 +312,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();

Expand Down

0 comments on commit e4b88b5

Please sign in to comment.