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: nodejs#37030

PR-URL: nodejs#37052
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
jasnell authored and targos committed Aug 13, 2021
1 parent 2dd9467 commit add1067
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 @@ -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;
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit add1067

Please sign in to comment.