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
  • Loading branch information
jasnell committed Jan 24, 2021
1 parent dbdc14b commit d205e50
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/node_blob.cc
Expand Up @@ -255,7 +255,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 +313,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 d205e50

Please sign in to comment.