async_wrap: clear destroy_ids vector #10400

Merged
merged 1 commit into from Dec 22, 2016

Projects

None yet

4 participants

@trevnorris
Contributor
trevnorris commented Dec 21, 2016 edited
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

async_wrap

Description of change

After processing all the callbacks in the destroy_ids vector make sure
to clear() it otherwise the DestroyIdsCb() won't run again.

This patch should land on all releases that have b49b496, or some cherry-pick of it.

CI: https://ci.nodejs.org/job/node-test-commit/6782/

@trevnorris trevnorris requested review from bnoordhuis and addaleax Dec 21, 2016
@trevnorris
Contributor

All failing AIX tests not related to this change.

@bnoordhuis

Left a suggestion but LGTM either way.

@@ -212,6 +212,8 @@ void AsyncWrap::DestroyIdsCb(uv_idle_t* handle) {
FatalException(env->isolate(), try_catch);
}
}
+
+ env->destroy_ids_list()->clear();
@bnoordhuis
bnoordhuis Dec 22, 2016 Member

Can I suggest you swap before iteration? I.e.:

std::vector<int64_t> destroy_ids_list;
destroy_ids_list.swap(*env->destroy_ids_list());
for (auto current_id : destroy_ids_list) {
  // ...
}

That way the list is both cleared and immune to concurrent modification by the callback.

@trevnorris
trevnorris Dec 22, 2016 Contributor

done

@addaleax

LGTM with Ben’s suggestion

@trevnorris trevnorris async_wrap: clear destroy_ids vector
After processing all the callbacks in the destroy_ids vector make sure
to clear() it otherwise the DestroyIdsCb() won't run again.

PR-URL: nodejs#10400
Fixes: b49b496 "async_wrap: call destroy() callback in uv_idle_t"
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
833294f
@trevnorris trevnorris merged commit 833294f into nodejs:master Dec 22, 2016
@trevnorris trevnorris added a commit that referenced this pull request Dec 22, 2016
@trevnorris trevnorris async_wrap: clear destroy_ids vector
After processing all the callbacks in the destroy_ids vector make sure
to clear() it otherwise the DestroyIdsCb() won't run again.

PR-URL: #10400
Fixes: b49b496 "async_wrap: call destroy() callback in uv_idle_t"
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
81a6dd5
@trevnorris
Contributor
trevnorris commented Dec 22, 2016 edited

Thank you. Merged, and landed on v7.x-staging in 81a6dd5.

@TheAlphaNerd This should land in v6.x before the next release, if possible. I'll wait until this lands on v6, then prep both this and #9174 for v4.

@joyeecheung joyeecheung added a commit to joyeecheung/node that referenced this pull request Jan 2, 2017
@trevnorris @joyeecheung trevnorris + joyeecheung async_wrap: clear destroy_ids vector
After processing all the callbacks in the destroy_ids vector make sure
to clear() it otherwise the DestroyIdsCb() won't run again.

PR-URL: nodejs#10400
Fixes: b49b496 "async_wrap: call destroy() callback in uv_idle_t"
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
732a1ad
@evanlucas evanlucas referenced this pull request Jan 3, 2017
Merged

v7.4.0 release proposal #10589

@evanlucas evanlucas added a commit that referenced this pull request Jan 3, 2017
@trevnorris @evanlucas trevnorris + evanlucas async_wrap: clear destroy_ids vector
After processing all the callbacks in the destroy_ids vector make sure
to clear() it otherwise the DestroyIdsCb() won't run again.

PR-URL: #10400
Fixes: b49b496 "async_wrap: call destroy() callback in uv_idle_t"
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
d1843ec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment