platform/upstream/nodejs.git
9 years agocrypto: allow padding in RSA methods
Fedor Indutny [Sat, 23 Aug 2014 13:38:32 +0000 (17:38 +0400)]
crypto: allow padding in RSA methods

Reviewed-By: Trevor Norris <trevnorris@gmail.com>
9 years agocrypto: fix memory leak in Connection::New
Fedor Indutny [Sat, 23 Aug 2014 19:22:23 +0000 (23:22 +0400)]
crypto: fix memory leak in Connection::New

Do not create `SSL` instance twice, `SSL_new` is called from `SSLBase`
constructor anyway.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
9 years agohttp: avoid create difference hidden class
Jackson Tian [Thu, 21 Aug 2014 16:05:42 +0000 (00:05 +0800)]
http: avoid create difference hidden class

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
9 years agonet,stream: add isPaused, don't read() when paused
Chris Dickinson [Tue, 19 Aug 2014 21:38:55 +0000 (14:38 -0700)]
net,stream: add isPaused, don't read() when paused

net Sockets were calling read(0) to start reading, without
checking to see if they were paused first. This would result
in paused Socket objects keeping the event loop alive.

Fixes #8200

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
9 years agodns: throw if hostname is not string or falsey
cjihrig [Fri, 15 Aug 2014 14:40:09 +0000 (10:40 -0400)]
dns: throw if hostname is not string or falsey

Fix assertion failure from poor argument parsing logic introduced in
6ea5d16. Add tests to make sure arguments are properly parsed.

Fixes: 6ea5d16 "dns: always set variable family in lookup()"
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
9 years agonode: add missing Isolate::Scope at startup
Ben Noordhuis [Tue, 19 Aug 2014 17:28:06 +0000 (10:28 -0700)]
node: add missing Isolate::Scope at startup

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
9 years agosrc: add missing Isolate arguments
Yazhong Liu [Wed, 13 Aug 2014 18:02:37 +0000 (02:02 +0800)]
src: add missing Isolate arguments

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
9 years agohttp: fix bailout for writeHead
Alex Kocharin [Thu, 14 Aug 2014 14:54:44 +0000 (18:54 +0400)]
http: fix bailout for writeHead

Reported-by: Jackson Tian <shyvo1987@gmail.com>
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
9 years agogyp: preserve v8dbg syms on freebsd too
Fedor Indutny [Sun, 17 Aug 2014 10:17:30 +0000 (14:17 +0400)]
gyp: preserve v8dbg syms on freebsd too

9 years agotest: fix dns test
Alexis Campailla [Tue, 12 Aug 2014 14:48:02 +0000 (16:48 +0200)]
test: fix dns test

Fix a few issues in test/internet/test-dns.js:
- 'hint' should be 'hints'
- reverse name lookup is not guaranteed to return 'localhost'
- V4MAPPED hint requires IPV6 address family

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
9 years agotests: don't assume IPv4 only in remote addr tests
Julien Gilli [Mon, 11 Aug 2014 20:29:00 +0000 (13:29 -0700)]
tests: don't assume IPv4 only in remote addr tests

Tests in test-net-remote-address-port.js assume that client and server
sockets always use IPv4. However, depending on the OS and the network
interfaces setup, this is not true. This change makes the test consider
that both IPv4 or IPv6 sockets are valid

Fixes #8096.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
9 years agotest: check ipv6 support before testing it
Fedor Indutny [Sat, 2 Aug 2014 08:42:42 +0000 (12:42 +0400)]
test: check ipv6 support before testing it

fix #7983
fix #8049

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
9 years agotests: do not hardcode service name in test-dns.
Julien Gilli [Wed, 6 Aug 2014 21:32:46 +0000 (14:32 -0700)]
tests: do not hardcode service name in test-dns.

Instead of hard-coding http service name in test-dns, retrieve it from
/etc/services. This is not ideal, but it's still better than hard-coding
it.

Fixes #8047.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
9 years agotests: fix invalid hints flags dns test.
Julien Gilli [Mon, 11 Aug 2014 22:15:21 +0000 (15:15 -0700)]
tests: fix invalid hints flags dns test.

1 is actually a valid flag on SmartOS. More generally, hints flags'
values are defined by the underlying native flags, and these can have
different values on different systems.

