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

Commit

Permalink
meta: merge node/master into node-chakracore/master
Browse files Browse the repository at this point in the history
Merge f29c2cb as of 2018-01-27
This commit was automatically generated. For any problems, please contact jackhorton

Reviewed-By: Jimmy Thomson <jithomso@microsoft.com>
  • Loading branch information
chakrabot committed Feb 8, 2018
2 parents aa3250d + f29c2cb commit a38d27e
Show file tree
Hide file tree
Showing 13 changed files with 266 additions and 137 deletions.
39 changes: 29 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,11 @@ coverage-clean:
$(RM) -r gcovr build
$(RM) -r out/$(BUILDTYPE)/.coverage
$(RM) -r .cov_tmp
$(RM) out/$(BUILDTYPE)/obj.target/node/{src,gen}/*.gcda
$(RM) out/$(BUILDTYPE)/obj.target/node/gen/*.gcda
$(RM) out/$(BUILDTYPE)/obj.target/node/src/*.gcda
$(RM) out/$(BUILDTYPE)/obj.target/node/src/tracing/*.gcda
$(RM) out/$(BUILDTYPE)/obj.target/node/{src,gen}/*.gcno
$(RM) out/$(BUILDTYPE)/obj.target/node/gen/*.gcno
$(RM) out/$(BUILDTYPE)/obj.target/node/src/*.gcno
$(RM) out/$(BUILDTYPE)/obj.target/node/src/tracing/*.gcno
$(RM) out/$(BUILDTYPE)/obj.target/cctest/src/*.gcno
$(RM) out/$(BUILDTYPE)/obj.target/cctest/test/cctest/*.gcno
Expand Down Expand Up @@ -186,7 +188,8 @@ coverage-build: all
coverage-test: coverage-build
$(RM) -r out/$(BUILDTYPE)/.coverage
$(RM) -r .cov_tmp
$(RM) out/$(BUILDTYPE)/obj.target/node/{src,gen}/*.gcda
$(RM) out/$(BUILDTYPE)/obj.target/node/gen/*.gcda
$(RM) out/$(BUILDTYPE)/obj.target/node/src/*.gcda
$(RM) out/$(BUILDTYPE)/obj.target/node/src/tracing/*.gcda
-$(MAKE) $(COVTESTS)
mv lib lib__
Expand Down Expand Up @@ -908,15 +911,31 @@ $(TARBALL): release-only $(NODE_EXE) doc
mkdir -p $(TARNAME)/doc/api
cp doc/node.1 $(TARNAME)/doc/node.1
cp -r out/doc/api/* $(TARNAME)/doc/api/
$(RM) -r $(TARNAME)/deps/v8/{test,samples,tools/profviz,tools/run-tests.py}
$(RM) -r $(TARNAME)/doc/images # too big
$(RM) -r $(TARNAME)/deps/uv/{docs,samples,test}
$(RM) -r $(TARNAME)/deps/openssl/openssl/{doc,demos,test}
$(RM) -r $(TARNAME)/.editorconfig
$(RM) -r $(TARNAME)/.git*
$(RM) -r $(TARNAME)/.mailmap
$(RM) -r $(TARNAME)/deps/openssl/openssl/demos
$(RM) -r $(TARNAME)/deps/openssl/openssl/doc
$(RM) -r $(TARNAME)/deps/openssl/openssl/test
$(RM) -r $(TARNAME)/deps/uv/docs
$(RM) -r $(TARNAME)/deps/uv/samples
$(RM) -r $(TARNAME)/deps/uv/test
$(RM) -r $(TARNAME)/deps/v8/samples
$(RM) -r $(TARNAME)/deps/v8/test
$(RM) -r $(TARNAME)/deps/v8/tools/profviz
$(RM) -r $(TARNAME)/deps/v8/tools/run-tests.py
$(RM) -r $(TARNAME)/deps/zlib/contrib # too big, unused
$(RM) -r $(TARNAME)/.{editorconfig,git*,mailmap}
$(RM) -r $(TARNAME)/tools/{eslint-rules,node_modules,osx-pkg.pmdoc,pkgsrc,remark-cli,remark-preset-lint-node}
$(RM) -r $(TARNAME)/tools/{osx-*,license-builder.sh,cpplint.py}
$(RM) -r $(TARNAME)/doc/images # too big
$(RM) -r $(TARNAME)/test*.tap
$(RM) -r $(TARNAME)/tools/cpplint.py
$(RM) -r $(TARNAME)/tools/eslint-rules
$(RM) -r $(TARNAME)/tools/license-builder.sh
$(RM) -r $(TARNAME)/tools/node_modules
$(RM) -r $(TARNAME)/tools/osx-*
$(RM) -r $(TARNAME)/tools/osx-pkg.pmdoc
$(RM) -r $(TARNAME)/tools/pkgsrc
$(RM) -r $(TARNAME)/tools/remark-cli
$(RM) -r $(TARNAME)/tools/remark-preset-lint-node
find $(TARNAME)/ -name ".eslint*" -maxdepth 2 | xargs $(RM)
find $(TARNAME)/ -type l | xargs $(RM) # annoying on windows
tar -cf $(TARNAME).tar $(TARNAME)
Expand Down
30 changes: 30 additions & 0 deletions benchmark/http/set_header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

const common = require('../common.js');
const { OutgoingMessage } = require('_http_outgoing');

const bench = common.createBenchmark(main, {
value: [
'X-Powered-By',
'Vary',
'Set-Cookie',
'Content-Type',
'Content-Length',
'Connection',
'Transfer-Encoding'
],
n: [1e6],
});

function main(conf) {
const n = +conf.n;
const value = conf.value;

const og = new OutgoingMessage();

bench.start();
for (var i = 0; i < n; i++) {
og.setHeader(value, '');
}
bench.end(n);
}
2 changes: 1 addition & 1 deletion doc/api/repl.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ within the action function for commands registered using the
added: v9.0.0
-->

The `replServer.clearBufferedComand()` method clears any command that has been
The `replServer.clearBufferedCommand()` method clears any command that has been
buffered but not yet executed. This method is primarily intended to be
called from within the action function for commands registered using the
`replServer.defineCommand()` method.
Expand Down
50 changes: 24 additions & 26 deletions lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const errors = require('internal/errors');
const { CRLF, debug } = common;
const { utcDate } = internalHttp;

const kIsCorked = Symbol('isCorked');

var RE_FIELDS =
/^(?:Connection|Transfer-Encoding|Content-Length|Date|Expect|Trailer|Upgrade)$/i;
var RE_CONN_VALUES = /(?:^|\W)close|upgrade(?:$|\W)/ig;
Expand Down Expand Up @@ -99,6 +101,7 @@ function OutgoingMessage() {

this.finished = false;
this._headerSent = false;
this[kIsCorked] = false;

this.socket = null;
this.connection = null;
Expand Down Expand Up @@ -510,18 +513,15 @@ OutgoingMessage.prototype.setHeader = function setHeader(name, value) {
const key = name.toLowerCase();
this[outHeadersKey][key] = [name, value];

switch (key.length) {
case 10:
if (key === 'connection')
this._removedConnection = false;
switch (key) {
case 'connection':
this._removedConnection = false;
break;
case 14:
if (key === 'content-length')
this._removedContLen = false;
case 'content-length':
this._removedContLen = false;
break;
case 17:
if (key === 'transfer-encoding')
this._removedTE = false;
case 'transfer-encoding':
this._removedTE = false;
break;
}
};
Expand Down Expand Up @@ -583,22 +583,18 @@ OutgoingMessage.prototype.removeHeader = function removeHeader(name) {

var key = name.toLowerCase();

switch (key.length) {
case 10:
if (key === 'connection')
this._removedConnection = true;
switch (key) {
case 'connection':
this._removedConnection = true;
break;
case 14:
if (key === 'content-length')
this._removedContLen = true;
case 'content-length':
this._removedContLen = true;
break;
case 17:
if (key === 'transfer-encoding')
this._removedTE = true;
case 'transfer-encoding':
this._removedTE = true;
break;
case 4:
if (key === 'date')
this.sendDate = false;
case 'date':
this.sendDate = false;
break;
}

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

if (!fromEnd && msg.connection && !msg.connection.corked) {
if (!fromEnd && msg.connection && !msg[kIsCorked]) {
msg.connection.cork();
process.nextTick(connectionCorkNT, msg.connection);
msg[kIsCorked] = true;
process.nextTick(connectionCorkNT, msg, msg.connection);
}

var len, ret;
Expand Down Expand Up @@ -686,7 +683,8 @@ function writeAfterEndNT(err, callback) {
}


function connectionCorkNT(conn) {
function connectionCorkNT(msg, conn) {
msg[kIsCorked] = false;
conn.uncork();
}

Expand Down
30 changes: 19 additions & 11 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1330,20 +1330,16 @@ if (constants.O_SYMLINK !== undefined) {
};

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

// Prefer to return the chmod error, if one occurs,
// but still try to close, and report closing errors if they occur.
var ret;
let ret;
try {
ret = fs.fchmodSync(fd, mode);
} catch (err) {
try {
fs.closeSync(fd);
} catch (ignore) {}
throw err;
} finally {
fs.closeSync(fd);
}
fs.closeSync(fd);
return ret;
};
}
Expand Down Expand Up @@ -1381,13 +1377,25 @@ if (constants.O_SYMLINK !== undefined) {
callback(err);
return;
}
fs.fchown(fd, uid, gid, callback);
// Prefer to return the chown error, if one occurs,
// but still try to close, and report closing errors if they occur.
fs.fchown(fd, uid, gid, function(err) {
fs.close(fd, function(err2) {
callback(err || err2);
});
});
});
};

fs.lchownSync = function(path, uid, gid) {
var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK);
return fs.fchownSync(fd, uid, gid);
const fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK);
let ret;
try {
ret = fs.fchownSync(fd, uid, gid);
} finally {
fs.closeSync(fd);
}
return ret;
};
}

Expand Down
9 changes: 4 additions & 5 deletions lib/internal/http2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,10 @@ const {
const {
kTimeout,
setUnrefTimeout,
validateTimerDuration
validateTimerDuration,
refreshFnSymbol
} = require('internal/timers');

const { _unrefActive } = require('timers');

const { ShutdownWrap, WriteWrap } = process.binding('stream_wrap');
const { constants } = binding;

Expand Down Expand Up @@ -912,7 +911,7 @@ class Http2Session extends EventEmitter {
[kUpdateTimer]() {
if (this.destroyed)
return;
if (this[kTimeout]) _unrefActive(this[kTimeout]);
if (this[kTimeout]) this[kTimeout][refreshFnSymbol]();
}

// Sets the id of the next stream to be created by this Http2Session.
Expand Down Expand Up @@ -1478,7 +1477,7 @@ class Http2Stream extends Duplex {
if (this.destroyed)
return;
if (this[kTimeout])
_unrefActive(this[kTimeout]);
this[kTimeout][refreshFnSymbol]();
if (this[kSession])
this[kSession][kUpdateTimer]();
}
Expand Down
45 changes: 22 additions & 23 deletions lib/internal/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,19 +180,18 @@ function setupKillAndExit() {

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

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

// Detect presence of a listener for the special signal types
process.on('newListener', function(type, listener) {
if (isSignal(type) &&
!signalWraps.hasOwnProperty(type)) {
const Signal = process.binding('signal_wrap').Signal;
process.on('newListener', function(type) {
if (isSignal(type) && signalWraps[type] === undefined) {
if (Signal === undefined)
Signal = process.binding('signal_wrap').Signal;
const wrap = new Signal();

wrap.unref();
Expand All @@ -203,7 +202,7 @@ function setupSignalHandlers() {
// -- ttdSigIntHandler will emit event after it runs
wrap.onsignal = function() { }; //ENABLE_TTD
} else {
wrap.onsignal = function() { process.emit(type, type); };
wrap.onsignal = process.emit.bind(process, type, type);
}

const signum = constants[type];
Expand All @@ -217,8 +216,8 @@ function setupSignalHandlers() {
}
});

process.on('removeListener', function(type, listener) {
if (signalWraps.hasOwnProperty(type) && this.listenerCount(type) === 0) {
process.on('removeListener', function(type) {
if (signalWraps[type] !== undefined && this.listenerCount(type) === 0) {
signalWraps[type].close();
delete signalWraps[type];
}
Expand All @@ -227,23 +226,30 @@ function setupSignalHandlers() {
//ENABLE_TTD
if (global.enabledDiagnosticsTrace) {
(function() {
const type = 'SIGINT';
var Signal = process.binding('signal_wrap').Signal;
var wrap = new Signal();

wrap.unref();

var handler = require('trace_mgr').onSigIntHandler;
const userHandler = process.emit.bind(process, type, type);
wrap.onsignal = function() {
handler(signalWraps.hasOwnProperty('SIGINT'));
process.emit('SIGINT');
// If signalWraps[type] exists, then the user script
// has set a handler for sigint
// If there is no user script handler, then
// handler here will terminate the process
handler(signalWraps[type] !== undefined);
// Otherwise, we should trigger the same function
// that would be triggered if TTD were not present
return userHandler();
};

const signum = constants.SIGINT;
const signum = constants[type];
const err = wrap.start(signum);
if (err) {
wrap.close();
const errnoException = require('util')._errnoException;
throw errnoException(err, 'uv_signal_start');
throw util._errnoException(err, 'uv_signal_start');
}

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

const cp = require('child_process');

// Load tcp_wrap to avoid situation where we might immediately receive
// a message.
// FIXME is this really necessary?
process.binding('tcp_wrap');

cp._forkChild(fd);
require('child_process')._forkChild(fd);
assert(process.send);
}
}
Expand Down
Loading

0 comments on commit a38d27e

Please sign in to comment.