Commit Graph

10033 Commits (46ccb201cb41b2979ce4127c67935cbf0932e15c)

Author SHA1 Message Date
Fedor Indutny 3d3d48d4b7 deps: update uv to v0.11.25 2014-05-01 20:26:26 +04:00
Vladimir Kurchatkin d0fc5538d1 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>
2014-04-30 10:44:31 -07:00
Timothy J Fontaine 7b72e15665 test: update test-dns.js after a60a9b0
resolveTxt now returns a 2-d array for all the chunks string chunks
relating to the record
2014-04-30 09:14:55 -07:00
Shigeki Ohtsu ab7a3d098d 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>
2014-04-30 09:02:18 -07:00
Ingmar Runge 26a1b712ec 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>
2014-04-29 14:20:14 +04:00
Forrest L Norvell 793c76e5c6 docs: add cautionary note to emitter.removeAllListeners
Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-04-29 14:15:10 +04:00
Rasmus Christian Pedersen d13e0297c3 crypto: fix a couple of VC++ warnings
Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-04-29 14:13:28 +04:00
Sean McArthur 226f98a356 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>
2014-04-28 22:09:48 -07:00
Ben Noordhuis 3f3a71e61e 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>
2014-04-28 19:34:07 +04:00
Rod Vagg 250782d139 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>
2014-04-26 00:52:49 +04:00
Denys Zariaiev 681fe599d7 vm: assign Environment to created context
ContextifyContext::CreateV8Context is now create context
with Environment pointer

Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-04-26 00:34:55 +04:00
Ben Noordhuis f9ced08de3 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>
2014-04-24 14:02:05 -07:00
Julian Gruber 0ee99565f9 doc: fix missing link in net api
Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-04-24 19:59:41 +04:00
Julian Gruber b0fa931e07 doc: fix order in net api
Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-04-24 19:59:41 +04:00
Ben Noordhuis bd24ab2bd7 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>
2014-04-24 10:43:51 +04:00
Fedor Indutny a60a9b0dbd 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
2014-04-24 10:40:35 +04:00
Fedor Indutny 4601e7c892 Revert "deps: backport b5135bbc from c-ares repo"
This reverts commit 896e19330a.

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

See #7371 for details.
2014-04-24 10:19:30 +04:00
Farrin Reid 3950024c2f 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>
2014-04-24 10:14:48 +04:00
Fedor Indutny 89e88e96df crypto: fix memory leak in CipherBase::Final
fix #7497

Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-04-23 14:13:43 +04:00
Fedor Indutny 0f3b72460b 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>
2014-04-22 16:19:57 +04:00
Fedor Indutny afaff70a9b src: lint after OCSP commits 2014-04-18 02:24:48 +04:00
Fedor Indutny 345c40b661 tls: `getPeerCertificate(detailed)`
Add `raw` property to certificate, add mode to output full certificate
chain.
2014-04-18 02:21:16 +04:00
Fedor Indutny b3ef289ffb tls: support OCSP on client and server 2014-04-18 02:21:16 +04:00
Fedor Indutny 77d1f4a91f 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>
2014-04-17 14:27:09 +04:00
isaacs 75bc11cf12 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
2014-04-15 15:31:36 -07:00
isaacs 9520adeb37 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.
2014-04-15 15:30:43 -07:00
Vladimir Kurchatkin 2c6b424829 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>
2014-04-15 13:00:31 -07:00
Trevor Norris c7f424e44b 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.
2014-04-14 16:35:33 -07:00
Fedor Indutny 1bd4f3a605 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
2014-04-14 20:15:09 +04:00
Yazhong Liu 940974ed03 net: deduplicate Socket.prototype.address
Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-04-14 20:12:38 +04:00
Fedor Indutny 2272052461 net: bind to `::` TCP address by default
Try binding TCP socket to `::` first before falling back to
`0.0.0.0`.
2014-04-14 20:11:57 +04:00
Geir Hauge c61b0e9cbc
main: Handle SIGINT properly.
As explained by http://www.cons.org/cracauer/sigint.html

Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-04-12 12:40:31 +04:00
goussardg 8e823bcbe6 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>
2014-04-10 14:22:05 -07:00
Fedor Indutny 4c36f3e7e6 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>
2014-04-11 01:20:43 +04:00
Fedor Indutny 525fad473b test: remove vm-infinite-recursion
It doesn't work reliably on all platforms.

see #7432

Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-04-11 00:54:12 +04:00
William Bert bfb7de5e75 docs: fix links to streams
Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-04-11 00:52:33 +04:00
Timothy J Fontaine 632c135622 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.
2014-04-10 10:55:02 -07:00
Fedor Indutny 045f765a1a test: add `reuseAddr` in dgram-multicast...
Add `reuseAddr` option in `test-dgram-multicast-multi-process.js`
2014-04-10 19:55:38 +04:00
Fedor Indutny 592be014b6
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>
2014-04-10 19:39:49 +04:00
Timothy J Fontaine af69f88a9d build: make sure changelog.html is generated 2014-04-08 09:06:28 -07:00
Alexis Campailla c20b209dbb openssl: fix keypress requirement in apps on win32
Re-applying commit 153784b348, 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
2014-04-08 08:56:52 +04:00
Fedor Indutny 3054decc19 test: fix test-crypto 2014-04-08 08:56:12 +04:00
Fedor Indutny de7c0e8c02 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
2014-04-08 08:55:57 +04:00
Fedor Indutny d6fd118727 deps: update openssl to 1.0.1g 2014-04-08 00:58:37 +04:00
Fedor Indutny f2b297cc7c 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
2014-04-08 00:40:22 +04:00
Brian White c2d32f4c0e doc: add missing space
Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-04-07 17:45:04 +04:00
Saúl Ibarra Corretgé a0a180a0ad src: fix use of uv_cwd, len includes the NULL byte 2014-04-07 16:37:29 +04:00
Saúl Ibarra Corretgé 42b9343710 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.
2014-04-07 16:37:20 +04:00
Fedor Indutny 962f96d341 deps: update libuv to v0.11.23 2014-04-07 16:36:51 +04:00
Evan Carroll 95dbb6bf64 util: made util.isArray a direct alias for Array.isArray 2014-04-03 22:39:42 +04:00