Using (ADDRCONFIG | V4MAPPED) + 1 ensure that the flag will be invalid,
since it will always be different from ADDRCONFIG, V4MAPPED, ADDRCONFIG
| V4MAPPED,  0 and any other combination of even flags.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
9 years agosrc: change kIsolateSlot to 3
Cheng Zhao [Sun, 10 Aug 2014 02:46:11 +0000 (10:46 +0800)]
src: change kIsolateSlot to 3

The slot 0 and 1 had already been taken by "gin" and "blink" in Chrome,
and the size of isolate's slots is 4 by default, so using 3 should hopefully
make node work independently when embedded into other application.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
9 years agosrc: require EventEmitter via NativeModule
Trevor Norris [Wed, 13 Aug 2014 04:50:21 +0000 (21:50 -0700)]
src: require EventEmitter via NativeModule

Fixes a recent change causing test-process-kill-pid.js to fail.

Fixes: 931cbc1 "lib: don't use emitter.listeners(type).length"
Signed-off-by: Trevor Norris <trev.norris@gmail.com>
9 years agodgram: remove new keyword from errnoException
Jackson Tian [Wed, 13 Aug 2014 04:03:25 +0000 (12:03 +0800)]
dgram: remove new keyword from errnoException

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
9 years agodoc: typo fixes on stream, tls and http
Kyle Robinson Young [Fri, 8 Aug 2014 17:49:24 +0000 (10:49 -0700)]
doc: typo fixes on stream, tls and http

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
9 years agoquerystring: remove prepended ? from query field
Ezequiel Rabinovich [Wed, 13 Aug 2014 02:32:22 +0000 (23:32 -0300)]
querystring: remove prepended ? from query field

Fixes an issue that caused the first querystring to be parsed prepending
a "?" in the first variable name on relative urls with no #fragment

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
9 years agolib: don't use emitter.listeners(type).length
Jackson Tian [Mon, 11 Aug 2014 08:41:18 +0000 (16:41 +0800)]
lib: don't use emitter.listeners(type).length

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
9 years agonode: set names for prototype methods
Trevor Norris [Tue, 12 Aug 2014 00:10:43 +0000 (17:10 -0700)]
node: set names for prototype methods

Fix issue where output of a native prototype method would simply print
[Function]. It will now print [Function: name].

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
9 years agocrypto: add RSA encryption
seishun [Mon, 5 May 2014 14:35:28 +0000 (17:35 +0300)]
crypto: add RSA encryption

Reviewed-By: Fedor Indutny <fedor@indutny.com>
9 years agowindows: fix memory leak in WinapiErrnoException
Alexis Campailla [Tue, 5 Aug 2014 13:33:16 +0000 (15:33 +0200)]
windows: fix memory leak in WinapiErrnoException

Fix https://github.com/joyent/node/issues/2341

Reviewed-By: Fedor Indutny <fedor@indutny.com>
9 years agodns: always set variable family in lookup()
cjihrig [Fri, 8 Aug 2014 02:36:56 +0000 (22:36 -0400)]
dns: always set variable family in lookup()

Regression occurred that prevented the variable "family" from being set
properly when the lookup() function's "options" parameter was passed a
number instead of an object.

Also included a sanity check by setting the default value of "family" to
a value that will not pass verification.

Fixes: e643fe4 "dns: fix GetAddrInfo assert"
Reviewed-by: Alexis Campailla <alexis@janeasystems.com>
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
9 years agoopenssl: fix keypress requirement in apps on win32
Fedor Indutny [Wed, 11 Dec 2013 17:19:04 +0000 (21:19 +0400)]
openssl: fix keypress requirement in apps on win32

Original source:

http://openssl.6102.n7.nabble.com/PATCH-s-client-Fix-keypress-requirement-with-redirected-input-on-Windows-td46787.html

Reviewed-By: Fedor Indutny <fedor@indutny.com>
9 years agobuild: linking CoreFoundation framework for OSX
Thorsten Lorenz [Wed, 6 Aug 2014 18:00:31 +0000 (14:00 -0400)]
build: linking CoreFoundation framework for OSX

Linking CoreFoundation for OSX is needed for OSX debugging features to
function properly.

For instance Instruments cannot record Heap Allocations if the
CoreFoundation is not linked.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
9 years agotest: fix test-process-kill-pid on Windows
Alexis Campailla [Thu, 7 Aug 2014 14:45:53 +0000 (16:45 +0200)]
test: fix test-process-kill-pid on Windows

