Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buffer: avoid creating the backing store in the thread #37052

Merged
merged 1 commit into from Jan 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/node_blob.cc
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