platform/upstream/nodejs.git
10 years agoMerge branch 'v0.10'
Fedor Indutny [Thu, 5 Jun 2014 14:28:39 +0000 (07:28 -0700)]
Merge branch 'v0.10'

Conflicts:
ChangeLog
lib/events.js
lib/tls.js
src/node_constants.cc
src/node_crypto.cc
src/node_crypto.h
src/node_version.h

10 years agodeps: update openssl to 1.0.1h
Fedor Indutny [Thu, 5 Jun 2014 14:09:35 +0000 (07:09 -0700)]
deps: update openssl to 1.0.1h

10 years agotest: remove duplicate tests
Michael Kebe [Thu, 15 May 2014 15:56:04 +0000 (17:56 +0200)]
test: remove duplicate tests

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
10 years agobench: fix buffers/buffer-base64-encode benchmark
Ben Noordhuis [Wed, 4 Jun 2014 13:25:09 +0000 (15:25 +0200)]
bench: fix buffers/buffer-base64-encode benchmark

The test is supposed to measure the performance of the base64 encoder
so move the Buffer#write() calls out of the benchmark section.

The overhead of the calls isn't terrible (about 1-3%) but having
unrelated activity in a micro-benchmark is never a good idea.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
10 years agodoc: fixed wording in child_process
Chris Barber [Fri, 30 May 2014 21:25:52 +0000 (14:25 -0700)]
doc: fixed wording in child_process

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agosrc: replace CONTAINER_OF with type-safe function
Ben Noordhuis [Tue, 27 May 2014 21:31:31 +0000 (23:31 +0200)]
src: replace CONTAINER_OF with type-safe function

Replace the CONTAINER_OF macro with a template function that is as
type-safe as a reinterpret_cast<> of an arbitrary pointer can be made.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agofs: close file if fstat() fails in readFile()
cjihrig [Wed, 28 May 2014 22:34:04 +0000 (18:34 -0400)]
fs: close file if fstat() fails in readFile()

Currently, if fstat() fails in readFile(), the callback
is invoked without closing the file. This commit closes
the file before calling back.

Closes #7697

10 years agofs: close file if fstat() fails in readFile()
cjihrig [Wed, 28 May 2014 22:34:04 +0000 (18:34 -0400)]
fs: close file if fstat() fails in readFile()

Currently, if fstat() fails in readFile(), the callback
is invoked without closing the file. This commit closes
the file before calling back.

Closes #7697

10 years agonet: Ensure consistent binding to IPV6 if address is absent
Raymond Feng [Tue, 27 May 2014 22:26:13 +0000 (15:26 -0700)]
net: Ensure consistent binding to IPV6 if address is absent

See https://github.com/joyent/node/issues/7675
net.server.listen() behaves inconsistently depending on whether the port
number is provided.

1. port === 0 && host == '' (i.e. false-y), node creates an AF_INET
socket but does not call bind().

2. port > 0 && host == '', node creates an AF_INET6 socket and calls
bind().

The fix makes 1 consistent with 2.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agodoc: Add a README for benchmark tests
Raymond Feng [Fri, 23 May 2014 03:57:31 +0000 (20:57 -0700)]
doc: Add a README for benchmark tests

The README.md documents how to run node core benchmark tests and
how to write new tests.

10 years agobenchmark: Add a test to measure Buffer.slice perf
Raymond Feng [Fri, 23 May 2014 03:37:47 +0000 (20:37 -0700)]
benchmark: Add a test to measure Buffer.slice perf

Buffer.slice can be expensive. One regression was reported by https://github.com/joyent/node/issues/7633. The method should be benchmarked.

10 years agosmalloc: rework double free bug fix
Ben Noordhuis [Fri, 23 May 2014 13:27:51 +0000 (15:27 +0200)]
smalloc: rework double free bug fix

Rework the fix from commit 6810132 in a way that removes ~60 lines of
code.

The bug was introduced in commit e87ceb2 (mea culpa) and is at its core
a pointer aliasing bug where sometimes two independent pointers existed
that pointed to the same chunk of heap memory.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
10 years agotls: fix performance issue
Alexis Campailla [Fri, 23 May 2014 18:55:34 +0000 (14:55 -0400)]
tls: fix performance issue

See https://github.com/orangemocha/node-connection-drop

I have pinpointed the performance degradation to
https://github.com/joyent/node/commit/ac2263b77f3f346458d06fc019de27e24c63cee0

This change brings performance back to the orginal levels.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agosrc: kill isolate on exit
Ben Noordhuis [Thu, 22 May 2014 23:08:27 +0000 (01:08 +0200)]
src: kill isolate on exit

Otherwise it's not possible to check from inside a destructor if V8 is
still alive with v8::V8::IsDead().  In V8 3.25, that function returns
true until the last isolate is destroyed.

