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

3727 Commits

Author SHA1 Message Date
Brian White
18490d3d5a module: always decorate thrown errors
This provides more information when encountering a syntax or similar
error when executing a file with require().

Fixes: https://github.com/nodejs/node/issues/4286
PR-URL: https://github.com/nodejs/node/pull/4287
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-12-19 14:15:38 -05:00
Fedor Indutny
32ac3769f5 http: do not emit upgrade on advertisement
Do not emit `upgrade` if the server is just advertising its protocols
support as per RFC 7230 Section 6.7.

    A server MAY send an Upgrade header field in any other response
    to advertise that it implements support for upgrading to the
    listed protocols, in order of descending preference, when
    appropriate for a future request.

Fix: https://github.com/nodejs/node/issues/4334
PR-URL: https://github.com/nodejs/node/pull/4337
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-12-17 19:25:43 -05:00
Brian White
0b43c08f44 util: pass on additional error() args
This fixes breakage introduced in 94b9948d63 when writing the max
EventEmitter listeners warning to stderr.

PR-URL: https://github.com/nodejs/node/pull/4279
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-12-17 13:03:36 -05:00
Bo Borgerson
88de88b5a6 http: Remove an unnecessary assignment
This just removes an assignment to `ret` of a value that's not used before
it's overwritten.  Immediately following the assigment is an `if/else` in
which both branches assign to `ret` without using it.

PR-URL: https://github.com/nodejs/node/pull/4323
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-12-17 08:35:59 -08:00
Minwoo Jung
ae5bcf9528 lib: use arrow functions instead of bind
use `arrow functions` instead of `bind(this)` in order to improve
performance through optimizations.

PR-URL: https://github.com/nodejs/node/pull/3622
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
2015-12-17 19:45:57 +09:00
Xotic750
93d6b5fb68 util: use consistent Dates in inspect()
Fix: https://github.com/nodejs/node/issues/4314
PR-URL: https://github.com/nodejs/node/pull/4318
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-12-16 22:15:18 -05:00
cjihrig
2a60e2ad71 module,src: do not wrap modules with -1 lineOffset
In b799a74709 and
dfee4e3712 the module wrapping
mechanism was changed for better error reporting. However,
the changes causes issues with debuggers and profilers. This
commit reverts the wrapping changes.

Fixes: https://github.com/nodejs/node/issues/4297
PR-URL: https://github.com/nodejs/node/pull/4298
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
2015-12-16 10:07:20 -05:00
ronkorving
4b267df93e udp: remove a needless instanceof Buffer check
When a string is passed to udpsock.send, it is automatically
converted to a Buffer. In that case, it is no longer needed
to test whether or not the argument is a Buffer or not.

PR-URL: https://github.com/nodejs/node/pull/4301
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Roman Reiss <me@silverwind.io>
2015-12-16 06:53:03 +01:00
Fedor Indutny
acef181fde https: support disabling session caching
Zero value of `maxCachedSessions` should disable TLS session caching in
`https.Agent`

PR-URL: https://github.com/nodejs/node/pull/4252
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-12-12 12:48:29 -05:00
Fedor Indutny
c5b4f6bc99 tls: introduce secureContext for tls.connect
Add `secureContext` option to `tls.connect`. It is useful for caching
client certificates, key, and CA certificates.

PR-URL: https://github.com/nodejs/node/pull/4246
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-12-11 19:53:30 -05:00
Julien Gilli
425a3545d2 domains: fix handling of uncaught exceptions
Fix node exiting due to an exception being thrown rather than emitting
an `'uncaughtException'` event on the process object when:
1. no error handler is set on the domain within which an error is thrown
2. an `'uncaughtException'` event listener is set on the process

Also fix an issue where the process would not abort in the proper
function call if an error is thrown within a domain with no error
handler and `--abort-on-uncaught-exception` is used.

Finally, change the behavior of --abort-on-uncaught-exception so that,
if the domain within which the error is thrown has no error handler, but
a domain further up the domains stack has one, the process will not
abort.

Fixes #3607 and #3653.

PR: #3654
PR-URL: https://github.com/nodejs/node/pull/3654
Reviewed-By: Chris Dickinson <chris@neversaw.us>
2015-12-11 14:33:48 -08:00
Tom Gallacher
9a9c5259bf doc: Fixing broken links to the v8 wiki
PR-URL: https://github.com/nodejs/node/pull/4241
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
2015-12-11 10:24:46 -08:00
Prince J Wesley
aad6b9f0eb repl: display error message when loading directory
When loading directory instead of file, no error message
is displayed. It's good to display error message for
this scenario.

PR-URL: https://github.com/nodejs/node/pull/4170
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
2015-12-11 10:21:14 +09:00
Alexander Martin
67e181986a buffer: add includes() for parity with TypedArray
Add Buffer#includes() by wrapping an indexOf and performing a strict
equals check to -1.

The includes method takes the search value, byteOffset, and encoding as
arguments.

The test is a modified version of the indexOf test.

Fixes: https://github.com/nodejs/node/issues/3552
PR-URL: https://github.com/nodejs/node/pull/3567
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-12-10 13:41:40 -07:00
Ben Noordhuis
213ede6cee repl: fix require('3rdparty') regression
Fix module loading of third-party modules in the REPL by inheriting
module.paths from the REPL's parent module.

Commit ee72ee7 ("module,repl: remove repl require() hack") introduced
a regression where require() of modules in node_modules directories
no longer worked in the REPL (and fortunately only in the REPL.)
It turns out we didn't have test coverage for that but we do now.

Fixes: https://github.com/nodejs/node/issues/4208
PR-URL: https://github.com/nodejs/node/pull/4215
Reviewed-By: Roman Reiss <me@silverwind.io>
2015-12-09 23:30:02 +01:00
Rich Trott
da5cdc2207 assert: accommodate ES6 classes that extend Error
`assert.throws()` and `assert.doesNotThrow()` blow up with a `TypeError`
if used with an ES6 class that extends Error.

Fixes: https://github.com/nodejs/node/issues/3188
PR-URL: https://github.com/nodejs/node/pull/4166
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-12-09 09:05:20 -08:00
Matt Loring
49440b7ea2 tools: add --prof-process flag to node binary
This change cleans up outstanding comments on #3032. It improves error
handling when no isolate file is provided and adds the --prof-process
flag to the node binary which executes the tick processor on the
provided isolate file.

PR-URL: https://github.com/nodejs/node/pull/4021
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Evan Lucas <evanlucas@me.com>
2015-12-08 02:00:46 +01:00
Matt Loring
ec836547c4 buffer: fix range checking for slowToString
If `start` is not a valid number in the range, then the default value
zero will be used. Same way, if `end` is not a valid number in the
accepted range, then, by default, the length of the buffer is assumed.

Fixes: https://github.com/nodejs/node/issues/2668
Ref: https://github.com/nodejs/node/pull/2919
PR-URL: https://github.com/nodejs/node/pull/4019
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-12-07 16:52:53 -07:00
Fedor Indutny
de2fd63612 stream_wrap: error if stream has StringDecoder
If `.setEncoding` was called on input stream - all emitted `data` will
be `String`s instances, not `Buffer`s. This is unacceptable for
`StreamWrap`, and should not lead to the crash.

Fix: https://github.com/nodejs/node/issues/3970
PR-URL: https://github.com/nodejs/node/pull/4031
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-12-06 21:55:25 -05:00
yorkie
8c35903ba3 fs,doc: use target instead of destination
PR-URL: https://github.com/nodejs/node/pull/3912
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-12-05 18:25:05 -08:00
Bryce Baril
7239494b54 buffer: Prevent Buffer constructor deopt
The Buffer constructor will generally get inlined, but any call to the Buffer
constructor for a string without encoding will cause an eager deoptimization
of any function that inlined the Buffer constructor. This is due to a an
out-of-bounds read on `arguments[1]`. This change prevents that deopt.

PR-URL: https://github.com/nodejs/node/pull/4158
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
2015-12-06 08:28:06 +09:00
Fedor Indutny
d332ae4799 http: fix pipeline regression
Always check that socket still has the parser. It may be destroyed
interim, and we may end up with an uncaught exception.

Fix: https://github.com/nodejs/node/issues/3508
PR-URL: https://github.com/nodejs/node-private/pull/5
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-12-04 14:42:13 +11:00
Brian White
292218828e stream: be less eager with readable flag
As of 34b535f4c, test-child-process-flush-stdio was failing
on CentOS 5 systems in CI due to the change in stream state
checking in `child_process`. This commit fixes those failures
by making readable streams less eager in setting their readable
flag on EOF.

Fixes: https://github.com/nodejs/node/issues/4125
PR-URL: https://github.com/nodejs/node/pull/4141
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-12-03 21:59:44 -05:00
Minwoo Jung
94b9948d63 lib,src: ensure '(node:pid)' prefix for stdout logging
Add '(node:pid)' prefix message for stdout logging

PR-URL: https://github.com/nodejs/node/pull/3833
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
2015-12-03 12:24:38 -08:00
Myles Borins
b619831381 meta: remove use of profanity in source
The CoC requests to avoid the casual use of profanity.

