0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
Commit Graph

3008 Commits

Author SHA1 Message Date
Calvin Metcalf
6561274d23 crypto: support passwords in publicEncrypt
Private keys may be used along with publicEncrypt since the private key
includes the public one.  This adds the ability to use encrypted private
keys which previously threw an error.  This commit also makes sure the
user exposed functions have names.

PR-URL: https://github.com/iojs/io.js/pull/626
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-02-02 23:21:49 +01:00
Sam Roberts
e9eb2ec1c4 process: fix regression in unlistening signals
When the last signal listener is removed, the signal wrap should be
closed, restoring the default signal handling behaviour. This is done in
a (patched) process.removeListener(). However, events.removeAllListeners
has an optimization to avoid calling removeListener() if there are no
listeners for the 'removeListener' event, introduced in 56668f54d1. That
caused the following code to fail to terminate:

    process.stdin.resume();
    function listener() {};
    process.on('SIGINT', listener);
    process.removeAllListeners('SIGINT');
    process.kill(process.pid, 'SIGINT')

while the following will terminate:

    process.stdin.resume();
    function listener() {};
    process.on('SIGINT', listener);
    process.removeListener('SIGINT', listener);
    process.kill(process.pid, 'SIGINT')

Replace the method patching with use of the 'newListener' and
'removeListener' events, which will fire no matter which methods are
used to add or remove listeners.

PR-URL: https://github.com/iojs/io.js/pull/687
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-02-02 21:59:57 +01:00
Sam Roberts
233e333b18 events: remove indeterminancy from event ordering
The order of the `newListener` and `removeListener` events with respect
to the actual adding and removing from the underlying listeners array
should be deterministic. There is no compelling reason for leaving it
indeterminate. Changing the ordering is likely to result in breaking
code that was unwittingly relying on the current behaviour, and the
indeterminancy makes it impossible to use these events to determine when
the first or last listener is added for an event.

PR-URL: https://github.com/iojs/io.js/pull/687
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-02-02 21:59:56 +01:00
Glen Keane
d75fecf6fd src: remove unused dtrace probes
Removed DTRACE_NET_SOCKET_READ and DTRACE_NET_SOCKET_WRITE
as they were never called from within the source code.

PR-URL: https://github.com/iojs/io.js/pull/694
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-02-02 21:55:56 +01:00
Yosuke Furukawa
8c0742f437 net: check close callback is function
PR-URL: https://github.com/iojs/io.js/pull/609
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Evan Lucas <evanlucas@me.com>
2015-02-02 18:45:34 +01:00
Yosuke Furukawa
207e48c934 dgram: check close callback is function
PR-URL: https://github.com/iojs/io.js/pull/609
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Evan Lucas <evanlucas@me.com>
2015-02-02 18:44:05 +01:00
cjihrig
40e29dcbbf assert: use util.inspect() to create error messages
Currently, JSON.stringify() is used to create error messages
on failed assertions. This causes an error when stringifying
objects with circular references. This commit switches out
JSON.stringify() for util.inspect(), which can handle
circular references.

PR-URL: https://github.com/iojs/io.js/pull/668
Reviewed-By: Julien Gilli <julien.gilli@joyent.com>
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
2015-01-31 09:34:50 -05:00
Bert Belder
bc2c85ceef fs: improve error messages
* Include a description for the error message
* For rename, link, and symlink, include both the source and destination
  path in the error message.
* Expose the destination path as the `dest` property on the error object.
* Fix a bug where `ThrowUVException()` would incorrectly delegate to
  `Environment::TrowErrnoException()`.

API impact:
* Adds an extra overload for node::UVException() which takes 6
  arguments.

PR: https://github.com/iojs/io.js/pull/675
Fixes: https://github.com/iojs/io.js/issues/207
Closes: https://github.com/iojs/io.js/pull/293
Reviewed-by: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-31 11:54:56 +01:00
Ben Noordhuis
0767c2feb1 lib: fix max size check in Buffer constructor
A number -> uint32 type coercion bug made buffer sizes
larger than kMaxLength (0x3fffffff) wrap around.

Instead of rejecting the requested size with an exception,
the constructor created a buffer with the wrong size.

