summaryrefslogtreecommitdiff
path: root/lib/internal
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-02-01 23:47:38 +0100
committerAnna Henningsen <anna@addaleax.net>2019-02-05 21:55:54 +0100
commit39eca841c30e1a54424b85f34e8dd56b2648f930 (patch)
tree2ab9c7bc285e20f85cefff16c6441c726bbed126 /lib/internal
parent8d63f4037e52eda125c5a70dafa602f47c13d0ad (diff)
downloadandroid-node-v8-39eca841c30e1a54424b85f34e8dd56b2648f930.tar.gz
android-node-v8-39eca841c30e1a54424b85f34e8dd56b2648f930.tar.bz2
android-node-v8-39eca841c30e1a54424b85f34e8dd56b2648f930.zip
src: split ownsProcessState off isMainThread
Embedders may want to control whether a Node.js instance controls the current process, similar to what we currently have with `Worker`s. Previously, the `isMainThread` flag had a bit of a double usage, both for indicating whether we are (not) running a Worker and whether we can modify per-process state. PR-URL: https://github.com/nodejs/node/pull/25881 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/internal')
-rw-r--r--lib/internal/bootstrap/node.js6
-rw-r--r--lib/internal/worker.js8
2 files changed, 8 insertions, 6 deletions
diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js
index 915d07d83d..358c4cb8c7 100644
--- a/lib/internal/bootstrap/node.js
+++ b/lib/internal/bootstrap/node.js
@@ -14,7 +14,7 @@
// This file is compiled as if it's wrapped in a function with arguments
// passed by node::LoadEnvironment()
-/* global process, loaderExports, isMainThread */
+/* global process, loaderExports, isMainThread, ownsProcessState */
const { internalBinding, NativeModule } = loaderExports;
@@ -51,7 +51,7 @@ const perThreadSetup = NativeModule.require('internal/process/per_thread');
let mainThreadSetup;
// Bootstrappers for the worker threads only
let workerThreadSetup;
-if (isMainThread) {
+if (ownsProcessState) {
mainThreadSetup = NativeModule.require(
'internal/process/main_thread_only'
);
@@ -140,7 +140,7 @@ if (credentials.implementsPosixCredentials) {
process.getegid = credentials.getegid;
process.getgroups = credentials.getgroups;
- if (isMainThread) {
+ if (ownsProcessState) {
const wrapped = mainThreadSetup.wrapPosixCredentialSetters(credentials);
process.initgroups = wrapped.initgroups;
process.setgroups = wrapped.setgroups;
diff --git a/lib/internal/worker.js b/lib/internal/worker.js
index f28f4cd663..1d1a5e7d22 100644
--- a/lib/internal/worker.js
+++ b/lib/internal/worker.js
@@ -30,9 +30,10 @@ const { deserializeError } = require('internal/error-serdes');
const { pathToFileURL } = require('url');
const {
- Worker: WorkerImpl,
+ ownsProcessState,
+ isMainThread,
threadId,
- isMainThread
+ Worker: WorkerImpl,
} = internalBinding('worker');
const kHandle = Symbol('kHandle');
@@ -243,7 +244,8 @@ function pipeWithoutWarning(source, dest) {
}
module.exports = {
+ ownsProcessState,
+ isMainThread,
threadId,
Worker,
- isMainThread
};