Disabling the part of the test that relies on dispatching SIGHUP,
because sending SIGHUP is not supported on Windows.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
9 years agodoc: document max `new Buffer(size)`
Jackson Tian [Wed, 6 Aug 2014 06:35:35 +0000 (14:35 +0800)]
doc: document max `new Buffer(size)`

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
9 years agoMerge remote-tracking branch 'upstream/v0.10' into v0.12
Timothy J Fontaine [Thu, 7 Aug 2014 23:33:35 +0000 (16:33 -0700)]
Merge remote-tracking branch 'upstream/v0.10' into v0.12

Conflicts:
ChangeLog
Makefile
deps/uv/ChangeLog
deps/uv/build.mk
deps/uv/src/unix/darwin.c
deps/uv/src/unix/getaddrinfo.c
deps/uv/src/version.c
deps/v8/src/checks.h
deps/v8/src/isolate.h
lib/cluster.js
lib/module.js
lib/timers.js
lib/tls.js
src/node_version.h

9 years agotests: fix child-process-fork-dgram on SmartOS.
Julien Gilli [Thu, 31 Jul 2014 23:16:42 +0000 (16:16 -0700)]
tests: fix child-process-fork-dgram on SmartOS.

Send messages until both the parent and the child process have received
at least one message. If at least one of them doesn't receive any
message, the test runner will make the test timeout.

Fixes #8046.

9 years agodoc: document arguments for 'error' event on a stream
Maciej Małecki [Thu, 7 Aug 2014 18:56:34 +0000 (20:56 +0200)]
doc: document arguments for 'error' event on a stream

Fixes #6361.

9 years agofs: fix fs.readFileSync fd leak when get RangeError
Jackson Tian [Wed, 6 Aug 2014 03:21:59 +0000 (11:21 +0800)]
fs: fix fs.readFileSync fd leak when get RangeError

9 years agosrc: handle UV_EAGAIN in TryWrite
Saúl Ibarra Corretgé [Sat, 5 Jul 2014 09:02:33 +0000 (11:02 +0200)]
src: handle UV_EAGAIN in TryWrite

Reviewed-By: Fedor Indutny <fedor@indutny.com>
9 years agoCluster: fix shared handles on Windows
Alexis Campailla [Thu, 24 Jul 2014 09:59:00 +0000 (11:59 +0200)]
Cluster: fix shared handles on Windows

This is the Node side of the fix for Node's cluster module on Windows.
https://github.com/joyent/node/issues/7691

The other required part is
https://github.com/joyent/libuv/pull/1384

Windows and Unix return certain socket errors (i.e. EADDRINUSE) at
different times: bind on Windows, and listen on Unix.
In an effort to hide this difference, libuv on Windows stores such
errors in the bind_error field of uv_tcp_t, to defer raising it at
listen time.
This worked fine except for the case in which a socket is shared in
a Node cluster and a bind error occurs.

A previous attempt to fix this (
https://github.com/joyent/libuv/commit/d1e6be1460f555a1f8a4063d7642696aa7238769
https://github.com/joyent/node/commit/3da36fe00e5d85414031ae812e473f16629d8645
) was flawed becaused in an attempt to relay the error at the JS level
it caused the master to start accepting connections.

With this new approach, libuv itself is relaying the bind errors,
providing for a uniform behavior of uv_tcp_listen.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
9 years agodeps: update libuv to v0.11.28
Fedor Indutny [Thu, 7 Aug 2014 11:03:17 +0000 (15:03 +0400)]
deps: update libuv to v0.11.28

9 years agodeps: update openssl to v1.0.1i
Fedor Indutny [Thu, 7 Aug 2014 09:36:56 +0000 (13:36 +0400)]
deps: update openssl to v1.0.1i

9 years agodoc: clarify factory methods for net.Socket
Kevin Simper [Sun, 3 Aug 2014 00:27:02 +0000 (02:27 +0200)]
doc: clarify factory methods for net.Socket

9 years agofs: fs.readFile should not throw uncaughtException
Jackson Tian [Tue, 5 Aug 2014 09:34:56 +0000 (17:34 +0800)]
fs: fs.readFile should not throw uncaughtException

Reviewed-By: Fedor Indutny <fedor@indutny.com>
9 years agodns: fix GetAddrInfo assert
Trevor Norris [Tue, 5 Aug 2014 01:12:54 +0000 (18:12 -0700)]
dns: fix GetAddrInfo assert

The method GetAddrInfo() is used by more than just dns.lookup(), and in
those cases a third argument isn't passed. This caused the following
check to abort:

  assert(args[3]->IsInt32());

