-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
src: use std::list for at_exit_functions #12255
Conversation
src/node.cc
Outdated
void (*cb_)(void* arg); | ||
void* arg_; | ||
}; | ||
|
||
static AtExitCallback* at_exit_functions_; | ||
static std::list<AtExitCallback*> at_exit_functions_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use AtExitCallback
not a pointer-to-AtExitCallback
. It's leaking memory now in RunAtExit()
.
(Tiny nit: it should really be called at_exit_functions
, it's not a class member.)
src/node.cc
Outdated
p->cb_(p->arg_); | ||
delete p; | ||
p = q; | ||
for (AtExitCallback* atExit : at_exit_functions_) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: at_exit
src/node.cc
Outdated
p->cb_ = cb; | ||
p->arg_ = arg; | ||
at_exit_functions_.push_back(p); | ||
AtExitCallback p = {cb, arg}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, maybe call this at_exit
for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah good point, will change that. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is using an anonymous object something considered ok to do?
at_exit_functions.push_back(AtExitCallback{cb, arg});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's fine.
This change was suggested by bnoordhuis in the following comment: nodejs#9163 (comment) Not including any tests as this is covered by test/addons/at-exit.
This change was suggested by bnoordhuis in the following comment: nodejs#9163 (comment) Not including any tests as this is covered by test/addons/at-exit. PR-URL: nodejs#12255 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Landed in fe016c6 |
This change was suggested by bnoordhuis in the following comment: nodejs#9163 (comment) Not including any tests as this is covered by test/addons/at-exit. PR-URL: nodejs#12255 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Should this be cherry-picked to v6.x? It lands cleanly fwiw |
@MylesBorins Not sure as it is a minor improvement, but if it lands cleanly I see no harm in that. Let me know if you'd like me to create a PR against v6.x-staging. Thanks |
This change was suggested by bnoordhuis in the following comment: #9163 (comment) Not including any tests as this is covered by test/addons/at-exit. PR-URL: #12255 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This change was suggested by bnoordhuis in the following comment: nodejs/node#9163 (comment) Not including any tests as this is covered by test/addons/at-exit. PR-URL: nodejs/node#12255 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This change was suggested by bnoordhuis in the following comment:
#9163 (comment)
Not including any tests as this is covered by test/addons/at-exit.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
src