src: move process.binding('signal_wrap') to internalBinding
PR-URL: https://github.com/nodejs/node/pull/22290 Refs: https://github.com/nodejs/node/issues/22160 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
884b23daf7
commit
0bdb95f4cf
@ -67,7 +67,7 @@
|
|||||||
perThreadSetup.setupConfig(NativeModule._source);
|
perThreadSetup.setupConfig(NativeModule._source);
|
||||||
|
|
||||||
if (isMainThread) {
|
if (isMainThread) {
|
||||||
mainThreadSetup.setupSignalHandlers();
|
mainThreadSetup.setupSignalHandlers(internalBinding);
|
||||||
}
|
}
|
||||||
|
|
||||||
perThreadSetup.setupUncaughtExceptionCapture(exceptionHandlerState,
|
perThreadSetup.setupUncaughtExceptionCapture(exceptionHandlerState,
|
||||||
@ -349,7 +349,8 @@
|
|||||||
'uv',
|
'uv',
|
||||||
'http_parser',
|
'http_parser',
|
||||||
'v8',
|
'v8',
|
||||||
'stream_wrap']);
|
'stream_wrap',
|
||||||
|
'signal_wrap']);
|
||||||
process.binding = function binding(name) {
|
process.binding = function binding(name) {
|
||||||
return internalBindingWhitelist.has(name) ?
|
return internalBindingWhitelist.has(name) ?
|
||||||
internalBinding(name) :
|
internalBinding(name) :
|
||||||
|
@ -117,7 +117,7 @@ function setupPosixMethods(_initgroups, _setegid, _seteuid,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Worker threads don't receive signals.
|
// Worker threads don't receive signals.
|
||||||
function setupSignalHandlers() {
|
function setupSignalHandlers(internalBinding) {
|
||||||
const constants = process.binding('constants').os.signals;
|
const constants = process.binding('constants').os.signals;
|
||||||
const signalWraps = Object.create(null);
|
const signalWraps = Object.create(null);
|
||||||
let Signal;
|
let Signal;
|
||||||
@ -130,7 +130,7 @@ function setupSignalHandlers() {
|
|||||||
process.on('newListener', function(type) {
|
process.on('newListener', function(type) {
|
||||||
if (isSignal(type) && signalWraps[type] === undefined) {
|
if (isSignal(type) && signalWraps[type] === undefined) {
|
||||||
if (Signal === undefined)
|
if (Signal === undefined)
|
||||||
Signal = process.binding('signal_wrap').Signal;
|
Signal = internalBinding('signal_wrap').Signal;
|
||||||
const wrap = new Signal();
|
const wrap = new Signal();
|
||||||
|
|
||||||
wrap.unref();
|
wrap.unref();
|
||||||
|
@ -128,4 +128,4 @@ class SignalWrap : public HandleWrap {
|
|||||||
} // namespace node
|
} // namespace node
|
||||||
|
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(signal_wrap, node::SignalWrap::Initialize)
|
NODE_MODULE_CONTEXT_AWARE_INTERNAL(signal_wrap, node::SignalWrap::Initialize)
|
||||||
|
@ -10,3 +10,4 @@ assert(process.binding('uv'));
|
|||||||
assert(process.binding('http_parser'));
|
assert(process.binding('http_parser'));
|
||||||
assert(process.binding('v8'));
|
assert(process.binding('v8'));
|
||||||
assert(process.binding('stream_wrap'));
|
assert(process.binding('stream_wrap'));
|
||||||
|
assert(process.binding('signal_wrap'));
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
|
// Flags: --expose-internals
|
||||||
'use strict';
|
'use strict';
|
||||||
require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const Signal = process.binding('signal_wrap').Signal;
|
const { internalBinding } = require('internal/test/binding');
|
||||||
|
const { Signal } = internalBinding('signal_wrap');
|
||||||
|
|
||||||
// Test Signal `this` safety
|
// Test Signal `this` safety
|
||||||
// https://github.com/joyent/node/issues/6690
|
// https://github.com/joyent/node/issues/6690
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
// Flags: --expose-gc --expose-internals
|
// Flags: --expose-gc --expose-internals --no-warnings
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const { internalBinding } = require('internal/test/binding');
|
const { internalBinding } = require('internal/test/binding');
|
||||||
@ -187,7 +187,7 @@ if (common.hasCrypto) { // eslint-disable-line node-core/crypto-check
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const Signal = process.binding('signal_wrap').Signal;
|
const { Signal } = internalBinding('signal_wrap');
|
||||||
testInitialized(new Signal(), 'Signal');
|
testInitialized(new Signal(), 'Signal');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user