PR-URL: https://github.com/iojs/io.js/pull/657
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-01-31 10:13:50 +01:00
Sam Roberts
65b1e4f56f dgram: implicit binds should be exclusive
Server sockets should be shared by default, and client sockets should be
exclusive by default. For net/TCP, this is how it is, for dgram/UDP, its
a little less clear what a client socket is, but a socket that is
auto-bound during a dgram.send() is not usefully shared among cluster
workers, any more than an outgoing TCP connection would be usefully
shared.

Since implicit binds become exclusive, implicit/client dgram sockets can
now be used with cluster on Windows. Before, neither explicit nor
implicitly bound sockets could be used, causing dgram to be completely
unsupported with cluster on Windows. After this change, they become half
supported.

PR: https://github.com/iojs/io.js/pull/325
PR: https://github.com/joyent/node/pull/8643
Reviewed-by: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-by: Bert Belder <bertbelder@gmail.com>
2015-01-31 00:10:39 +01:00
Ben Noordhuis
24bd4e0555 test: add http upgrade header regression test
Add a regression test for https://github.com/iojs/io.js/issues/627.

Before the http_parser rollback to 2.3.0, the request callback was
called but an 'upgrade' event was not emitted, even though there is
an Upgrade header present in the request.

PR-URL: https://github.com/iojs/io.js/pull/628
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
2015-01-28 16:57:12 +01:00
Vladimir Kurchatkin
45d8d9f826 buffer: implement iterable interface
This makes possible to use `for..of` loop with
buffers. Also related `keys`, `values` and `entries`
methods are added for feature parity with `Uint8Array`.

PR-URL: https://github.com/iojs/io.js/pull/525
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-28 16:40:15 +03:00
cjihrig
3cbb5cdfdb console: allow Object.prototype fields as labels
Console.prototype.timeEnd() returns NaN if the timer label
corresponds to a property on Object.prototype. This commit
uses a Map to construct the _times object.

Fixes: https://github.com/joyent/node/issues/9069
PR-URL: https://github.com/iojs/io.js/pull/563
Reviewed-By: Vladimir Kurchatkin <vladimir.kurchatkin@gmail.com>
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
2015-01-27 18:28:09 -05:00
Fedor Indutny
87e62bd4c8 crypto: implement privateEncrypt/publicDecrypt
PR-URL: https://github.com/iojs/io.js/pull/625
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Fix iojs/io.js#477
2015-01-28 02:02:52 +03:00
Rod Vagg
1953886126 test: fs.createReadStream().destroy() fd leak
PR-URL: https://github.com/iojs/io.js/pull/56
Reviewed-By: Rod Vagg <rod@vagg.org>

See PR for long discussion
2015-01-27 17:06:29 +11:00
cjihrig
785481149d child_process: clone spawn options argument
spawnSync() modifies the options argument. This commit makes
a copy of options before any modifications occur.

Fixes: https://github.com/iojs/io.js/issues/576
PR-URL: https://github.com/iojs/io.js/pull/579
Reviewed-By: Bert Belder <bertbelder@gmail.com>
2015-01-26 11:59:30 -05:00
Vladimir Kurchatkin
8de89ec465 lib: move default address logic to net._listen2
When address is not provided to `server.listen()`, `_connectionKey` and
error messages should include actual address and correct family.

PR-URL: https://github.com/iojs/io.js/pull/539
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-23 18:09:39 +01:00
Ben Noordhuis
3143d732f6 test: delete parallel/test-process-active-wraps
It is supposed to test an internal debug feature but what it effectively
ends up testing, is the exact lifecyle of different kinds of internal
handles.

Lifecycles are different across releases and platforms, making the test
fail intermittently or, in some environments, consistently.  It's not a
good test, delete it.

PR-URL: https://github.com/iojs/io.js/pull/575
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-01-23 17:59:12 +01:00
Ben Noordhuis
4f95b5d825 test: fix parallel/test-http-destroyed-socket-write2
Ameliorate a timing sensitivity issue by switching from setImmediate()
to setTimeout() with a 50 ms timeout.

This commit also adds EPIPE as an accepted error (besides ECONNABORT
and ECONNRESET) because that's a plausible outcome given the timing
sensitive nature of test.