This used to work in v0.10 and is a standard trick to dispose persistent
handles conditionally.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agosmalloc: prevent double free on dispose()
Trevor Norris [Fri, 23 May 2014 10:42:46 +0000 (03:42 -0700)]
smalloc: prevent double free on dispose()

dispose() free's the memory when executed and sets the external array
data to NULL and length to zero.

To prevent the same memory from being free'd twice when the object is
garbage collected we first check if the object's external array data
length == 0. Since alloc() passes NULL to
SetIndexedPropertiesToExternalArrayData() if length == 0 there's no
opportunity for memory leak.

10 years agosrc: NODE_UNIXTIME_V8 needs to use an Isolate
Rohini Harendra [Sat, 17 May 2014 05:36:56 +0000 (05:36 +0000)]
src: NODE_UNIXTIME_V8 needs to use an Isolate

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
10 years agolint: lib/_http_client.js
Timothy J Fontaine [Thu, 22 May 2014 19:55:03 +0000 (12:55 -0700)]
lint: lib/_http_client.js

10 years agotest: fix up pummel/test-net-pingpong
Ben Noordhuis [Thu, 22 May 2014 11:00:55 +0000 (13:00 +0200)]
test: fix up pummel/test-net-pingpong

Fix up a bad assumption in pummel/test-net-pingpong, namely that binding
to 'localhost' or '' means that incoming connections will have an IPv4
address.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
10 years agochild_process: don't throw on EMFILE/ENFILE
Ben Noordhuis [Wed, 21 May 2014 11:47:21 +0000 (13:47 +0200)]
child_process: don't throw on EMFILE/ENFILE

EMFILE and ENFILE mean 'out of file descriptors'.  It's a run-time error
and as such should emit an error on the child process object, not throw
an exception.

Fixes #7453.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
10 years agohttp: Optimize queued client aborts
Kevin Decker [Wed, 30 Apr 2014 13:20:25 +0000 (09:20 -0400)]
http: Optimize queued client aborts

Avoid sending unsent data and destroying otherwise legitimate sockets
for requests that are aborted while still in the agent queue. This
reduces stress on upstream systems who will likely respond to the
request but client app already knows that it will be dropped on the
floor and also helps avoid killing keep-alive connections.

10 years agobuild: disable v8 handle zapping
Ben Noordhuis [Sun, 18 May 2014 12:58:43 +0000 (14:58 +0200)]
build: disable v8 handle zapping

See also commit e7bfbaf.  Don't depend on deps/v8/build/features.gypi
to disable handle zapping, be explicit about it.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
10 years agodoc: document url `slashes` property
Yazhong Liu [Wed, 7 May 2014 10:59:23 +0000 (18:59 +0800)]
doc: document url `slashes` property

Slashes should be documented, because 3rd-party protocols -- those
postfixed with `://` -- would incorrectly `format` and `parse` if they
didn't set/get the `slashes` option.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
10 years agoquerystring: custom encode and decode
fengmk2 [Tue, 29 Apr 2014 01:40:40 +0000 (09:40 +0800)]
querystring: custom encode and decode

Not all querystring are utf-8 encoding, make querystring can be used
to encode / decode `non-utf8` encoding string if necessary.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
10 years agochild_process: add path to spawn ENOENT Error
Ryan Cole [Mon, 28 Apr 2014 01:25:02 +0000 (20:25 -0500)]
child_process: add path to spawn ENOENT Error

Add a file property to the ENOENT Error returned from ChildProcess's
spawn function.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
10 years agocontexify: fix infinite recursion in delete cb
Fedor Indutny [Fri, 16 May 2014 11:32:43 +0000 (15:32 +0400)]
contexify: fix infinite recursion in delete cb

Do not ever call `Delete()` on `proxy_global_`, it will invoke
`GlobalPropertyDeleteCallback` and cause crash because of the infinite
recursion.

fix #7529

10 years agodoc: clarify `end` vs `finish` in streams
Calvin Metcalf [Tue, 13 May 2014 15:52:38 +0000 (11:52 -0400)]
doc: clarify `end` vs `finish` in streams

Adds a section to the transform stream docs to clarify the
difference between the `end` event and the `finish` events.
Also clarifies the wording on the `end` event.

10 years agov8: backport no handle zapping for release builds
jochen@chromium.org [Mon, 19 May 2014 15:27:49 +0000 (15:27 +0000)]
v8: backport no handle zapping for release builds

BUG=318206
LOG=y
R=danno@chromium.org

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

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

10 years agostring_bytes: ucs2 support big endian
Andrew Low [Tue, 8 Apr 2014 14:39:33 +0000 (10:39 -0400)]
string_bytes: ucs2 support big endian

64bit constants are keyed for x64 platforms only, add PowerPC based
platform constants.

