Commit Graph

8171 Commits (40b1c9a66d2d32673dec4ac5ec03f927dd33b32b)

Author SHA1 Message Date
isaacs 53978bdf42 2013.02.06, Version 0.8.19 (Stable)
* npm: Upgrade to v1.2.10

* zlib: pass object size hint to V8 (Ben Noordhuis)

* zlib: reduce memory consumption, release early (Ben Noordhuis)

* buffer: slow buffer copy compatibility fix (Trevor Norris)

* zlib: don't assert on malformed dictionary (Ben Noordhuis)

* zlib: don't assert on missing dictionary (Ben Noordhuis)

* windows: better ipv6 support (Bert Belder)

* windows: add error mappings related to unsupported protocols (Bert Belder)

* windows: map ERROR_DIRECTORY to UV_ENOENT (Bert Belder)
2013-02-06 08:46:14 -08:00
isaacs 5aef65a98a npm: Upgrade to v1.2.10 2013-02-06 08:39:31 -08:00
Fedor Indutny c024d2d8c0 streams: both `finish` and `close` should unpipe
Otherwise sockets that are 'finish'ed won't be unpiped and `writing to
ended stream` error will arise.

This might sound unrealistic, but it happens in net.js. When
`socket.allowHalfOpen === false`, EOF will cause `.destroySoon()` call which
ends the writable side of net.Socket.
2013-02-06 20:38:20 +04:00
Ben Noordhuis b58efe7709 test: add cluster EADDRINUSE test
Check that having a worker bind to a port that's already taken doesn't
leave the master process in a confused state. Releasing the port and
trying again should Just Work[TM].
2013-02-06 15:10:53 +01:00
Ben Noordhuis 01ee551e70 typed arrays: only share ArrayBuffer backing store
Follow browser behavior, only share the backing store when it's a
ArrayBuffer. That is:

  var abuf = new ArrayBuffer(32);
  var a = new Int8Array(abuf);
  var b = new Int8Array(abuf);
  a[0] = 0;
  b[0] = 1;
  assert(a[0] === b[0]);  // a and b share memory

But:

  var a = new Int8Array(32);
  var b = new Int8Array(a);
  a[0] = 0;
  b[0] = 1;
  assert(a[0] !== b[0]);  // a and b don't share memory

The typed arrays spec allows both `a[0] === b[0]` and `a[0] !=== b[0]`
but Chrome and Firefox implement the behavior where memory is not
shared.

Copying the memory is less efficient but let's do it anyway for the
sake of the Principle of Least Surprise.

Fixes #4714.
2013-02-06 14:21:35 +01:00
Bryan Cantrill 202b5db4ef v8: loosen artificial mmap constraint
Fixes #4010.
2013-02-06 13:30:59 +04:00
Nathan Rajlich a9c4a20331 stream: make Writable#end() accept a callback function
This is more backwards-compatible with stream1 streams like `fs.WriteStream`
which would allow a callback function to be passed in as the only argument.

Closes #4719.
2013-02-05 15:12:06 -08:00
Ben Noordhuis a86ebbe288 blog: remove dangling symlink
Fixes #4716.
2013-02-05 22:34:51 +01:00
Ben Noordhuis 6b99fd2323 zlib: pass object size hint to V8
Inform V8 that the zlib context object is tied to a large off-heap buffer.

This makes the GC run more often (in theory) and improves the accuracy of
--trace_external_memory.
2013-02-05 22:26:03 +01:00
Ben Noordhuis 8d14668992 zlib: reduce memory consumption, release early
In zlibBuffer(), don't wait for the garbage collector to reclaim the zlib memory
but release it manually. Reduces memory consumption by a factor of 10 or more
with some workloads.

Test case:

  function f() {
    require('zlib').deflate('xxx', g);
  }
  function g() {
    setTimeout(f, 5);
  }
  f();

Observe RSS memory usage with and without this commit. After 10,000 iterations,
RSS stabilizes at ~35 MB with this commit. Without, RSS is over 300 MB and keeps
growing.

Cause: whenever the JS object heap hits the high-water mark, the V8 GC sweeps
it clean, then tries to grow it in order to avoid more sweeps in the near
future. Rule of thumb: the bigger the JS heap, the lazier the GC can be.

A side effect of a bigger heap is that objects now live longer. This is harmless
in general but it affects zlib context objects because those are tied to large
buffers that live outside the JS heap, on the order of 16K per context object.

Ergo, don't wait for the GC to reclaim the memory - it may take a long time.

Fixes #4172.
2013-02-05 22:25:54 +01:00
Ben Noordhuis 5fe05464cb doc: don't suggest to reuse net.Socket objects
Using Socket.prototype.connect() to reconnect an existing Socket object
is not reliable. Users should just create a new Socket object.

See #4698.
2013-02-05 12:50:48 +01:00
isaacs 9a488a667c blog: Correct shasums for v0.9.8 release 2013-02-02 11:14:42 -08:00
Ben Noordhuis cd42f56178 buffer: optimize Buffer.prototype.write(s, 'hex')
Move the implementation to C++ land. This is similar to commit 3f65916
but this time for the write() function and the Buffer(s, 'hex')
constructor.

Speeds up the benchmark below about 24x (2.6s vs 1:02m).

  var s = 'f';
  for (var i = 0; i < 26; ++i) s += s;  // 64 MB
  Buffer(s, 'hex');
2013-02-02 01:01:42 +01:00
isaacs 916aebabb8 debugger: Make the debugger timeout configurable
If the NODE_DEBUGGER_TIMEOUT environment variable is set, then use
that as the number of ms to wait for the debugger to start.

This is primarily to work around a race condition that almost never
happens in real usage with the debugger, but happens EVERY FRACKING
TIME when the debugger tests run as part of 'make test'.
2013-02-01 15:58:51 -08:00
Ben Noordhuis 3f65916fa9 buffer: optimize Buffer.prototype.toString('hex')
Move the implementation to C++ land. The old JS implementation used
string concatenation, was dog slow and consumed copious amounts of
memory for large buffers. Example:

  var buf = Buffer(0x1000000);  // 16 MB
  buf.toString('hex')           // Used 3+ GB of memory.

The new implementation operates in O(n) time and space.

Fixes #4700.
2013-02-01 23:07:17 +01:00
isaacs c7c1ed01ae gitignore: Ignore release tarballs and shasum files 2013-02-01 10:17:53 -08:00
Ben Noordhuis 6aed61f1ca dns, cares: don't filter NOTIMP, REFUSED, SERVFAIL
Report the aforementioned DNS server failure codes as-is, stop c-ares
from reporting them as ARES_ECONNREFUSED.

Reported by Steve Freegard.
2013-02-01 17:58:15 +01:00
isaacs a6c18472cd stream: Don't stop reading on zero-length decoded output
Fixes regression introduced in 7e1cf84c9e
2013-01-31 13:33:37 -08:00
isaacs 7e1cf84c9e stream: Don't signal EOF on '' or Buffer(0)
Those values, if passed to the _read() cb, will not signal an EOF.  Only
null or undefined will mark the end of data, and trigger the end event.

However, great care must be taken if you are returning an empty string
or buffer!  There must be some other thing somewhere that will trigger
a read() call, because there will never be a readable event fired later.

This is in preparation for CryptoStreams being ported to streams2, where
it is safe to simply stop reading, because the crypto cycle process will
cause it to read(0) again at some future date.
2013-01-31 11:59:36 -08:00
Bert Belder 1a87776be9 deps: upgrade libuv to 034ea31 2013-01-30 20:30:10 +01:00
isaacs 016810913d node: Do not use fn.apply() in process._makeCallback 2013-01-30 09:04:30 -08:00
isaacs f64d1febc8 lint 2013-01-29 23:57:23 -08:00
Ben Noordhuis 3fe6aba558 os: rename tmpDir() to tmpdir() for consistency
Make the casing consistent with the other os.* functions but keep
os.tmpDir() around as an alias.
2013-01-30 04:24:58 +01:00
isaacs 60f18ede39 readline: treat bare \r as a line ending
Fixes #3305
2013-01-29 18:21:31 -08:00
Ben Noordhuis 9bd9c546c8 readline: make \r\n emit one 'line' event
Make lines ending \r\n emit one 'line' event, not two (where the second
one is an empty string).

This adds a new keypress name: 'return' (as in: 'carriage return').

Fixes #3305.
2013-01-29 17:15:24 +01:00
isaacs bda45a8be1 Revert "net: Avoid tickDepth warnings on small writes"
This commit breaks simple/test-stream2-stderr-sync.  Need to figure out
a better way, or just accept that `(function W(){stream.write(b,W)})()`
is going to be noisy.  People should really be using the `'drain'` event
for this use-case anyway.

This reverts commit 02f7d1bfd8.
2013-01-28 17:15:22 -08:00
isaacs 02f7d1bfd8 net: Avoid tickDepth warnings on small writes
Always defer the _write callback.  The optimization here was only
relevant in some oddball edge cases that we don't actually care about.

Our benchmarks confirm that just always deferring the Socket._write cb
is perfectly fine to do, and in some cases, even slightly more
performant.
2013-01-28 16:16:21 -08:00
Bert Belder 6311f1c30a dgram: avoid EventEmitter leak warning
When a datagram socket hasn't been bound yet, node will defer `send()`
operations until binding has completed. Before this patch a `listening`
listener would be installed every time `send` was called. This triggered
an EventEmitter leak warning when more than 10 packets were sent in a
tight loop. Therefore switch to using a single `listening` listener, and
use an array to enqueue outbound packets.
2013-01-28 22:19:02 +01:00
Bert Belder 5e7e51c2fe cluster: support datagram sockets 2013-01-28 22:12:21 +01:00
Fedor Indutny c13354e339 child_process: move binding init in constructor
Doing this in net.Socket constructor has much more overhead, and
error is actually may happen before the construction of socket object.
2013-01-28 21:24:45 +04:00
isaacs 4c78a52a3a net: Initialize _connection, _handle in Socket ctor
The better to reduce the hidden classes
2013-01-28 09:09:34 -08:00
isaacs faf78604ca http: Don't dump twice 2013-01-28 08:54:08 -08:00
isaacs e26622bd18 stream: Correct Transform class backpressure
The refactor in b43e544140 to use
stream.push() in Transform inadvertently caused it to immediately
consume all the written data, regardless of whether or not the readable
side was being consumed.

Only pull data through the _transform() process when the readable side
is being consumed.

Fix #4667
2013-01-28 08:40:45 -08:00
Fedor Indutny 0d7a0216dc net: initialize TCPWrap when receiving socket
TCPWrap::Initialize() and PipeWrap::Initialize() should be called before
any data will be read from received socket. But, because of lazy
initialization of these bindings, Initialize() method isn't called.

Init bindings manually upon socket receiving.

See #4669
2013-01-28 16:37:09 +04:00
Ben Noordhuis a39f669bc7 test: move simple/test-http-dns-fail to test/internet
The test times out when the upstream DNS resolver takes too long to
respond.

See #4672.
2013-01-28 12:41:56 +01:00
Ben Noordhuis acd0df4ad9 test: fix pummel test out-of-memory errors
Fix the following OOM error in pummel/test-net-connect-memleak
and pummel/test-tls-connect-memleak:

  FATAL ERROR: CALL_AND_RETRY_0 Allocation failed - process out of
  memory

Commit v8/v8@91afd39 increases the size of the deoptimization table
to the extent that a 64M float array pushes it over the brink. Switch
to SMIs so it stays below the limit.

pummel/test-net-connect-memleak is still failing albeit with a different
error this time. Needs further investigation.

  === release test-net-connect-memleak ===
  Path: pummel/test-net-connect-memleak
  -64 kB reclaimed
  assert.js:102
    throw new assert.AssertionError({
          ^
  AssertionError: false == true
      at done [as _onTimeout] (/home/bnoordhuis/src/nodejs/master/
  test/pummel/test-net-connect-memleak.js:48:3)
      at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
      at process._makeCallback (node.js:306:20)
2013-01-27 22:01:14 +01:00
Ben Noordhuis 2e371b8f92 buffer: fix Buffer::Copy regression from 00b4b7b
If the end argument is omitted or not a number, make it default to
the end of the buffer, not zero.

Ideally, it should not matter what it defaults to because the JS shim
in lib/buffer.js should handle that but there are still several places
in node.js core that secrete SlowBuffers, hence Buffer::Copy() gets
called without going through Buffer.prototype.copy() first.
2013-01-27 21:50:01 +01:00
Fedor Indutny 0972acb548 stream_wrap: reference handle before uv_write2
Revert commit 7f2a78bf4d and fix using
empty symbol handle.
2013-01-27 20:11:41 +04:00
Ben Noordhuis 7f2a78bf4d Revert "stream_wrap: reference handle before uv_write2"
It's segfaulting in release mode and asserting in debug mode:

  #
  # Fatal error in ../../deps/v8/src/api.h, line 297
  # CHECK(allow_empty_handle || that != __null) failed
  #

This reverts commit 99f0b022d5.
2013-01-27 15:21:03 +01:00
Rick Yakubowski 5abde8161a doc: fix typo in cluster module documentation
Fix a small typo in the cluster.settings documentation.
2013-01-27 00:25:35 +01:00
Fedor Indutny 99f0b022d5 stream_wrap: reference handle before uv_write2
Before sending handle to another process using uv_write2(), it should be
referenced to prevent it from being GCed before AfterWrite() will be
called.

see #4599
2013-01-26 22:38:00 +04:00
isaacs bdc7251b64 doc: fix line wrapping in addons.markdown 2013-01-25 14:27:46 -08:00
Rod Vagg f210710795 doc: NODE_MODULE() to pass full `module` to addons
mainly to allow native addons to export single functions on `exports`
rather than being restricted to operating on an existing `exports`
object.

added link to addons repo in docs
2013-01-25 14:26:52 -08:00
isaacs 15508589a1 addon: Pass module object to NODE_MODULE init function
mainly to allow native addons to export single functions on
rather than being restricted to operating on an existing
object.

Init functions now receive exports as the first argument, like
before, but also the module object as the second argument, if they
support it.

Related to #4634

cc: @rvagg
2013-01-25 14:25:35 -08:00
Ben Noordhuis 00b4b7bb97 buffer: remove minor Buffer::Copy deoptimizations
* Omit ToObject() call. Buffer::Data() and Buffer::Length() know how
  to deal with Values.

* Don't check if the argument is undefined because it realistically
  never is and undefined->integer coercion achieves the same thing.
2013-01-25 22:07:04 +01:00
Trevor Norris 65249ccd9b buffer: slow buffer copy compatibility fix
Fix issue where SlowBuffers couldn't be passed as target to Buffer
copy().

Also included checks to see if Argument parameters are defined before
assigning their values. This offered ~3x's performance gain.

Backport of 16bbecc from master branch. Closes #4633.
2013-01-25 10:42:38 -08:00
Trevor Norris cbe3941db9 buffer: error and misc cleanup
Changed types of errors thrown to be more indicative of what the error
represents. Also removed a few unnecessary uses of the v8 fully
quantified typename.
2013-01-25 11:59:26 +01:00
Trevor Norris 49175e6ae2 buffer: clean up copy() asserts and tests
Argument checks were simplified by setting all undefined/NaN or out of
bounds values equal to their defaults.

Also copy() tests had a flaw that each buffer had the same bit pattern at
the same offset. So even if the copy failed, the bit-by-bit comparison
would have still been true. This was fixed by filling each buffer with a
unique value before copy operations.
2013-01-25 11:59:21 +01:00
Trevor Norris 16bbeccd40 buffer: slow buffer copy compatibility fix
Fix issue where SlowBuffers couldn't be passed as target to Buffer
copy().

Also included checks to see if Argument parameters are defined before
assigning their values. This offered ~3x's performance gain.
2013-01-25 11:58:51 +01:00
isaacs 72dd3b4e25 benchmark: Port http.sh from master 2013-01-24 17:23:22 -08:00