FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

src: properly manage timer in cares ChannelWrap by addaleax · Pull Request #14634 · nodejs/node · GitHub

/ node Public

src: properly manage timer in cares ChannelWrap - #14634

Closed
addaleax wants to merge 5 commits into
nodejs:masterfrom
addaleax:cares-fix-timer
Closed

src: properly manage timer in cares ChannelWrap#14634
addaleax wants to merge 5 commits into
nodejs:masterfrom
addaleax:cares-fix-timer

Conversation

addaleax commented Aug 4, 2017

Copy link
Copy Markdown
Member

This fixes a bug introduced in 727b291 where code managing the uv_timer_t for a ChannelWrap instance was left unchanged, when it should have changed the lifetime of the handle to being tied to the ChannelWrap instance’s lifetime.

Fixes: #14599
Ref: #14518

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included (eeeeh … in the form of an existing test that was flaky)
  • commit message follows commit guidelines
Affected core subsystem(s)

src/cares_wrap

This fixes a bug introduced in 727b291
where code managing the `uv_timer_t` for a `ChannelWrap` instance was
left unchanged, when it should have changed the lifetime of the handle
to being tied to the `ChannelWrap` instance’s lifetime.

Fixes: nodejs#14599
Ref: nodejs#14518
addaleax requested a review from XadillaX August 4, 2017 19:01
nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. cares Issues and PRs related to the c-ares dependency or the cares_wrap binding. labels Aug 4, 2017

addaleax commented Aug 4, 2017
edited
Loading

Copy link
Copy Markdown
Member Author

CI: https://ci.nodejs.org/job/node-test-commit/11555/ (edit: green except infra failure)
Stress master: https://ci.nodejs.org/job/node-stress-single-test/1358/ (edit: red, 245/1000 failed)
Stress this PR: https://ci.nodejs.org/job/node-stress-single-test/1359/ (edit: green, 0/1000 failed)

It would be cool to have this in 8.3.0, this fixes a real crash.

edit: I won’t be here for most of the weekend, please feel free to fix any change requests yourself

mscdex commented Aug 4, 2017

Copy link
Copy Markdown
Contributor

Is it possible to add a test?

mscdex added the timers Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout. label Aug 4, 2017

addaleax commented Aug 4, 2017

Copy link
Copy Markdown
Member Author

@mscdex I don’t think that would be any more or less reliable than the existing failing test.

Also, this isn’t about the set* globals/the timers core module that the label is for, so I think that can be removed?

Trott commented Aug 5, 2017

Copy link
Copy Markdown
Member

Given the frequency of crashes in CI on test-async-wrap-getasyncid, it would be great to fast-track this. But of course, first it needs some reviews... 📟 @bnoordhuis @trevnorris @indutny

refack commented Aug 5, 2017

Copy link
Copy Markdown
Contributor

+1 to fast track after it gets a review from the aforementioned

indutny left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM with minor nits.

Comment thread src/cares_wrap.cc
ares_destroy(channel_);
CleanupTimer();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Double newline here, please.

Comment thread src/cares_wrap.cc

uv_close(reinterpret_cast<uv_handle_t*>(timer_handle_),
[](uv_handle_t* handle) {
delete reinterpret_cast<uv_timer_t*>(handle);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Not absolutely necessary, but doing handle->data = NULL prior to this may help in the future.

refack commented Aug 5, 2017

Copy link
Copy Markdown
Contributor

Comment thread src/cares_wrap.cc Outdated

uv_close(reinterpret_cast<uv_handle_t*>(timer_handle_),
[](uv_handle_t* handle) {
handle->data = NULL;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yikes, nullptr 😉 Sorry!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Sorry I'm doing this "blind" on the GitHub GUI.

refack commented Aug 5, 2017
edited
Loading

Copy link
Copy Markdown
Contributor

refack commented Aug 5, 2017

Copy link
Copy Markdown
Contributor

ARM fail is #14206
So CI & stress are ✔️

XadillaX left a comment
edited
Loading

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM. But IMHO why don't we use CARE's own timeout?

Refs: c-ares/c-ares#135 (comment)

addaleax commented Aug 7, 2017

Copy link
Copy Markdown
Member Author

@XadillaX As far as I can tell, c-ares is not involved in actually creating timers in any way.

bnoordhuis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM modulo nits.

Comment thread src/cares_wrap.cc Outdated


void ChannelWrap::CleanupTimer() {
if (!timer_handle_) return;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

if (timer_handle_ == nullptr) return;

Comment thread src/cares_wrap.cc Outdated

uv_close(reinterpret_cast<uv_handle_t*>(timer_handle_),
[](uv_handle_t* handle) {
handle->data = nullptr;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Dead store; the memory is deleted immediately afterwards.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Right, this was requested by @indutny and added by @refack. If they had any particular reason for that, please speak up, but I’ve removed it again for now.

addaleax mentioned this pull request Aug 7, 2017

addaleax commented Aug 7, 2017

Copy link
Copy Markdown
Member Author

Landed in 41a0dfc

addaleax closed this Aug 7, 2017
addaleax deleted the cares-fix-timer branch August 7, 2017 11:59
addaleax added a commit that referenced this pull request Aug 7, 2017
This fixes a bug introduced in 727b291
where code managing the `uv_timer_t` for a `ChannelWrap` instance was
left unchanged, when it should have changed the lifetime of the handle
to being tied to the `ChannelWrap` instance’s lifetime.

Fixes: #14599
Ref: #14518
PR-URL: #14634
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
addaleax added a commit that referenced this pull request Aug 7, 2017
This fixes a bug introduced in 727b291
where code managing the `uv_timer_t` for a `ChannelWrap` instance was
left unchanged, when it should have changed the lifetime of the handle
to being tied to the `ChannelWrap` instance’s lifetime.

Fixes: #14599
Ref: #14518
PR-URL: #14634
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
MylesBorins added lts-watch-v6.x baking-for-lts PRs that need to wait before landing in a LTS release. labels Aug 16, 2017
MylesBorins removed the baking-for-lts PRs that need to wait before landing in a LTS release. label Aug 17, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. cares Issues and PRs related to the c-ares dependency or the cares_wrap binding. timers Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test/parallel/test-async-wrap-getasyncid.js crashing

Back | FazBrowse Home | New Git URL