Node's "ucs2" encoding wants LE character data stored in the Buffer, so
we need to reorder on BE platforms.  See
http://nodejs.org/api/buffer.html regarding Node's "ucs2" encoding
specification

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
10 years agotls_wrap: do not store TLSCallbacks in SSL_CTX
Fedor Indutny [Tue, 20 May 2014 09:26:37 +0000 (13:26 +0400)]
tls_wrap: do not store TLSCallbacks in SSL_CTX

Storing it in SSL_CTX is incorrect as it may go away and get destructed
earlier, also it'll yield invalid results in SelectSNIContextCallback.

Use `SSL_get_app_data()` instead.

fix #7484

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
10 years agotest: rewrite spawnsync test
Timothy J Fontaine [Tue, 13 May 2014 21:49:59 +0000 (14:49 -0700)]
test: rewrite spawnsync test

The spawnsync test was written wrong, the timeout can never fire before
the sync process has returned, the delta is immaterial and times when
it was succeeding are not reliable cases.

Instead verify that the timeout doesn't fire while the sync process is
happening.

10 years agonet: don't throw on net.Server.close()
cjihrig [Fri, 16 May 2014 02:48:27 +0000 (22:48 -0400)]
net: don't throw on net.Server.close()

When close() is called on a non-listening server, a synchronous
error is thrown. This commit causes the error to be passed to
the asynchronous callback function instead.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agoreadline: fixes scoping bug
Dan Kaplun [Sat, 17 May 2014 07:25:10 +0000 (02:25 -0500)]
readline: fixes scoping bug

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agoconfigure: allow V8 snapshot for cross-compilation
Andrei Sedoi [Thu, 15 May 2014 23:11:51 +0000 (02:11 +0300)]
configure: allow V8 snapshot for cross-compilation

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agocrypto: fix version check in hello parser
Fedor Indutny [Fri, 16 May 2014 08:47:51 +0000 (12:47 +0400)]
crypto: fix version check in hello parser

This is a follow up for 89cb740fc31f3be1c3af9fe787c7a405429ccac4

10 years agocrypto: check protocol version at handshake header
Yazhong Liu [Sat, 10 May 2014 18:07:30 +0000 (02:07 +0800)]
crypto: check protocol version at handshake header

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agodocs: Update docs on TEST single test run.
Mark Stosberg [Tue, 13 May 2014 02:30:58 +0000 (22:30 -0400)]
docs: Update docs on TEST single test run.

The Contributing docs now clarify how to run a single test.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agocrypto: improve memory usage
Alexis Campailla [Wed, 14 May 2014 17:07:29 +0000 (13:07 -0400)]
crypto: improve memory usage

ClientHelloParser used to contain an 18k buffer that was kept around
for the life of the connection, even though it was not needed in many
situations. I changed it to be deallocated when it's determined to
be no longer needed.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agochild_process: do not set args before throwing
Greg Sabia Tucker [Wed, 14 May 2014 05:32:57 +0000 (22:32 -0700)]
child_process: do not set args before throwing

No point in setting args and options if TypeError
is being thrown.

fix #7456

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agosrc: fix _XOPEN_SOURCE redefinition warning
Ben Noordhuis [Tue, 13 May 2014 11:45:21 +0000 (13:45 +0200)]
src: fix _XOPEN_SOURCE redefinition warning

Fix the following compiler warning on systems where _XOPEN_SOURCE is
defined by default:

    ../src/node_constants.cc:35:0: warning: "_XOPEN_SOURCE" redefined
     #define _XOPEN_SOURCE 500

Move the (re)definition of _XOPEN_SOURCE to the top of the file while
we're here.  Commit 00890e4 adds a `#define _XOPEN_SOURCE 500` in order
to make <fcntl.h> expose O_NONBLOCK but it does so after other system
headers have been included.  If those headers include <fcntl.h>, then
the #include in node_constants.cc will be a no-op and O_NONBLOCK won't
be visible.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agofs: add consistent flag fall throughs
Colin Ihrig [Fri, 9 May 2014 02:26:26 +0000 (22:26 -0400)]
fs: add consistent flag fall throughs

stringToFlags() has fall throughs in a case statement.
However, they are not consistently implemented. This commit adds
consistency.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
10 years agoreadline: implements keypress buffering
Dan Kaplun [Mon, 12 May 2014 09:42:21 +0000 (04:42 -0500)]
readline: implements keypress buffering

There was an underlying assumption in readline.emitKeypressEvents (and
by extension emitKey) that the given stream (usually process.stdin)
would emit 'data' once per keypress, which is not always the case.

This commit buffers the input stream and ensures a 'keypress' event is
triggered for every keypress (including escape codes).

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agotls_wrap: remove unused variable
Fedor Indutny [Tue, 13 May 2014 09:13:23 +0000 (13:13 +0400)]
tls_wrap: remove unused variable

