0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
Commit Graph

2420 Commits

Author SHA1 Message Date
isaacs
9208c89058 stream: Raise readable high water mark in powers of 2
This prevents excessively raising the buffer level in tiny increments in
pathological cases.
2013-03-06 11:44:30 -08:00
isaacs
a978bedee7 stream: Allow strings in Readable.push/unshift
Fix #4909
2013-03-06 11:44:30 -08:00
isaacs
b0f6789a78 stream: Remove bufferSize option
Now that highWaterMark increases when there are large reads, this
greatly reduces the number of calls necessary to _read(size), assuming
that _read actually respects the size argument.
2013-03-06 11:44:30 -08:00
isaacs
d5a0940fff stream: Remove pipeOpts.chunkSize
It's not actually necessary for backwards compatibility, isn't
used anywhere, and isn't even tested.  Better to just remove it.
2013-03-06 11:44:30 -08:00
isaacs
8c44869f1d stream: Increase highWaterMark on large reads
If the consumer of a Readable is asking for N bytes, and N > hwm,
then clearly we have set the hwm to low, and ought to increase it.

Fix #4931
2013-03-06 11:44:30 -08:00
isaacs
e0cec37d50 stream: Remove unnecessary nextTick usage in Writable
Fix #4928
2013-03-06 11:44:29 -08:00
isaacs
5038f40185 node: Add --throw-deprecation
Extremely handy when tracking down a flood of recursive nextTick warnings.
2013-03-06 11:44:29 -08:00
Eugene Girshov
25ba971f41 http: fix multiple timeout events
Fixed up slightly by @isaacs so as not to miss 'timeout' events in some
cases.
2013-03-06 10:45:37 -08:00
Ben Noordhuis
fb3ec32b0e net: use close callback, not process.nextTick
Don't emit the 'close' event with process.nextTick.

Closing a handle is an operation that usually *but not always* completes
on the next tick of the event loop, hence using process.nextTick is not
reliable.

Use a proper handle close callback and emit the 'close' event from
inside the callback.

Update tests that depend on the intricacies of the old model.

Fixes #3459.
2013-03-06 16:15:18 +01:00
Pavel Lang
2ad98725d6 DNS: Support NAPTR queries
They were previously removed in a90bc78534.
2013-03-06 14:31:22 +04:00
Scott Blomquist
323120b5c9 child_process: handle ENOENT correctly on Windows 2013-03-05 23:47:35 -08:00
isaacs
312289b791 stream: Use class for write buffer entries 2013-03-05 14:27:16 -08:00
isaacs
426b4c6258 stream: _write takes an encoding argument
This vastly reduces the overhead of decodeStrings:false streams,
such as net and http.
2013-03-05 14:27:15 -08:00
isaacs
cd68d86c32 stream: Remove output function from _transform
Just use stream.push(outputChunk) instead.
2013-03-05 14:27:15 -08:00
isaacs
049903e333 stream: Split Writable logic into small functions
1. Get rid of unnecessary 'finishing' flag
2. Dont check both ending and ended. Extraneous.

Also: Remove extraneous 'finishing' flag, and don't check both 'ending'
and 'ended', since checking just 'ending' is sufficient.
2013-03-05 14:26:34 -08:00
Ben Noordhuis
862f7b850d Merge remote-tracking branch 'origin/v0.8' 2013-03-05 15:43:03 +01:00
Ben Noordhuis
532d9929c7 cluster: propagate bind errors
This commit fixes a bug where the cluster module fails to propagate
EADDRINUSE errors.

When a worker starts a (net, http) server, it requests the listen socket
from its master who then creates and binds the socket.

Now, OS X and Windows don't always signal EADDRINUSE from bind() but
instead defer the error until a later syscall. libuv mimics this
behaviour to provide consistent behaviour across platforms but that
means the worker could end up with a socket that is not actually bound
to the requested addresss.

That's why the worker now checks if the socket is bound, raising
EADDRINUSE if that's not the case.

