0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 23:16:30 +01:00
Commit Graph

11861 Commits

Author SHA1 Message Date
Sakthipriyan Vairamani
eea66e2a7b buffer: fix case of one buffer passed to concat
Fix Buffer.concat() so a copy is always returned regardless of the
number of buffers that were passed.

Previously if the array length was one then the same same buffer was
returned. This created a special case for the user where there was a
chance mutating the buffer returned by .concat() could mutate the buffer
passed in.

Also fixes an inconsistency when throwing if an array member was not a
Buffer instance. For example:

    Buffer.concat([42]);      // Returns 42
    Buffer.concat([42, 1]);  // Throws a TypeError

Now .concat() will always throw if an array member is not a Buffer
instance.

See: https://github.com/nodejs/io.js/issues/1891
PR-URL: https://github.com/nodejs/io.js/pull/1937
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-08-04 11:56:12 -07:00
Fedor Indutny
11e4249227 http_server: prefinish vs finish
Do not detach the socket from the response until all data is actually
sent to the other side.

See: https://github.com/iojs/io.js/pull/1373
PR-URL: https://github.com/nodejs/io.js/pull/1411
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-08-04 11:56:12 -07:00
Matteo Collina
ef2c8cd4ec dgram: make send cb act as "error" event handler
Modifies the dgram send() method to not emit errors when a DNS
lookup fails if there is a callback. Given that the same UDP
socket can be used to send messages to different hosts, the socket
can be reused even if one of those send() fails.

This slightly changes the behavior of a stable API, so that it behaves
as users would expect to.

This is based on https://github.com/joyent/node/pull/7738, which
landed in 77266d7fad.

Fixes: https://github.com/joyent/node/issues/4846
Refs: https://github.com/joyent/node/pull/7738
PR-URL: https://github.com/nodejs/io.js/pull/1796
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-04 11:56:12 -07:00
Chris Dickinson
3da057fef6 dgram: make send cb act as "error" event handler
This allows users to provide a callback that handles potential
errors resulting from a `socket.send` call. The original behavior
of emitting the error event on the socket is preserved.

Fixes: https://github.com/joyent/node/issues/4846
PR-URL: https://github.com/joyent/node/pull/7738
PR-URL: https://github.com/nodejs/io.js/pull/1796
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-04 11:56:12 -07:00
Domenic Denicola
3b021efe11 vm: fix symbol access
By using the new SetHandler API instead of SetNamedPropertyHandler, we can
intercept symbols now. This forces us to use Maybes and MaybeLocals more,
since this new API does not have a non-maybe variant.

Fixes: https://github.com/nodejs/io.js/issues/884
PR-URL: https://github.com/nodejs/io.js/pull/1773
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-04 11:56:11 -07:00
Domenic Denicola
7b81e4ba36 vm: remove unnecessary access checks
No reason to install access checks if they're always going to return
true.

PR-URL: https://github.com/nodejs/io.js/pull/1773
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-04 11:56:11 -07:00
Domenic Denicola
659dadd410 vm: fix property descriptors of sandbox properties
The GlobalPropertyQueryCallback was changed in 2010 to return an
integer instead of a boolean:

https://groups.google.com/forum/#!topic/v8-users/OOjHJrix-cU

This integer communicates the property descriptors of the property,
instead of just its presence or absence. However, the original
contextify code was probably written before this change, and it was
not updated when porting to Node.js.

Credit to @smikes for the test and the original PR of #885.

Fixes: https://github.com/nodejs/io.js/pull/864
Fixes: https://github.com/nodejs/io.js/pull/885
PR-URL: https://github.com/nodejs/io.js/pull/1773
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-04 11:56:11 -07:00
Trevor Norris
944f68046c crypto: remove kMaxLength on randomBytes()
New Buffer implementation allows greater than kMaxLength to be created.
So instead check if the passed value is a valid Smi.

PR-URL: https://github.com/nodejs/io.js/pull/1825
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-04 11:56:11 -07:00
Trevor Norris
8664084166 buffer: make additional changes to native API
Address comments and deprecations left in source files. These changes
include:

* Remove the deprecated API.
* Change Buffer::New() that did a copy of the data to Buffer::Copy()
* Change Buffer::Use() to Buffer::New()

PR-URL: https://github.com/nodejs/io.js/pull/1825
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-04 11:56:11 -07:00
Trevor Norris
36f78f4c1c buffer: switch API to return MaybeLocal<T>
Instead of aborting in case of internal failure, return an empty
Local<Object>. Using the MaybeLocal<T> API, users must check their
return values.

PR-URL: https://github.com/nodejs/io.js/pull/1825
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-04 11:56:11 -07:00
Trevor Norris
571ec13841 buffer: switch to using Maybe<T> API
Use the new Maybe<T> syntax for v8::Object::SetPrototype().