Fixes: 4306786 "net: don't prefer IPv4 addresses during resolution"

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
9 years agonet: don't prefer IPv4 addresses during resolution
cjihrig [Thu, 22 May 2014 02:13:09 +0000 (22:13 -0400)]
net: don't prefer IPv4 addresses during resolution

Currently the address resolution family defaults to IPv4. Instead remove
the preference and instead resolve to a family suitable for the host.

Expose the getaddrinfo flags and allow them to be passed.

Add documentation about new flags.

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
9 years agov8: Fix compliation with GCC 4.8
Timothy J Fontaine [Mon, 4 Aug 2014 20:43:50 +0000 (13:43 -0700)]
v8: Fix compliation with GCC 4.8

Supresses a very loud warning from GCC 4.8 about unused typedefs

Original url https://codereview.chromium.org/69413002

9 years agotest: fix test-net-remote-address-port
Julien Gilli [Fri, 1 Aug 2014 18:06:54 +0000 (11:06 -0700)]
test: fix test-net-remote-address-port

Do not use first socket in second socket's connect handler. Probably a
copy/paste mistake.

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
9 years agopath: isAbsolute() should always return boolean
Herman Lee [Mon, 4 Aug 2014 14:18:54 +0000 (22:18 +0800)]
path: isAbsolute() should always return boolean

On Windows, path.isAbsolute() returns an empty string on failed cases.
This forces the return value to always be boolean.

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
9 years agotimers: fix timers with non-integer delay hanging.
Julien Gilli [Mon, 4 Aug 2014 16:52:35 +0000 (09:52 -0700)]
timers: fix timers with non-integer delay hanging.

When backporting f8193ab into v0.10, a regression was introduced. Timers
with non-integer timeout could trigger a infinite recursion with 100%
cpu usage. This commit backports 93b0624 which fixes the regression.

After backporting f8193ab, instead of using Date.now(), timers would use
Timer.now() to determine if they had expired. However, Timer.now() is
based on loop->time, which is not updated when a timer's remaining time
is > 0 and < 1. Timers would thus never timeout if their remaining time
was at some point > 0 and < 1.

With this commit, Timer.now() updates loop->time itself, and timers
always timeout eventually.

Fixes #8065 and #8068.

9 years agoprocess: improve process binding
Jackson Tian [Fri, 1 Aug 2014 11:26:09 +0000 (19:26 +0800)]
process: improve process binding

Reviewed-By: Fedor Indutny <fedor@indutny.com>
9 years agotest: disable 0-dgram tests on darwin
Fedor Indutny [Sat, 2 Aug 2014 11:06:25 +0000 (15:06 +0400)]
test: disable 0-dgram tests on darwin

fix #8023

9 years agocluster: disconnect should not be synchronous
Sam Roberts [Thu, 31 Jul 2014 23:44:15 +0000 (16:44 -0700)]
cluster: disconnect should not be synchronous

Callbacks in node are usually asynchronous, and should never be
sometimes synchronous, and sometimes asynchronous.

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
9 years agopath: fix slice OOB in trim
Lucio M. Tato [Sat, 2 Aug 2014 05:33:35 +0000 (02:33 -0300)]
path: fix slice OOB in trim

Internal function trim(arr). 2nd parameter of slice() should be slice's
end index (not included). Because of function normalize() (called before
trim()), "start" is always zero so the bug -for now- has no effect, but
its a bug waiting to happen.

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
9 years agotest: assert cluster.disconnect is async
Sam Roberts [Thu, 31 Jul 2014 23:49:28 +0000 (16:49 -0700)]
test: assert cluster.disconnect is async

See joyent/node#8043, test passed on v0.11 already, but this makes the
test stronger.

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
9 years agostream: fix Readable.wrap objectMode falsy values
James Halliday [Mon, 9 Jun 2014 01:58:53 +0000 (18:58 -0700)]
stream: fix Readable.wrap objectMode falsy values

A streams1 stream will have its falsy values such as 0, false, or ""
eaten by the upgrade to streams2, even when objectMode is enabled.

Include test for said cases.

Reviewed-by: isaacs <i@izs.me>
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
9 years agotls: throw an error, not string
Jackson Tian [Fri, 1 Aug 2014 06:08:52 +0000 (14:08 +0800)]
tls: throw an error, not string

Reviewed-By: Fedor Indutny <fedor@indutny.com>
9 years agocluster: support options in Worker constructor
cjihrig [Thu, 31 Jul 2014 02:20:52 +0000 (22:20 -0400)]
cluster: support options in Worker constructor