10 years agotest: fixes test/disabled/test-readline.js
Dan Kaplun [Mon, 12 May 2014 03:23:21 +0000 (22:23 -0500)]
test: fixes test/disabled/test-readline.js

This test is still in test/disabled because it requires a tty, however
when executed directly this test now passes.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agochild_process: spawn() does not throw TypeError
Greg Sabia Tucker [Wed, 30 Apr 2014 01:24:44 +0000 (18:24 -0700)]
child_process: spawn() does not throw TypeError

Ensure TypeError is thrown, fix a bug where `env` option was
assuming the option was actually an object.

This case is especially bad because it then sets `env == null`
instead of using `process.env`.

Fix #7456

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agobuffer: remove Buffer#toArrayBuffer()
Trevor Norris [Mon, 12 May 2014 23:45:44 +0000 (16:45 -0700)]
buffer: remove Buffer#toArrayBuffer()

A recent change to v8's API now makes it impossible to memcpy to a
v8::ArrayBuffer without causing it to be externalized. This means that
the garbage collector will not automatically free the memory when the
object is collected.

When/If the necessary API is included to allow the above
Buffer#toArrayBuffer() will be reintroduced.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
10 years agoreadline: fix close event of readline.Interface()
Yazhong Liu [Wed, 7 May 2014 16:05:39 +0000 (00:05 +0800)]
readline: fix close event of readline.Interface()

Not removing 'end' listeners for input and output on the 'close' event
resulted in an EventEmitter related memory leak.

This issue also might be reproduced at:
https://github.com/npm/npm/issues/5203

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
10 years agosrc: fix spelling mistake
Taojie [Tue, 6 May 2014 12:05:32 +0000 (20:05 +0800)]
src: fix spelling mistake

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
10 years agonode: remove duplicate tickInfo assignment
Trevor Norris [Mon, 12 May 2014 20:52:33 +0000 (13:52 -0700)]
node: remove duplicate tickInfo assignment

When process._setupNextTick() was introduced as the means to properly
initialize the mechanism behind process.nextTick() a chunk of code was
left behind that assigned memory to process._tickInfo. This code is no
longer needed.

10 years agosrc: fix StringBytes::Write if string is external
Refael Ackermann [Fri, 9 May 2014 11:12:37 +0000 (14:12 +0300)]
src: fix StringBytes::Write if string is external

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agocrypto, zlib: replace _binding with _handle
Nicholas Vavilov [Wed, 30 Apr 2014 22:57:16 +0000 (01:57 +0300)]
crypto, zlib: replace _binding with _handle

Also include whitespace fixes to appease jslint.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
10 years agodoc: add spec for util.deprecate()
Yazhong Liu [Wed, 7 May 2014 09:48:55 +0000 (17:48 +0800)]
doc: add spec for util.deprecate()

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
10 years agosrc: add --throw-deprecation entry to --help
Trevor Norris [Wed, 7 May 2014 21:47:57 +0000 (14:47 -0700)]
src: add --throw-deprecation entry to --help

10 years agodoc: fix a typo
Nikolai Vavilov [Wed, 30 Apr 2014 19:14:59 +0000 (22:14 +0300)]
doc: fix a typo

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
10 years agourl: treat \ the same as /
isaacs [Tue, 25 Mar 2014 21:16:55 +0000 (14:16 -0700)]
url: treat \ the same as /

See https://code.google.com/p/chromium/issues/detail?id=25916

Parse URLs with backslashes the same as web browsers, by replacing all
backslashes with forward slashes, except those that occur after the
first # character.

Manual rebase of 9520ade

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
10 years agobuffer: Fix incorrect Buffer.compare behavior
Feross Aboukhadijeh [Sat, 3 May 2014 05:48:34 +0000 (22:48 -0700)]
buffer: Fix incorrect Buffer.compare behavior

Fixes #7551

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
10 years agolib: name EventEmitter prototype methods
Ben Noordhuis [Mon, 5 May 2014 14:48:51 +0000 (16:48 +0200)]
lib: name EventEmitter prototype methods

Before this commit the EventEmitter methods were anonymous functions.
V8 tries to infer names for anonymous functions based on the execution
context but it frequently gets it wrong and when that happens, the
stack trace is usually confusing and unhelpful.  This commit names all
methods so V8 can fall back to the method.name property.

The above gotcha applies to all anonymous functions but is exacerbated
for EventEmitter methods because those are invoked with a plenitude of
different receivers.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
10 years agotest: http-destroyed-socket-write win32 may ABORT
Timothy J Fontaine [Tue, 6 May 2014 17:45:20 +0000 (10:45 -0700)]
test: http-destroyed-socket-write win32 may ABORT

On windows you can see ECONNABORTED instead of ECONNRESET in various
scenarios, and they are both applicable we're testing that Node is not
swallowing these errors which it was known to do prior to 0.10

