summaryrefslogtreecommitdiff
path: root/src/node_errors.cc
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2019-01-01 13:56:53 +0800
committerAnna Henningsen <anna@addaleax.net>2019-01-08 00:28:16 +0100
commit9db9e7e541c1ff9a30b7f1b61c6d3a7b6d30fab3 (patch)
treef16cfd671dd32467ae0cc221335118733c09030a /src/node_errors.cc
parentae2d1f0e05449221ee770a393e5c967b359d9b1b (diff)
downloadandroid-node-v8-9db9e7e541c1ff9a30b7f1b61c6d3a7b6d30fab3.tar.gz
android-node-v8-9db9e7e541c1ff9a30b7f1b61c6d3a7b6d30fab3.tar.bz2
android-node-v8-9db9e7e541c1ff9a30b7f1b61c6d3a7b6d30fab3.zip
src: move per-process global variables into node::per_process
So that it's easier to tell whether we are manipulating per-process global states that may need to be treated with care to avoid races. Also added comments about these variables and moved some of them to a more suitable compilation unit: - Move `v8_initialized` to `util.h` since it's only used in `util.cc` and `node.cc` - Rename `process_mutex` to `tty_mutex` and move it into `node_errors.cc` since that's the only place it's used to guard the tty. - Move `per_process_opts_mutex` and `per_process_opts` into `node_options.h` and rename them to `per_process::cli_options[_mutex]` - Rename `node_isolate[_mutex]` to `per_process::main_isolate[_mutex]` PR-URL: https://github.com/nodejs/node/pull/25302 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'src/node_errors.cc')
-rw-r--r--src/node_errors.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/node_errors.cc b/src/node_errors.cc
index 7775e36b69..9ffd8d88f1 100644
--- a/src/node_errors.cc
+++ b/src/node_errors.cc
@@ -35,6 +35,10 @@ bool IsExceptionDecorated(Environment* env, Local<Value> er) {
return false;
}
+namespace per_process {
+static Mutex tty_mutex;
+} // namespace per_process
+
void AppendExceptionLine(Environment* env,
Local<Value> er,
Local<Message> message,
@@ -137,7 +141,7 @@ void AppendExceptionLine(Environment* env,
// by the caller.
if (!can_set_arrow || (mode == FATAL_ERROR && !err_obj->IsNativeError())) {
if (env->printed_error()) return;
- Mutex::ScopedLock lock(process_mutex);
+ Mutex::ScopedLock lock(per_process::tty_mutex);
env->set_printed_error(true);
uv_tty_reset_mode();