Fixes #2721.
2013-03-05 15:23:55 +01:00
Felix Böhm
3e64b5677f events: loop backwards in removeListener
`removeAllListeners` is removing events from end to start. Therefore
it spends O(n^2) time, since `removeListener` is searching from start to
end.
2013-03-05 12:47:57 +04:00
Trevor Norris
d09ab61dcd events: code consistency
v8 likes when smaller functions have a single return point, and cleaned
up the single non-strict check.
2013-03-04 11:59:55 -08:00
Trevor Norris
04688614f7 events: remove type check for event type
Strict checking for typeof types broke backwards compatibility for other
libraries. This reverts those checks.

The subclass test has been changed to ensure all operations can be
performed on the inherited EE before instantiation. Including the
ability to set event names with numbers.
2013-03-04 11:57:35 -08:00
isaacs
119cbf4854 stream: Don't require read(0) to emit 'readable' event
When a readable listener is added, call read(0) so that data will flow in, up to
the high water mark.

Otherwise, it's somewhat confusing that you have to listen for readable,
and ALSO call read() (when it will certainly return null) just to get some
data out of the stream.

See: #4720
2013-03-04 07:38:32 -08:00
Xidorn Quan
009ba02e18 dns: fix ReferenceError in resolve() error path
A typo in the variable name makes it throw a ReferenceError instead of
the expected "Unknown type" error when dns.resolve() is passed a bad
record type argument.

Fixes the following exception:

  ReferenceError: type is not defined
    at Object.exports.resolve (dns.js:189:40)
    at /Users/bnoordhuis/src/master/test/simple/test-c-ares.js:48:9
    <snip>
2013-03-04 16:20:40 +01:00
isaacs
e428bb7eae cluster: Rename destroy() to kill(signal=SIGTERM)
Fix #4133, bringing the cluster worker API more in line with the
child process API.
2013-03-03 17:26:38 -08:00
isaacs
384f1be739 stream: Writable.end(chunk) after end is an error
Calling end(data) calls write(data).  Doing this after end should
raise a 'write after end' error.

However, because end() calls were previously ignored on already
ended streams, this error was confusingly suppressed, even though the
data never is written, and cannot get to the other side.

This is a re-hash of 5222d19a11, but
without assuming that the data passed to end() is valid, and thus
breaking a bunch of tests.
2013-03-03 17:26:38 -08:00
Dave Olszewski
22aa767421 make repl compatible with domains
The try/catch in repl.js keeps any active domain from catching the
error.  Since the domain may not even be enterd until the code is run,
it's not possible to avoid the try/catch, so emit on the domain when an
error is thrown.
2013-03-03 15:28:45 -08:00
Ben Noordhuis
80ea63b958 Revert "stream: Writable.end(chunk) after end is an error"
It's breaking ~22 tests, Needs further investigation.

This reverts commit 5222d19a11.
2013-03-03 02:21:28 +01:00
isaacs
5222d19a11 stream: Writable.end(chunk) after end is an error
Calling end(data) calls write(data).  Doing this after end should
raise a 'write after end' error.

However, because end() calls were previously ignored on already
ended streams, this error was confusingly suppressed, even though the
data never is written, and cannot get to the other side.
2013-03-02 16:09:16 -08:00
isaacs
63edde0e01 events: Handle emit('error') before ctor
The previous commit did not handle the case when the event type
is 'error', since that is checked before reading the handler.
2013-03-02 15:11:23 -08:00
isaacs
d345c1173a events: Handle emit before constructor call 2013-03-02 15:01:20 -08:00
Ben Noordhuis
2d51036fb9 Merge remote-tracking branch 'origin/v0.8'
Conflicts:
	doc/api/http.markdown
	test/simple/test-crypto.js
2013-03-02 23:13:35 +01:00
isaacs
4ac73d2c99 net: s/closed/ended/ in write-after-fin message 2013-03-02 11:50:33 -08:00
isaacs
2106ef000c net: Provide better error when writing after FIN
The stock writable stream "write after end" message is overly vague, if
you have clearly not called end() yourself yet.

When we receive a FIN from the other side, and call destroySoon() as a
result, then generate an EPIPE error (which is what would happen if you
did actually write to the socket), with a message explaining what
actually happened.
2013-03-02 11:26:39 -08:00
Trevor Norris
d1b4dcd6ac events: add type checks to once
Also cleanup unnecessary use of "self" since it will always be called
using .apply() from emit.
2013-03-01 17:36:48 -08:00
Trevor Norris
e1ac2ef7cf events: emit cleanup
Cleanup check logic. Place vars at top. Remove PROCESS.
2013-03-01 17:36:48 -08:00
Trevor Norris
1ccc6fbe05 events: additional type check for addListener
Check both passed args to addListener.