10 years agostream: don't try to finish if buffer is not empty
Vladimir Kurchatkin [Tue, 6 May 2014 10:19:54 +0000 (14:19 +0400)]
stream: don't try to finish if buffer is not empty

fixes #5715

10 years agotest: replace http-destroyed-socket-write
Alexis Campailla [Mon, 20 Jan 2014 16:40:07 +0000 (08:40 -0800)]
test: replace http-destroyed-socket-write

As a comment in the test states: "This test should not be ported to
v0.10 and higher, because the problem is fixed by not ignoring
ECONNRESET in the first place."

The test is checking whether write returns false instead of whether an
ECONNRESET has been raised.

Replace with test-http-destroyed-socket-write2, this test verifies that
ECONNRESET is raised when writing to an http request where the server
has destroyed the socket.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
10 years agonpm: upgrade to 1.4.10
isaacs [Tue, 6 May 2014 01:20:40 +0000 (18:20 -0700)]
npm: upgrade to 1.4.10

* Don't set referer if already set
* fetch: Send referer and npm-session headers
* run-script: Support --parseable and --json
* list runnable scripts (Evan Lucas)
* Use marked instead of ronn for html docs

10 years agodoc: correct check for failed child_process.spawn
Adrian Lang [Wed, 14 Aug 2013 19:31:33 +0000 (21:31 +0200)]
doc: correct check for failed child_process.spawn

Since 0.10.x, exec failures are no longer signaled through stderr,
but rather as error events.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agoinstaller: copy smalloc.h on installation
Fedor Indutny [Sat, 19 Apr 2014 13:29:26 +0000 (17:29 +0400)]
installer: copy smalloc.h on installation

fix #7485

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agoconstants: export O_NONBLOCK
Fedor Indutny [Thu, 6 Mar 2014 16:29:21 +0000 (20:29 +0400)]
constants: export O_NONBLOCK

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agodeps: backport 23f2736a from v8 upstream
Fedor Indutny [Fri, 2 May 2014 18:44:45 +0000 (22:44 +0400)]
deps: backport 23f2736a from v8 upstream

Original text:

    Fix corner case in x64 compare stubs.

    BUG=v8:2416

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

fix #7528

10 years agodebugger: assign Environment to DebugContext too
Fedor Indutny [Sun, 27 Apr 2014 08:42:43 +0000 (12:42 +0400)]
debugger: assign Environment to DebugContext too

fix #7517

10 years agotest: use larger buffer in net-error-twice
Timothy J Fontaine [Fri, 2 May 2014 15:50:48 +0000 (08:50 -0700)]
test: use larger buffer in net-error-twice

Use a larger buffer to ensure that we're still writing when the client
disconnects so the write error is actually raised.

10 years agotest: fix test-http-flush on Windows
Alexis Campailla [Fri, 2 May 2014 15:22:19 +0000 (11:22 -0400)]
test: fix test-http-flush on Windows

On Windows we cannot get the server address until a connection
is accepted.

From MSDN:
The getsockname function does not always return information about
the host address when the socket has been bound to an unspecified
address, unless the socket has been connected with connect or accept
(for example, using ADDR_ANY). A Windows Sockets application must not
assume that the address will be specified unless the socket is
connected.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
10 years agoNow working on 0.11.14
Timothy J Fontaine [Fri, 2 May 2014 14:53:42 +0000 (07:53 -0700)]
Now working on 0.11.14

10 years agoMerge branch 'v0.11.13-release'
Timothy J Fontaine [Fri, 2 May 2014 14:53:32 +0000 (07:53 -0700)]
Merge branch 'v0.11.13-release'

10 years agoNow working on 0.10.29
Timothy J Fontaine [Fri, 2 May 2014 14:46:15 +0000 (07:46 -0700)]
Now working on 0.10.29

10 years agoMerge branch 'v0.10.28-release' into v0.10
Timothy J Fontaine [Fri, 2 May 2014 14:46:05 +0000 (07:46 -0700)]
Merge branch 'v0.10.28-release' into v0.10

10 years agoMerge remote-tracking branch 'upstream/v0.10' into v0.11.13-release v0.11.13
Timothy J Fontaine [Fri, 2 May 2014 00:49:51 +0000 (17:49 -0700)]
Merge remote-tracking branch 'upstream/v0.10' into v0.11.13-release

10 years ago2014.05.01, Version 0.10.28 (Stable) v0.10.28
Timothy J Fontaine [Fri, 2 May 2014 00:47:47 +0000 (17:47 -0700)]
2014.05.01, Version 0.10.28 (Stable)

* npm: upgrade to v1.4.9

10 years agonpm: upgrade to v1.4.9
isaacs [Thu, 1 May 2014 23:30:33 +0000 (16:30 -0700)]
npm: upgrade to v1.4.9

