summaryrefslogtreecommitdiff
path: root/src/env.cc
AgeCommit message (Collapse)Author
2017-08-11src: remove duplicate loopAnna Henningsen
Two identical `while` loops after each other can be folded into a single one. PR-URL: https://github.com/nodejs/node/pull/14750 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Khaidi Chu <i@2333.moe>
2017-08-10src: add overlooked handle to cleanupAnna Henningsen
The `Environment::destroy_ids_timer_handle` should be cleaned up by `Environment::CleanupHandles()`. Fix that by adding it to the list. This partially fixes a cctest. Ref: https://github.com/nodejs/node/issues/14206 PR-URL: https://github.com/nodejs/node/pull/14749 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2017-06-16async_hooks: proper id stacking for PromisesAnna Henningsen
Until now, the async_hooks PromiseHook did not register the Promise’s async id and trigger id on the id stack, so inside the `.then()` handler those ids would be invalid. To fix this, add push and pop calls to its `before` and `after` parts, respectively. Some care needs to be taken for the cases that the Promise hook is being disabled or enabled during the execution of a Promise handler; in the former case, actually removing the hook is delayed by adding another task to the microtask queue, in the latter case popping the id off the async id stack is skipped if the ids don’t match. Fixes: https://github.com/nodejs/node/issues/13583 PR-URL: https://github.com/nodejs/node/pull/13585 Reviewed-By: Trevor Norris <trevnorris@gmail.com>
2017-06-10async_wrap: expose enable/disablePromiseHook APIAnna Henningsen
Allow node::PromiseHook (src/async-wrap.cc) to be enabled/disabled from the JavaScript API. PR-URL: https://github.com/nodejs/node/pull/13509 Reviewed-By: Andreas Madsen <amwebdk@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-06-02async_wrap: run destroy in uv_timer_tTrevor Norris
Calling the destroy callbacks in a uv_idle_t causes a timing issue where if a handle or request is closed then the class isn't deleted until uv_close() callbacks are called (which happens after the poll phase). This results in some destroy callbacks not being called just before the application exits. So instead switch the destroy callbacks to be called in a uv_timer_t with the timeout set to zero. When uv_run() is called with UV_RUN_ONCE the final operation of the event loop is to process all remaining timers. By setting the timeout to zero it results in the destroy callbacks being processed after uv_close() but before uv_run() returned. Processing the destroyed ids that were previously missed. Also, process the destroy_ids_list() in a do {} while() loop that makes sure the vector is empty before returning. Which also makes running clear() unnecessary. Fixes: https://github.com/nodejs/node/issues/13262 PR-URL: https://github.com/nodejs/node/pull/13369 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
2017-04-27src: expose `node::AddPromiseHook`Anna Henningsen
Expose `node::AddPromiseHook`, which wraps V8’s `SetPromiseHook` in a way that allows multiple hooks to be set up. PR-URL: https://github.com/nodejs/node/pull/12489 Reviewed-By: Matthew Loring <mattloring@google.com> Reviewed-By: Julien Gilli <jgilli@nodejs.org> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-04-19src: don't call uv_run() after 'exit' eventBen Noordhuis
It makes timers and other libuv handles fire intermittently after the 'exit' event, contrary to what the documentation states. Regression introduced in commit aac79df ("src: use stack-allocated Environment instances") from June last year that made the `while (handle_cleanup_waiting_ != 0) uv_run(event_loop(), UV_RUN_ONCE)` loop run unconditionally on exit because it merged CleanupHandles() into the Environment destructor. This change breaks parallel/test-async-wrap-throw-from-callback because the async_wrap idle handle is no longer cleaned up, which I resolved pragmatically by removing the test. In all seriousness, it is being removed in the upcoming async_wrap revamp - it doesn't make sense to sink a lot of time in it now. Fixes: https://github.com/nodejs/node/issues/12322 PR-URL: https://github.com/nodejs/node/pull/12344 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-04-12src: make AtExit callback's per EnvironmentDaniel Bevenius
This commit attempts to address one of the TODOs in https://github.com/nodejs/node/issues/4641 regarding making the AtExit callback's per environment, instead of the current global. bnoordhuis provided a few options for solving this, and one was to use a thread-local which is what this commit attempts to do. PR-URL: https://github.com/nodejs/node/pull/9163 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
2016-12-01async_wrap: call destroy() callback in uv_idle_tTrevor Norris
Calling JS during GC is a no-no. So intead create a queue of all ids that need to have their destroy() callback called and call them later. Removed checking destroy() in test-async-wrap-uid because destroy() can be called after the 'exit' callback. Missing a reliable test to reproduce the issue that caused the FATAL_ERROR. PR-URL: https://github.com/nodejs/node/pull/9753 Fixes: https://github.com/nodejs/node/issues/8216 Fixes: https://github.com/nodejs/node/issues/9465 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-10-24src: clean up program/isolate/env init logicBen Noordhuis
Reorder the initialization logic so that program-wide, per-isolate and per-environment initialization is more cleanly separated. PR-URL: https://github.com/nodejs/node/pull/9224 Reviewed-By: James M Snell <jasnell@gmail.com>
2016-08-08src: remove unused using declsHaojian Wu
PR-URL: https://github.com/nodejs/node/pull/7990 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yorkie Liu <yorkiefixer@gmail.com>
2016-06-02src: move env init logic into Environment classBen Noordhuis
PR-URL: https://github.com/nodejs/node/pull/7090 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2016-04-25src: fix check-imports.py linter errorsSakthipriyan Vairamani
This patch fixes all the linter errors. PR-URL: https://github.com/nodejs/node/pull/6105 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2016-03-28src,http_parser: remove KickNextTick callTrevor Norris
Now that HTTPParser uses MakeCallback it is unnecessary to manually process the nextTickQueue. The KickNextTick function is now no longer needed so code has moved back to node::MakeCallback to simplify implementation. Include minor cleanup moving Environment::tick_info() call below the early return to save an operation. PR-URL: https://github.com/nodejs/node/pull/5756 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
2016-02-12src: remove TryCatch in MakeCallbackTrevor Norris
After attempting to use ReThrow() and Reset() there were cases where firing the domain's error handlers was not happening. Or in some cases reentering MakeCallback would still cause the domain enter callback to abort (because the error had not been Reset yet). In order for the script to properly stop execution when a subsequent call to MakeCallback throws it must not be located within a TryCatch. PR-URL: https://github.com/nodejs/node/pull/4507 Reviewed-By: Fedor Indutny <fedor@indutny.com>
2016-02-12src: remove unused of TickInfo::last_threw()Trevor Norris
Environment::TickInfo::last_threw() is no longer in use. Also pass Isolate to few methods and fix whitespace alignment. PR-URL: https://github.com/nodejs/node/pull/4507 Reviewed-By: Fedor Indutny <fedor@indutny.com>
2016-02-12src: add AsyncCallbackScopeTrevor Norris
Add a scope that will allow MakeCallback to know whether or not it's currently running. This will prevent nextTickQueue and the MicrotaskQueue from being processed recursively. It is also required to wrap the bootloading stage since it doesn't run within a MakeCallback. Ref: https://github.com/nodejs/node-v0.x-archive/issues/9245 PR-URL: https://github.com/nodejs/node/pull/4507 Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-12-03src: define getpid() based on OScjihrig
94b9948 added unistd.h to src/env.cc in order to use getpid(). However, this doesn't exist on Windows. This commit conditionally defines getpid() based on the OS. Fixes: https://github.com/nodejs/node/issues/4145 PR-URL: https://github.com/nodejs/node/pull/4146 Reviewed-By: Brian White <mscdex@mscdex.net>
2015-12-03lib,src: ensure '(node:pid)' prefix for stdout loggingMinwoo Jung
Add '(node:pid)' prefix message for stdout logging PR-URL: https://github.com/nodejs/node/pull/3833 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com>
2015-08-26env: introduce `KickNextTick`Fedor Indutny
There might be a need to "kick off" the next tick queue and execute events on it. Normally it is done through the `MakeCallback` interface, but in case when it is not - we need a way to "kick them off" manually. PR-URL: https://github.com/nodejs/node/pull/2355 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-05-18core: implement runtime flag to trace sync ioTrevor Norris
Use the --trace-sync-io flag to print a stack trace whenever a sync method is used after the first tick, excluding during the process exit event. (e.g. fs.readFileSync()) It does not track if the warning has occurred at a specific location in the past and so will print the warning every time. Reason for not printing during the first tick of the appication is so all necessary resources can be required. Also by excluding synchronous calls during exit is necessary in case any data needs to be logged out by the application before it shuts down. Fixes: https://github.com/nodejs/io.js/issues/1674 PR-URL: https://github.com/nodejs/io.js/pull/1707 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Petka Antonov <petka_antonov@hotmail.com>