This commit moves some common Worker code into the constructor
via support for an options argument.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
9 years agodocs: fix non-string ignore note in path.resolve
Jakob Gillich [Wed, 25 Jun 2014 17:08:46 +0000 (19:08 +0200)]
docs: fix non-string ignore note in path.resolve

Reviewed-By: Fedor Indutny <fedor@indutny.com>
9 years agoAdd fast path for simple URL parsing
Gabriel Wicke [Tue, 1 Jul 2014 19:28:49 +0000 (12:28 -0700)]
Add fast path for simple URL parsing

This patch adds a fast path for parsing of simple path-only URLs, as commonly
found in HTTP requests received by a server.

Benchmark results [ms], before / after patch:
/foo/bar              0.008956   0.000418 (fast path used)
http://example.com/   0.011426   0.011437 (normal slow path, no change)

In a simple 'ab' benchmark of a single-threaded web server, this patch
increases the request rate from around 6400 to 7400 req/s.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
9 years agoNow working on 0.10.31
Timothy J Fontaine [Thu, 31 Jul 2014 18:12:08 +0000 (11:12 -0700)]
Now working on 0.10.31

9 years agoMerge branch 'v0.10.30-release' into v0.10
Timothy J Fontaine [Thu, 31 Jul 2014 18:11:53 +0000 (11:11 -0700)]
Merge branch 'v0.10.30-release' into v0.10

9 years ago2014.07.31, Version 0.10.30 (Stable) v0.10.30
Timothy J Fontaine [Thu, 31 Jul 2014 17:24:06 +0000 (10:24 -0700)]
2014.07.31, Version 0.10.30 (Stable)

* uv: Upgrade to v0.10.28

* npm: Upgrade to v1.4.21

* v8: Interrupts must not mask stack overflow.

* Revert "stream: start old-mode read in a next tick" (Fedor Indutny)

* buffer: fix sign overflow in `readUIn32BE` (Fedor Indutny)

* buffer: improve {read,write}{U}Int* methods (Nick Apperson)

* child_process: handle writeUtf8String error (Fedor Indutny)

* deps: backport 4ed5fde4f from v8 upstream (Fedor Indutny)

* deps: cherry-pick eca441b2 from OpenSSL (Fedor Indutny)

* lib: remove and restructure calls to isNaN() (cjihrig)

* module: eliminate double `getenv()` (Maciej Małecki)

* stream2: flush extant data on read of ended stream (Chris Dickinson)

* streams: remove unused require('assert') (Rod Vagg)

* timers: backport f8193ab (Julien Gilli)

* util.h: interface compatibility (Oguz Bastemur)

* zlib: do not crash on write after close (Fedor Indutny)

9 years agouv: Upgrade to v0.10.28
Timothy J Fontaine [Thu, 31 Jul 2014 16:31:01 +0000 (09:31 -0700)]
uv: Upgrade to v0.10.28

9 years agov8: Interrupts must not mask stack overflow.
Fedor Indutny [Wed, 30 Jul 2014 22:33:52 +0000 (15:33 -0700)]
v8: Interrupts must not mask stack overflow.

Backport of https://codereview.chromium.org/339883002

9 years agonpm: Upgrade to v1.4.21
Timothy J Fontaine [Thu, 31 Jul 2014 16:05:30 +0000 (09:05 -0700)]
npm: Upgrade to v1.4.21

9 years agomodule: eliminate double `getenv()`
Maciej Małecki [Tue, 25 Mar 2014 21:47:05 +0000 (04:47 +0700)]
module: eliminate double `getenv()`

`process.env` access results in a synchronous `getenv` call. Cache the
first result instead and save one syscall.

9 years agostreams: remove unused require('assert')
Rod Vagg [Sun, 30 Mar 2014 08:51:01 +0000 (19:51 +1100)]
streams: remove unused require('assert')

9 years agotimers: backport f8193ab
Julien Gilli [Wed, 23 Jul 2014 01:03:10 +0000 (18:03 -0700)]
timers: backport f8193ab

Original commit message:

 timers: use uv_now instead of Date.now

 This saves a few calls to gettimeofday which can be expensive, and
 potentially subject to clock drift. Instead use the loop time which
 uses hrtime internally.

In addition to the backport, this commit:
 - keeps _idleStart timers' property which is still set to
   Date.now() to avoid breaking existing code that uses it, even if
   its use is discouraged.
 - adds automated tests. These tests use a specific branch of
   libfaketime that hasn't been submitted upstream yet. libfaketime
   is git cloned if needed when running automated tests.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
