Skip to content

Commit

Permalink
src: move process.binding('signal_wrap') to internalBinding
Browse files Browse the repository at this point in the history
  • Loading branch information
jasnell committed Aug 19, 2018
1 parent 884b23d commit 5436dfd
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
5 changes: 3 additions & 2 deletions lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
perThreadSetup.setupConfig(NativeModule._source);

if (isMainThread) {
mainThreadSetup.setupSignalHandlers();
mainThreadSetup.setupSignalHandlers(internalBinding);
}

perThreadSetup.setupUncaughtExceptionCapture(exceptionHandlerState,
Expand Down Expand Up @@ -349,7 +349,8 @@
'uv',
'http_parser',
'v8',
'stream_wrap']);
'stream_wrap',
'signal_wrap']);
process.binding = function binding(name) {
return internalBindingWhitelist.has(name) ?
internalBinding(name) :
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/process/main_thread_only.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function setupPosixMethods(_initgroups, _setegid, _seteuid,
}

// Worker threads don't receive signals.
function setupSignalHandlers() {
function setupSignalHandlers(internalBinding) {
const constants = process.binding('constants').os.signals;
const signalWraps = Object.create(null);
let Signal;
Expand All @@ -130,7 +130,7 @@ function setupSignalHandlers() {
process.on('newListener', function(type) {
if (isSignal(type) && signalWraps[type] === undefined) {
if (Signal === undefined)
Signal = process.binding('signal_wrap').Signal;
Signal = internalBinding('signal_wrap').Signal;
const wrap = new Signal();

wrap.unref();
Expand Down
2 changes: 1 addition & 1 deletion src/signal_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@ class SignalWrap : public HandleWrap {
} // namespace node


NODE_BUILTIN_MODULE_CONTEXT_AWARE(signal_wrap, node::SignalWrap::Initialize)
NODE_MODULE_CONTEXT_AWARE_INTERNAL(signal_wrap, node::SignalWrap::Initialize)
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ assert(process.binding('uv'));
assert(process.binding('http_parser'));
assert(process.binding('v8'));
assert(process.binding('stream_wrap'));
assert(process.binding('signal_wrap'));
4 changes: 3 additions & 1 deletion test/parallel/test-signal-safety.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Flags: --expose-internals
'use strict';
require('../common');
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
// https://github.com/joyent/node/issues/6690
Expand Down
4 changes: 2 additions & 2 deletions test/sequential/test-async-wrap-getasyncid.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
// Flags: --expose-gc --expose-internals
// Flags: --expose-gc --expose-internals --no-warnings

const common = require('../common');
const { internalBinding } = require('internal/test/binding');
Expand Down Expand Up @@ -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');
}

Expand Down

0 comments on commit 5436dfd

Please sign in to comment.