PR-URL: https://github.com/iojs/io.js/pull/575
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-01-23 17:59:10 +01:00
Ben Noordhuis
5ba307a978 test: fix parallel/test-dgram-error-message-address
The test expects EADDRNOTAVAIL when trying to bind to address 111::1.
Systems that have IPv6 disabled throw EAFNOSUPPORT instead, however.
Update the test accordingly.

PR-URL: https://github.com/iojs/io.js/pull/575
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-01-23 17:58:27 +01:00
Ben Noordhuis
ee9cd004d8 lib: fix TypeError with EventEmitter#on() abuse
Commit 2931348 added EventEmitter#getMaxListeners() but introduced a
regression when people abuse EventEmitter.prototype.on.call() to call
EventEmitter#on() on a non-EE object.  Add a workaround for that.

Fixes: https://github.com/iojs/io.js/issues/523
PR-URL: https://github.com/iojs/io.js/pull/527
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-01-20 23:25:57 +01:00
Ben Noordhuis
77d68070da test: fix event-emitter-get-max-listeners style
Add missing commas in parallel/test-event-emitter-get-max-listeners.

Comma-less style is fine and dandy but it throws off vim's autoindent.

PR-URL: https://github.com/iojs/io.js/pull/527
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-01-20 23:25:45 +01:00
Ben Noordhuis
767ee73486 test: strip copyright boilerplate
Commit 3e1b1dd missed a few files in test/parallel, this commit
rectifies that.

Only test/parallel/test-url.js still has a copyright header.  I left
it in because the original author is neither an io.js contributor nor
a StrongLoop employee.

PR-URL: https://github.com/iojs/io.js/pull/527
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-01-20 23:25:19 +01:00
cjihrig
03ee4d8547 fs: add error code on null byte paths
This commit adds a code field to the error returned by
nullCheck().