9 years agoRevert "Cluster: fix shared handles on Windows"
Fedor Indutny [Thu, 31 Jul 2014 08:38:46 +0000 (12:38 +0400)]
Revert "Cluster: fix shared handles on Windows"

This reverts commit 4e68a28e20b348f3519b359a17fcb941b235202b.

9 years agoCluster: fix shared handles on Windows
Alexis Campailla [Thu, 24 Jul 2014 09:59:00 +0000 (11:59 +0200)]
Cluster: fix shared handles on Windows

This is the Node side of the fix for Node's cluster module on Windows.
https://github.com/joyent/node/issues/7691

The other required part is
https://github.com/joyent/libuv/pull/1384

Windows and Unix return certain socket errors (i.e. EADDRINUSE) at
different times: bind on Windows, and listen on Unix.
In an effort to hide this difference, libuv on Windows stores such
errors in the bind_error field of uv_tcp_t, to defer raising it at
listen time.
This worked fine except for the case in which a socket is shared in
a Node cluster and a bind error occurs.

A previous attempt to fix this (
https://github.com/joyent/libuv/commit/d1e6be1460f555a1f8a4063d7642696aa7238769
https://github.com/joyent/node/commit/3da36fe00e5d85414031ae812e473f16629d8645
) was flawed becaused in an attempt to relay the error at the JS level
it caused the master to start accepting connections.

With this new approach, libuv itself is relaying the bind errors,
providing for a uniform behavior of uv_tcp_listen.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
9 years agorepl: proper `setPrompt()` and `multiline` support
Fedor Indutny [Thu, 31 Jul 2014 08:30:46 +0000 (12:30 +0400)]
repl: proper `setPrompt()` and `multiline` support

fix #8031

9 years agoRevert "repl: fix overwrite for this._prompt"
Fedor Indutny [Thu, 31 Jul 2014 08:12:18 +0000 (12:12 +0400)]
Revert "repl: fix overwrite for this._prompt"

This reverts commit 7166b55015261de8ab69758320f3d9159b3eaadd.

9 years agocluster: test events emit on cluster.worker
Sam Roberts [Mon, 28 Jul 2014 23:53:10 +0000 (16:53 -0700)]
cluster: test events emit on cluster.worker

v0.10 and node docs specific that in a worker, the 'message' and 'error'
event emits on process, and on cluster.worker.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
9 years agogyp: do not rm unused openssl syms on osx/linux
Fedor Indutny [Wed, 30 Jul 2014 10:54:36 +0000 (14:54 +0400)]
gyp: do not rm unused openssl syms on osx/linux

fix #8026

Reviewed-By: Fedor Indutny <fedor@indutny.com>
9 years agotests: fix internet/test-dns.js
Julien Gilli [Wed, 30 Jul 2014 01:06:47 +0000 (18:06 -0700)]
tests: fix internet/test-dns.js

internet/test-dns.js assumes that ::1 always resolves to "localhost" on
all platforms. This is not what happens in reality. Some platforms
resolve it to "ip6-localhost" too. There doesn't seem to be any consensus
on what's the right thing to do. However, most sane platforms will use
either one of these two values.

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
9 years agorepl: fix overwrite for this._prompt
Yazhong Liu [Wed, 9 Jul 2014 10:01:05 +0000 (18:01 +0800)]
repl: fix overwrite for this._prompt

Signed-off-by: Fedor Indutny <fedor@indutny.com>
9 years agoMerge remote-tracking branch 'origin/v0.10' into master
Fedor Indutny [Tue, 29 Jul 2014 08:50:49 +0000 (12:50 +0400)]
Merge remote-tracking branch 'origin/v0.10' into master

Conflicts:
doc/api/buffer.markdown
lib/_stream_readable.js
lib/assert.js
lib/buffer.js
lib/child_process.js
lib/http.js
lib/string_decoder.js
lib/zlib.js
node.gyp
test/simple/test-buffer.js
test/simple/test-https-foafssl.js
test/simple/test-stream2-compatibility.js
test/simple/test-tls-server-verify.js

9 years agobuffer: fix sign overflow in `readUIn32BE`
Fedor Indutny [Tue, 29 Jul 2014 08:34:49 +0000 (12:34 +0400)]
buffer: fix sign overflow in `readUIn32BE`

`|` operation takes precendence on `+`, which will result in
`new Buffer('ffffffff', 16).readUInt32BE(0)` returning `-1` instead of
`ffffffff`.

