diff options
-rwxr-xr-x | configure | 8 | ||||
-rw-r--r-- | doc/api/assert.markdown | 4 | ||||
-rw-r--r-- | lib/_http_client.js | 6 | ||||
-rw-r--r-- | lib/_stream_readable.js | 3 | ||||
-rw-r--r-- | lib/_tls_wrap.js | 3 | ||||
-rw-r--r-- | lib/assert.js | 9 | ||||
-rw-r--r-- | node.gyp | 34 | ||||
-rw-r--r-- | src/node_dtrace.cc | 4 | ||||
-rw-r--r-- | test/simple/test-assert.js | 5 | ||||
-rw-r--r-- | test/simple/test-http-createConnection.js | 47 | ||||
-rwxr-xr-x | tools/install.py | 6 | ||||
-rwxr-xr-x | tools/specialize_node_d.py | 32 |
12 files changed, 139 insertions, 22 deletions
@@ -464,13 +464,15 @@ def configure_node(o): if not is_clang and cc_version < (4,0,0): o['variables']['visibility'] = '' - if flavor in ('solaris', 'mac', 'linux'): + if flavor in ('solaris', 'mac', 'linux', 'freebsd'): use_dtrace = not options.without_dtrace - # Don't enable by default on linux, it needs the sdt-devel package. + # Don't enable by default on linux and freebsd + if flavor in ('linux', 'freebsd'): + use_dtrace = options.with_dtrace + if flavor == 'linux': if options.systemtap_includes: o['include_dirs'] += [options.systemtap_includes] - use_dtrace = options.with_dtrace o['variables']['node_use_dtrace'] = b(use_dtrace) o['variables']['uv_use_dtrace'] = b(use_dtrace) o['variables']['uv_parent_path'] = '/deps/uv/' diff --git a/doc/api/assert.markdown b/doc/api/assert.markdown index 5849f6d93..1a6602221 100644 --- a/doc/api/assert.markdown +++ b/doc/api/assert.markdown @@ -39,7 +39,7 @@ Tests strict non-equality, as determined by the strict not equal operator ( `!== ## assert.throws(block, [error], [message]) -Expects `block` to throw an error. `error` can be constructor, regexp or +Expects `block` to throw an error. `error` can be constructor, `RegExp` or validation function. Validate instanceof using constructor: @@ -76,7 +76,7 @@ Custom error validation: ## assert.doesNotThrow(block, [message]) -Expects `block` not to throw an error, see assert.throws for details. +Expects `block` not to throw an error, see `assert.throws` for details. ## assert.ifError(value) diff --git a/lib/_http_client.js b/lib/_http_client.js index 4e1754961..fe9d634bf 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -53,7 +53,7 @@ function ClientRequest(options, cb) { var defaultAgent = options._defaultAgent || Agent.globalAgent; if (agent === false) { agent = new defaultAgent.constructor(); - } else if (util.isNullOrUndefined(agent)) { + } else if (util.isNullOrUndefined(agent) && !options.createConnection) { agent = defaultAgent; } self.agent = agent; @@ -70,9 +70,9 @@ function ClientRequest(options, cb) { throw new Error('Protocol:' + options.protocol + ' not supported.'); } - var defaultPort = options.defaultPort || self.agent.defaultPort; + var defaultPort = options.defaultPort || self.agent && self.agent.defaultPort; - var port = options.port = options.port || defaultPort; + var port = options.port = options.port || defaultPort || 80; var host = options.host = options.hostname || options.host || 'localhost'; if (util.isUndefined(options.setHost)) { diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index e1636c85a..3534bf912 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -373,8 +373,7 @@ function chunkInvalid(state, chunk) { if (!util.isBuffer(chunk) && !util.isString(chunk) && !util.isNullOrUndefined(chunk) && - !state.objectMode && - !er) { + !state.objectMode) { er = new TypeError('Invalid non-string/buffer chunk'); } return er; diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index c0af83a7e..f3061c47b 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -1,5 +1,8 @@ // Copyright Joyent, Inc. and other Node contributors. // +// // Emit `beforeExit` if the loop became alive either after emitting +// event, or after running some callbacks. +// // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including diff --git a/lib/assert.js b/lib/assert.js index 5e9f78f9e..7602996c9 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -201,10 +201,11 @@ function objEquiv(a, b) { if (a.prototype !== b.prototype) return false; //~~~I've managed to break Object.keys through screwy arguments passing. // Converting to array solves the problem. - if (isArguments(a)) { - if (!isArguments(b)) { - return false; - } + var aIsArgs = isArguments(a), + bIsArgs = isArguments(b); + if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs)) + return false; + if (aIsArgs) { a = pSlice.call(a); b = pSlice.call(b); return _deepEqual(a, b); @@ -187,8 +187,12 @@ }], [ 'node_use_dtrace=="true"', { 'defines': [ 'HAVE_DTRACE=1' ], - 'dependencies': [ 'node_dtrace_header' ], + 'dependencies': [ + 'node_dtrace_header', + 'specialize_node_d', + ], 'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)' ], + # # DTrace is supported on linux, solaris, mac, and bsd. There are # three object files associated with DTrace support, but they're @@ -544,10 +548,36 @@ ] } ], ] - } + }, ] } ], ] + }, + { + 'target_name': 'specialize_node_d', + 'type': 'none', + 'conditions': [ + [ 'node_use_dtrace=="true"', { + 'actions': [ + { + 'action_name': 'specialize_node_d', + 'inputs': [ + 'src/node.d' + ], + 'outputs': [ + '<(PRODUCT_DIR)/node.d', + ], + 'action': [ + 'tools/specialize_node_d.py', + '<@(_outputs)', + '<@(_inputs)', + '<@(OS)', + '<@(target_arch)', + ], + }, + ], + } ], + ] } ] # end targets } diff --git a/src/node_dtrace.cc b/src/node_dtrace.cc index 0b8db1e07..a4b5645d1 100644 --- a/src/node_dtrace.cc +++ b/src/node_dtrace.cc @@ -287,7 +287,7 @@ void DTRACE_HTTP_CLIENT_RESPONSE(const FunctionCallbackInfo<Value>& args) { } -static int dtrace_gc_start(GCType type, GCCallbackFlags flags) { +int dtrace_gc_start(GCType type, GCCallbackFlags flags) { NODE_GC_START(type, flags); /* * We avoid the tail-call elimination of the USDT probe (which screws up @@ -297,7 +297,7 @@ static int dtrace_gc_start(GCType type, GCCallbackFlags flags) { } -static int dtrace_gc_done(GCType type, GCCallbackFlags flags) { +int dtrace_gc_done(GCType type, GCCallbackFlags flags) { NODE_GC_DONE(type, flags); return 0; } diff --git a/test/simple/test-assert.js b/test/simple/test-assert.js index 91c8ef1e5..84ea9249c 100644 --- a/test/simple/test-assert.js +++ b/test/simple/test-assert.js @@ -249,6 +249,11 @@ try { gotError = true; } +// GH-7178. Ensure reflexivity of deepEqual with `arguments` objects. +var args = (function() { return arguments; })(); +a.throws(makeBlock(a.deepEqual, [], args)); +a.throws(makeBlock(a.deepEqual, args, [])); + console.log('All OK'); assert.ok(gotError); diff --git a/test/simple/test-http-createConnection.js b/test/simple/test-http-createConnection.js new file mode 100644 index 000000000..bc29d9aee --- /dev/null +++ b/test/simple/test-http-createConnection.js @@ -0,0 +1,47 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var common = require('../common'); +var assert = require('assert'); +var http = require('http'); +var net = require('net'); + +var create = 0; +var response = 0; +process.on('exit', function() { + assert.equal(1, create, 'createConnection() http option was not called'); + assert.equal(1, response, 'http server "request" callback was not called'); +}); + +var server = http.createServer(function(req, res) { + res.end(); + response++; +}).listen(common.PORT, '127.0.0.1', function() { + http.get({ createConnection: createConnection }, function (res) { + res.resume(); + server.close(); + }); +}); + +function createConnection() { + create++; + return net.createConnection(common.PORT, '127.0.0.1'); +} diff --git a/tools/install.py b/tools/install.py index eb6c1ce01..c495746c8 100755 --- a/tools/install.py +++ b/tools/install.py @@ -129,10 +129,8 @@ def subdir_files(path, dest, action): def files(action): action(['out/Release/node'], 'bin/node') - # install unconditionally, checking if the platform supports dtrace doesn't - # work when cross-compiling and besides, there's at least one linux flavor - # with dtrace support now (oracle's "unbreakable" linux) - action(['src/node.d'], 'lib/dtrace/') + if 'true' == variables.get('node_use_dtrace'): + action(['out/Release/node.d'], 'lib/dtrace/node.d') # behave similarly for systemtap action(['src/node.stp'], 'share/systemtap/tapset/') diff --git a/tools/specialize_node_d.py b/tools/specialize_node_d.py new file mode 100755 index 000000000..0ee505ae9 --- /dev/null +++ b/tools/specialize_node_d.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +# +# specialize_node_d.py output_file src/node.d flavor arch +# +# Specialize node.d for given flavor (`freebsd`) and arch (`x64` or `ia32`) +# + +import re +import subprocess +import sys +import errno + +if len(sys.argv) != 5: + print "usage: specialize_node_d.py outfile src/node.d flavor arch" + sys.exit(2); + +outfile = file(sys.argv[1], 'w'); +infile = file(sys.argv[2], 'r'); +flavor = sys.argv[3]; +arch = sys.argv[4]; + +model = r'curpsinfo->pr_dmodel == PR_MODEL_ILP32' + +for line in infile: + if flavor == 'freebsd': + line = re.sub('procfs.d', 'psinfo.d', line); + if arch == 'x64': + line = re.sub(model, '0', line); + else: + line = re.sub(model, '1', line); + outfile.write(line); |