Fixes: https://github.com/iojs/io.js/issues/517
PR-URL: https://github.com/iojs/io.js/pull/519
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-19 18:07:46 -05:00
Ben Noordhuis
6b91c78e20 test: reland changes from 11c1bae
Reland the changes from commit 11c1bae ("lib: make --debug-port work
with cluster") that were temporarily backed out to cherry-pick commits
from joyent/node.

PR-URL: https://github.com/iojs/io.js/pull/501
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
2015-01-19 19:30:31 +01:00
Timothy J Fontaine
992a1e7f5f test: debug-signal-cluster should not be racey
unref one superfluous timer (as the test suite already has a global
timeout), and improve the state machine to iterate the messages more
reliably.

Ultimately make the test complete more quickly.

Original-PR-URL: [unknown]
Signed-off-by: Julien Gilli <julien.gilli@joyent.com>

PR-URL: https://github.com/iojs/io.js/pull/501
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
2015-01-19 19:30:17 +01:00
Ben Noordhuis
cdf0df13d8 test: temporarily back out changes from 11c1bae
Temporarily revert the changes to test/ from commit 11c1bae ("lib: make
--debug-port work with cluster") to ease cherry-picks from joyent/node.

PR-URL: https://github.com/iojs/io.js/pull/501
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
2015-01-19 19:30:11 +01:00
Ben Noordhuis
1ea607cb29 test: move sequential/test-debug-port-from-cmdline
Move sequential/test-debug-port-from-cmdline to test/parallel.  Per the
previous commit, it should now be possible to run the test in parallel
with other debugger tests.

PR-URL: https://github.com/iojs/io.js/pull/501
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
2015-01-19 19:30:04 +01:00
Julien Gilli
2f33e00d71 test: fix test-debug-port-from-cmdline.js
Make this test less prone to race conditions by using synchronous
interprocess communication instead of a timer to determine when the
child process is ready to receive messages from its parent.

Also, remove a superfluous timer since the tests suite already makes
tests time out after a while.

Original-PR-URL: https://github.com/joyent/node/pull/9049
Reviewed-By: Timothy J Fontaine <tjfontaine@gmail.com>

PR-URL: https://github.com/iojs/io.js/pull/501
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
2015-01-19 19:29:18 +01:00
Xiaowei Li
b7365c1559 repl: make REPL support multiline template literals
Let REPL enter multiline mode if user's input contains unterminated
template literals.

PR-URL: https://github.com/iojs/io.js/pull/333
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-19 13:06:37 +01:00
Johan Bergström
fce1acd748 test: introduce a test for process.versions output
make sure that process.versions contains an expected list of software to avoid
potential mistakes with refactoring.

PR-URL: https://github.com/iojs/io.js/pull/352
Reviewed-By: Rod Vagg <rod@vagg.org>
2015-01-14 12:43:52 +11:00
Fedor Indutny
50648d6018 test: disable fs-readfile-error on FreeBSD
FreeBSD does not return EISDIR when reading "/".

PR-URL: https://github.com/iojs/io.js/pull/332
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-13 20:36:44 +03:00
Fedor Indutny
27e9ed6e98 test: fix setproctitle on FreeBSD
PR-URL: https://github.com/iojs/io.js/pull/332
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-13 20:36:44 +03:00
Fedor Indutny
ccc91aea35 test: loosen timeout in spawnsync-test for FreeBSD
PR-URL: https://github.com/iojs/io.js/pull/332
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-13 20:36:44 +03:00
Sam Roberts
f76722686b test: use assert.throw to test exceptions
The test wasn't checking directly that an assertion was thrown. Instead,
it was checking that spawn did not sucessfully spawn a non-existent
command.

However, the command chosen, dir, exists in GNU coreutils, so it exists
on Linux (though not on BSD derived OS X). The test as written passed on
Linux, even with the TypeError it is supposed to be checking for deleted
from spawn(). It would also pass on Windows if a ls.exe existed.

The approach is unnecessarily obscure, assert.throw() is for asserting
code throws, using it is more clear and works regardless of what
commands do or do not exist.

PR-URL: https://github.com/joyent/node/pull/8454
Reviewed-by: Trevor Norris <trev.norris@gmail.com>

Cherry-picked-from: 2ff29cc7e3

Conflicts:
	test/parallel/test-child-process-spawn-typeerror.js
2015-01-13 03:28:32 +01:00
Timothy J Fontaine
22d20582cc test: check for multi-localhost support
Cherry-picked-from: 2b7c8a2f02
2015-01-13 03:28:31 +01:00
Bert Belder
0bf1d124af http: optimize on_headers_complete
Use an array instead of an object to pass a parsed header chunk from c++
to javascript. This offers a 5-10% speedup on the http_simple benchmark,
as evidenced by running:

  ab -k -t 100 -c 100 http://127.0.0.1:8000/bytes/100

PR: https://github.com/iojs/io.js/pull/292
Reviewed-by: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-13 02:35:27 +01:00
Ben Noordhuis
5165d71048 build,src: remove sslv3 support
SSLv3 is susceptible to downgrade attacks.  Provide secure defaults,
disable v3 protocol support entirely.

PR-URL: https://github.com/iojs/io.js/pull/315
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-01-13 01:59:30 +01:00
Ben Noordhuis
635337f953 test: fix message tests regression
Commit 3e1b1dd ("Remove excessive copyright/license boilerplate") broke
some of the message tests because without the license boilerplate at
the top, the line numbers no longer match up.

PR-URL: https://github.com/iojs/io.js/pull/316
Reviewed-By: Bert Belder <bertbelder@gmail.com>
2015-01-13 01:50:32 +01:00
isaacs
3e1b1dd4a9 Remove excessive copyright/license boilerplate
The copyright and license notice is already in the LICENSE file.  There
is no justifiable reason to also require that it be included in every
file, since the individual files are not individually distributed except
as part of the entire package.
2015-01-12 15:30:28 -08:00
Ben Noordhuis
dd260d2152 test: fix make test-addons target
I broke the python script in commit edaf7af but because test-all does
not run test-addons, it slipped under the radar.  Mea culpa.

Fixes the following test runner error:

    Traceback (most recent call last):
      File "tools/test.py", line 1522, in <module>
        sys.exit(Main())
      File "tools/test.py", line 1454, in Main
        test_list = root.ListTests([], path, context, arch, mode)
      File "tools/test.py", line 720, in ListTests
        test.AddTestsToList(result, full_path, path, context, arch, mode)
      File "tools/test.py", line 690, in AddTestsToList
        arch, mode)
      File "/home/bnoordhuis/src/v1.x/test/gc/../testpy/__init__.py", line 176, in ListTests
        result.append(SimpleTestCase(test, file_path, mode, self.context, self))
    TypeError: __init__() takes at least 7 arguments (6 given)

PR-URL: https://github.com/iojs/io.js/pull/313
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
2015-01-12 23:21:51 +01:00
cjihrig
14dc9175eb assert: throw when block is not a function
Currently, anything passed as the block argument to throws()
and doesNotThrow() is interpreted as a function, which can
lead to unexpected results. This commit checks the type of
block, and throws a TypeError if it is not a function.

Fixes: https://github.com/iojs/io.js/issues/275
PR-URL: https://github.com/iojs/io.js/pull/308
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-12 14:10:33 -05:00
Fedor Indutny
a76811c811 test: fix crypto-stream after openssl update
PR-URL: https://github.com/iojs/io.js/pull/289
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-12 21:31:09 +03:00
Ben Noordhuis
c8676cb361 test: move sequential/test-debug-port-cluster
Move sequential/test-debug-port-cluster to test/parallel.  This test
is safe to run in parallel with other debugger tests, it doesn't use
fixed port numbers.

PR-URL: https://github.com/iojs/io.js/pull/306
Reviewed-By: Miroslav Bajtoš <miroslav@strongloop.com>
2015-01-12 18:31:34 +01:00
Ben Noordhuis
3da4f87b32 test: move sequential/test-debug-signal-cluster
Move sequential/test-debug-signal-cluster to test/parallel.  Per the
previous commit, it can now run in parallel with other debugger tests.

PR-URL: https://github.com/iojs/io.js/pull/306
Reviewed-By: Miroslav Bajtoš <miroslav@strongloop.com>
2015-01-12 18:31:31 +01:00
Ben Noordhuis
11c1bae734 lib: make --debug-port work with cluster
Make the cluster module intercept the `--debug-port=<port>` command line
switch and replace it with the debug port of the child process.

A happy coincidence of this change is that it finally makes it possible
to run the sequential/test-debug-signal-cluster in parallel, it now no
longer needs the default port numbers.

PR-URL: https://github.com/iojs/io.js/pull/306
Reviewed-By: Miroslav Bajtoš <miroslav@strongloop.com>
2015-01-12 18:31:29 +01:00
Ben Noordhuis
5ec5fd83d4 test: delete sequential/test-debug-cluster
The test does not work well with concurrent invocations of the test
runner because it uses fixed port numbers.  The functionality it tests
is covered by sequential/test-debug-port-cluster, a verbatim copy with
the only difference being that it doesn't use fixed port numbers.

PR-URL: https://github.com/iojs/io.js/pull/306
Reviewed-By: Miroslav Bajtoš <miroslav@strongloop.com>
2015-01-12 18:30:54 +01:00
Ben Noordhuis
913addbff5 Revert "url: support path for url.format"
This reverts commit d312b6d15c.

Reverted for breaking `npm install` with git+ssh URLs.

Conflicts:
    doc/api/url.markdown

Fixes: https://github.com/iojs/io.js/issues/295
PR-URL: https://github.com/iojs/io.js/pull/303
Reviewed-By: Rod Vagg <rod@vagg.org>
2015-01-12 12:15:38 +01:00
Evan Lucas
a1e54d6fb7 url: fix parsing of ssh urls
Fix regression introduced in 6120472036
that broke parsing of some ssh: urls.

An example url is ssh://git@github.com:npm/npm.git

PR-URL: https://github.com/iojs/io.js/pull/299
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-12 10:56:41 +01:00
Ben Noordhuis
7e648da834 test: fix bad assumption in pummel/test-vm-memleak
pummel/test-vm-memleak is an old test that assumes the fairly
aggressive heuristics that were common with the old collector.

The current garbage collector has a more laissez-faire attitude.
Put an upper limit on the size of the old space and update the
test's expectations.

PR-URL: https://github.com/iojs/io.js/pull/280
Reviewed-By: Bert Belder <bertbelder@gmail.com>
2015-01-10 23:45:49 +01:00