Place var at beginning.
2013-03-01 17:36:48 -08:00
Trevor Norris
4f7f8bbdf8 events: _events to object and undefined not null
By making sure the _events is always an object there is one less check
that needs to be performed by emit.

Use undefined instead of null. typeof checks are a lot faster than
isArray.

There are a few places where the this._events check cannot be removed
because it is possible for the user to call those methods after using
utils.extend to create their own EventEmitter, but before it has
actually been instantiated.
2013-03-01 17:36:47 -08:00
Trevor Norris
b3ea8443bd events: removeListener add checks and cleanup
Remove unecessary splice for single listener events. Add type check for
"type" argument.
2013-03-01 17:36:47 -08:00
Trevor Norris
aba03ebb5a events: type check listeners
Make sure the argument passed is a string. Also use typeof === function
check instead of isArray().
2013-03-01 17:36:47 -08:00
Trevor Norris
8ab346c98f events: simplify removeAllListeners logic
Unnecessary checks were being performed on if the event existed before
being removed.

_events starts out as null, so reset to null when emptied.

Checking typeof is a lot cheaper than isArray().
2013-03-01 17:36:47 -08:00
Trevor Norris
dd171d24df events: type check setMaxListeners, cleanup throws
setMaxListeners will now make sure a positive number is passed. Also
throwing more definitive Error types.
2013-03-01 17:36:47 -08:00
Trevor Norris
8ca43a7f40 events: ensure usingDomain is always boolean
Small addition to ensure that exports.usingDomains is always a bool.
2013-03-01 17:36:47 -08:00
Trevor Norris
75305f3bab events: add check for listeners length
Ability to return just the length of listeners for a given type, using
EventEmitter.listenerCount(emitter, event). This will be a lot cheaper
than creating a copy of the listeners array just to check its length.
2013-03-01 17:36:47 -08:00
isaacs
0928a526dd fs: Support mode/flag options to read/append/writeFile
Fix #4841
2013-03-01 09:48:57 -08:00
Ben Noordhuis
f26362e938 http: use socket.once, not socket.on
Register the 'close' event listener with .once(), not .on().

It doesn't matter in the grand scheme of things because the listener
doesn't keep references to any heavy-weight objects but using .once()
for a oneshot listener is something of a best practice.
2013-03-01 13:11:40 +01:00
isaacs
88644eaa2d stream: There is no _read cb, there is only push
This makes it so that `stream.push(chunk)` is the only way to signal the
end of reading, removing the confusing disparity between the
callback-style _read method, and the fact that most real-world streams
do not have a 1:1 corollation between the "please give me data" event,
and the actual arrival of a chunk of data.

It is still possible, of course, to implement a `CallbackReadable` on
top of this.  Simply provide a method like this as the callback:

    function readCallback(er, chunk) {
      if (er)
        stream.emit('error', er);
      else
        stream.push(chunk);
    }

However, *only* fs streams actually would behave in this way, so it
makes not a lot of sense to make TCP, TLS, HTTP, and all the rest have
to bend into this uncomfortable paradigm.
2013-02-28 17:38:17 -08:00
isaacs
4b67f0be6d stream: Add stream.unshift(chunk) 2013-02-28 17:38:17 -08:00
isaacs
7764b84297 stream: Break up the onread function
A primary motivation of this is to make the onread function more
inline-friendly, but also to make it more easy to explore not having
onread at all, in favor of always using push() to signal the end of
reading.
2013-02-28 17:38:17 -08:00
Ben Noordhuis
c11612026f net: omit superfluous 'connect' event
Don't emit a 'connect' event on sockets that are handed off to
net.Server 'connection' event listeners.

1. It's superfluous because the connection has already been established
   at that point.

2. The implementation is arguably wrong because the event is emitted on
   the same tick of the event loop while the rule of thumb is to always
   emit it on the next one.

This has been tried before in commit f0a440d but was reverted again in
ede1acc because the change was incomplete (at least one test hadn't
been updated).