PR-URL: https://github.com/nodejs/io.js/pull/1825
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-04 11:56:11 -07:00
Trevor Norris
d75f5c8d0e buffer: finish implementing FreeCallback
Passing a FreeCallback to Buffer::New() now uses externalized
ArrayBuffer's.

PR-URL: https://github.com/nodejs/io.js/pull/1825
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-04 11:56:10 -07:00
Trevor Norris
63da0dfd3a buffer: implement Uint8Array backed Buffer
With V8 4.4 removing the external array data API currently used by
Buffer, the new implementation uses the Uint8Array to back Buffer.

Buffers now have a maximum size of Smi::kMaxLength, as defined by V8.
Which is ~2 GB on 64 bit and ~1 GB on 32 bit.

The flag --use-old-buffer allows using the old Buffer implementation.
This flag will be removed once V8 4.4 has landed.

The two JS Buffer implementations have been split into two files for
simplicity.

Use getter to return expected .parent/.offset values for backwards
compatibility.

PR-URL: https://github.com/nodejs/io.js/pull/1825
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-04 11:56:10 -07:00
Trevor Norris
23be6ca189 buffer: allow ARGS_THIS to accept a name
Allowing the name to be passed to the ARGS_THIS macro will make it
easier to share code with the Uint8Array implementation.