9 years agotests: fix process.kill pid test.
Julien Gilli [Tue, 29 Jul 2014 00:19:03 +0000 (17:19 -0700)]
tests: fix process.kill pid test.

Prevent test-process-kill-pid.js tests suite from sending SIGHUP
to its process group, which was causing the test runner to terminate.

Fix jenkins' jobs for nodejs-master.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
9 years agocluster: enable error/message events using .worker
cjihrig [Fri, 25 Jul 2014 17:11:10 +0000 (13:11 -0400)]
cluster: enable error/message events using .worker

Between 0.11.1 and 0.11.2, the message and error events stopped
being usable via the cluster.worker object. This commit makes
them usable again. Closes #7998.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
9 years agoprocess: throw TypeError if kill pid not a number
Sam Roberts [Wed, 23 Jul 2014 21:22:22 +0000 (14:22 -0700)]
process: throw TypeError if kill pid not a number

Currently, invalid usage such as:

    process.kill('SIGTERM')
    process.kill(null)
    process.kill(undefined);

all coerce the pid to 0, and signal the current process.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
9 years agodeps: backport 60c316 from v8 trunk
Fedor Indutny [Thu, 24 Jul 2014 09:31:45 +0000 (09:31 +0000)]
deps: backport 60c316 from v8 trunk

Original commit message:

    Extend the interceptor setter ASSERT to support the JSGlobalProxy case.

    BUG=v8:3463
    LOG=n
    R=dcarney@chromium.org

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

    git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22589 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

Signed-off-by: Fedor Indutny <fedor@indutny.com>
fix #7969

9 years agoquerystring: do not add sep for empty array
cjihrig [Sat, 19 Jul 2014 05:27:34 +0000 (01:27 -0400)]
querystring: do not add sep for empty array

Currently, stringification of an empty array outputs a single
separator character. This commit causes an empty array to output
the empty string.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
9 years agotest: fix test-https-foafssl
Fedor Indutny [Wed, 23 Jul 2014 19:55:24 +0000 (23:55 +0400)]
test: fix test-https-foafssl

9 years agotest: fix test-tls-server-verify
Fedor Indutny [Wed, 23 Jul 2014 19:51:14 +0000 (23:51 +0400)]
test: fix  test-tls-server-verify

fix #7963

9 years agonet: add remoteFamily for socket
Jackson Tian [Wed, 16 Jul 2014 14:04:34 +0000 (22:04 +0800)]
net: add remoteFamily for socket

Signed-off-by: Fedor Indutny <fedor@indutny.com>
9 years agotls: fix to send TLS Alert before socket destroyed
Shigeki Ohtsu [Thu, 17 Jul 2014 14:01:40 +0000 (23:01 +0900)]
tls: fix to send TLS Alert before socket destroyed

When TLS Alert is occured in handshake, ClearOut only write it into
wbio and does not flush to socket. TLS Alert should be written to
socket with EncOut before socket is destroyed within its error
callback.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
9 years agogyp: fix ARM build
Maciej Małecki [Wed, 23 Jul 2014 13:24:07 +0000 (15:24 +0200)]
gyp: fix ARM build

According to V8 changelog, `armv7` config variable was replaced by
`arm_version`, with value either '7', '6' or 'default'.

Detect ARMv7 and ARMv6 CPUs and default to 'default'.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
9 years agochild_process: do not access stderr when stdio set to 'ignore'
cjihrig [Sun, 20 Jul 2014 02:35:07 +0000 (22:35 -0400)]
child_process: do not access stderr when stdio set to 'ignore'

Currently, checkExecSyncError() attempts to access the contents
of stderr. When stdio is set to 'ignore', this causes a crash.
This commit adds a check on the access of stderr. Closes #7966.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
9 years agodoc: console.trace takes a message format
Sam Roberts [Sat, 19 Jul 2014 21:34:41 +0000 (14:34 -0700)]
doc: console.trace takes a message format

Documentation claimed it accepted a single label argument, as time and
timeEnd do, which was incorrect.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
9 years agodeps: update http_parser to 2.3.0
Fedor Indutny [Wed, 23 Jul 2014 19:08:46 +0000 (23:08 +0400)]
deps: update http_parser to 2.3.0

9 years agosrc: export additional startup functions
Dean McNamee [Fri, 18 Jul 2014 07:16:28 +0000 (09:16 +0200)]
src: export additional startup functions

This allows embedders enough control to initialize node, run the
event loop, and cleanly exit (including calling handlers).