* Send referer header (with any potentially private stuff redacted)
* Fix critical typo bug in previous npm release

10 years ago2014.05.01, Version 0.11.13 (Unstable)
Timothy J Fontaine [Thu, 1 May 2014 23:06:44 +0000 (16:06 -0700)]
2014.05.01, Version 0.11.13 (Unstable)

* v8: upgrade to 3.24.35.22

* buffer: add compare and equals methods (Sean McArthur)

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

* buffer: return uint if MSB is 1 in readUInt32 (goussardg)

* buffer: truncate buffer after string decode (Fedor Indutny)

* child_process: fix assertion error in spawnSync (Shigeki Ohtsu)

* crypto: fix memory leak in CipherBase::Final (Fedor Indutny)

* crypto: improve error messages (Ingmar Runge)

* crypto: move `createCredentials` to tls (Fedor Indutny)

* crypto: work around OpenSSL oddness (Fedor Indutny)

* dgram: introduce `reuseAddr` option (Fedor Indutny)

* domain: don't crash on "throw null" (Alex Kocharin)

* events: check if _events is an own property (Vladimir Kurchatkin)

* fs: improve performance of all stat functions (James Pickard)

* fs: return blksize on stats object (Trevor Norris)

* http: add request.flush() method (Ben Noordhuis)

* http: better client "protocol not supported" error (Nathan Rajlich)

* http: use defaultAgent.protocol in protocol check (Nathan Rajlich)

* main: Handle SIGINT properly. (Geir Hauge)

* net: bind to `::` TCP address by default (Fedor Indutny)

* readline: consider newlines for cursor position (Yazhong Liu)

* stream: split `objectMode` for Duplex (Vladimir Kurchatkin)

* tls: `getPeerCertificate(detailed)` (Fedor Indutny)

* tls: do not call SNICallback unless present (Fedor Indutny)

* tls: force readable/writable to `true` (Fedor Indutny)

* tls: support OCSP on client and server (Fedor Indutny)

* util: made util.isArray a direct alias for Array.isArray (Evan Carroll)

10 years agoMerge remote-tracking branch 'upstream/v0.10'
Timothy J Fontaine [Thu, 1 May 2014 22:44:47 +0000 (15:44 -0700)]
Merge remote-tracking branch 'upstream/v0.10'

Conflicts:
AUTHORS
ChangeLog
src/node_version.h

10 years agoNow working on 0.10.28
Timothy J Fontaine [Thu, 1 May 2014 22:30:07 +0000 (15:30 -0700)]
Now working on 0.10.28

10 years agoMerge branch 'v0.10.27-release' into v0.10
Timothy J Fontaine [Thu, 1 May 2014 22:29:52 +0000 (15:29 -0700)]
Merge branch 'v0.10.27-release' into v0.10

10 years ago2014.05.01, Version 0.10.27 (Stable) v0.10.27
Timothy J Fontaine [Thu, 1 May 2014 21:04:20 +0000 (14:04 -0700)]
2014.05.01, Version 0.10.27 (Stable)

* npm: upgrade to v1.4.8

* openssl: upgrade to 1.0.1g

* uv: update to v0.10.27

* dns: fix certain txt entries (Fedor Indutny)

* assert: Ensure reflexivity of deepEqual (Mike Pennisi)

* child_process: fix deadlock when sending handles (Fedor Indutny)

* child_process: fix sending handle twice (Fedor Indutny)

* crypto: do not lowercase cipher/hash names (Fedor Indutny)

* dtrace: workaround linker bug on FreeBSD (Fedor Indutny)

* http: do not emit EOF non-readable socket (Fedor Indutny)

* http: invoke createConnection when no agent (Nathan Rajlich)

* stream: remove useless check (Brian White)

* timer: don't reschedule timer bucket in a domain (Greg Brail)

* url: treat  the same as / (isaacs)

* util: format as Error if instanceof Error (Rod Vagg)

10 years agoMerge remote-tracking branch 'upstream/v0.10'
Timothy J Fontaine [Thu, 1 May 2014 20:54:23 +0000 (13:54 -0700)]
Merge remote-tracking branch 'upstream/v0.10'

Reverted 9520adeb37f5ebe02a68669ec97770f4869705bb

Conflicts:
deps/cares/src/ares_parse_txt_reply.c
deps/uv/.mailmap
deps/uv/AUTHORS
deps/uv/ChangeLog
deps/uv/include/uv.h
deps/uv/src/unix/error.c
deps/uv/src/unix/process.c
deps/uv/src/version.c
deps/uv/src/win/pipe.c
deps/uv/src/win/signal.c
deps/uv/src/win/util.c
deps/uv/test/test-spawn.c
deps/uv/vcbuild.bat
deps/v8/src/platform-posix.cc
deps/v8/tools/gyp/v8.gyp
lib/util.js
src/node.cc
test/simple/test-util-format.js
test/simple/test-util.js

