platform/upstream/nodejs.git
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 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 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.

10 years agodoc: tls: added path property to tls.connect
Farrin Reid [Sat, 15 Dec 2012 01:00:13 +0000 (17:00 -0800)]
doc: tls: added path property to tls.connect

In tls.connect a unix socket connection to a path may be made in
recent versions of node by specifying the value for the path
property.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agocrypto: fix memory leak in CipherBase::Final
Fedor Indutny [Tue, 22 Apr 2014 15:53:59 +0000 (19:53 +0400)]
crypto: fix memory leak in CipherBase::Final

fix #7497

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agocrypto: work around OpenSSL oddness
Fedor Indutny [Thu, 17 Apr 2014 23:53:15 +0000 (03:53 +0400)]
crypto: work around OpenSSL oddness

OpenSSL behaves oddly: on client `cert_chain` contains
the `peer_certificate`, but on server it doesn't.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agosrc: lint after OCSP commits
Fedor Indutny [Thu, 17 Apr 2014 22:24:48 +0000 (02:24 +0400)]
src: lint after OCSP commits

10 years agotls: `getPeerCertificate(detailed)`
Fedor Indutny [Thu, 17 Apr 2014 11:57:36 +0000 (15:57 +0400)]
tls: `getPeerCertificate(detailed)`

Add `raw` property to certificate, add mode to output full certificate
chain.

10 years agotls: support OCSP on client and server
Fedor Indutny [Mon, 14 Apr 2014 17:15:57 +0000 (21:15 +0400)]
tls: support OCSP on client and server

10 years agotls: set _connecting before starting the flow
Fedor Indutny [Mon, 14 Apr 2014 10:12:35 +0000 (14:12 +0400)]
tls: set _connecting before starting the flow