Signed-off-by: Fedor Indutny <fedor@indutny.com>
9 years agogyp: fix post-mortem in v0.11
Fedor Indutny [Mon, 21 Jul 2014 18:12:11 +0000 (22:12 +0400)]
gyp: fix post-mortem in v0.11

Expose missing constants and keep symbols on OSX.

9 years agogyp: fix post-mortem in v0.11
Fedor Indutny [Mon, 21 Jul 2014 18:12:11 +0000 (22:12 +0400)]
gyp: fix post-mortem in v0.11

Expose missing constants and keep symbols on OSX.

10 years agodeps: backport 4ed5fde4f from v8 upstream
Fedor Indutny [Fri, 21 Dec 2012 17:52:00 +0000 (17:52 +0000)]
deps: backport 4ed5fde4f from v8 upstream

Original commit message:

    Fix x64 MathMinMax for negative untagged int32 arguments.

    An untagged int32 has zeros in the upper half even if it is negative.
    Using cmpq to compare such numbers will incorrectly ignore the sign.

    BUG=164442
    R=mvstanton@chromium.org

    Review URL: https://chromiumcodereview.appspot.com/11665007

    git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@13273 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agogyp: do not let `v8dbg_` slip away on osx
Fedor Indutny [Thu, 17 Jul 2014 05:55:07 +0000 (09:55 +0400)]
gyp: do not let `v8dbg_` slip away on osx

Pass `-force_load` to linker when linking to `libv8_base` to preserve
`v8dbg_` symbols, which are useful for debugging.

10 years agotls_wrap: remove unused variable
Brian White [Thu, 17 Jul 2014 04:23:15 +0000 (00:23 -0400)]
tls_wrap: remove unused variable

Closes #7957.

10 years agolib: jslint string_decoder.js
Fedor Indutny [Tue, 15 Jul 2014 08:43:59 +0000 (12:43 +0400)]
lib: jslint string_decoder.js

10 years agostream2: flush extant data on read of ended stream
Chris Dickinson [Wed, 9 Jul 2014 09:16:45 +0000 (02:16 -0700)]
stream2: flush extant data on read of ended stream

A ReadableStream with a base64 StringDecoder backed by only
one or two bytes would fail to output its partial data before
ending. This fix adds a check to see if the `read` was triggered
by an internal `flow`, and if so, empties any remaining data.

fixes #7914.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agocluster: include settings object in 'setup' event
Ryan Graham [Thu, 10 Jul 2014 16:13:27 +0000 (09:13 -0700)]
cluster: include settings object in 'setup' event

Emits on every call to cluster.setupMaster(), even if no new settings
are given. This is because calling cluster.setupMaster() without
arguments (or with an empty options object) results in the settings
being restored to their defaults.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agocluster: allow multiple calls to setupMaster()
Ryan Graham [Fri, 23 May 2014 01:56:18 +0000 (18:56 -0700)]
cluster: allow multiple calls to setupMaster()

Only attributes of 'cluster.settings' will be modified after the first
call, leaving all other cluster initialization alone. Each call that
includes a 'settings' argument triggers a 'setup' event to be emitted.

Instead of each call resetting all values to their defaults, use the
current settings (if any) as the default. This retains setupMaster's
support how cluster.fork() uses setupMaster() to ensure
cluster.settings has been populated.

Update example in docs to use current node coding style and include
an example of progressive configuration.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agotest: fix regress-GH-1726
Fedor Indutny [Sun, 13 Jul 2014 19:15:52 +0000 (23:15 +0400)]
test: fix regress-GH-1726

10 years agosrc: pass the v8::Context to CreateEnvironment
Dean McNamee [Wed, 9 Jul 2014 11:36:50 +0000 (13:36 +0200)]
src: pass the v8::Context to CreateEnvironment

Pass in the v8::Context, instead of creating it
within CreateEnvironment.  This allows callers
to use a pre-existing context.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agochild_process: copy spawnSync() cwd option to proper buffer
cjihrig [Wed, 25 Jun 2014 03:18:00 +0000 (23:18 -0400)]
child_process: copy spawnSync() cwd option to proper buffer

The spawnSync() cwd option was being copied to the incorrect
location. This commit copies to the correct location.

Closes #7824

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agochild_process: handle writeUtf8String error
Fedor Indutny [Sat, 12 Jul 2014 09:35:26 +0000 (12:35 +0300)]
child_process: handle writeUtf8String error

When handling `writeUtf8String` error, return after emitting it.
Otherwise a runtime failure can occur.

fix #7923