Fixes #1047 (again).
2013-03-01 02:09:36 +01:00
Ben Noordhuis
12d0f0bd3a lib, src: remove errno global
Remove the errno global. It's a property on the process object now.

Fixes #3095.
2013-02-28 23:11:47 +01:00
Ben Noordhuis
cb87920ba9 Merge remote-tracking branch 'origin/v0.8'
Conflicts:
	AUTHORS
	ChangeLog
	deps/uv/src/unix/pipe.c
	lib/http.js
	src/node_version.h
2013-02-28 16:58:24 +01:00
Trevor Norris
0c1e7b53d0 process: separate nextTick domain logic
It's cleaner to only load domain ticker logic when the domains are being
used. This makes execution slightly quicker in both cases, and simpler
from the spinner since there is no need to check if the latest callback
requires use of domains.
2013-02-27 16:37:10 -08:00
isaacs
875e4a0c59 core: Remove the nextTick for running the main file
Not necessary, since we can handle the error properly on the first tick
now, even if there are event listeners, etc.

Additionally, this removes the unnecessary "_needTickCallback" from
startup, since Module.loadMain() will kick off a nextTick callback right
after it runs the main module.

Fix #4856
2013-02-27 16:29:36 -08:00
isaacs
86433979c6 stream: Writables are not pipe()able
This handles the fact that stream.Writable inherits from the Stream class,
meaning that it has the legacy pipe() method.  Override that with a pipe()
method that emits an error.

Ensure that Duplex streams ARE still pipe()able, however.

Since the 'readable' flag on streams is sometimes temporary, it's probably
better not to put too much weight on that.  But if something is an instanceof
Writable, rather than of Readable or Duplex, then it's safe to say that
reading from it is the wrong thing to do.

Fix #3647
2013-02-26 18:54:05 -08:00
Ben Noordhuis
d4a297ccb0 http: fix case in 505 response status line
Fixes #4850.
2013-02-26 15:18:40 +01:00
isaacs
b0e7dbf2c0 http: Do not free the wrong parser on socket close
This appears to fix #4673.  That bug is very hard to reproduce, so it's
hard to tell for certain, but this approach is more correct anyway.

Hat-tip: @dougwilson
2013-02-25 09:06:46 -08:00
isaacs
34046084c0 stream: Do not switch to objectMode implicitly
Only handle objects if explicitly told to do so in the options
object.  Non-buffer/string chunks are an error if not already in
objectMode.

Close #4662
2013-02-25 07:38:10 -08:00
isaacs
e03bc472f0 stream: Start out in sync=true state
The Readable and Writable classes will nextTick certain things
if in sync mode.  The sync flag gets unset after a call to _read
or _write.  However, most of these behaviors should also be
deferred until nextTick if no reads have been made (for example,
the automatic '_read up to hwm' behavior on Readable.push(chunk))

Set the sync flag to true in the constructor, so that it will not
trigger an immediate 'readable' event, call to _read, before the
user has had a chance to set a _read method implementation.
2013-02-25 07:38:10 -08:00
Ben Noordhuis
4231dab39f crypto: fix base64 padding regression
Commit 9901b69c introduces a small regression where the trailing base64
padding is no longer written out when Cipher#final is called. Rectify
that.

Fixes #4837.
2013-02-25 15:21:52 +01:00
isaacs
74c08403d8 lint 2013-02-22 16:30:27 -08:00
isaacs
27d1babaae streams: Pre-emptively buffer readables up to the highWaterMark
Also, this adds a test that guarantees that the ordering of several
push() calls in a row is always preserved in synchronous readable streams
2013-02-22 11:24:05 -08:00
isaacs
f9a0140ef1 http: Handle hangup writes more gently 2013-02-22 10:35:07 -08:00
isaacs
a63c28e6eb stream: Return false from push() more properly
There are cases where a push() call would return true, even though
the thing being pushed was in fact way way larger than the high
water mark, simply because the 'needReadable' was already set, and
would not get unset until nextTick.

In some cases, this could lead to an infinite loop of pushing data
into the buffer, never getting to the 'readable' event which would
unset the needReadable flag.

Fix by splitting up the emitReadable function, so that it always
sets the flag on this tick, even if it defers until nextTick to
actually emit the event.