PR-URL: https://github.com/nodejs/io.js/pull/1825
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-04 11:56:10 -07:00
Rod Vagg
deb7ee93a7 deps: backport 7b24219346 from v8 upstream
Original:
	Fix lookup iterator checks in GetRealNamedProperty* methods

	BUG=v8:4143
	R=verwaest@chromium.org
	LOG=n

	Review URL: https://codereview.chromium.org/1161553004

	Cr-Commit-Position: refs/heads/master@{#28616}

PR-URL: https://github.com/nodejs/io.js/pull/1805
Reviewed-By: Domenic Denicola <domenic@domenicdenicola.com>
2015-08-04 11:56:10 -07:00
Julien Gilli
9bc2e26720 net: do not set V4MAPPED on FreeBSD
V4MAPPED is not supported on recent FreeBSD versions, at least on 10.1.
Thus, do not set this flag in net.connect on FreeBSD.

Fixes: https://github.com/joyent/node/issues/8540
Fixes: https://github.com/joyent/node/issues/9204
PR-URL: https://github.com/joyent/node/pull/18204
PR-URL: https://github.com/iojs/io.js/pull/1555
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-04 11:56:10 -07:00
cjihrig
df1994fe53 Revert "dns: remove AI_V4MAPPED hint flag on FreeBSD"
This reverts commit 04bea9f9c2.

PR-URL: https://github.com/iojs/io.js/pull/1555
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-04 11:56:10 -07:00
Michaël Zasso
d12df7f159 doc: update v8 flags in man page
PR-URL: https://github.com/iojs/io.js/pull/1701
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-04 11:56:09 -07:00
Chris Dickinson
d58e780504 deps: update v8 to 4.3.61.21
* @indutny's SealHandleScope patch (484bebc38319fc7c622478037922ad73b2edcbf9)
  has been cherry picked onto the top of V8 to make it compile.
* There's some test breakage in contextify.
* This was merged at the request of the TC.

PR-URL: https://github.com/iojs/io.js/pull/1632
2015-08-04 11:56:09 -07:00
Chris Dickinson
21d31c08e7 test: remove obsolete harmony flags 2015-08-04 11:56:08 -07:00
Sakthipriyan Vairamani
ed85c95a9c doc,test: documents behaviour of non-existent file
As per the discussion in
https://github.com/nodejs/io.js/pull/2093#discussion_r34343965, this
patch documents the behavior of calling fs.watchFile() with a path that
does not yet exist.

This patch also includes a test which checks if a file not present, the
callback is invoked at least once and if the file is created after
the callback is invoked, it will be invoked again with new stat
objects.

PR-URL: https://github.com/nodejs/io.js/pull/2169
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
2015-08-04 22:31:01 +05:30
Sakthipriyan Vairamani
ea05e760cd repl: don't clobber RegExp.$ properties
In REPL, if we evaluate the `RegExp` object's predefined properties,
and if they happen to have the same expression, for example,

    > RegExp.$1
    'RegExp.$1'

then doing `eval(RegExp.$1)` would evaluate `RegExp.$1` recursively and
eventually throw `RangeError: Maximum call stack size exceeded`.

This patch stores the old values of `RegExp`'s predefined proprties in
an array and restores them just before the current expression entered
by user is evaluated.

Fixes: https://github.com/nodejs/io.js/issues/597
PR-URL: https://github.com/nodejs/io.js/pull/2137
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-04 10:21:37 +05:30
Sakthipriyan Vairamani
64cf71195c test: change the hostname to an invalid name
In my Ubuntu 14.04.2 LTS machine, it tries to resolve the name
'blah.blah' and it fails with ETIMEOUT instead of ENOTFOUND. This patch
changes the hostname to "...", an invalid name, so that it will fail
immediately.

PR-URL: https://github.com/nodejs/io.js/pull/2287
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Evan Lucas <evanlucas@me.com>
2015-08-03 23:04:47 +05:30
Sakthipriyan Vairamani
80a1cf7425 test: fix messages and use return to skip tests
This is a followup of https://github.com/nodejs/io.js/pull/2109.
The tests which didn't make it in #2109, are included in this patch.
The skip messages are supposed to follow the format

    1..0 # Skipped: [Actual reason why the test is skipped]

and the tests should be skipped with the return statement.

PR-URL: https://github.com/nodejs/io.js/pull/2290
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
2015-08-03 21:32:48 +05:30
Bert Belder
9bac1dbae9 win,node-gyp: enable delay-load hook by default
The delay-load hook allows node.exe/iojs.exe to be renamed. See efadffe
for more background.

PR-URL: https://github.com/iojs/io.js/pull/1433
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-01 09:46:17 -07:00
cjihrig
2a63cf612b deps: make node-gyp work with io.js
Every npm version bump requires a few patches to be floated on
node-gyp for io.js compatibility. These patches are found in
03d199276e,
5de334c230, and
da730c76e9. This commit squashes
them into a single commit.

PR-URL: https://github.com/iojs/io.js/pull/990
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-01 09:46:17 -07:00
Kat Marchán
bf63266460 deps: upgrade to npm 2.13.3
PR-URL: https://github.com/nodejs/io.js/pull/2284
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-08-01 09:45:44 -07:00
Sakthipriyan Vairamani
d5ab92bcc1 test: use common.isWindows consistently
In the tests, we use "process.platform === 'win32'" in some places.
This patch replaces them with the "common.isWindows" for consistency.

PR-URL: https://github.com/nodejs/io.js/pull/2269
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-07-31 00:29:36 +05:30
Ben Noordhuis
fa98b97171 cluster: add handle ref/unref stubs in rr mode
Add ref() and unref() stub methods to the faux handle in round-robin
mode.  Fixes the following TypeError when calling `server.unref()` in
the worker:

    net.js:1521
        this._handle.unref();
                     ^
    TypeError: this._handle.unref is not a function
        at Server.unref (net.js:1521:18)

No actual reference counting is implemented.  It would effectively be
a no-op because the control channel would still keep the worker alive.

Fixes: https://github.com/nodejs/node/issues/73
PR-URL: https://github.com/nodejs/io.js/pull/2274
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-07-30 18:17:53 +02:00
Johan Bergström
3cbb5870e5 tools: expose skip output to test runner
In the TAP protocol, skips are flagged as ok. Expose more
information so we can understand if the test was skipped or not.

PR-URL: https://github.com/nodejs/io.js/pull/2130
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-07-30 08:45:03 +02:00
Ali Ijaz Sheikh
24dd016deb build: produce symbol map files on windows
This produces map files as part of the build on windows. The existence of
these files enable profiling and tick-processing using the --prof command
line.
See: https://github.com/nodejs/io.js/pull/2090#issuecomment-124746673

Map files are documented here:
https://msdn.microsoft.com/en-us/library/k7xkk3e2.aspx

PR-URL: https://github.com/nodejs/io.js/pull/2243
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-07-29 09:36:25 -07:00
Ben Noordhuis
bc733f7065 test: fix fs.readFile('/dev/stdin') tests
The tests were creating the temp fixture file in both the parent
and the child process, leading to interesting race conditions on
the slower buildbots.

Rod notes that the tests started failing after putting the build
directory on a NFS mount.

Fixes: https://github.com/nodejs/io.js/issues/2261
PR-URL: https://github.com/nodejs/io.js/pull/2265
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
2015-07-29 13:57:14 +02:00
Sakthipriyan Vairamani
d168d01b04 doc: properly inheriting from EventEmitter
There are so many buggy code out there, just because not inheriting
properly from `EventEmitter`. This patch gives an official
recommendation.

PR-URL: https://github.com/nodejs/io.js/pull/2168
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
2015-07-29 14:57:58 +05:30
Sam Roberts
500f2538cc doc: a listener, not "an" listener
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
PR-URL: https://github.com/nodejs/io.js/pull/1025
2015-07-28 11:06:14 -07:00
Sam Roberts
54627a919d doc: server close event does not have an argument
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
PR-URL: https://github.com/nodejs/io.js/pull/1025
2015-07-28 11:06:02 -07:00
cjihrig
a4b46001e8 Working on v2.5.1
PR-URL: https://github.com/nodejs/io.js/pull/2239
2015-07-28 11:22:37 -04:00
cjihrig
3ce020b7ba 2015-07-28 io.js v2.5.0 Release
Notable changes

* **https**: TLS sessions in Agent are reused (Fedor Indutny)
https://github.com/nodejs/io.js/pull/2228.
* **src**: base64 decoding is now 50% faster (Ben Noordhuis)
https://github.com/nodejs/io.js/pull/2193.
* **npm**: Upgraded to v2.13.2, release notes can be found in
<https://github.com/npm/npm/releases/tag/v2.13.2> (Kat Marchán)
https://github.com/nodejs/io.js/pull/2241.

PR-URL: https://github.com/nodejs/io.js/issues/2239
2015-07-28 11:08:18 -04:00
Ali Ijaz Sheikh
ab479659c7 util: delay creation of debug context
We need the debug context to be able to inspect promises. However, this is
very expensive and should not be done on default startup.

PR-URL: https://github.com/nodejs/io.js/pull/2248
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Christopher Monsanto <chris@monsan.to>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-07-27 17:14:08 -07:00
Rich Trott
c786d6341d test: do not use public IPs for timeout testing
PR-URL: https://github.com/nodejs/io.js/pull/2057
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-07-27 17:07:54 -07:00
Ben Noordhuis
543dabb609 timers: improve Timer.now() performance
Record the start time so we can make the return value of Timer.now()
relative to it, increasing the chances that it fits in a tagged integer
instead of a heap-allocated double, at least for the first one or two
billion milliseconds.

PR-URL: https://github.com/nodejs/io.js/pull/2256
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-07-28 00:13:30 +02:00
Ben Noordhuis
3663b124e6 timers: remove unused Timer.again()
PR-URL: https://github.com/nodejs/io.js/pull/2256
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-07-28 00:13:29 +02:00
Ben Noordhuis
bcce5cf9bb timers: remove unused Timer.getRepeat()
PR-URL: https://github.com/nodejs/io.js/pull/2256
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-07-28 00:13:27 +02:00
Ben Noordhuis
f2c83bd202 timers: remove unused Timer.setRepeat()
PR-URL: https://github.com/nodejs/io.js/pull/2256
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-07-28 00:13:02 +02:00
Evan Lucas
503b089dd8 net: don't throw on immediately destroyed socket
Fixes regression introduced in af249fa8a1.

With connect being deferred to the next tick, Socket.destroy could be
called before connect. Socket.destroy sets _connecting to false which
would cause an assertion error.

Fixes: https://github.com/nodejs/io.js/issues/2250
PR-URL: https://github.com/nodejs/io.js/pull/2251
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2015-07-27 16:23:21 -05:00
Fedor Indutny
2ca5a3db47 https: reuse TLS sessions in Agent
Fix: #1499
PR-URL: https://github.com/nodejs/io.js/pull/2228
Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-07-27 11:48:36 -07:00
Sakthipriyan Vairamani
4e78cd71c0 test: skip IPv6 part before testing it
PR-URL: https://github.com/nodejs/io.js/pull/2226
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
2015-07-27 23:24:03 +05:30
Trevor Norris
93660c8b8e node: remove bad fn call and check
These two lines exist because of a screw up on my part while combining
MakeCallback() and MakeDomainCallback().

The reason it never broke core tests is because any paths it would have
broken were rerouted to AsyncWrap::MakeCallback(). The only case that
node::MakeCallback() handles anymore is setImmediate().

Fix: a1da024 "node, async-wrap: remove MakeDomainCallback"
PR-URL: https://github.com/nodejs/io.js/pull/2157
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-07-27 11:41:07 -06:00
Nathan Woltman
99d9d7e716 benchmark: add remaining path benchmarks & optimize
As a follow-up to 0d15161, this commit adds benchmarks for the rest
of the path functions and also forces V8 to optimize the functions
before starting the benchmark test.

PR-URL: https://github.com/nodejs/io.js/pull/2103
Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
2015-07-26 22:17:41 -07:00
Ben Noordhuis
ac70bc8240 test: fix valgrind uninitialized memory warning
parallel/test-buffer called `Buffer.prototype.toString()` on a buffer
with uninitialized memory.  Call `Buffer.prototype.fill()` on it first.

PR-URL: https://github.com/nodejs/io.js/pull/2193
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-07-25 19:08:22 +02:00
Ben Noordhuis
8fd3ce100e src: make base64 decoding 50% faster
Make the inner loop execute fewer compare-and-branch executions per
processed byte, resulting in a 50% or more speedup.

This coincidentally fixes an out-of-bounds read:

    while (unbase64(*src) < 0 && src < srcEnd)

Should have read:

    while (src < srcEnd && unbase64(*src) < 0)

But this commit removes the offending code altogether.

Fixes: https://github.com/nodejs/io.js/issues/2166
PR-URL: https://github.com/nodejs/io.js/pull/2193
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-07-25 19:07:23 +02:00