10 years agonpm: upgrade to v1.4.8
isaacs [Thu, 1 May 2014 18:09:00 +0000 (11:09 -0700)]
npm: upgrade to v1.4.8

* Check SHA before using files from cache
* adduser: allow change of the saved password
* Make `npm install` respect `config.unicode`
* Fix lifecycle to pass `Infinity` for config env value
* Don't return 0 exit code on invalid command
* cache: Handle 404s and other HTTP errors as errors
* bump tap dep, make tests stderr a bit quieter
* Resolve ~ in path configs to env.HOME
* Include npm version in default user-agent conf
* npm init: Use ISC as default license, use save-prefix for deps
* Many test and doc fixes

10 years agobuffer: normalize compare() output
Trevor Norris [Tue, 29 Apr 2014 21:46:58 +0000 (14:46 -0700)]
buffer: normalize compare() output

Because of differences in memcmp() implementation, normalize output to
return -1, 0 or 1 only.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
10 years agouv: update to v0.10.27
Timothy J Fontaine [Thu, 1 May 2014 16:27:39 +0000 (09:27 -0700)]
uv: update to v0.10.27

10 years agodeps: update uv to v0.11.25
Fedor Indutny [Thu, 1 May 2014 16:26:26 +0000 (20:26 +0400)]
deps: update uv to v0.11.25

10 years agostream: split `objectMode` for Duplex
Vladimir Kurchatkin [Tue, 15 Apr 2014 16:44:46 +0000 (20:44 +0400)]
stream: split `objectMode` for Duplex

This commit introduces `readableObjectMode` and
`writableObjectMode` options for Duplex streams.
This can be used mostly to make parsers and
serializers with Transform streams.

Also the docs section about stream state objects
is removed, because it is not relevant anymore.
The example from the section is remade to show
new options.

fixes #6284

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
10 years agotest: update test-dns.js after a60a9b0
Timothy J Fontaine [Wed, 30 Apr 2014 16:14:55 +0000 (09:14 -0700)]
test: update test-dns.js after a60a9b0

resolveTxt now returns a 2-d array for all the chunks string chunks
relating to the record

10 years agochild_process: fix assertion error in spawnSync
Shigeki Ohtsu [Mon, 21 Apr 2014 16:26:11 +0000 (01:26 +0900)]
child_process: fix assertion error in spawnSync

When ExitCallback was not called with an error such as ENOENT in
uv_spawn, the process handle still remains refed and needs to be closed.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
10 years agocrypto: improve error messages
Ingmar Runge [Tue, 22 Apr 2014 20:03:53 +0000 (22:03 +0200)]
crypto: improve error messages

1) ThrowCryptoTypeErrors was not actually used for
   type-related errors. Removed it.
2) For AEAD modes, OpenSSL does not set any internal
   error information if Final does not complete suc-
   cessfully. Therefore, "TypeError:error:00000000:l
   ib(0):func(0):reason(0)" would be the error mess-
   age. Use a default message for these cases.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agodocs: add cautionary note to emitter.removeAllListeners
Forrest L Norvell [Mon, 28 Apr 2014 19:38:06 +0000 (12:38 -0700)]
docs: add cautionary note to emitter.removeAllListeners

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agocrypto: fix a couple of VC++ warnings
Rasmus Christian Pedersen [Mon, 28 Apr 2014 12:45:20 +0000 (14:45 +0200)]
crypto: fix a couple of VC++ warnings

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agobuffer: add compare and equals methods
Sean McArthur [Thu, 6 Mar 2014 18:21:04 +0000 (10:21 -0800)]
buffer: add compare and equals methods

compare() works like String.localeCompare such that:

    Buffer.compare(a, b) === a.compare(b);

equals() does a native check to see if two buffers are equal.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
10 years agodeps: fix v8 link error with glibc < 2.17
Ben Noordhuis [Mon, 28 Apr 2014 11:05:00 +0000 (13:05 +0200)]
deps: fix v8 link error with glibc < 2.17

Commit f9ced08 switches V8 on Linux over from gettimeofday() to
clock_getres() and clock_gettime().  As of glibc 2.17, those functions
live in libc.  For older versions, we need to pull them in from librt.