Also, if we're not ending or already in the process of reading, it
now calls read(0) if we're below the high water mark.  Thus, the
highWaterMark value is the intended amount to buffer up to, and it
is smarter about hitting the target.
2013-02-21 15:23:18 -08:00
isaacs
3b2e9d2648 stream: remove lowWaterMark feature
It seems like a good idea on the face of it, but lowWaterMarks are
actually not useful, and in practice should always be set to zero.

It would be worthwhile for writers if we actually did some kind of
writev() type of thing, but actually this just delays calling write()
and the overhead of doing a bunch of Buffer copies is not worth the
slight benefit of calling write() fewer times.
2013-02-21 15:23:18 -08:00
isaacs
089ec58613 path: Throw TypeError on non-string args to path.resolve 2013-02-21 15:18:44 -08:00
Arianit Uka
055110dab0 path: join throws TypeError on non-string args
lib/path.js:
  - throws a TypeError on the filter if the argument is not a string.

test/simple/test-path.js:
  - removed the test to check if non-string types are filtered.
  - added a test to check if path.join throws TypeError on arguments that
    are not strings.
2013-02-21 11:50:47 -08:00
Fedor Indutny
ebc95f0716 tls: _handle.readStart/readStop for CryptoStream
lib/http.js is using stream._handle.readStart/readStop to control
data-flow coming out from underlying stream. If this methods are not
present - data might be buffered regardless of whether it'll be read.

see #4657
2013-02-21 23:29:18 +04:00
isaacs
bbcb8b3ae0 path: Do not coerce paths to strings on Windows
Fix #4795
2013-02-20 14:04:30 -08:00
Trevor Norris
d69a26b965 buffer: check logic simplification
Checks have been simplified and optimized for most-used cases.

Calling Buffer with another Buffer as the subject will now use the
SlowBuffer Copy method instead of the for loop.

No need to call for value coercion, just place the ternary inline.
2013-02-20 20:34:34 +01:00
isaacs
60238cce12 tls: Write pending data on socket drain
Fixes #4800
2013-02-19 11:41:39 -08:00
isaacs
09b1212254 http: Add fixme comment about ECONNRESET handling 2013-02-18 10:38:37 -08:00
isaacs
d75e39794b Merge remote-tracking branch 'ry/v0.8' into master
Conflicts:
	AUTHORS
	ChangeLog
	lib/http.js
	src/node_version.h
	test/simple/test-http-header-response-splitting.js
2013-02-18 10:21:08 -08:00
Gil Pedersen
0a9930a230 stream: Pipe data in chunks matching read data
This creates better flow for large values of lowWaterMark.
2013-02-15 18:51:22 -08:00
isaacs
8476aefc8e fs: Change default WriteStream config, increase perf
This increases fs.WriteStream throughput dramatically by removing the
"higher default water marks" for fs.WriteStream.

Also includes a benchmark.  Current performance is significantly higher
than v0.8 for strings at all tested levels except size=1.  Buffer
performance is still lackluster.

Further improvement in the stream.Writable base class is required, but
this is a start.
2013-02-15 18:48:43 -08:00
Shigeki Ohtsu
cd372510bb timer: move setImmediate from timer to uv_check
uv_check is the robust place to invoke setImmediate callbacks after
process.nextTick and before timers(setTimeout/setInterval)
2013-02-15 16:11:05 -08:00
isaacs
987338fe31 http: Do not let Agent hand out destroyed sockets
Fix #4373
2013-02-14 16:03:40 -08:00
isaacs
c9dcf5718c http: Raise hangup error on destroyed socket write
Prior to v0.10, Node ignored ECONNRESET errors in many situations.
There *are* valid cases in which ECONNRESET should be ignored as a
normal part of the TCP dance, but in many others, it's a very relevant
signal that must be heeded with care.

Exacerbating this problem, if the OutgoingMessage does not have a
req.connection._handle, it assumes that it is in the process of
connecting, and thus buffers writes up in an array.

The problem happens when you reuse a socket between two requests, and it
is destroyed abruptly in between them.  The writes will be buffered,
because the socket has no handle, but it's not ever going to GET a
handle, because it's not connecting, it's destroyed.