When creating a TLSSocket instance based on the existing connecting
socket, `_connecting` property is copied after the initialization of
`net.Socket`. However, since `net.Socket` constructor will call
`.read(0)` if the `readable` is true - error may happen at this code
chunk in net.js:

    Socket.prototype._read = function(n) {
      debug('_read');

      if (this._connecting || !this._handle) {
        debug('_read wait for connection');
        this.once('connect', this._read.bind(this, n));
    ...

Leading to a test failures on windows:

 - test/simple/test-tls-connect-given-socket.js

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agonpm: upgrade to 1.4.7
isaacs [Tue, 15 Apr 2014 22:31:36 +0000 (15:31 -0700)]
npm: upgrade to 1.4.7

* isaacs, Robert Kowalski, Benjamin Coe: Test Improvements
* isaacs doc: Add canonical url
* isaacs view: handle unpublished packages properly
* Raynos (Jake Verbaten) do not log if silent
* Julian Gruber fix no such property error
* isaacs npmconf@0.1.14
* Thorsten Lorenz adding save-prefix configuration option
* isaacs npm-registry-client@0.4.7
* isaacs cache: treat missing versions as a 404
* isaacs cache: Save shasum, write resolved/etc data to cache
* isaacs cache: Always fetch root doc
* isaacs cache: don't repack unnecessarily from tmp
* Andrey Kislyuk Don't crash if shrinkwrap-dependencies were not passed in pkginfo
* Robert Kowalski fix link in faq
* Jean Lauliac Add a peerDependencies section in package.json doc
* isaacs read-installed@2.0.2

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.

10 years agoevents: check if _events is an own property
Vladimir Kurchatkin [Thu, 3 Apr 2014 22:11:56 +0000 (02:11 +0400)]
events: check if _events is an own property

Without this check it is possible to have the _events object shared
amongst instances.

Fixes #7157

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
10 years agofs: return blksize on stats object
Trevor Norris [Mon, 14 Apr 2014 23:35:33 +0000 (16:35 -0700)]
fs: return blksize on stats object

Oversight to not pass blksize to fs.Stats on initialization.

Also added a test to make sure the object property has been set. Since
now on Windows both blksize and blocks will simply be set to undefined.

10 years agochild_process: fix deadlock when sending handles
Fedor Indutny [Mon, 14 Apr 2014 09:33:22 +0000 (13:33 +0400)]
child_process: fix deadlock when sending handles

Fix possible deadlock, when handles are sent in both direction
simultaneously. In such rare cases, both sides may queue their
`NODE_HANDLE_ACK` replies and wait for them.

fix #7465

10 years agonet: deduplicate Socket.prototype.address
Yazhong Liu [Sun, 13 Apr 2014 17:19:14 +0000 (01:19 +0800)]
net: deduplicate Socket.prototype.address

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agonet: bind to `::` TCP address by default
Fedor Indutny [Sun, 13 Apr 2014 15:11:56 +0000 (19:11 +0400)]
net: bind to `::` TCP address by default

Try binding TCP socket to `::` first before falling back to
`0.0.0.0`.

10 years agomain: Handle SIGINT properly.
Geir Hauge [Mon, 31 Mar 2014 07:52:03 +0000 (09:52 +0200)]
main: Handle SIGINT properly.

As explained by http://www.cons.org/cracauer/sigint.html

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agobuffer: return uint if MSB is 1 in readUInt32
goussardg [Wed, 9 Apr 2014 23:39:31 +0000 (16:39 -0700)]
buffer: return uint if MSB is 1 in readUInt32

Fix issue where a signed integer is returned.

Example:

var b = new Buffer(4);
b.writeUInt32BE(0xffffffff);
b.readUInt32BE(0) == -1

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
10 years agobuffer: truncate buffer after string decode
Fedor Indutny [Thu, 27 Mar 2014 17:45:15 +0000 (21:45 +0400)]
buffer: truncate buffer after string decode

When our estimates for a storage size are higher than the actual length
of decoded data, the destination buffer should be truncated. Otherwise
`Buffer::Length` will give misleading information to C++ layer.

fix #7365

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agotest: remove vm-infinite-recursion
Fedor Indutny [Thu, 10 Apr 2014 20:53:47 +0000 (00:53 +0400)]
test: remove vm-infinite-recursion

It doesn't work reliably on all platforms.

see #7432

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agodocs: fix links to streams
William Bert [Wed, 9 Apr 2014 20:50:08 +0000 (16:50 -0400)]
docs: fix links to streams

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agosrc: use monotonic time for process.uptime()
Timothy J Fontaine [Sat, 5 Apr 2014 20:49:47 +0000 (13:49 -0700)]
src: use monotonic time for process.uptime()

`process.uptime()` interface will return the amount of time the
current process has been running. To achieve this it was caching the
`uv_uptime` value at program start, and then on the call to
`process.uptime()` returning the delta between the two values.

`uv_uptime` is defined as the number of seconds the operating system
has been up since last boot. On sunos this interface uses `kstat`s
which can be a significantly expensive operation as it requires
exclusive access, but because of the design of `process.uptime()` node
*had* to always call this on start. As a result if you had many node
processes all starting at the same time you would suffer lock
contention as they all tried to read kstats.

Instead of using `uv_uptime` to achieve this, the libuv loop already
has a concept of current loop time in the form of `uv_now()` which is
in fact monotonically increasing, and already stored directly on the
loop. By using this value at start every platform performs at least
one fewer syscall during initialization.

Since the interface to `uv_uptime` is defined as seconds, in the call
to `process.uptime()` we now `uv_update_time` get our delta, divide by
1000 to get seconds, and then convert to an `Integer`. In 0.12 we can
move back to `Number::New` instead and not lose precision.

Caveat: For some platforms `uv_uptime` reports time monotonically
increasing regardless of system hibernation, `uv_now` interface is
also monotonically increasing but may not reflect time spent in
hibernation.

10 years agotest: add `reuseAddr` in dgram-multicast...
Fedor Indutny [Thu, 10 Apr 2014 15:55:38 +0000 (19:55 +0400)]
test: add `reuseAddr` in dgram-multicast...

Add `reuseAddr` option in `test-dgram-multicast-multi-process.js`

10 years agodgram: introduce `reuseAddr` option
Fedor Indutny [Tue, 8 Apr 2014 23:04:53 +0000 (03:04 +0400)]
dgram: introduce `reuseAddr` option

Introduce new signature for both `dgram.createSocket` method and
`dgram.Socket` constructor:

    dgram.createSocket(options, [listener])

Options should contain `type` property and may contain `reuseAddr`
property. When `reuseAddr` is `true` - SO_REUSEADDR will be issued on
socket on bind.

fix #7415

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agobuild: make sure changelog.html is generated
Timothy J Fontaine [Tue, 8 Apr 2014 16:05:59 +0000 (09:05 -0700)]
build: make sure changelog.html is generated

10 years agoopenssl: fix keypress requirement in apps on win32
Alexis Campailla [Tue, 4 Feb 2014 01:23:15 +0000 (17:23 -0800)]
openssl: fix keypress requirement in apps on win32

Re-applying commit 153784b3489e2feb9d93a3a5eee5a4aa34f74e39, which
was overwritten by the update to openssl 1.0.1f.

Original source:

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

10 years agotest: fix test-crypto
Fedor Indutny [Tue, 8 Apr 2014 04:56:12 +0000 (08:56 +0400)]
test: fix test-crypto

10 years agoMerge branch 'v0.10'
Fedor Indutny [Tue, 8 Apr 2014 04:55:57 +0000 (08:55 +0400)]
Merge branch 'v0.10'

Conflicts:
deps/openssl/asm/x64-elf-gas/aes/vpaes-x86_64.s
deps/openssl/asm/x64-macosx-gas/aes/vpaes-x86_64.s
deps/openssl/asm/x64-win32-masm/aes/vpaes-x86_64.asm
deps/openssl/openssl/CHANGES
deps/openssl/openssl/Makefile
deps/openssl/openssl/Makefile.org
deps/openssl/openssl/NEWS
deps/openssl/openssl/README
deps/openssl/openssl/crypto/opensslv.h
deps/openssl/openssl/openssl.spec
deps/openssl/openssl/ssl/s23_clnt.c
lib/http.js
test/simple/test-http-client-readable.js

10 years agodeps: update openssl to 1.0.1g
Fedor Indutny [Mon, 7 Apr 2014 20:58:37 +0000 (00:58 +0400)]
deps: update openssl to 1.0.1g

10 years agohttp: do not emit EOF non-readable socket
Fedor Indutny [Fri, 24 Jan 2014 12:25:11 +0000 (16:25 +0400)]
http: do not emit EOF non-readable socket

Socket may become not `readable`, but http should not rely on this
property and should not think that it means that no data will ever
arrive from it. In fact, it may arrive in a next tick and, since
`this.push(null)` was already called, it will result in a error like
this:

    Error: stream.push() after EOF
        at readableAddChunk (_stream_readable.js:143:15)
        at IncomingMessage.Readable.push (_stream_readable.js:123:10)
        at HTTPParser.parserOnBody (_http_common.js:132:22)
        at Socket.socketOnData (_http_client.js:277:20)
        at Socket.EventEmitter.emit (events.js:101:17)
        at Socket.Readable.read (_stream_readable.js:367:10)
        at Socket.socketCloseListener (_http_client.js:196:10)
        at Socket.EventEmitter.emit (events.js:123:20)
        at TCP.close (net.js:479:12)

fix #6784

10 years agodoc: add missing space
Brian White [Mon, 7 Apr 2014 02:08:50 +0000 (22:08 -0400)]
doc: add missing space

Signed-off-by: Fedor Indutny <fedor@indutny.com>
10 years agosrc: fix use of uv_cwd, len includes the NULL byte
Saúl Ibarra Corretgé [Wed, 12 Mar 2014 23:22:50 +0000 (00:22 +0100)]
src: fix use of uv_cwd, len includes the NULL byte

10 years agosrc: update uv callbacks after API changes
Saúl Ibarra Corretgé [Wed, 12 Mar 2014 23:08:29 +0000 (00:08 +0100)]
src: update uv callbacks after API changes

async, timer, prepare, idle and check handles no longer get a status
parameter since they can never fail.

10 years agodeps: update libuv to v0.11.23
Fedor Indutny [Mon, 7 Apr 2014 12:36:51 +0000 (16:36 +0400)]
deps: update libuv to v0.11.23

10 years agoutil: made util.isArray a direct alias for Array.isArray
Evan Carroll [Wed, 2 Apr 2014 00:04:15 +0000 (19:04 -0500)]
util: made util.isArray a direct alias for Array.isArray

10 years agodomain: don't crash on "throw null"
Alex Kocharin [Tue, 24 Dec 2013 12:33:03 +0000 (16:33 +0400)]
domain: don't crash on "throw null"

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
10 years agodocs: correct tls docs. server -> client
Dominic Tarr [Sun, 30 Mar 2014 22:25:41 +0000 (11:25 +1300)]
docs: correct tls docs. server -> client

when a pfx file is passed to tls.connection,
it is the client private key, not the server's private key.

10 years agolib: use triple equals
Yuki KAN [Sat, 1 Mar 2014 02:09:29 +0000 (11:09 +0900)]
lib: use triple equals

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
10 years agonode: add signature to SET_PROTOTYPE_METHOD
C. Scott Ananian [Thu, 6 Mar 2014 20:44:18 +0000 (15:44 -0500)]
node: add signature to SET_PROTOTYPE_METHOD

This prevents segfaults when a native method is reassigned to a
different object (which corrupts args.This()).  When unwrapping,
clients should use args.Holder() instead of args.This().

Closes #6690.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
10 years agobuffer: improve {read,write}{U}Int* methods
Nick Apperson [Tue, 25 Mar 2014 14:51:13 +0000 (09:51 -0500)]
buffer: improve {read,write}{U}Int* methods

Increase the performance and simplify the logic of Buffer#write{U}Int*
and Buffer#read{U}Int* methods by placing the byte manipulation code
directly inline.

Also improve the speed of buffer-write benchmarks by creating a new
call directly to each method by using Function() instead of calling by
buff[fn].

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
10 years agosrc: fix up after v8 upgrade
Ben Noordhuis [Mon, 31 Mar 2014 13:13:37 +0000 (15:13 +0200)]
src: fix up after v8 upgrade

The two biggest changes are that v8::Script::New() has been removed and
that a v8::Script object now has to be explicitly bound to a context if
you want to run it from another context.

We can accommodate both changes without breaking the vm module's public
API or even the internal JS API.

10 years agodeps: fix up v8 postmortem codegen
Ben Noordhuis [Mon, 31 Mar 2014 13:07:59 +0000 (15:07 +0200)]
deps: fix up v8 postmortem codegen

Fix up overzealous parses, strip whitespace from class and field names.

10 years agodeps: upgrade v8 to 3.25.30
Ben Noordhuis [Mon, 31 Mar 2014 12:38:28 +0000 (14:38 +0200)]
deps: upgrade v8 to 3.25.30

10 years agotest: make test-smalloc endian aware
Andrew Low [Tue, 1 Apr 2014 14:18:09 +0000 (10:18 -0400)]
test: make test-smalloc endian aware

The test/simple/test-smalloc.js has an implicit assumption
of the byte order of the data stored for Double and Uint32
values. On a big endian platform this test fails without
these patches.

Use os.endianness() to detect the endian of the platform
and use it to gate the static value used for comparison.

10 years agov8: upgrade to 3.24.35.22
Trevor Norris [Tue, 1 Apr 2014 18:46:28 +0000 (11:46 -0700)]
v8: upgrade to 3.24.35.22

10 years agoconfigure: make --v8-options switch more robust
Ben Noordhuis [Mon, 31 Mar 2014 12:22:49 +0000 (14:22 +0200)]
configure: make --v8-options switch more robust

Improve on commit b55c9d6 by not requiring that switches are comma
separated.  This commit makes `./configure --v8-options="--foo --bar"`
work and takes special care to properly escape quotes in the options
string.

10 years agofs: improve performance of all stat functions
James Pickard [Thu, 27 Feb 2014 20:45:18 +0000 (15:45 -0500)]
fs: improve performance of all stat functions

By building the fs.Stats object in JS, which is returned by all fs stat
functions, calls to v8::Object::Set() are removed. This also includes
creating all associated Date objects in JS, rather than using
v8::Date::New(). Both these changes have significant performance gains.

Note that the returned value from fs.stat changes slightly for non-POSIX
systems. Whereas before the stats object would be missing blocks and
blksize keys, it now has these keys with undefined as the value.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
10 years agodoc: typo clean up in tls
Goh Yisheng (Andrew) [Sat, 29 Mar 2014 00:20:14 +0000 (08:20 +0800)]
doc: typo clean up in tls

10 years agocrypto: move `createCredentials` to tls
Fedor Indutny [Thu, 6 Mar 2014 23:27:01 +0000 (03:27 +0400)]
crypto: move `createCredentials` to tls

Move `createCredentials` to `tls` module and rename it to
`createSecureContext`. Make it use default values from `tls` module:
`DEFAULT_CIPHERS` and `DEFAULT_ECDH_CURVE`.

fix #7249

10 years agoconfigure: --v8-options option
Fedor Indutny [Wed, 26 Mar 2014 20:30:49 +0000 (00:30 +0400)]
configure: --v8-options option

Introduce a way to set some v8 flags at compile time, the values should
be separated by comma.

10 years agohttp: better client "protocol not supported" error
Nathan Rajlich [Tue, 25 Mar 2014 20:48:57 +0000 (10:48 -1000)]
http: better client "protocol not supported" error

Include the "expected protocol" in the Error message
string, which evaluates to "http:" for the `http`
core module, and "https:" for the `https` module.

Closes #7355.

10 years agodeps: apply floating patch to v8
dcarney@chromium.org [Mon, 24 Mar 2014 19:36:59 +0000 (19:36 +0000)]
deps: apply floating patch to v8

Original commit message below:

fix FunctionCallbackInfo ambiguity

- when compiling tools that embed v8 with g++ FunctionCallbackInfo is currently ambigous
- more info: https://github.com/joyent/node/issues/7337
- original patch is here: https://codereview.appspot.com/78770045/

TBR=svenpanne@chromium.org

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

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

10 years agotls: do not call SNICallback unless present
Fedor Indutny [Thu, 6 Mar 2014 22:25:38 +0000 (02:25 +0400)]
tls: do not call SNICallback unless present

When asynchronously parsing ClientHello for session resumption -
SNICallback may not be set. Check if it is present before invoking
it.

fix #7010

10 years agotls: force readable/writable to `true`
Fedor Indutny [Tue, 25 Feb 2014 16:38:33 +0000 (20:38 +0400)]
tls: force readable/writable to `true`

These are an old and deprecated properties that was used by previous
stream implementation, and are still in use in some user-land modules.

Prior to this commit, they were read from the underlying socket, which
may be non-readable/non-writable while connecting or while staying
uninitialized.

Force set them to `true`, just to make sure that there will be no
inconsistency.

fix #7152

10 years agobuild: windows signing should include timestamps
Josh Dague [Wed, 26 Mar 2014 05:26:17 +0000 (01:26 -0400)]
build: windows signing should include timestamps

Previously the build artifacts did not include a signed timestamp, so
when the certificate expired the validation of the artifact would fail.
Now we sign against a timestamp server such that the artifact will
always be valid regardless of the disposition of the certificate.

Closes #7360 and #7059.

10 years agocrypto: fix lint
Fedor Indutny [Wed, 26 Mar 2014 07:52:00 +0000 (11:52 +0400)]
crypto: fix lint

10 years agoMerge remote-tracking branch 'origin/v0.10'
Fedor Indutny [Wed, 26 Mar 2014 07:42:57 +0000 (11:42 +0400)]
Merge remote-tracking branch 'origin/v0.10'

Conflicts:
src/node.cc
src/node_crypto.cc
src/node_crypto.h

10 years agosrc: ensure that openssl's PRNG is fully seeded
Ben Noordhuis [Tue, 25 Mar 2014 22:35:28 +0000 (23:35 +0100)]
src: ensure that openssl's PRNG is fully seeded

Ensure that OpenSSL has enough entropy (at least 256 bits) for its PRNG.

The entropy pool starts out empty and needs to fill up before the PRNG
can be used securely.

OpenSSL normally fills the pool automatically but not when someone
starts generating random numbers before the pool is full: in that case
OpenSSL keeps lowering the entropy estimate to thwart attackers trying
to guess the initial state of the PRNG.

When that happens, we wait until enough entropy is available, something
that normally should never take longer than a few milliseconds.

Fixes #7338.

10 years agosrc: seed V8's random number generator at startup
Ben Noordhuis [Fri, 20 Sep 2013 20:01:49 +0000 (22:01 +0200)]
src: seed V8's random number generator at startup

The default entropy source is /dev/urandom on UNIX platforms, which is
okay but we can do better by seeding it from OpenSSL's entropy pool.

On Windows we can certainly do better; on that platform, V8 seeds the
random number generator using only the current system time.

Fixes #6250.

NB: This is a back-port of commit 7ac2391 from the master branch that
for some reason never got back-ported to the v0.10 branch.

The default on UNIX platforms in v0.10 is different and arguably worse
than it is with master: if no entropy source is provided, V8 3.14 calls
srandom() with a xor of the PID and the current time in microseconds.

That means that on systems with a coarse system clock, the initial
state of the PRNG may be easily guessable.

The situation on Windows is even more dire because there the PRNG is
seeded with only the current time... in milliseconds.

10 years agonpm: upgrade to 1.4.6
isaacs [Wed, 19 Mar 2014 16:25:40 +0000 (09:25 -0700)]
npm: upgrade to 1.4.6

* Documentation upgrades
* Fix glob bug which prevents proper README publishing
* node-gyp upgrade to 0.13
* Documentation updates
* Add --save-exact to save an exact dep (instead of a range)
* alias 't' to 'test'

10 years agodoc: remove `agent.request()` call in example
Nathan Rajlich [Tue, 25 Mar 2014 20:02:42 +0000 (10:02 -1000)]
doc: remove `agent.request()` call in example

The `Agent#request()` function was removed in
f3189ace6b5e31a874df421ac2f74da0e77cb14d, so don't
use it in the documentation example. The function
wasn't documented in the first place.

10 years agohttp: use defaultAgent.protocol in protocol check
Nathan Rajlich [Mon, 24 Mar 2014 22:59:31 +0000 (12:59 -1000)]
http: use defaultAgent.protocol in protocol check

Default to the `defaultAgent.protocol` when comparing the
user-specified `options.protocol` string. This is so that
`http.Agent` instances do not need to specify their own
`protocol` field, since we have the relevant information
already from the `defaultAgent`.

Note that the test case could be separately cherry-picked
to the `v0.10` branch, since it already passes correctly.

Fixes #7349.
Fixes the regression described in: http://git.io/2ds-WQ

10 years agobuild: fix g++ 4.8 build, disable -Werror
Ben Noordhuis [Thu, 6 Mar 2014 04:11:07 +0000 (05:11 +0100)]
build: fix g++ 4.8 build, disable -Werror

Turn off -Werror when building V8, it hits -Werror=unused-local-typedefs
with g++ 4.8.  The warning itself is harmless so don't abort the build.

This was originally implemented in commit d2ab314e back in 2011 but the
build process has gone through a few iterations since then, that change
no longer works.

10 years agovm: share security token between contexts
Fedor Indutny [Tue, 18 Mar 2014 10:03:22 +0000 (14:03 +0400)]
vm: share security token between contexts

By default, each `v8::Context` has a different Security Token, which
prevents access to one context from another.

fix #7140

10 years agopipe_wrap: use Instantiate() method
Trevor Norris [Mon, 17 Mar 2014 21:39:37 +0000 (14:39 -0700)]
pipe_wrap: use Instantiate() method

Retrieve a new client object via PipeWrap::Instantiate(). This method
performs appropriate checks to make sure everything is as it should be.

10 years agoheaders: remove env.h from node_internals.h
Fedor Indutny [Mon, 17 Mar 2014 20:46:40 +0000 (00:46 +0400)]
headers: remove env.h from node_internals.h

`env.h` is an internal header file and should not be copied or exposed
to the users.

Additionally, export convenience `Throw*` methods with `v8::Isolate*` as
a first argument.

10 years agodeps: update v8 to 3.24.35.17
Fedor Indutny [Mon, 17 Mar 2014 20:33:01 +0000 (00:33 +0400)]
deps: update v8 to 3.24.35.17

10 years agotest: update our branched weakref to v8 3.24
Timothy J Fontaine [Mon, 17 Mar 2014 17:19:47 +0000 (10:19 -0700)]
test: update our branched weakref to v8 3.24

10 years agosrc: fix tracing infrastructure after v8 upgrade
Ben Noordhuis [Sat, 15 Mar 2014 06:15:11 +0000 (07:15 +0100)]
src: fix tracing infrastructure after v8 upgrade

Fix up the dtrace/etw/systemtap infrastructure after the V8 upgrade in
commit 1c7bf24.  The win32 changes are untested but can hardly make
things worse because node doesn't build on windows right now.

Fixes #7313 with some luck.

10 years agosrc: don't call DecodeWrite() on Buffers
Ben Noordhuis [Sat, 15 Mar 2014 01:04:02 +0000 (02:04 +0100)]
src: don't call DecodeWrite() on Buffers

Don't call DecodeWrite() with a Buffer as its argument because it in
turn calls StringBytes::Write() and that method expects a Local<String>.

"Why then does that function take a Local<Value>?" I hear you ask.
Good question but I don't have the answer.  I added a CHECK for good
measure and what do you know, all of a sudden a large number of crypto
tests started failing.

Calling DecodeWrite(BINARY) on a buffer is nonsensical anyway: if you
want the contents of the buffer, just copy out the data, there is no
need to decode it - and that's exactly what this commit does.

Fixes a great many instances of the following run-time error in debug
builds:

    FATAL ERROR: v8::String::Cast() Could not convert to string

10 years agosrc: fix up smalloc weak persistent usage
Ben Noordhuis [Sat, 15 Mar 2014 00:12:53 +0000 (01:12 +0100)]
src: fix up smalloc weak persistent usage

Fix a regression that was introduced in commit ce04c726 after the
upgrade to V8 3.24.

The new weak persistent handle API no longer gives you the original
persistent but still requires that you clear it inside your weak
callback.

Rearrange the code in src/smalloc.cc to keep track of the persistent
handle with the least amount of pain and try hard to share as much
code as possible between the 'just free it' and 'invoke my callback'
versions of the smalloc API.

Fixes #7309.

10 years agosrc: add CHECK_{GE,GT,LE,LT} macros
Ben Noordhuis [Sat, 15 Mar 2014 00:25:53 +0000 (01:25 +0100)]
src: add CHECK_{GE,GT,LE,LT} macros

Conform to the Google styleguide more and make cpplint happy, add more
CHECK macros.

Preemptively addresses cpplint's readability/check warnings ("Consider
using CHECK_GT instead of CHECK(a > b)".)

10 years agosrc: deduplicate CHECK_EQ/CHECK_NE macros
Ben Noordhuis [Sat, 15 Mar 2014 00:23:47 +0000 (01:23 +0100)]
src: deduplicate CHECK_EQ/CHECK_NE macros

DRY the macros, there is no need to define them twice depending on
whether NDEBUG is defined or not.