Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit a38d27e

Browse files
committed
meta: merge node/master into node-chakracore/master
Merge f29c2cb as of 2018-01-27 This commit was automatically generated. For any problems, please contact jackhorton Reviewed-By: Jimmy Thomson <[email protected]>
2 parents aa3250d + f29c2cb commit a38d27e

File tree

13 files changed

+266
-137
lines changed

13 files changed

+266
-137
lines changed

Diff for: Makefile

+29-10
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,11 @@ coverage-clean:
148148
$(RM) -r gcovr build
149149
$(RM) -r out/$(BUILDTYPE)/.coverage
150150
$(RM) -r .cov_tmp
151-
$(RM) out/$(BUILDTYPE)/obj.target/node/{src,gen}/*.gcda
151+
$(RM) out/$(BUILDTYPE)/obj.target/node/gen/*.gcda
152+
$(RM) out/$(BUILDTYPE)/obj.target/node/src/*.gcda
152153
$(RM) out/$(BUILDTYPE)/obj.target/node/src/tracing/*.gcda
153-
$(RM) out/$(BUILDTYPE)/obj.target/node/{src,gen}/*.gcno
154+
$(RM) out/$(BUILDTYPE)/obj.target/node/gen/*.gcno
155+
$(RM) out/$(BUILDTYPE)/obj.target/node/src/*.gcno
154156
$(RM) out/$(BUILDTYPE)/obj.target/node/src/tracing/*.gcno
155157
$(RM) out/$(BUILDTYPE)/obj.target/cctest/src/*.gcno
156158
$(RM) out/$(BUILDTYPE)/obj.target/cctest/test/cctest/*.gcno
@@ -186,7 +188,8 @@ coverage-build: all
186188
coverage-test: coverage-build
187189
$(RM) -r out/$(BUILDTYPE)/.coverage
188190
$(RM) -r .cov_tmp
189-
$(RM) out/$(BUILDTYPE)/obj.target/node/{src,gen}/*.gcda
191+
$(RM) out/$(BUILDTYPE)/obj.target/node/gen/*.gcda
192+
$(RM) out/$(BUILDTYPE)/obj.target/node/src/*.gcda
190193
$(RM) out/$(BUILDTYPE)/obj.target/node/src/tracing/*.gcda
191194
-$(MAKE) $(COVTESTS)
192195
mv lib lib__
@@ -908,15 +911,31 @@ $(TARBALL): release-only $(NODE_EXE) doc
908911
mkdir -p $(TARNAME)/doc/api
909912
cp doc/node.1 $(TARNAME)/doc/node.1
910913
cp -r out/doc/api/* $(TARNAME)/doc/api/
911-
$(RM) -r $(TARNAME)/deps/v8/{test,samples,tools/profviz,tools/run-tests.py}
912-
$(RM) -r $(TARNAME)/doc/images # too big
913-
$(RM) -r $(TARNAME)/deps/uv/{docs,samples,test}
914-
$(RM) -r $(TARNAME)/deps/openssl/openssl/{doc,demos,test}
914+
$(RM) -r $(TARNAME)/.editorconfig
915+
$(RM) -r $(TARNAME)/.git*
916+
$(RM) -r $(TARNAME)/.mailmap
917+
$(RM) -r $(TARNAME)/deps/openssl/openssl/demos
918+
$(RM) -r $(TARNAME)/deps/openssl/openssl/doc
919+
$(RM) -r $(TARNAME)/deps/openssl/openssl/test
920+
$(RM) -r $(TARNAME)/deps/uv/docs
921+
$(RM) -r $(TARNAME)/deps/uv/samples
922+
$(RM) -r $(TARNAME)/deps/uv/test
923+
$(RM) -r $(TARNAME)/deps/v8/samples
924+
$(RM) -r $(TARNAME)/deps/v8/test
925+
$(RM) -r $(TARNAME)/deps/v8/tools/profviz
926+
$(RM) -r $(TARNAME)/deps/v8/tools/run-tests.py
915927
$(RM) -r $(TARNAME)/deps/zlib/contrib # too big, unused
916-
$(RM) -r $(TARNAME)/.{editorconfig,git*,mailmap}
917-
$(RM) -r $(TARNAME)/tools/{eslint-rules,node_modules,osx-pkg.pmdoc,pkgsrc,remark-cli,remark-preset-lint-node}
918-
$(RM) -r $(TARNAME)/tools/{osx-*,license-builder.sh,cpplint.py}
928+
$(RM) -r $(TARNAME)/doc/images # too big
919929
$(RM) -r $(TARNAME)/test*.tap
930+
$(RM) -r $(TARNAME)/tools/cpplint.py
931+
$(RM) -r $(TARNAME)/tools/eslint-rules
932+
$(RM) -r $(TARNAME)/tools/license-builder.sh
933+
$(RM) -r $(TARNAME)/tools/node_modules
934+
$(RM) -r $(TARNAME)/tools/osx-*
935+
$(RM) -r $(TARNAME)/tools/osx-pkg.pmdoc
936+
$(RM) -r $(TARNAME)/tools/pkgsrc
937+
$(RM) -r $(TARNAME)/tools/remark-cli
938+
$(RM) -r $(TARNAME)/tools/remark-preset-lint-node
920939
find $(TARNAME)/ -name ".eslint*" -maxdepth 2 | xargs $(RM)
921940
find $(TARNAME)/ -type l | xargs $(RM) # annoying on windows
922941
tar -cf $(TARNAME).tar $(TARNAME)

Diff for: benchmark/http/set_header.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
'use strict';
2+
3+
const common = require('../common.js');
4+
const { OutgoingMessage } = require('_http_outgoing');
5+
6+
const bench = common.createBenchmark(main, {
7+
value: [
8+
'X-Powered-By',
9+
'Vary',
10+
'Set-Cookie',
11+
'Content-Type',
12+
'Content-Length',
13+
'Connection',
14+
'Transfer-Encoding'
15+
],
16+
n: [1e6],
17+
});
18+
19+
function main(conf) {
20+
const n = +conf.n;
21+
const value = conf.value;
22+
23+
const og = new OutgoingMessage();
24+
25+
bench.start();
26+
for (var i = 0; i < n; i++) {
27+
og.setHeader(value, '');
28+
}
29+
bench.end(n);
30+
}

Diff for: doc/api/repl.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ within the action function for commands registered using the
381381
added: v9.0.0
382382
-->
383383

384-
The `replServer.clearBufferedComand()` method clears any command that has been
384+
The `replServer.clearBufferedCommand()` method clears any command that has been
385385
buffered but not yet executed. This method is primarily intended to be
386386
called from within the action function for commands registered using the
387387
`replServer.defineCommand()` method.

Diff for: lib/_http_outgoing.js

+24-26
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ const errors = require('internal/errors');
3838
const { CRLF, debug } = common;
3939
const { utcDate } = internalHttp;
4040

41+
const kIsCorked = Symbol('isCorked');
42+
4143
var RE_FIELDS =
4244
/^(?:Connection|Transfer-Encoding|Content-Length|Date|Expect|Trailer|Upgrade)$/i;
4345
var RE_CONN_VALUES = /(?:^|\W)close|upgrade(?:$|\W)/ig;
@@ -99,6 +101,7 @@ function OutgoingMessage() {
99101

100102
this.finished = false;
101103
this._headerSent = false;
104+
this[kIsCorked] = false;
102105

103106
this.socket = null;
104107
this.connection = null;
@@ -510,18 +513,15 @@ OutgoingMessage.prototype.setHeader = function setHeader(name, value) {
510513
const key = name.toLowerCase();
511514
this[outHeadersKey][key] = [name, value];
512515

513-
switch (key.length) {
514-
case 10:
515-
if (key === 'connection')
516-
this._removedConnection = false;
516+
switch (key) {
517+
case 'connection':
518+
this._removedConnection = false;
517519
break;
518-
case 14:
519-
if (key === 'content-length')
520-
this._removedContLen = false;
520+
case 'content-length':
521+
this._removedContLen = false;
521522
break;
522-
case 17:
523-
if (key === 'transfer-encoding')
524-
this._removedTE = false;
523+
case 'transfer-encoding':
524+
this._removedTE = false;
525525
break;
526526
}
527527
};
@@ -583,22 +583,18 @@ OutgoingMessage.prototype.removeHeader = function removeHeader(name) {
583583

584584
var key = name.toLowerCase();
585585

586-
switch (key.length) {
587-
case 10:
588-
if (key === 'connection')
589-
this._removedConnection = true;
586+
switch (key) {
587+
case 'connection':
588+
this._removedConnection = true;
590589
break;
591-
case 14:
592-
if (key === 'content-length')
593-
this._removedContLen = true;
590+
case 'content-length':
591+
this._removedContLen = true;
594592
break;
595-
case 17:
596-
if (key === 'transfer-encoding')
597-
this._removedTE = true;
593+
case 'transfer-encoding':
594+
this._removedTE = true;
598595
break;
599-
case 4:
600-
if (key === 'date')
601-
this.sendDate = false;
596+
case 'date':
597+
this.sendDate = false;
602598
break;
603599
}
604600

@@ -655,9 +651,10 @@ function write_(msg, chunk, encoding, callback, fromEnd) {
655651
// signal the user to keep writing.
656652
if (chunk.length === 0) return true;
657653

658-
if (!fromEnd && msg.connection && !msg.connection.corked) {
654+
if (!fromEnd && msg.connection && !msg[kIsCorked]) {
659655
msg.connection.cork();
660-
process.nextTick(connectionCorkNT, msg.connection);
656+
msg[kIsCorked] = true;
657+
process.nextTick(connectionCorkNT, msg, msg.connection);
661658
}
662659

663660
var len, ret;
@@ -686,7 +683,8 @@ function writeAfterEndNT(err, callback) {
686683
}
687684

688685

689-
function connectionCorkNT(conn) {
686+
function connectionCorkNT(msg, conn) {
687+
msg[kIsCorked] = false;
690688
conn.uncork();
691689
}
692690

Diff for: lib/fs.js

+19-11
Original file line numberDiff line numberDiff line change
@@ -1330,20 +1330,16 @@ if (constants.O_SYMLINK !== undefined) {
13301330
};
13311331

13321332
fs.lchmodSync = function(path, mode) {
1333-
var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK);
1333+
const fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK);
13341334

13351335
// Prefer to return the chmod error, if one occurs,
13361336
// but still try to close, and report closing errors if they occur.
1337-
var ret;
1337+
let ret;
13381338
try {
13391339
ret = fs.fchmodSync(fd, mode);
1340-
} catch (err) {
1341-
try {
1342-
fs.closeSync(fd);
1343-
} catch (ignore) {}
1344-
throw err;
1340+
} finally {
1341+
fs.closeSync(fd);
13451342
}
1346-
fs.closeSync(fd);
13471343
return ret;
13481344
};
13491345
}
@@ -1381,13 +1377,25 @@ if (constants.O_SYMLINK !== undefined) {
13811377
callback(err);
13821378
return;
13831379
}
1384-
fs.fchown(fd, uid, gid, callback);
1380+
// Prefer to return the chown error, if one occurs,
1381+
// but still try to close, and report closing errors if they occur.
1382+
fs.fchown(fd, uid, gid, function(err) {
1383+
fs.close(fd, function(err2) {
1384+
callback(err || err2);
1385+
});
1386+
});
13851387
});
13861388
};
13871389

13881390
fs.lchownSync = function(path, uid, gid) {
1389-
var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK);
1390-
return fs.fchownSync(fd, uid, gid);
1391+
const fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK);
1392+
let ret;
1393+
try {
1394+
ret = fs.fchownSync(fd, uid, gid);
1395+
} finally {
1396+
fs.closeSync(fd);
1397+
}
1398+
return ret;
13911399
};
13921400
}
13931401

Diff for: lib/internal/http2/core.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,10 @@ const {
5757
const {
5858
kTimeout,
5959
setUnrefTimeout,
60-
validateTimerDuration
60+
validateTimerDuration,
61+
refreshFnSymbol
6162
} = require('internal/timers');
6263

63-
const { _unrefActive } = require('timers');
64-
6564
const { ShutdownWrap, WriteWrap } = process.binding('stream_wrap');
6665
const { constants } = binding;
6766

@@ -912,7 +911,7 @@ class Http2Session extends EventEmitter {
912911
[kUpdateTimer]() {
913912
if (this.destroyed)
914913
return;
915-
if (this[kTimeout]) _unrefActive(this[kTimeout]);
914+
if (this[kTimeout]) this[kTimeout][refreshFnSymbol]();
916915
}
917916

918917
// Sets the id of the next stream to be created by this Http2Session.
@@ -1478,7 +1477,7 @@ class Http2Stream extends Duplex {
14781477
if (this.destroyed)
14791478
return;
14801479
if (this[kTimeout])
1481-
_unrefActive(this[kTimeout]);
1480+
this[kTimeout][refreshFnSymbol]();
14821481
if (this[kSession])
14831482
this[kSession][kUpdateTimer]();
14841483
}

Diff for: lib/internal/process.js

+22-23
Original file line numberDiff line numberDiff line change
@@ -180,19 +180,18 @@ function setupKillAndExit() {
180180

181181
var ttdSigIntHandler = undefined;
182182
function setupSignalHandlers() {
183-
// Load events module in order to access prototype elements on process like
184-
// process.addListener.
185-
const signalWraps = {};
183+
const signalWraps = Object.create(null);
184+
let Signal;
186185

187186
function isSignal(event) {
188187
return typeof event === 'string' && constants[event] !== undefined;
189188
}
190189

191190
// Detect presence of a listener for the special signal types
192-
process.on('newListener', function(type, listener) {
193-
if (isSignal(type) &&
194-
!signalWraps.hasOwnProperty(type)) {
195-
const Signal = process.binding('signal_wrap').Signal;
191+
process.on('newListener', function(type) {
192+
if (isSignal(type) && signalWraps[type] === undefined) {
193+
if (Signal === undefined)
194+
Signal = process.binding('signal_wrap').Signal;
196195
const wrap = new Signal();
197196

198197
wrap.unref();
@@ -203,7 +202,7 @@ function setupSignalHandlers() {
203202
// -- ttdSigIntHandler will emit event after it runs
204203
wrap.onsignal = function() { }; //ENABLE_TTD
205204
} else {
206-
wrap.onsignal = function() { process.emit(type, type); };
205+
wrap.onsignal = process.emit.bind(process, type, type);
207206
}
208207

209208
const signum = constants[type];
@@ -217,8 +216,8 @@ function setupSignalHandlers() {
217216
}
218217
});
219218

220-
process.on('removeListener', function(type, listener) {
221-
if (signalWraps.hasOwnProperty(type) && this.listenerCount(type) === 0) {
219+
process.on('removeListener', function(type) {
220+
if (signalWraps[type] !== undefined && this.listenerCount(type) === 0) {
222221
signalWraps[type].close();
223222
delete signalWraps[type];
224223
}
@@ -227,23 +226,30 @@ function setupSignalHandlers() {
227226
//ENABLE_TTD
228227
if (global.enabledDiagnosticsTrace) {
229228
(function() {
229+
const type = 'SIGINT';
230230
var Signal = process.binding('signal_wrap').Signal;
231231
var wrap = new Signal();
232232

233233
wrap.unref();
234234

235235
var handler = require('trace_mgr').onSigIntHandler;
236+
const userHandler = process.emit.bind(process, type, type);
236237
wrap.onsignal = function() {
237-
handler(signalWraps.hasOwnProperty('SIGINT'));
238-
process.emit('SIGINT');
238+
// If signalWraps[type] exists, then the user script
239+
// has set a handler for sigint
240+
// If there is no user script handler, then
241+
// handler here will terminate the process
242+
handler(signalWraps[type] !== undefined);
243+
// Otherwise, we should trigger the same function
244+
// that would be triggered if TTD were not present
245+
return userHandler();
239246
};
240247

241-
const signum = constants.SIGINT;
248+
const signum = constants[type];
242249
const err = wrap.start(signum);
243250
if (err) {
244251
wrap.close();
245-
const errnoException = require('util')._errnoException;
246-
throw errnoException(err, 'uv_signal_start');
252+
throw util._errnoException(err, 'uv_signal_start');
247253
}
248254

249255
if (!ttdSigIntHandler) {
@@ -264,14 +270,7 @@ function setupChannel() {
264270
// Make sure it's not accidentally inherited by child processes.
265271
delete process.env.NODE_CHANNEL_FD;
266272

267-
const cp = require('child_process');
268-
269-
// Load tcp_wrap to avoid situation where we might immediately receive
270-
// a message.
271-
// FIXME is this really necessary?
272-
process.binding('tcp_wrap');
273-
274-
cp._forkChild(fd);
273+
require('child_process')._forkChild(fd);
275274
assert(process.send);
276275
}
277276
}

0 commit comments

Comments
 (0)