The proper fix is to treat ECONNRESET correctly.  However, this is a
behavior/semantics change, and cannot land in a stable branch.

Fix #4775
2013-02-14 16:03:40 -08:00
Ben Noordhuis
3f7e88a852 buffer: accept negative indices in Buffer#slice()
A negative start or end parameter now indexes from the end of the
buffer. More in line with String#slice() and ArrayBuffer#slice().
2013-02-12 17:09:19 -08:00
isaacs
2789323902 net: Respect the 'readable' flag on sockets
Previously, we were only destroying sockets on end if their readable
side had already been ended.  This causes a problem for non-readable
streams, since we don't expect to ever see an 'end' event from those.

Treat the lack of a 'readable' flag the same as if it was an ended
readable stream.

Fix #4751
2013-02-12 16:49:26 -08:00
isaacs
02374d0c17 tls: Cycle data when underlying socket drains 2013-02-11 16:43:10 -08:00
isaacs
1762dd7ed9 stream: read(0) should not always trigger _read(n,cb)
This is causing the CryptoStreams to get into an awful state when
there is a tight loop calling connection.write(chunk) waiting for
a false return.

Because CryptoStreams use read(0) to cycle data, this was causing
the encrypted side to pull way too much data in from the cleartext
side, since the read(0) would make it always call _read.

The unfortunate side effect, fixed in the next patch, is that
CryptoStreams don't automatically cycle when the Socket drains.
2013-02-11 16:43:09 -08:00
isaacs
6bd450155c stream: Empty strings/buffers do not signal EOF any longer 2013-02-11 16:43:09 -08:00
Ben Noordhuis
14a4245051 net: don't suppress ECONNRESET
Let ECONNRESET network errors bubble up so clients can detect them.

Commit c4454d2e suppressed and turned them into regular end-of-stream
events to fix the then-failing simple/test-regress-GH-1531 test. See
also issue #1571 for (scant) details.

It turns out that special handling is no longer necessary. Remove the
special casing and let the error bubble up naturally.

pummel/test-https-ci-reneg-attack and pummel/test-tls-ci-reneg-attack
are updated because they expected an EPIPE error code that is now an
ECONNRESET. Suppression of the ECONNRESET prevented the test from
detecting that the connection has been severed whereupon the next
write would fail with an EPIPE.

Fixes #1776.
2013-02-11 12:31:21 -08:00
Ben Noordhuis
c7b84a1d01 fs: fix immediate WriteStream#end()
Fix an exception that was raised when the WriteStream was closed
immediately after creating it:

  TypeError: Cannot read property 'fd' of undefined
      at WriteStream.close (fs.js:1537:18)
      <snip>

Avoid the TypeError and make sure the file descriptor is closed.