PR-URL: https://github.com/nodejs/node/pull/4122
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: targos - Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
2015-12-02 11:05:11 -08:00
Brian White
cc0342a517 streams: update .readable/.writable to false
These properties were initially used to determine stream status
back in node v0.8 and earlier. Since streams2 however, these
properties were *always* true, which can be misleading for
example if you are trying to immediately determine whether
a Writable stream is still writable or not (to avoid a "write after
end" exception).

PR-URL: https://github.com/nodejs/node/pull/4083
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
2015-12-02 12:56:48 -05:00
cjihrig
6526ae7b37 util: determine object types in C++
Determine object types of regular expressions, Dates, Maps, and
Sets in the C++ layer instead of depending on toString()
behavior in JavaScript.

PR-URL: https://github.com/nodejs/node/pull/4100
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-12-02 11:16:21 -05:00
Andrei Sedoi
fbcd687c08 timers: optimize callback call: bind -> arrow
ES6 arrow functions are much more efficient than `.bind()` functions.

PR-URL: https://github.com/nodejs/node/pull/4038
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-12-02 11:14:28 -05:00
Evan Lucas
24012a879d util: make inspect more reliable
34a35919e1 added pretty printing for
TypedArray, ArrayBuffer, and DataView. This change allows inspecting
those across different contexts.

Since instanceof does not work across contexts, we can use
v8::Value::IsTypedArray, v8::Value::IsArrayBuffer, and
v8::Value::IsDataView

PR-URL: https://github.com/nodejs/node/pull/4098
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-12-02 06:11:45 -06:00
Zirak
451254ed25 repl: allow leading period in multiline input
When writing multiline input, one can't chain function calls as if the
lines begin with a period, since those are treated as REPL commands.

Before:

    > ([0, 1, 2]
    ... .map(x => x + 1))
    Invalid REPL keyword

After:

    > ([0, 1, 2]
    ... .map(x => x + 1))
    [ 1, 2, 3 ]

PR-URL: https://github.com/nodejs/node/pull/3835
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-12-01 19:40:43 -05:00
Peter A. Bigot
bea67422df buffer: fix writeInt{B,L}E for some neg values
The algorithm used to convert negative values to hex generates incorrect
values when the low byte(s) of the value are zero because a carried
subtraction is applied prematurely.

Fixes: https://github.com/nodejs/node/issues/3992
PR-URL: https://github.com/nodejs/node/pull/3994
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2015-12-01 15:58:47 -07:00
Dave
34b535f4ca child_process: flush consuming streams
When a client calls read() with a nonzero argument
on a Socket, that Socket sets this._consuming to true.
It never sets this._consuming back to false.
ChildProcess.flushStdio() currently doesn't flush
any streams where _consuming is truthy. But, that means
that it never flushes any stream that has ever been read from.
This prevents a child process from ever closing if one of
its streams has been read from, causing issue #4049. This
commit allows consuming streams to be flushed, and the
child process to emit a close event.

Fixes: https://github.com/nodejs/node/issues/4049
PR-URL: https://github.com/nodejs/node/pull/4071
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-12-01 09:55:35 -05:00
Brian White
82b8355e12 util: fix constructor/instanceof checks
These new checks are similar to the one introduced in 089d68861,
but for other types of objects. Specifically, if an object was
created in a different context, the constructor object will not be
the same as the constructor object in the current context, so we
have to compare constructor names instead.

PR-URL: https://github.com/nodejs/node/pull/3385
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
2015-11-30 21:44:52 -05:00
Ben Noordhuis
04b1a2f756 util: move .decorateErrorStack to internal/util
Move the method that was added in commit 8ca412b from earlier this month
from lib/util.js to lib/internal/util.js.

Avoids exposing a method that we may not wish to expose just yet, seeing
how it relies on implementation details.

PR-URL: https://github.com/nodejs/node/pull/4026
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-11-30 23:58:32 +01:00
Ben Noordhuis
ee72ee7531 module,repl: remove repl require() hack
Remove a hack that was introduced in commit bb6d468d from November 2010.
This is groundwork for a follow-up commit that makes it possible to use
internal modules in lib/repl.js.

PR-URL: https://github.com/nodejs/node/pull/4026
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-11-30 23:58:27 +01:00
Nathan Woltman
d1000b4137 path: make format() consistent and more functional
Make the win32 and posix versions of path.format() consistent in when
they add a directory separator between the dir and base parts of the
path (always add it unless the dir part is the same as the root).

Also, path.format() is now more functional in that it uses the name
and ext parts of the path if the base part is left out and it uses
the root part if the dir part is left out.

Reviewed-By: João Reis <reis@janeasystems.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/2408
2015-11-27 11:53:33 +00:00
cjihrig
459b106d6c repl: attach location info to syntax errors
Currently, when a file with a syntax error is imported in the
REPL, no information is provided on the error's location. This
commit adds the error's location to the stack trace.

Refs: https://github.com/nodejs/node/issues/2762
Refs: https://github.com/nodejs/node/issues/3411
Refs: https://github.com/nodejs/node/issues/3784
PR-URL: https://github.com/nodejs/node/pull/4013
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-11-25 13:34:13 -05:00
cjihrig
8ca412b7a3 util: add decorateErrorStack()
This commit adds the decorateErrorStack() method. This function
uses the internal util's getHiddenValue() method to extract
arrow messages from error objects and attach them to the
error's stack trace.

PR-URL: https://github.com/nodejs/node/pull/4013
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-11-25 13:28:06 -05:00
Tom Gallacher
93739f48ff buffer: default to UTF8 in byteLength()
If an undefined encoding is passed to byteLength(),
assume that it is UTF8 immediately. This yields a
small speedup, as it prevents string operations on
the encoding argument.

PR-URL: https://github.com/nodejs/node/pull/4010
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-11-25 10:53:52 -05:00
Jan Schär
d7b199d9e3 net: add local address/port for better errors
Adds localAddress and localPort to req so we have better error messages.
Also fixes a case where ex is used before it is declared.

PR-URL: https://github.com/nodejs/node/pull/3946
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-11-24 16:00:51 -06:00
cjihrig
5169311bf9 util,src: allow lookup of hidden values
This commit adds an internal util method that makes hidden
values in the C++ layer visible in JS.

PR-URL: https://github.com/nodejs/node/pull/3988
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-11-24 15:49:50 -05:00
Jan Schär
9472a0cfad net: small code cleanup
`options` is already a param of the function.

PR-URL: https://github.com/nodejs/node/pull/3943
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-11-20 15:53:11 -08:00
Tristian Flanagan
dfee4e3712 module: fix column offsets in errors
Because Node modules are wrapped, errors on the first line
of a file leak the wrapper to the user and report the wrong
column number. This commit adds a line break to the module
wrapper so that the first line is treated the same as all
other lines. To compensate for the additional line, a line
offset of -1 is also applied to errors.

Fixes: https://github.com/nodejs/node/issues/2860
PR-URL: https://github.com/nodejs/node/pull/2867
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-11-20 16:26:24 -05:00
Matt Loring
22478d3669 buffer: move checkFloat from lib into src
The type and range checks performed by this function can be done more
efficiently in native code.

PR-URL: https://github.com/nodejs/node/pull/3763
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-11-20 12:23:05 -07:00
Minwoo Jung
d01eb6882f lib: add 'pid' prefix in internal/util
This PR improves `prefix` in `util` that we've agreed on
https://github.com/nodejs/node/pull/3833
(separate code for javascript to move the printing function
to C++ directly)

PR-URL: https://github.com/nodejs/node/pull/3878
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-11-20 09:24:53 -08:00
cjihrig
ca2e8b292f readline: deprecate undocumented exports
This commit moves several of readline's undocumented functions
into an internal module. Specifically, isFullWidthCodePoint,
stripVTControlCharacters, getStringWidth, and emitKeys are
moved to the internal module. The existing public exports
of the first three functions are given a deprecation notice.

Refs: https://github.com/nodejs/node/pull/3847
Fixes: https://github.com/nodejs/node/issues/3836
PR-URL: https://github.com/nodejs/node/pull/3862
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
2015-11-19 17:01:25 -05:00
Wyatt Preul
007cfea308 util: remove pump
Remove util.pump and associated tests

PR-URL: https://github.com/nodejs/node/pull/2531
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-11-18 14:28:35 -08:00
Wyatt Preul
a2c0aa84e0 tty: Remove deprecated setRawMode wrapper
PR-URL: https://github.com/nodejs/node/pull/2528
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-11-18 13:16:02 -08:00
Wyatt Preul
4cf19ad1bb util: Remove exec, has been deprecated for years
PR-URL: https://github.com/nodejs/node/pull/2530
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-11-18 13:04:16 -08:00
Jackson Tian
b33e9da8f9 debugger: introduce exec method for debugger
In debugger, the usage of `repl` very ugly. I'd like there is a `p`
like gdb. So the `exec` is coming.

Usage:

```
$ ./iojs debug ~/git/node_research/server.js
< Debugger listening on port 5858
connecting to 127.0.0.1:5858 ... ok
break in /Users/jacksontian/git/node_research/server.js:1
> 1 var http = require('http');
  2
  3 http.createServer(function (req, res) {
debug> exec process.title
/Users/jacksontian/git/io.js/out/Release/iojs
debug>
```

And the `repl`:

```
debug> repl
Press Ctrl + C to leave debug repl
> process.title
'/Users/jacksontian/git/io.js/out/Release/iojs'
debug>
(^C again to quit)
```

The enter and leave debug repl is superfluous.

R-URL: https://github.com/nodejs/node/pull/1491
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-11-17 12:11:40 -08:00
Evan Lucas
4fed62c876 module: cache regular expressions
None of these regular expressions will change, so there is no need to
generate them every time in hot code paths.

Provides a small performance improvement in module loading. (5-10%)

PR-URL: https://github.com/nodejs/node/pull/3869
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-11-16 23:02:36 -08:00
Stefan Budeanu
df268f97bc tls: use SHA1 for sessionIdContext
FIPS 140-2 disallows use of MD5, which is used to derive the
default sessionIdContext for tls.createServer().

PR-URL: https://github.com/nodejs/node/pull/3866
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-11-16 17:26:23 -05:00
Stefan Budeanu
424ae5d4ac tls: Use SHA1 for sessionIdContext in FIPS mode
FIPS 140-2 disallows use of MD5, which is used to derive the
default sessionIdContext for tls.createServer().

PR-URL: https://github.com/nodejs/node/pull/3755
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-11-16 16:47:00 -05:00
Felix Böhm
a95eb5c671 debugger: also exit when the repl emits 'exit'
Exit the debug repl when repl emits 'exit'

Refs: https://github.com/nodejs/node-v0.x-archive/issues/5637
Fixes: https://github.com/nodejs/node-v0.x-archive/issues/5631
PR-URL: https://github.com/nodejs/node/pull/2369
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-11-16 10:05:24 -08:00
Minwoo Jung
9d0396cd63 util: use Object.create(null) for dictionary object
Fixes https://github.com/nodejs/node/issues/3788
`arrayToHash()` needs to use `Object.create(null)` for its dictionary object.

Refs: https://github.com/nodejs/node/pull/3791
PR-URL: https://github.com/nodejs/node/pull/3831
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-11-15 18:48:42 -08:00
Craig Cavalier
1736ad8264 zlib: only apply drain listener if given callback
When stream.flush() is called without a callback, an empty listener is
being added. Since flush may be called multiple times to push SSE's
down to the client, multiple noop listeners are being added. This in
turn causes the memory leak detected message.

PR-URL: https://github.com/nodejs/node/pull/3534
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-11-14 08:11:28 -08:00
Myles Borins
fa27c5634b zlib: pass kind to recursive calls to flush
Bug spotted by @bnoordhuis while doing code review on #3534

Refs: https://github.com/nodejs/node/pull/3534#discussion_r43047477
PR-URL: https://github.com/nodejs/node/pull/3534
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-11-14 08:10:02 -08:00
Ben Noordhuis
34a35919e1 util: improve typed array formatting
Pretty-print typed arrays like regular arrays.  Speeds up formatting by
almost 300% because it no longer stringifies the array indices.

Pretty-print ArrayBuffer and DataView as well by including byteLength,
byteOffset and buffer properties in the stringified representation.

PR-URL: https://github.com/nodejs/node/pull/3793
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-11-14 13:32:14 +01:00
Yosuke Furukawa
a776a86859 querystring: Parse multiple separator characters
Fix querystring.parse to handle multiple separator characters

PR-URL: https://github.com/nodejs/node/pull/3807
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-11-13 10:13:35 -08:00
Vladimir Varankin
a5cce79ec3 console: delete timers that have ended
Currently, console timers that have been ended with timeEnd()
are not removed. This has the potential to leak memory. This
commit deletes ended timers from the containing Map.

PR-URL: https://github.com/nodejs/node/pull/3562
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
2015-11-13 11:36:45 -05:00
cjihrig
7b355c5bb3 child_process: add safety checks on stdio access
When a child process is spawned, there is no guarantee that stdout
and stderr will be created successfully. This commit adds checks
before attempting to access the streams.

PR-URL: https://github.com/nodejs/node/pull/3799
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-11-12 17:52:09 -08:00
Zheng Chaoping
1594198600 fs: return null error on readFile() success
This commit ensures that readFile() callsback with a null
error consistently on success.

PR-URL: https://github.com/nodejs/node/pull/3740
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2015-11-11 13:58:47 -05:00
cjihrig
f299d870dc cluster: send suicide message on disconnect
This commit causes Worker.prototype.disconnect() to send a
suicide message to the cluster master. The function is also
restructured to eliminate redundant code.

Fixes: https://github.com/nodejs/node/issues/3238
PR-URL: https://github.com/nodejs/node/pull/3720
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-11-11 11:17:37 -05:00
cjihrig
b70dc67828 lib,test: remove publicly exposed freelist
The freelist module was deprecated in io.js and moved to an
internal module. This commit removes public access to freelist,
while leaving the internal module, which is still in use.

Fixes: https://github.com/nodejs/node/issues/569
PR-URL: https://github.com/nodejs/node/pull/3738
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2015-11-11 10:36:06 -05:00
Roman Reiss
9aee2c0e26 console: use 'label' argument for time and timeEnd
Turns out the argument is actually called label in the console spec,
while being wrongly named on MDN. This reverts commit
8c043c1245.

MDN has been updated in:

https://developer.mozilla.org/en-US/docs/Web/API/Console/timeEnd$compare?locale=en-US&to=947893&from=918571
https://developer.mozilla.org/en-US/docs/Web/API/Console/time$compare?locale=en-US&to=947891&from=896987

PR-URL: https://github.com/nodejs/node/pull/3590
Reviewed-By: targos - Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-11-10 15:37:06 +01:00
cjihrig
2c33819370 test: fix tests that check error messages
20285ad177 changed the format
of error messages throughout lib. However, the tests were not
updated to reflect these changes. This commit makes those
changes.

PR-URL: https://github.com/nodejs/node/pull/3727
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-11-10 07:12:33 +01:00
Hemanth.HM
354f9ce458 repl: To exit, press ^C again or type .exit.
When the user hits `^C` in the REPL show more info about `.exit`.

The idea was to give more info to the user when they hit ^C.
Current version just displays `(^C again to quit)` and most
of the users are not aware of the `.exit` command that would
Exit the repl.

PR-URL: https://github.com/nodejs/node/pull/3368
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-11-09 11:52:13 -08:00
micnic
20285ad177 lib: Consistent error messages in all modules
This commit fixes some error messages that are not consistent with
some general rules which most of the error messages follow.

PR-URL: https://github.com/nodejs/node/pull/3374
Reviewed-By: Roman Reiss <me@silverwind.io>
2015-11-09 20:08:36 +01:00
Ben Noordhuis
33827e3f68 cluster: remove handles when disconnecting worker
Due to the race window between the master's "disconnect" message and the
worker's "handle received" message, connections sometimes got stuck in
the pending handles queue when calling `worker.disconnect()` in the
master process.

The observable effect from the client's perspective was a TCP or HTTP
connection that simply stalled.  This commit fixes that by closing open
handles in the master when the "disconnect" message is sent.

Fixes: https://github.com/nodejs/node/issues/3551
PR-URL: https://github.com/nodejs/node/pull/3677
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-11-06 23:02:11 +01:00
qinjia
02a44e0bfd util: use regexp instead of str.replace().join()
PR-URL: https://github.com/nodejs/node/pull/3689
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-11-06 07:35:05 -08:00
Andres Suarez
faa3bb8663 module: remove unnecessary JSON.stringify
`debuglog` uses `%j` as a placeholder for replacement with
`JSON.stringify`. So that `JSON.stringify` is only called when the
appropriate debug flag is on. The other `%s` changes are for style
consistency.

PR-URL: https://github.com/nodejs/node/pull/3578
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-11-05 09:48:11 -08:00
Ashok Suthar
8625a3815e http: remove unneeded cb check from setTimeout()
- This check is already covered in EventEmitter#addListener()

Refs: https://github.com/nodejs/node/pull/3618
PR-URL: https://github.com/nodejs/node/pull/3631
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-11-05 11:34:31 -05:00
Evan Lucas
a4a0efc534 repl: don't crash if cannot open history file
Previously, if we are unable to open the history file, an error would
be thrown. Now, print an error message that we could not open
the history file, but don't fail.

Fixes: https://github.com/nodejs/node/issues/3610
PR-URL: https://github.com/nodejs/node/pull/3630
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-11-03 09:52:35 -06:00
Ben Noordhuis
82022a79b0 test: more regression tests for minDHSize option
Check that tls.connect() fails in the expected way when passing in
invalid minDHSize options.

PR-URL: https://github.com/nodejs/node/pull/3629
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2015-11-03 11:47:26 +01:00
Rich Trott
cf0130dc0d lib: return boolean from child.send()
Previous change reinstated returning boolean from child.send() but
missed one instance where undefined might be returned instead.

PR-URL: https://github.com/nodejs/node/pull/3577
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-10-29 17:00:27 -07:00
Ben Noordhuis
57bce60da3 child_process: don't fork bomb ourselves from -e
Remove the `-e` argument from process.execArgv in child_process.fork()
to keep `node -e 'require("child_process").fork("empty.js")'` from
spawning itself recursively.

Fixes: https://github.com/nodejs/node/issues/3574
PR-URL: https://github.com/nodejs/node/pull/3575
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2015-10-29 01:31:54 +01:00
Myles Borins
6b0c906e6b tls: remove util and calls to util.format
Currently util.format is being used for string templating in tls.
By replacing all of the instances of util.format with backtick
string we can remove the need to require util in tls all together.

PR-URL: https://github.com/nodejs/node/pull/3456
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-10-28 16:57:55 -07:00
Rich Trott
cdcf00a0b9 lib,doc: return boolean from child.send()
The documentation indicates that child.send() returns a boolean but it
has returned undefinined at since v0.12.0. It now returns a boolean per
the (slightly updated) documentation.

PR-URL: https://github.com/nodejs/node/pull/3516
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-10-28 16:21:36 -07:00
Sakthipriyan Vairamani
6cf19103b6 repl: handle comments properly
As it is, the comments are not handled properly in REPL. So, if the
comments have `'` or `"`, then they are treated as incomplete string
literals and the error is thrown in REPL.

This patch refactors the existing logic and groups everything in a
class.

Fixes: https://github.com/nodejs/node/issues/3421
PR-URL: https://github.com/nodejs/node/pull/3515
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-10-28 07:32:07 +05:30
Sakthipriyan Vairamani
aaf9b488e2 lib,test: update let to const where applicable
As per the `prefer-const` eslint rule, few instances of `let` have been
identified to be better with `const`. This patch updates all those
instances.

Refer: https://github.com/nodejs/node/issues/3118
PR-URL: https://github.com/nodejs/node/pull/3152
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
2015-10-27 23:03:33 +05:30
Rich Trott
da21dba1a0 lib: fix cluster handle leak
It is possible to cause a resource leak in SharedHandle. This commit
fixes the leak.

Fixes: https://github.com/nodejs/node/issues/2510
PR-URL: https://github.com/nodejs/node/pull/3510
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-10-27 09:55:15 -07:00
ronkorving
c339fa36f5 fs: reduced duplicate code in fs.write()
PR-URL: https://github.com/nodejs/node/pull/2947
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-10-27 10:48:55 -06:00
Michaël Zasso
29da8cf8d7 util: make inherits work with classes
The current implementation overwrites the prototype of the target
constructor. It is not allowed with ES2015 classes because the prototype
property is read only. Use Object.setPrototypeOf instead.

Fixes: https://github.com/nodejs/node/issues/3452
PR-URL: https://github.com/nodejs/node/pull/3455
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-10-27 06:40:05 +01:00
Sakthipriyan Vairamani
437930c0cc http{s}: don't connect to localhost on invalid URL
If the URL passed to `http{s}.request` or `http{s}.get` is not properly
parsable by `url.parse`, we fall back to use `localhost` and port 80.
This creates confusing error messages like in this question
http://stackoverflow.com/q/32675907/1903116.

This patch throws an error message, if `url.parse` fails to parse the
URL properly.

Previous Discussion: https://github.com/nodejs/node/pull/2966
PR-URL: https://github.com/nodejs/node/pull/2967

Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-10-27 08:47:23 +05:30
Trevor Norris
3308e5ea2a buffer: fix value check for writeUInt{B,L}E
Fixes: https://github.com/nodejs/node/issues/3497
PR-URL: https://github.com/nodejs/node/pull/3500
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-10-26 14:57:35 -06:00
Shigeki Ohtsu
802a2e79e1 tls, crypto: add ALPN Support
ALPN is added to tls according to RFC7301, which supersedes NPN.
When the server receives both NPN and ALPN extensions from the client,
ALPN takes precedence over NPN and the server does not send NPN
extension to the client. alpnProtocol in TLSSocket always returns
false when no selected protocol exists by ALPN.
In https server, http/1.1 token is always set when no
options.ALPNProtocols exists.

PR-URL: https://github.com/nodejs/node/pull/2564
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-10-27 01:31:47 +09:00
Evan Lucas
57359cd1e4 fs: don't throw in read if buffer too big
If the resulting buffer.toString() call in fs.read throws, catch the
error and pass it back in the callback.

This issue only presents itself when fs.read is called using the legacy
string interface:

fs.read(fd, length, position, encoding, callback)

PR-URL: https://github.com/nodejs/node/pull/3503
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-10-25 21:24:12 -05:00
Evan Lucas
b6207906c4 fs: pass err to callback if buffer is too big
In fs.readFile, if an encoding is specified and toString fails, do not
throw an error. Instead, pass the error to the callback.

Fixes: https://github.com/nodejs/node/issues/2767
PR-URL: https://github.com/nodejs/node/pull/3485
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-10-23 16:09:46 -05:00
Jeremiah Senkpiel
ecab7a6bee repl: event ordering: delay 'close' until 'flushHistory'
Emitting 'close' before the history has flushed is somewhat incorrect
and rather confusing.

This also makes the 'close' event always asynchronous for consistency.

Refs: https://github.com/nodejs/node/pull/2356
PR-URL: https://github.com/nodejs/node/pull/3435
Reviewed By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-10-22 13:39:04 -04:00
Rich Trott
b354be7761 lib: avoid REPL exit on completion error
If a tab completion is attempted on an undefined reference inside of a
function, the REPL was exiting without reporting an error or anything
else. This change results in the REPL reporting the ReferenceError and
continuing.

Fixes: https://github.com/nodejs/node/issues/3346
PR-URL: https://github.com/nodejs/node/pull/3358
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-10-21 15:30:49 -07:00
Yuval Brik
adfd20b6fd tls: TLSSocket options default isServer false
Upon creating a TLSSocket object, set the default isServer option to false
Updated tls docs and added test-tls-socket-default-options

PR-URL: https://github.com/nodejs/node/pull/2614
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-10-20 16:14:22 -04:00
Fedor Indutny
3eecdf9f14 timers: reuse timer in setTimeout().unref()
Instead of creating new timer - reuse the timer from the freelist. This
won't make the freelist timer active for the duration of `uv_close()`,
and will let the event-loop exit properly.

Fix: #1264
PR-URL: https://github.com/nodejs/node/pull/3407
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-10-20 14:20:24 -04:00
Wyatt Preul
8b4adb267b util: Remove p, has been deprecated for years
Update deprecation test to use another method.

Ref: https://github.com/nodejs/node/pull/2529
PR-URL: https://github.com/nodejs/node/pull/3432
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-10-19 20:52:56 +02:00
Jeremiah Senkpiel
73b7e052c0 repl: limit persistent history correctly on load
Previously the wrong end of the history was limited on load.

PR-URL: https://github.com/nodejs/node/pull/2356
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed By: Evan Lucas <evanlucas@me.com>
2015-10-19 11:53:54 -04:00
Коренберг Марк
d8db75730f tls: add options argument to createSecurePair
Helps in implementation of #6204, where some options passed to
`createSecurePair()` are ignored before this patch.

These options are very helpful if someone wants to pass
`options.servername` or `options.SNICallback` to securepair.

PR-URL: https://github.com/nodejs/node/pull/2441
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-10-17 11:53:45 -04:00
Johannes Wüller
0803962860 fs: add file descriptor support to *File() funcs
These changes affect the following functions and their synchronous
counterparts:

 * fs.readFile()
 * fs.writeFile()
 * fs.appendFile()

If the first parameter is a uint32, it is treated as a file descriptor.
In all other cases, the original implementation is used to ensure
backwards compatibility. File descriptor ownership is never taken from
the user.

The documentation was adjusted to reflect these API changes. A note was
added to make the user aware of file descriptor ownership and the
conditions under which a file descriptor can be used by each of these
functions.

Tests were extended to test for file descriptor parameters under the
conditions noted in the relevant documentation.

PR-URL: https://github.com/nodejs/node/pull/3163
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-10-16 17:14:21 -06:00
Michaël Zasso
8c043c1245 console: rename argument of time and timeEnd
Name it timerName instead of label. It is clearer that way and matches
the description in the doc. It is also how it's named in MDN.

PR-URL: https://github.com/nodejs/node/pull/3166
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-10-16 21:03:44 +02:00
Michaël Zasso
419f7d4726 console: sub-millisecond accuracy for console.time
This makes the output of console.timeEnd in line with major browsers.

PR-URL: https://github.com/nodejs/node/pull/3166
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-10-16 21:00:51 +02:00
Shigeki Ohtsu
0140e1b5e3 tls: output warning of setDHParam to console.trace
To make it easy to figure out where the warning comes from.
Also fix style and variable name that was made in #1739.

PR-URL: https://github.com/nodejs/node/pull/1831
Reviewed-By: indutny - Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
2015-10-16 11:40:05 +09:00
Shigeki Ohtsu
f72e178a78 tls: add minDHSize option to tls.connect()
Add a new option to specifiy a minimum size of an ephemeral DH
parameter to accept a tls connection. Default is 1024 bit.

PR-URL: https://github.com/nodejs/node/pull/1831
Reviewed-By: indutny - Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
2015-10-16 11:39:54 +09:00
Shigeki Ohtsu
6d92ebac11 tls: add TLSSocket.getEphemeralKeyInfo()
Returns an object representing a type, name and size of an ephemeral
key exchange in a client connection. Currently only DHE and ECHE are
supported.

This api only works on on a client connection. When it is called on a
server connection, null is returned. When its key exchange is not
ephemeral, an empty object is returned.

PR-URL: https://github.com/nodejs/node/pull/1831
Reviewed-By: indutny - Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
2015-10-16 11:39:45 +09:00
Calvin Metcalf
8854183fe5 stream: avoid unnecessary concat of a single buffer.
Avoids doing a buffer.concat on the internal buffer
when that array has only a single thing in it.

Reviewed-By: Chris Dickinson <chris@neversaw.us>
Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/3300
2015-10-14 12:28:52 -07:00
Fedor Indutny
ab03635fb1 http: fix stalled pipeline bug
This is a two-part fix:

- Fix pending data notification in `OutgoingMessage` to notify server
  about flushed data too
- Fix pause/resume behavior for the consumed socket. `resume` event is
  emitted on a next tick, and `socket._paused` can already be `true` at
  this time. Pause the socket again to avoid PAUSED error on parser.

Fix: https://github.com/nodejs/node/issues/3332
PR-URL: https://github.com/nodejs/node/pull/3342
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-10-14 12:16:18 -04:00
Fábio Santos
85b74de9de stream: fix signature of _write() in a comment
This comment was a bit misleading, since it was missing the `encoding`
argument.

PR-URL: https://github.com/nodejs/node/pull/3248
Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
2015-10-13 22:32:21 -07:00
Ryan Graham
bde32f8a4d lib: fix undefined timeout regression
63644dd1cd introduced a regression caused by everyone's favourite
JavaScript feature: undefined < 0 === undefined >= 0.

Add a case to the existing tests to cover this scenario and then add
the check for undefined that makes the test pass.

PR-URL: https://github.com/nodejs/node/pull/3331
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed By: Evan Lucas <evanlucas@me.com>
2015-10-12 19:25:14 -04:00
Fedor Indutny
51325c03d4 tls: use parent handle's close callback
When closing the child TLSWrap handle - wait for the proper parent's
handle close callback invocation. `uv_close_cb` may be invoked much
later than the next libuv tick, depending on the platform.

The only platform that currently seem to defer `uv_close_cb` is Windows
XP. This behavior was not observed on other Windows systems, and is not
possible on Unixes.

Fix: https://github.com/nodejs/node/issues/2979
PR-URL: https://github.com/nodejs/node/pull/2991
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-10-12 13:26:51 -04:00
Trevor Norris
a713024579 net: don't throw on bytesWritten access
If bytesWritten is accessed before the object has been properly
constructed then return undefined.

Fixes: https://github.com/nodejs/node/issues/3298
PR-URL: https://github.com/nodejs/node/pull/3305
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-10-12 08:29:30 -06:00
Brian White
68990948fe stream: avoid pause with unpipe in buffered write
If a pipe is cleaned up (due to unpipe) during a write that
returned false, the source stream can get stuck in a paused state.

Fixes: https://github.com/nodejs/node/issues/2323
PR-URL: https://github.com/nodejs/node/pull/2325
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2015-10-11 14:07:25 -04:00
Trevor Norris
e97dae573c buffer: don't abort on prototype getters
Accessing prototype properties directly on a typed array will throw. So
do an extra check in Buffer's own getters to verify it is being called
on an instance.

Fixes: https://github.com/nodejs/node/issues/3297
PR-URL: https://github.com/nodejs/node/pull/3302
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-10-09 15:42:23 -06:00
Rich Trott
47befffc53 lib,test: deprecate _linklist
Deprecate _linklist and add test to confirm internal linklist and
public _linklist are the same.

PR-URL: https://github.com/nodejs/node/pull/3078
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-10-08 17:32:08 -07:00
Ben Noordhuis
ded4f91eef assert: support arrow functions in .throws()
`x instanceof f` where f is an arrow function throws a (spec-conforming)
"Function has non-object prototype 'undefined' in instanceof check"
exception.

Add a workaround so that it's possible to pass arrow functions as the
second argument to assert.throws().  The try/catch block is a little
jarring but swapping around the clauses in the if statements changes
the semantics too much.

Fixes: https://github.com/nodejs/node/issues/3275
PR-URL: https://github.com/nodejs/node/pull/3276
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2015-10-08 19:26:01 +02:00
Karl Skomski
a18dd7b788 src: replace naive search in Buffer::IndexOf
Adds the string search implementation from v8
which uses naive search if pattern length < 8
or to a specific badness then uses Boyer-Moore-Horspool

Added benchmark shows the expected improvements
Added option to use ucs2 encoding with Buffer::IndexOf

Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/2539
2015-10-07 21:09:53 -07:00
Fedor Indutny
184f09dbe4 http: cork/uncork before flushing pipelined res
Make sure that the pipelined response data will be written as less TCP
packets as possible.

PR-URL: https://github.com/nodejs/node/pull/3172
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-10-06 19:41:45 -04:00
James M Snell
e655a437b3 http: do not allow multiple instances of certain response headers
Response headers such as ETag and Last-Modified do not permit
multiple instances, and therefore the comma-separated syntax is
not allowed. When multiple values for these headers are specified,
use only the first instance.

Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
PR-URL: https://github.com/nodejs/node/pull/3090
2015-10-06 14:53:21 -07:00
James M Snell
0094a8dad7 http: add callback is function check
We were checking that the callback existed, but not
checking that it was a function. In `setTimeout`, if
callback is truthy but not a function, throw a
TypeError

Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
PR-URL: https://github.com/nodejs/node/pull/3090
2015-10-06 14:53:06 -07:00
Trevor Norris
8a685e7fe3 buffer: clean up usage of __proto__
Prefer using Object.setPrototypeOf() instead.

PR-URL: https://github.com/nodejs/node/pull/3080
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-10-06 15:41:24 -06:00
Evan Lucas
a1bda1b4de util: fix for inspecting promises
The upgrade to v8 4.6 removes ObjectIsPromise. This change utilizes
v8::Value::IsPromise to verify that the argument is indeed a promise.

PR-URL: https://github.com/nodejs/node/pull/3221
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-10-06 16:19:55 -05:00
Rich Trott
070aac4a87 lib: remove redundant code, add tests in timers.js
insert() is only called from one place where there is already a check
that msecs is greater than or equal to zero, so do not repeat the check
inside insert().

timers.active() is not documented and should not be exposed, but since
it is exposed for now, let's test it.

PR-URL: https://github.com/nodejs/node/pull/3143
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2015-10-06 08:28:07 -07:00
Sakthipriyan Vairamani
6ad458b752 module: remove unnecessary property and method
`require.paths` property and `require.registerExtension` function have
been throwing errors when used. They both are like this for years now.
This patch removes them from the system.

PR-URL: https://github.com/nodejs/node/pull/2922
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-10-06 18:56:20 +05:30
Evan Lucas
88533881dd util: correctly inspect Map/Set Iterators
Previously, a MapIterator or SetIterator would
not be inspected properly. This change makes it possible
to inspect them by creating a Debug Mirror and previewing
the iterators to not consume the actual iterator that
we are trying to inspect.

This change also adds a node_util binding that uses
v8's Value::IsSetIterator and Value::IsMapIterator
to verify that the values passed in are actual iterators.

Fixes: https://github.com/nodejs/node/issues/3107
PR-URL: https://github.com/nodejs/node/pull/3119
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-10-05 20:24:08 -05:00
Evan Lucas
089d688617 util: fix check for Array constructor
In the event an Array is created in a Debug context, the constructor
will be Array, but !== Array. This adds a check
constructor.name === 'Array' to handle edge cases like that.

PR-URL: https://github.com/nodejs/node/pull/3119
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-10-05 20:24:08 -05:00
Jeremy Whitlock
77a10ed05f src: fix --abort-on-uncaught-exception
Revert 0af4c9ea74, parts of
921f2de6cf and port
https://github.com/nodejs/node-v0.x-archive/pull/25835 from v0.12 to
master so that node aborts at the right time when an error is thrown
and --abort-on-uncaught-exception is used.

Fixes #3035.

PR: #3036
PR-URL: https://github.com/nodejs/node/pull/3036
Reviewed-By: Ben Noordhuis <ben@strongloop.com>
2015-10-05 18:12:43 -07:00
Justin Chase
8593b3e8eb module: use UNC paths when loading native addons
When using require to load a native addon the path must be converted
into a long path, otherwise the addon will fail to be loaded on
windows if the path is longer than 260 characters.

PR-URL: https://github.com/nodejs/node/pull/2965
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Benjamin Gruenbaum <inglor@gmail.com>
2015-10-05 22:09:51 +02:00
Fedor Indutny
59cb053394 http: add comment about outputSize in res/server
PR-URL: https://github.com/nodejs/node/pull/3128
2015-10-06 07:03:39 +11:00
Fedor Indutny
b3d96782d4 http_server: pause socket properly
Account pending response data to decide whether pause the socket or
not. Writable stream state is a not reliable measure, because it just
says how much data is pending on a **current** request, thus not helping
much with problem we are trying to solve here.

PR-URL: https://github.com/nodejs/node/pull/3128
2015-10-06 07:02:20 +11:00
Fedor Indutny
05040664c2 http: fix out-of-order 'finish' bug in pipelining
Changes to `stream_base.cc` are required to support empty writes.
Fixes CVE-2015-7384, https://github.com/nodejs/node/issues/3138

Fix: https://github.com/nodejs/node/issues/2639
PR-URL: https://github.com/nodejs/node/pull/3128
2015-10-06 07:02:20 +11:00
Dave Eddy
2e6ece44e1 node: add -c|--check CLI arg to syntax check script
PR-URL: https://github.com/nodejs/node/pull/2411
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Evan Lucas <evanlucas@me.com>
2015-10-03 21:58:38 +10:00
charlierudolph
87e820ead5 fs: include filename in watch errors
This commit adds the relevant filename to fs.watch() errors.

Refs: https://github.com/nodejs/node-v0.x-archive/pull/25542
PR-URL: https://github.com/nodejs/node/pull/2748
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-10-02 10:04:02 -04:00
Trevor Norris
3f476ada1e async_wrap: ensure all objects have internal field
If the constructor can't assign a class id then the heap snapshot will
not be able to report the object. So ensure that all AsyncWrap instances
use a FunctionTemplate instance with an internal field count >= 1.

PR-URL: https://github.com/nodejs/node/pull/3139
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-by: Stephen Belanger <admin@stephenbelanger.com>
2015-10-01 13:56:25 -06:00
Ben Noordhuis
9a1bc4ea7e util: optimize promise introspection
Use V8's builtin ObjectIsPromise() to check that the value is a promise
before creating the promise mirror.  Reduces garbage collector strain
in the (common) non-promise case, which is beneficial when inspecting
deep object graphs.

PR-URL: https://github.com/nodejs/node/pull/3130
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2015-09-30 23:43:16 +02:00
Brendan Ashworth
20dae2a906 smalloc: remove module
Bye bye, smalloc. I'm not sure why this was still here; it was removed
in 70d1f32 and hasn't worked since. It wasn't packaged in the
binary, either.

Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
PR-URL: https://github.com/nodejs/node/pull/3099
2015-09-28 16:22:48 -07:00
Roman Reiss
680dda8023 dns: remove nonexistant exports.ADNAME
This error code export was mistakingly introduced in a 2012 commit which
added more error codes. The correct export.BADNAME was added in
https://github.com/nodejs/node/pull/3051.

Semver: Major
PR-URL: https://github.com/nodejs/node/pull/3051
Fixes: https://github.com/nodejs/node/issues/3050
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2015-09-27 15:34:08 +02:00
Roman Reiss
24fe112ec5 dns: add missing exports.BADNAME
Adds the documented but missing DNS error exports.BADNAME. This export
has been there before but got lost in a 2012 commit that added more
error codes. https://github.com/nodejs/node/pull/3076 will remove the
wrong error code exports.ADNAME.

PR-URL: https://github.com/nodejs/node/pull/3051
Fixes: https://github.com/nodejs/node/issues/3050
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
2015-09-27 13:50:03 +02:00
James M Snell
6192c9892f http: add checkIsHttpToken check for header fields
Ref: https://github.com/nodejs/node-convergence-archive/issues/13

This adds a new check for header and trailer fields names and method
names to ensure that they conform to the HTTP token rule. If they do
not, a `TypeError` is thrown.

Previously this had an additional `strictMode` option that has been
removed in favor of making the strict check the default (and only)
behavior.

Doc and test case are included.

On the client-side
```javascript
var http = require('http');
var url = require('url');
var p = url.parse('http://localhost:8888');
p.headers = {'testing 123': 123};
http.client(p, function(res) { }); // throws
```

On the server-side
```javascript
var http = require('http');
var server = http.createServer(function(req,res) {
  res.setHeader('testing 123', 123); // throws
  res.end('...');
});
```

Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Trevor Norris <trevnorris@nodejs.org>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
PR-URL: https://github.com/nodejs/node/pull/2526
2015-09-25 08:37:57 -07:00
Evan Lucas
b50e89e01f path: improve posixSplitPath performance
Instead of slicing the first element off of the matches, shift and then
return. This improves performance of the following path functions:

- basename: 18-20%
- extname: 60-70%
- dirname: 18-20%
- parse: 20-25%

PR-URL: https://github.com/nodejs/node/pull/3034
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2015-09-25 08:28:26 -05:00
Fedor Indutny
36b969ff44 child_process: null channel handle on close
`HandleWrap::OnClose` destroys the underlying C++ object and null's the
internal field pointer to it. Therefore there should be no references to
the wrapping JavaScript object.

`null` the process' `_channel` field right after closing it, to ensure
no crashes will happen.

Fix: https://github.com/nodejs/node/issues/2847
PR-URL: https://github.com/nodejs/node/pull/3041
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-09-25 00:17:45 -04:00
Sakthipriyan Vairamani
f32a606e37 lib,src: remove usage of events.EventEmitter
The `events` module already exports `EventEmitter` constructor function
So, we don't have to use `events.EventEmitter` to access it.

Refer: https://github.com/nodejs/node/pull/2896

PR-URL: https://github.com/nodejs/node/pull/2921
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
2015-09-23 00:23:08 +05:30
Salman Aljammaz
ccea33df62 repl: don't use tty control codes when $TERM is set to "dumb"
This change stops the REPL from using ANSI control codes for colours
when the TERM environment variable is set to "dumb".

"dumb" is the terminal type with the smallest set of capabilities as
described by terminfo. See:

http://invisible-island.net/ncurses/terminfo.ti.html#toc-_Specials

Related: https://github.com/nodejs/node-v0.x-archive/issues/5344
Related: https://github.com/nodejs/node-v0.x-archive/pull/25506
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
PR-URL: https://github.com/nodejs/node/pull/2712
2015-09-22 19:38:46 +02:00
Malcolm Ahoy
79d2c4e1bf http: remove redundant code in _deferToConnect
Logic for calling the passed in socket method and/or callback
was duplicated. This commit refactors the relevant code to
remove the redundancy.

PR-URL: https://github.com/nodejs/node/pull/2769
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
2015-09-22 11:04:26 -04:00
Sakthipriyan Vairamani
fcfd87d7e1 repl: backslash bug fix
The actual problem was with the line parsing logic for string literals.
When we use backslash in the string literals, it used to remember the
`\` as the previous character even after we parsed the character next
to it. This leads to REPL thinking that the end of string literals is
not reached.

This patch replaces the previous character with `null`, so that it will
properly skip the character next to it.

Previous Discussion: https://github.com/nodejs/node/pull/2952
Fixes: https://github.com/nodejs/node/issues/2749
PR-URL: https://github.com/nodejs/node/pull/2968
Reviewed-By: Roman Reiss <me@silverwind.io>
2015-09-22 16:43:14 +02:00
Ben Noordhuis
e68a119c18 http: guard against response splitting in trailers
Commit 3c293ba ("http: protect against response splitting attacks")
filters out newline characters from HTTP headers but forgot to apply
the same logic to trailing HTTP headers, i.e., headers that come after
the response body.  This commit rectifies that.

The expected security impact is low because approximately no one uses
trailing headers.  Some HTTP clients can't even parse them.

PR-URL: https://github.com/nodejs/node/pull/2945
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Rod Vagg <r@va.gg>
2015-09-18 21:36:27 +02:00
Matt Harrison
e29e470c14 readline: fix tab completion bug
This fixes a problem where tab completion is empty when the input
stream column size is undefined. As a solution we can force maxColumns
to 1 in this scenario.

PR-URL: https://github.com/nodejs/node/pull/2816
Fixes: https://github.com/nodejs/node/issues/2396
Reviewed-By: Roman Reiss <me@silverwind.io>
2015-09-18 14:32:00 +02:00
Trevor Norris
0a329d2d1f buffer: don't set zero fill for zero-length buffer
Instantiating a Buffer of length zero would set the kNoZeroFill flag to
true but never actually call ArrayBuffer::Allocator(). Which means the
flag was never set back to false. The result was that the next
allocation would unconditionally not be zero filled.

Add test to ensure Uint8Array's are zero-filled after creating a Buffer
of length zero. This test may falsely succeed, but will not falsely fail.

Fix: https://github.com/nodejs/node/issues/2930
PR-URL: https://github.com/nodejs/node/pull/2931
Reviewed-By: Rod Vagg <rod@vagg.org>
2015-09-18 01:14:16 -06:00
Sakthipriyan Vairamani
5f6579d366 buffer: remove raw & raws encoding
As `raw` and `raws` encodings are deprecated for such a long time, and
they both are undocumented, this patch removes the support for those
encodings completely.

Previous discussion: https://github.com/nodejs/node/pull/2829

PR-URL: https://github.com/nodejs/node/pull/2859
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-09-17 05:03:51 +05:30
Sam Roberts
94e663ac5f timer: ref/unref return self
Most calls to ref() and unref() are chainable, timers should be
chainable, too.

Typical use:

    var to = setTimeout(ontimeout, 123).unref();

PR-URL: https://github.com/nodejs/node/pull/2905
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trevor Norris <trevnorris@nodejs.org>
2015-09-16 10:29:13 -07:00
Trevor Norris
74178a5682 buffer: construct Uint8Array in JS
Overall construction time of Typed Arrays is faster in JS, but the
problem with using it normally is zero-fill of memory. Get around this
by using a flag in the ArrayBuffer::Allocator to trigger when memory
should or shouldn't be zero-filled.

Remove Buffer::Create() as it is no longer called.

The creation of the Uint8Array() was done at each callsite because at
the time of this patch there was a performance penalty for centralizing
the call in a single function.

PR-URL: https://github.com/nodejs/node/pull/2866
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-09-15 16:20:23 -06:00
Malcolm Ahoy
7d7941235a http: default Agent.getName to 'localhost'
Refactor out the if/else statement checking for option.host.
Add whitespace to make concatenation chunks more readable and
consistent with the https version of Agent.getName().

PR-URL: https://github.com/nodejs/node/pull/2825
Reviewed-By: Julian Duque <julianduquej@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2015-09-15 15:05:33 -07:00
Karl Skomski
e7a3ca3d31 src: use subarray() in Buffer#slice() for speedup
Use the built-in Typed Array method subarray() to improve performance of
Buffer#slice().

Benchmark improvements:

    benchmark/buffer-slice: 40%
    benchmark/buffer-creation (pool): 25%

Additional tests also added.

PR-URL: https://github.com/nodejs/node/pull/2777
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
2015-09-15 15:50:25 -06:00
Brendan Ashworth
c70c7781e3 streams: refactor LazyTransform to internal/
This commit refactors LazyTransform from the crypto implementation
(lib/crypto.js) into an internal module (not publicy accessible) in
internal/streams/lazy_transform.js. This promotes a more modular core
design and removes code bloat in crypto, as LazyTransform didn't
specifically have anything to do with cryptography, but rather a fast
way to support two APIs on a stream.

PR-URL: https://github.com/nodejs/node/pull/2566
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
2015-09-14 19:58:04 -07:00
Fedor Indutny
7ec0491fd0 http_server: fix resume after socket close
Socket resume may happen on a next tick, and in following scenario:

1. `socket.resume()`
2. `socket._handle.close()`
3. `socket._handle = null;`

The `_resume` will be invoked with empty `._handle` property. There is
nothing bad about it, and we should just ignore the `resume`/`pause`
events in this case.

Same applies to the unconsuming of socket on adding `data` and/or
`readable` event listeners.

Fix: https://github.com/nodejs/node/issues/2821

PR-URL: https://github.com/nodejs/node/pull/2824
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-09-14 21:08:02 -04:00
Yazhong Liu
1f842c2c61 fs: consider NaN/Infinity in toUnixTimestamp
PR-URL: https://github.com/nodejs/node/pull/2387
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-09-14 16:55:15 -06:00
Ron Korving
05d30d5396 fs: implemented WriteStream#writev
Streams with writev allow many buffers to be pushed to underlying OS
APIs in one batch, in this case improving write throughput by an order
of magnitude. This is especially noticeable when writing many (small)
buffers.

PR-URL: https://github.com/nodejs/node/pull/2167
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-09-14 16:50:43 -06:00
Fedor Indutny
c7be08cec1 cluster: allow shared reused dgram sockets
Allow listening on reused dgram ports in cluster workers.

Fix: https://github.com/joyent/node/issues/9261
PR-URL: https://github.com/nodejs/node/pull/2548
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-09-07 20:07:03 -07:00
Evan Lucas
3bc7e58ab0 child_process: use stdio.fd even if it is 0
Previously, in _validateStdio we were using stdio.fd || stdio. If
stdio.fd was falsy (or 0 in the case of stdin), then the entire stdio
object would be passed which could cause a crash.

Fixes: https://github.com/nodejs/node/issues/2721
PR-URL: https://github.com/nodejs/node/pull/2727
Reviewed-By: silverwind - Roman Reiss <me@silverwind.io>
Reviewed-By: cjihrig - Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: indutny - Fedor Indutny <fedor.indutny@gmail.com>
2015-09-07 19:03:19 -05:00
Michaël Zasso
729479f3f4 buffer: SlowBuffer only accept valid numeric values
Fixes a regression that appeared with the new Buffer implementation in v3.
Without this change, calling the SlowBuffer constructor with something else
than a number would abort on the C++ side. This makes sure that the length
argument is coerced to number or is 0.

Fixes: https://github.com/nodejs/node/issues/2634
PR-URL: https://github.com/nodejs/node/pull/2635
Reviewed-By: trevnorris - Trevor Norris <trev.norris@gmail.com>
Reviewed-By: cjihrig - Colin Ihrig <cjihrig@gmail.com>
2015-09-06 21:38:07 +10:00
Ali Ijaz Sheikh
0159ac9c99 src: apply debug force load fixups from 41e63fb
Apply the src/node_contextify.cc and lib/module.js fixups from @bnoordhuis
41e63fb088

PR-URL: https://github.com/nodejs/node/pull/2509
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-09-06 21:38:04 +10:00
Jeremiah Senkpiel
46b7d15167 events,lib: don't require EE#listenerCount()
Now parts of our public and public-ish APIs fall back to old-style
listenerCount() if the emitter does not have a listenerCount function.

Fixes: https://github.com/nodejs/node/issues/2655
Refs: 8f58fb92ff

PR-URL: https://github.com/nodejs/node/pull/2661
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-09-06 21:38:00 +10:00
James M Snell
32037b78a2 child_process: check execFile and fork args
Port of joyent/node commits:

 * e17c5a72b2
 * 70dafa7b62

Pull over test-child-process-spawn-typeerror.js from v0.12, replacing
the existing test in master. The new test includes a broader set of
tests on the various arg choices and throws.

Reviewed-By: trevnorris - Trevor Norris <trevnorris@nodejs.org>
Reviewed-By: cjihrig - Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: thefourtheye - Sakthipriyan Vairamani
PR-URL: https://github.com/nodejs/node/pull/2667
Fixes: https://github.com/nodejs/node/issues/2515
2015-09-06 21:38:00 +10:00
Ben Noordhuis
607aa3ac82 child_process: add callback parameter to .send()
Add an optional callback parameter to `ChildProcess.prototype.send()`
that is invoked when the message has been sent.

Juggle the control channel's reference count so that in-flight messages
keep the event loop (and therefore the process) alive until they have
been sent.

`ChildProcess.prototype.send()` and `process.send()` used to operate
synchronously but became asynchronous in commit libuv/libuv@393c1c5
("unix: set non-block mode in uv_{pipe,tcp,udp}_open"), which landed
in io.js in commit 07bd05b ("deps: update libuv to 1.2.1").

Fixes: https://github.com/nodejs/node/issues/760
PR-URL: https://github.com/nodejs/node/pull/2620
Reviewed-By: trevnorris - Trevor Norris <trev.norris@gmail.com>
Reviewed-By: jasnell - James M Snell <jasnell@gmail.com>
2015-09-06 21:37:58 +10:00
Karl Skomski
599d4f5f3a src: fix memory leak in ExternString
v8 will silently return an empty handle
which doesn't delete our data if string length is
above String::kMaxLength

Fixes: https://github.com/nodejs/node/issues/1374
PR-URL: https://github.com/nodejs/node/pull/2402
Reviewed-By: trevnorris - Trevor Norris <trev.norris@gmail.com>
Reviewed-By: indutny - Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>

Amended by @rvagg to change author date from
  "1970-08-16 16:09:02 +0200"
to
  "2015-08-16 16:09:02 +0200"
as per discussion @ https://github.com/nodejs/node/issues/2713
2015-09-06 21:37:37 +10:00
Jeremiah Senkpiel
049b3a3ae2 timers: minor _unrefActive fixes and improvements
This commit addresses most of the review comments in
https://github.com/nodejs/node/pull/2540, which are kept in this
separate commit so as to better preserve the prior two patches as they
landed in 0.12.

This commit:
- Fixes a bug with unrefActive timers and disposed domains.
- Fixes a bug with unrolling an unrefActive timer from another.
- Adds a test for both above bugs.
- Improves check logic, making it stricter, simpler, or both.
- Optimizes nicer with a smaller, separate function for the try/catch.

Fixes: https://github.com/nodejs/node-convergence-archive/issues/23
Ref: https://github.com/nodejs/node/issues/268
PR-URL: https://github.com/nodejs/node/pull/2540
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
2015-09-02 08:14:26 -04:00
Julien Gilli
9724047268 timers: don't mutate unref list while iterating it
Commit 934bfe23a1 had introduced a
regression where node would crash trying to access a null unref timer if
a given unref timer's callback would remove other unref timers set to
fire in the future.

More generally, it makes the unrefTimeout function more solid by not
mutating the unrefList while traversing it.

Fixes: https://github.com/joyent/node/issues/8897

Conflicts:
	lib/timers.js

Fixes: https://github.com/nodejs/node-convergence-archive/issues/23
Ref: https://github.com/nodejs/node/issues/268
PR-URL: https://github.com/nodejs/node/pull/2540
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
2015-09-02 08:14:25 -04:00
Julien Gilli
e5bb66886b timers: Avoid linear scan in _unrefActive.
Before this change, _unrefActive would keep the unrefList sorted when
adding a new timer.

Because _unrefActive is called extremely frequently, this linear scan
(O(n) at worse) would make _unrefActive show high in the list of
contributors when profiling CPU usage.

This commit changes _unrefActive so that it doesn't try to keep the
unrefList sorted. The insertion thus happens in constant time.

However, when a timer expires, unrefTimeout has to go through the whole
unrefList because it's not ordered anymore.

It is usually not large enough to have a significant impact on
performance because:
- Most of the time, the timers will be removed before unrefTimeout is
  called because their users (sockets mainly) cancel them when an I/O
  operation takes place.
- If they're not, it means that some I/O took a long time to happen, and
  the initiator of subsequents I/O operations that would add more timers
  has to wait for them to complete.

With this change, _unrefActive does not show as a significant
contributor in CPU profiling reports anymore.

Fixes: https://github.com/joyent/node/issues/8160

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>

Conflicts:
	lib/timers.js

Fixes: https://github.com/nodejs/node-convergence-archive/issues/23
Ref: https://github.com/nodejs/node/issues/268
PR-URL: https://github.com/nodejs/node/pull/2540
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
2015-09-02 08:14:25 -04:00
Ben Noordhuis
de88255b0f Revert "lib,src: add unix socket getsockname/getpeername"
This reverts commit 6cd0e2664b.
This reverts commit 7a999a1376.
This reverts commit f337595441.

It turns out that on Windows, uv_pipe_getsockname() is a no-op for
client sockets.  It slipped through testing because of a CI snafu.

PR-URL: https://github.com/nodejs/node/pull/2584
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2015-08-28 00:14:13 +02:00
Ben Noordhuis
7a999a1376 lib: add net.Socket#localFamily property
Complements the existing net.Socket#remoteFamily property.

PR-URL: https://github.com/nodejs/node/pull/956
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-08-27 17:45:29 +02:00
Ben Noordhuis
f337595441 lib,src: add unix socket getsockname/getpeername
The implementation is a minor API change in that socket.address() now
returns a `{ address: '/path/to/socket' }` object, like it does for TCP
and UDP sockets.  Before this commit, it returned `socket._pipeName`,
which is a string when present.

Change common.PIPE on Windows from '\\\\.\\pipe\\libuv-test' to
'\\\\?\\pipe\\libuv-test'.  Windows converts the '.' to a '?' when
creating a named pipe, meaning that common.PIPE didn't match the
result from NtQueryInformationFile().

Fixes: https://github.com/nodejs/node/issues/954
PR-URL: https://github.com/nodejs/node/pull/956
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-08-27 17:45:04 +02:00
Minwoo Jung
f55926a1f0 debugger: use strict equality comparison
There is no type-conversion to be done. Therefore, use the === operator.

PR-URL: https://github.com/nodejs/node/pull/2558
Reviewed-By: Rich Trott <rtrott@gmail.com>
2015-08-26 13:22:55 -07:00
Fedor Indutny
607bbd3166 http_parser: consume StreamBase instance
Consume StreamBase instance and operate on incoming data directly
without allocating Buffer instances. Improves performance.

PR-URL: https://github.com/nodejs/node/pull/2355
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-08-26 12:45:22 -07:00
Jeremiah Senkpiel
8cdac78bdf doc: add internal modules notice
Explicitly note that these modules should not be used outside of core.

PR-URL: https://github.com/nodejs/node/pull/2523
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
2015-08-25 11:58:50 -04:00
Ben Noordhuis
caa0d0c0a7 stream: rename poorly named function
roundUpToNextPowerOf2() does more than just rounding up to the next
power of two.  Rename it to computeNewHighWaterMark().

PR-URL: https://github.com/nodejs/node/pull/2479
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2015-08-24 20:24:15 +02:00
Ben Noordhuis
3af8e451f2 stream: micro-optimize high water mark calculation
Don't iterate over all 32 bits, use some hacker's delight bit twiddling
to compute the next power of two.

The logic can be reduced to `n = 1 << 32 - Math.clz32(n)` but then it
can't easily be backported to v2.x; Math.clz32() was added in V8 4.3.

PR-URL: https://github.com/nodejs/node/pull/2479
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2015-08-24 20:24:13 +02:00
Ben Noordhuis
1a3f4a87b6 stream: fix off-by-factor-16 error in comment
The high watermark is capped at 8 MB, not 128 MB like the comment
in lib/_stream_readable.js said.

PR-URL: https://github.com/nodejs/node/pull/2479
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2015-08-24 20:21:22 +02:00
Bradley Meck
2d251e661a module: fix module preloading when cwd is ENOENT
Fixes a regression from 5759722cfa
that prevented modules from being preloaded if the cwd does not exist.
Absolute and builtin modules now preload correctly again.

Refs: https://github.com/nodejs/node/issues/1803
PR-URL: https://github.com/nodejs/node/pull/2353
Reviewed-By: Jeremiah Senkpiel <fishrock123@rockemail.com>
2015-08-24 10:46:14 -04:00
cjihrig
a69ab27ab4 node: rename from io.js to node
This commit replaces instances of io.js with Node.js, based on the
recent convergence. There are some remaining instances of io.js,
related to build and the installer.

Fixes: https://github.com/nodejs/node/issues/2361
PR-URL: https://github.com/nodejs/node/pull/2367
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: João Reis <reis@janeasystems.com>
2015-08-23 17:59:43 -04:00
Minwoo Jung
f3c3b23d55 doc: fix comments in tls_wrap.cc and _http_client.js
fixed grammatically wrong expressions to make it clear

Reviewed By: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/2490
PR-URL: https://github.com/nodejs/node/pull/2489
2015-08-23 09:01:22 -07:00
James M Snell
5ba868f024 tls: add --tls-cipher-list command line switch
This adds a new `--tls-cipher-list` command line switch
that can be used to override the built-in default cipher
list. The intent of this is to make it possible to enforce
an alternative default cipher list at the process level.
Overriding the default cipher list is still permitted at
the application level by changing the value of
`require('tls').DEFAULT_CIPHERS`.

As part of the change, the built in default list is moved
out of tls.js and into node_constants.h and node_constants.cc.
Two new constants are added to require('constants'):

  * defaultCipherList (the active default cipher list)
  * defaultCoreCipherList (the built-in default cipher list)

A test case and doc changes are included.

A new NODE_DEFINE_STRING_CONSTANT macro is also created in
node_internals.h

When node_constants is initialized, it will pick up either
the passed in command line switch or fallback to the default
built-in suite.

Within joyent/node, this change had originaly been wrapped
up with a number of other related commits involving the
removal of the RC4 cipher. This breaks out this isolated
change.

/cc @mhdawson, @misterdjules, @trevnorris, @indutny, @rvagg

Reviewed By: Ben Noordhuis <ben@strongloop.com>
PR-URL: https://github.com/nodejs/node/pull/2412
2015-08-23 08:52:01 -07:00
James M Snell
ce145bf358 repl: filter integer keys from repl tab complete list
Refactored version of https://github.com/joyent/node/pull/25819

Removes integer keys (and keys starting with numbers) from
candidate list on repl tab complete. Refactored the originally
submitted change to simplify and ensure that the integer keys
do not show up on objects either.

Reviewed By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/2409
2015-08-21 21:40:44 -07:00
Fedor Indutny
43660ad37b buffer: reapply 07c0667
Original commit message:

    buffer: align chunks on 8-byte boundary

    When slicing global pool - ensure that the underlying buffer's data
    ptr is 8-byte alignment to do not ruin expectations of 3rd party C++
    addons.

    NOTE: 0.10 node.js always returned aligned pointers and io.js should
    do this too for compatibility.

PR-URL: https://github.com/nodejs/node/pull/2487
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-08-21 14:12:49 -07:00
Mike Atkins
f1810ed1b8 tls: handle empty cert in checkServerIndentity
This resolves joyent/node#9272. `tlsSocket.getPeerCertificate` will
return an empty object when the peer does not provide a certificate,
but, prior to this, when the certificate is empty, `checkServerIdentity`
would throw because the `subject` wasn't present on the cert.
`checkServerIdentity` must return an error, not throw one, so this
returns an error when the cert is empty instead of throwing
a `TypeError`.

PR-URL: https://github.com/nodejs/node/pull/2343
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
2015-08-21 11:24:51 +09:00
Todd Kennedy
3849750a09 repl: dont throw ENOENT on NODE_REPL_HISTORY_FILE
If you have no history file written to disk, but the environment
variable set, `fs.readFileSync` will throw an ENOENT error,
but there's nothing to convert. The converter should ignore
ENOENT on that `fs.readFileSync` call.

Fixes: https://github.com/nodejs/node/issues/2449
PR-URL: https://github.com/nodejs/node/pull/2451
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2015-08-20 10:29:35 -04:00
Fedor Indutny
291b310e21 stream_base: various improvements
Expose and use in TLSWrap an `v8::External` wrap of the
`StreamBase*` pointer instead of guessing the ancestor C++ class in
`node_wrap.h`.

Make use of `StreamBase::Callback` structure for storing/passing both
callback and context in a single object.

Introduce `GetObject()` for future user-land usage, when a child class
is not going to be inherited from AsyncWrap.

PR-URL: https://github.com/nodejs/node/pull/2351
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-08-20 01:14:37 -07:00
Sakthipriyan Vairamani
8f58fb92ff events: deprecate static listenerCount function
As per the discussion in #734, this patch deprecates the usage of
`EventEmitter.listenerCount` static function in the docs, and introduces
the `listenerCount` function in the prototype of `EventEmitter` itself.

PR-URL: https://github.com/nodejs/node/pull/2349
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
2015-08-20 03:17:08 +05:30
Sam Stites
1a3b295d0f path: use '===' instead of '==' for comparison
Per: https://github.com/joyent/node/pull/7554

Originally submitted by @stites

PR-URL: https://github.com/nodejs/node/pull/2388
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
2015-08-17 20:47:41 +02:00
Roman Klauke
ad7f74453d src: add total_available_size to v8 statistics
v8 introduced the new flag `total_available_size` in version 4.4
and upwards. This flag is now available on `v8.getHeapStatistics`
with the name `total_available_size`. It contains the total
available heap size of v8.

Introduced with commit: v8/v8-git-mirror@0a1352a7

PR-URL: https://github.com/nodejs/io.js/pull/2348
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-11 22:51:50 +02:00
Nathan Woltman
2db57bdecc path: remove dead code in favor of unit tests
Remove dead code paths that are created by assertions that will never
trigger. They may only trigger if either the `splitDeviceRe` or
`splitPathRe` regular expressions are modified. If at some point they
are modified, current unit tests will catch most of the resulting
errors and this commit adds extra tests to catch the remaining errors.

PR-URL: https://github.com/nodejs/io.js/pull/2282
Reviewed-By: Roman Reiss <me@silverwind.io>
2015-08-09 12:29:01 +02:00
Christopher Monsanto
7d14dd9b5e util: display constructor when inspecting objects
This commit modifies util.inspect(obj) to additionally show the name of
the function that constructed the object. This often reveals useful
information about the object's prototype. In other words, instead of

> new Cls
{}

we have

> new Cls
Cls {}

This also works with exotic objects:

> class ArrayCls extends Array {}
> new ArrayCls(1, 2, 3)
ArrayCls [ 1, 2, 3 ]

The names of "trivial" constructors like Object and Array are not shown,
unless there is a mismatch between the object representation and the
prototype:

> Object.create([])
Array {}

This feature is inspired by browser devtools.

PR-URL: https://github.com/nodejs/io.js/pull/1935
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-08-08 00:13:52 -04:00
Fedor Indutny
6ad99ac1ef tls: fix check for reused session
When TLS Session Ticket is renewed by server - no Certificate record is
to the client. We are prepared for empty certificate in this case, but
this relies on the session reuse check, which was implemented
incorrectly and was returning false when the TLS Session Ticket was
renewed.

Use session reuse check provided by OpenSSL instead.

Fix: https://github.com/nodejs/io.js/issues/2304
PR-URL: https://github.com/nodejs/io.js/pull/2312
Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
2015-08-08 07:16:58 +09:00
Ryan Graham
5d2acfb8e5 net: ensure Socket reported address is current
Any time the connection state or the underlying handle itself changes,
the socket's name (aka, local address) can change.

To deal with this we need to reset the cached sockname any time we
set or unset the internal handle or an existing handle establishes a
connection.

PR-URL: https://github.com/nodejs/io.js/pull/2095
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-08-06 10:45:59 -07:00
James M Snell
936c9ffb0f doc: multiple documentation updates cherry picked from v0.12
* doc: improve http.abort description
 * doc: mention that mode is ignored if file exists
 * docs: Fix default options for fs.createWriteStream()
 * Documentation update about Buffer initialization
 * doc: add a note about readable in flowing mode
 * doc: Document http.request protocol option
 * doc, comments: Grammar and spelling fixes
 * updated documentation for fs.createReadStream
 * Update child_process.markdown, spelling
 * doc: Clarified read method with specified size argument.
 * docs:events clarify emitter.listener() behavior
 * doc: two minor stream doc improvements
 * doc: clarify Readable._read and Readable.push
 * doc: stream.unshift does not reset reading state
 * doc: readable event clarification
 * doc: additional refinement to readable event

Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noorduis <ben@strongloop.com>
PR-URL: https://github.com/nodejs/io.js/pull/2302
2015-08-05 08:44:55 -07:00
Jeremiah Senkpiel
ed6c249104 repl: persist history in plain text
Persists the REPL history in plain text using the new NODE_REPL_HISTORY
environment variable. Deprecates NODE_REPL_HISTORY_FILE. The REPL will
notify the user and automatically convert the history to the new format
if files are specified.

PR-URL: https://github.com/nodejs/io.js/pull/2224
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
2015-08-04 11:56:18 -07:00
Jeremiah Senkpiel
f7d5e4c618 repl: default persistence to ~/.node_repl_history
Makes the REPL persistently save history by default to
~/.node_repl_history when in terminal mode.
This can be disabled by setting NODE_REPL_HISTORY="".

PR-URL: https://github.com/nodejs/io.js/pull/2224
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
2015-08-04 11:56:18 -07:00
Jeremiah Senkpiel
ceee8d2807 test: add tests for persistent repl history
PR-URL: https://github.com/nodejs/io.js/pull/2224
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
2015-08-04 11:56:18 -07:00
Brendan Ashworth
2965442308 http: fix agent.getName() and add tests
This commit fixes agent.getName(), which returned an extra colon
according to the docs, and adds tests (it was previously not unit
tested).

PR-URL: https://github.com/nodejs/io.js/pull/1617
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-04 11:56:17 -07:00
Rich Trott
4cffaa3f55 readline: allow tabs in input
If tab completion is not being used, allow user to enter tab
characters.

PR-URL: https://github.com/nodejs/io.js/pull/1761
Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
2015-08-04 11:56:17 -07:00
Trevor Norris
60a974d200 buffer: fix missing null/undefined check
The new implementation of Buffer missed the check for null/undefined as
the first argument to new Buffer(). Reintroduce the check and add test.

Fix: e8734c0 "buffer: implement Uint8Array backed Buffer"
Fix: https://github.com/nodejs/io.js/issues/2194
PR-URL: https://github.com/nodejs/io.js/pull/2195
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
2015-08-04 11:56:17 -07:00
jomo
2d9456e3e6 http: use official IANA Status Codes
* adds missing HTTP status codes
* corrects those with a wrong description
* the falsely included codes have been kept

PR-URL: https://github.com/nodejs/io.js/pull/1470
Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-08-04 11:56:16 -07:00
Ben Noordhuis
1057d1186b buffer: rename internal/buffer_new.js to buffer.js
The old smalloc-based implementation has been removed, the typed array
implementation is the only one that is left now.

PR-URL: https://github.com/nodejs/io.js/pull/2022
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-08-04 11:56:15 -07:00
Ben Noordhuis
70d1f32f56 deps: update v8 to 4.4.63.9
Upgrade the bundled V8 and update code in src/ and lib/ to the new API.

Notable backwards incompatible changes are the removal of the smalloc
module and dropped support for CESU-8 decoding.  CESU-8 support can be
brought back if necessary by doing UTF-8 decoding ourselves.

This commit includes https://codereview.chromium.org/1192973004 to fix
a build error on python 2.6 systems.  The original commit log follows:

    Use optparse in js2c.py for python compatibility

    Without this change, V8 won't build on RHEL/CentOS 6 because the
    distro python is too old to know about the argparse module.

PR-URL: https://github.com/nodejs/io.js/pull/2022
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-08-04 11:56:14 -07:00
Trevor Norris
4643b8b667 buffer: allow ArrayBuffer as Buffer argument
Buffer now uses the ArrayBuffer as the backing store if passed to the
constructor.

Fixes: https://github.com/nodejs/io.js/issues/106
PR-URL: https://github.com/nodejs/io.js/pull/2002
Reviewed-By: Domenic Denicola <d@domenic.me>
2015-08-04 11:56:13 -07:00
Trevor Norris
e5ada116cd buffer: minor cleanup from rebase
PR-URL: https://github.com/nodejs/io.js/pull/2003
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
2015-08-04 11:56:13 -07:00