Fixes the following link-time error;

    Release/obj.target/deps/v8/tools/gyp/libv8_base.a(platform-posix.o):
    In function `v8::internal::OS::Ticks()':
    platform-posix.cc:(.text+0x93c):
    undefined reference to `clock_gettime'
    platform-posix.cc:(.text+0x989):
    undefined reference to `clock_getres'

Fixes #7514.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agoutil: format as Error if instanceof Error
Rod Vagg [Tue, 15 Oct 2013 01:26:18 +0000 (12:26 +1100)]
util: format as Error if instanceof Error

Conflicts:
lib/util.js
test/simple/test-util-format.js

This is a backport to fix #7253

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agovm: assign Environment to created context
Denys Zariaiev [Fri, 25 Apr 2014 12:06:06 +0000 (15:06 +0300)]
vm: assign Environment to created context

ContextifyContext::CreateV8Context is now create context
with Environment pointer

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agodeps: make v8 use CLOCK_REALTIME_COARSE
Ben Noordhuis [Thu, 24 Apr 2014 02:27:40 +0000 (04:27 +0200)]
deps: make v8 use CLOCK_REALTIME_COARSE

Date.now() indirectly calls gettimeofday() on Linux and that's a system
call that is extremely expensive on virtualized systems when the host
operating system has to emulate access to the hardware clock.

Case in point: output from `perf record -c 10000 -e cycles:u -g -i`
for a benchmark/http_simple bytes/8 benchmark with a light load of
50 concurrent clients:

    53.69%     node  node                 [.] v8::internal::OS::TimeCurrentMillis()
               |
               --- v8::internal::OS::TimeCurrentMillis()
                  |
                  |--99.77%-- v8::internal::Runtime_DateCurrentTime(v8::internal::Arguments, v8::internal::Isolate*)
                  |          0x23587880618e

That's right - over half of user time spent inside the V8 function that
calls gettimeofday().

Notably, nearly all system time gets attributed to acpi_pm_read(), the
kernel function that reads the ACPI power management timer:

    32.49%     node  [kernel.kallsyms]    [k] acpi_pm_read
               |
               --- acpi_pm_read
                  |
                  |--98.40%-- __getnstimeofday
                  |          getnstimeofday
                  |          |
                  |          |--71.61%-- do_gettimeofday
                  |          |          sys_gettimeofday
                  |          |          system_call_fastpath
                  |          |          0x7fffbbaf6dbc
                  |          |          |
                  |          |          |--98.72%-- v8::internal::OS::TimeCurrentMillis()

The cost of the gettimeofday() system call is normally measured in
nanoseconds but we were seeing 100 us averages and spikes >= 1000 us.
The numbers were so bad, my initial hunch was that the node process was
continuously getting rescheduled inside the system call...

v8::internal::OS::TimeCurrentMillis()'s most frequent caller is
v8::internal::Runtime_DateCurrentTime(), the V8 run-time function
that's behind Date.now().  The timeout handling logic in lib/http.js
and lib/net.js calls into lib/timers.js and that module will happily
call Date.now() hundreds or even thousands of times per second.
If you saw exports._unrefActive() show up in --prof output a lot,
now you know why.

That's why this commit makes V8 switch over to clock_gettime() on Linux.
In particular, it checks if CLOCK_REALTIME_COARSE is available and has
a resolution <= 1 ms because in that case the clock_gettime() call can
be fully serviced from the vDSO.

It speeds up the aforementioned benchmark by about 100% on the affected
systems and should go a long way toward addressing the latency issues
that StrongLoop customers have been reporting.

This patch will be upstreamed as a CR against V8 3.26.  I'm sending it
as a pull request for v0.10 first because that's what our users are
running and because the delta between 3.26 and 3.14 is too big to
reasonably back-port the patch.  I'll open a pull request for the
master branch once the CR lands upstream.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agodoc: fix missing link in net api
Julian Gruber [Thu, 24 Apr 2014 11:19:14 +0000 (04:19 -0700)]
doc: fix missing link in net api

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agodoc: fix order in net api
Julian Gruber [Thu, 24 Apr 2014 11:18:31 +0000 (04:18 -0700)]
doc: fix order in net api

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agohttp: add request.flush() method
Ben Noordhuis [Wed, 9 Apr 2014 13:02:03 +0000 (15:02 +0200)]
http: add request.flush() method

Forcibly flushes the request headers.  You need this with long-lived
HTTP connections where the first data isn't written until the connection
has been established (think: tunneling requests over HTTP CONNECT.)

Fixes #7296.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agodeps: provide TXT chunk info in c-ares
Fedor Indutny [Thu, 27 Mar 2014 20:09:20 +0000 (00:09 +0400)]
deps: provide TXT chunk info in c-ares

Provide more information in `ares_txt_reply` to coalesce chunks from the
same record into one string.

fix #7367

10 years agoRevert "deps: backport b5135bbc from c-ares repo"
Fedor Indutny [Thu, 24 Apr 2014 06:19:30 +0000 (10:19 +0400)]
Revert "deps: backport b5135bbc from c-ares repo"

This reverts commit 896e19330ad06ace8973c5d7b75d2de538228062.

Proper handling of TXT records requires API change, we can't afford it
in v0.10.

See #7371 for details.