Fixes #4745.
2013-02-11 21:15:13 +01:00
isaacs
33b2aebb6d stream: Writable should ignore encoding for buffers
Fix #4727
Fix einaros/ws#159
2013-02-07 08:50:18 -08:00
Bert Belder
255bc945c2 http: protect against response splitting attacks
This patch is a back-port of 3c293ba.
Closes #4696
2013-02-07 14:39:47 +01:00
isaacs
5cc3569f6d Merge remote-tracking branch 'ry/v0.8' into master
Conflicts:
	AUTHORS
	ChangeLog
	deps/npm/html/api/bin.html
	deps/npm/html/api/bugs.html
	deps/npm/html/api/commands.html
	deps/npm/html/api/config.html
	deps/npm/html/api/deprecate.html
	deps/npm/html/api/docs.html
	deps/npm/html/api/edit.html
	deps/npm/html/api/explore.html
	deps/npm/html/api/help-search.html
	deps/npm/html/api/init.html
	deps/npm/html/api/install.html
	deps/npm/html/api/link.html
	deps/npm/html/api/load.html
	deps/npm/html/api/ls.html
	deps/npm/html/api/npm.html
	deps/npm/html/api/outdated.html
	deps/npm/html/api/owner.html
	deps/npm/html/api/pack.html
	deps/npm/html/api/prefix.html
	deps/npm/html/api/prune.html
	deps/npm/html/api/publish.html
	deps/npm/html/api/rebuild.html
	deps/npm/html/api/restart.html
	deps/npm/html/api/root.html
	deps/npm/html/api/run-script.html
	deps/npm/html/api/search.html
	deps/npm/html/api/shrinkwrap.html
	deps/npm/html/api/start.html
	deps/npm/html/api/stop.html
	deps/npm/html/api/submodule.html
	deps/npm/html/api/tag.html
	deps/npm/html/api/test.html
	deps/npm/html/api/uninstall.html
	deps/npm/html/api/unpublish.html
	deps/npm/html/api/update.html
	deps/npm/html/api/version.html
	deps/npm/html/api/view.html
	deps/npm/html/api/whoami.html
	deps/npm/html/doc/README.html
	deps/npm/html/doc/adduser.html
	deps/npm/html/doc/bin.html
	deps/npm/html/doc/bugs.html
	deps/npm/html/doc/build.html
	deps/npm/html/doc/bundle.html
	deps/npm/html/doc/cache.html
	deps/npm/html/doc/changelog.html
	deps/npm/html/doc/coding-style.html
	deps/npm/html/doc/completion.html
	deps/npm/html/doc/config.html
	deps/npm/html/doc/dedupe.html
	deps/npm/html/doc/deprecate.html
	deps/npm/html/doc/developers.html
	deps/npm/html/doc/disputes.html
	deps/npm/html/doc/docs.html
	deps/npm/html/doc/edit.html
	deps/npm/html/doc/explore.html
	deps/npm/html/doc/faq.html
	deps/npm/html/doc/folders.html
	deps/npm/html/doc/global.html
	deps/npm/html/doc/help-search.html
	deps/npm/html/doc/help.html
	deps/npm/html/doc/index.html
	deps/npm/html/doc/init.html
	deps/npm/html/doc/install.html
	deps/npm/html/doc/json.html
	deps/npm/html/doc/link.html
	deps/npm/html/doc/ls.html
	deps/npm/html/doc/npm.html
	deps/npm/html/doc/outdated.html
	deps/npm/html/doc/owner.html
	deps/npm/html/doc/pack.html
	deps/npm/html/doc/prefix.html
	deps/npm/html/doc/prune.html
	deps/npm/html/doc/publish.html
	deps/npm/html/doc/rebuild.html
	deps/npm/html/doc/registry.html
	deps/npm/html/doc/removing-npm.html
	deps/npm/html/doc/restart.html
	deps/npm/html/doc/rm.html
	deps/npm/html/doc/root.html
	deps/npm/html/doc/run-script.html
	deps/npm/html/doc/scripts.html
	deps/npm/html/doc/search.html
	deps/npm/html/doc/semver.html
	deps/npm/html/doc/shrinkwrap.html
	deps/npm/html/doc/star.html
	deps/npm/html/doc/start.html
	deps/npm/html/doc/stop.html
	deps/npm/html/doc/submodule.html
	deps/npm/html/doc/tag.html
	deps/npm/html/doc/test.html
	deps/npm/html/doc/uninstall.html
	deps/npm/html/doc/unpublish.html
	deps/npm/html/doc/update.html
	deps/npm/html/doc/version.html
	deps/npm/html/doc/view.html
	deps/npm/html/doc/whoami.html
	deps/npm/man/man1/global.1
	deps/npm/man/man1/ls.1
	deps/npm/man/man1/npm.1
	deps/npm/man/man1/rm.1
	deps/npm/man/man3/npm.3
	deps/npm/node_modules/glob/glob.js
	deps/npm/node_modules/glob/package.json
	deps/npm/node_modules/node-gyp/package.json
	deps/npm/node_modules/npm-registry-client/package.json
	deps/npm/node_modules/npmconf/package.json
	deps/npm/node_modules/read-installed/package.json
	deps/npm/node_modules/rimraf/package.json
	deps/npm/node_modules/rimraf/rimraf.js
	deps/npm/package.json
	deps/uv/src/win/error.c
	doc/api/crypto.markdown
	lib/zlib.js
	src/node_version.h
	src/node_zlib.cc
	test/simple/test-buffer.js
2013-02-06 16:29:30 -08:00
Fedor Indutny
d59beb9f68 tls: port CryptoStream to streams2 2013-02-06 23:23:54 +04: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
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
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
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
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
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
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