0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-22 15:47:56 +01:00
Commit Graph

2176 Commits

Author SHA1 Message Date
isaacs
d76eacd4e6 http: Handle end only when stream is not dumped
This fixes regression introduced in some cases by 8bf0c15
2012-12-26 15:57:49 -08:00
Ryunosuke SATO
0db521d0b0 repl: remove 'repl' from automatic loading libs
In repl, calling `repl` twice shows the following message:
```
> repl
A different "repl" already exists globally
```
2012-12-26 15:25:00 -08:00
Ryunosuke SATO
31cffae2ba repl: add 'domain' to automatic loading libs
`domain` should be a member of automatic loading libs in `repl`.

Conflicts:

	lib/repl.js
2012-12-26 15:23:31 -08:00
Shigeki Ohtsu
8bf0c15a5b stream2: fix to emit end event on http.ClientResponse 2012-12-26 15:20:48 -08:00
Andreas Madsen
d68ee22dda stream: do only fake drain when unpiped stream is the source
If the destination had multiply read streams piped to it,
they would all decrease the awaitDrain state and thereby
start the flow
2012-12-26 14:56:02 -08:00
Andreas Madsen
5daa701aba stream: fix event handler leak in readstream pipe and unpipe
After a stream was unpiped there would stil be residual event handlers
2012-12-26 14:56:02 -08:00
Ryunosuke SATO
27a91387ae util: fix deprecation message in util.pump 2012-12-26 14:54:56 -08:00
Ben Taber
526d852565 net: allow socket end before connect
Fix a bug where calling .end() on a socket without calling .connect() first
throws a TypeError:

  TypeError: Cannot read property 'shutdown' of undefined
      at Socket.onSocketFinish (net.js:194:20)
      at Socket.EventEmitter.emit (events.js:91:17)
      at Socket.Writable.end (_stream_writable.js:281:10)
      at Socket.end (net.js:352:31)

Fixes #4463.
2012-12-25 22:18:56 +01:00
Nathan Rajlich
837df70b75 repl: don't touch require.cache
Fixes #3226.

Consider a production server that uses a REPL to debug. Creating the instance
would wipe out the global cache of modules, and subsequent "require" calls in
the server would be reloaded from disk. The REPL should observe only, without
altering, its environment.
2012-12-21 11:42:40 -08:00
isaacs
244924823e stdio: Do not read from stdout/err
This fixes windows stdio pipes in streams2 land.
2012-12-21 11:05:46 -08:00
isaacs
fb915ed957 lint 2012-12-21 16:51:43 +00:00
isaacs
c048c814c7 http: Trivial fix for comments and 'this.read' 2012-12-21 16:48:32 +00:00
isaacs
f9caf7020c streams: Speed up by doing less work in the state ctors 2012-12-21 00:07:34 +00:00
isaacs
8624adf5d8 http: use IncomingMessage._dump() instead of resume() 2012-12-21 00:07:34 +00:00
Ben Noordhuis
79ae8b7ae2 Merge remote-tracking branch 'origin/v0.8' 2012-12-20 12:39:04 +01:00
Ben Noordhuis
5a19c07c08 http: pack response body buffer in first tcp packet
Apply the same optimization to res.end(buf) that is applied to res.end(str).

Speeds up `node benchmark/http_simple_auto -k -c 1 -n 25000 buffer/1`
(non-chunked response body) by about 750x. That's not a typo.

Chunked responses:

  $ cat tmp/http-chunked-client.js
  // Run `node benchmark/http_simple` in another terminal.
  var http = require('http'), url = require('url');
  var options = url.parse('http://127.0.0.1:8000/buffer/1/1');
  options.agent = new http.Agent({ maxSockets: 1 });
  for (var i = 0; i < 25000; ++i) http.get(options);

Before:

  $ time out/Release/node tmp/http-chunked-client.js
  real    16m40.411s
  user    0m9.184s
  sys     0m0.604s

After:

  $ time out/Release/node tmp/http-chunked-client.js
  real    0m5.386s
  user    0m2.768s
  sys     0m0.728s

That's still a 185x speed-up.

Fixes #4415.
2012-12-20 12:02:06 +01:00
Farid Neshat
dcaebec208 fs: add autoClose=true option to fs.createReadStream 2012-12-20 11:25:39 +01:00
isaacs
9f4c0988c3 streams2: Process write buffer in a loop, not recursively
This fixes pummel/test-net-write-callbacks
2012-12-19 10:55:23 -08:00
isaacs
cab22644a5 net: Properly read buffer in Socket.bytesWritten 2012-12-19 10:55:23 -08:00
isaacs
f63af64eb8 test-pummel: Add call validation in net-write-callbacks 2012-12-19 10:55:23 -08:00
isaacs
82c7c84e25 net: Handle sync writable streams synchronously
This fixes the case where stderr doesn't flush before the process exits.
2012-12-17 15:08:57 -08:00
isaacs
6c5356bfe2 Revert "buffer: allocate memory with mmap()"
Also Revert "buffer: use MAP_ANON, fix OS X build"

This reverts commit ddb15603e7.
This reverts commit 2433ec8276.
2012-12-17 10:47:17 -08:00
Brian White
827b2a9b0b http: bubble up parser errors to ClientRequest
Make parser errors bubble up to the ClientRequest instead of the underlying
net.Socket object.

This is a back-port of commit c78678b from the master branch.

Fixes #3776.
2012-12-16 17:25:03 +01:00
Ben Noordhuis
2433ec8276 buffer: allocate memory with mmap()
Work around an issue with the glibc malloc() implementation where memory blocks
are never returned to the operating system when they are allocated with brk()
and have overlapping lifecycles.

Fixes #4283.
2012-12-16 10:19:09 +01:00
isaacs
3751c0fe40 streams2: Still emit error if there was a write() cb 2012-12-14 17:46:23 -08:00
isaacs
1d369317ea http: Refactor for streams2
Because of some of the peculiarities of http, this has a bit of special
magic to handle cases where the IncomingMessage would wait forever in a
paused state.

In the server, if you do not begin consuming the request body by the
time the response emits 'finish', then it will be flushed out.

In the client, if you do not add a 'response' handler onto the request,
then the response stream will be flushed out.
2012-12-14 17:46:23 -08:00
isaacs
81e356279d child_process: Remove stream.pause/resume calls
Unnecessary in streams2
2012-12-14 10:52:30 -08:00
isaacs
bb56dcc450 tty/stdin: Refactor for streams2 2012-12-14 10:52:30 -08:00
isaacs
8a3befa0c6 net: Refactor to use streams2
This is a combination of 6 commits.

* XXX net fixup lcase stream

* net: Refactor to use streams2

    Use 'socket.resume()' in many tests to trigger old-mode behavior.

* net: Call destroy() if shutdown() is not provided

    This is important for TTY wrap streams

* net: Call .end() in socket.destroySoon if necessary

    This makes the http 1.0 keepAlive test pass, also.

* net wtf-ish stuff kinda busted

* net fixup
2012-12-14 10:52:30 -08:00
isaacs
854171dc6f streams2: Remove extraneous bufferSize setting 2012-12-14 10:52:29 -08:00
isaacs
04541cf7bc streams2: Emit pause/resume events 2012-12-14 10:52:29 -08:00
isaacs
8fe7b0c910 streams2: Support a Readable hwm of 0
Necessary for proper stdin functioning
2012-12-14 10:52:29 -08:00
isaacs
5760244cc6 streams2: Writable only emit 'finish' once 2012-12-14 10:52:28 -08:00
isaacs
8f428f3b0d streams2: Call read(0) on resume()
Otherwise (especially with stdin) you sometimes end up in cases
where the high water mark is zero, and the current buffer is at 0,
and it doesn't need a readable event, so it never calls _read().
2012-12-14 10:52:28 -08:00
isaacs
fc7d8d59f7 lint 2012-12-14 10:52:28 -08:00
isaacs
dbcacc5afe streams2: NextTick the emit('readable') in resume()
Otherwise resume() will cause data to be emitted before it can be handled.
2012-12-14 10:52:28 -08:00
isaacs
99021b7a4f streams2: pause() should be immediate 2012-12-14 10:52:28 -08:00
isaacs
42981e2aad streams2: Switch to old-mode immediately, not nextTick
This fixes the CONNECT/Upgrade HTTP functionality, which was not getting
sliced properly, because readable wasn't emitted on this tick.

Conflicts:

	test/simple/test-http-connect.js
2012-12-14 10:52:28 -08:00
isaacs
83704f1279 streams2: Set readable=false on end 2012-12-14 10:52:27 -08:00
isaacs
dd3ebb8cf6 crypto: Streaming interface for Sign and Verify 2012-12-14 10:52:27 -08:00
isaacs
e336134658 crypto: Streaming interface for cipher/decipher/iv 2012-12-14 10:52:27 -08:00
isaacs
175f78c6ba crypto: Streaming api for Hmac 2012-12-14 10:52:27 -08:00
isaacs
90de2ddb77 crypto: Streaming interface for Hash 2012-12-14 10:52:26 -08:00
isaacs
0e01d6398f zlib: streams2 2012-12-14 10:52:26 -08:00
isaacs
44b308b1f7 fs: streams2 2012-12-14 10:52:26 -08:00
isaacs
d58f2654bc streams2: Unpipe on dest.emit('close') 2012-12-13 17:00:34 -08:00
isaacs
49ea653363 streams2: Remove pipe if the dest emits error 2012-12-13 17:00:34 -08:00
isaacs
ac5a185edf streams2: Handle pipeChunkSize properly 2012-12-13 17:00:33 -08:00
isaacs
53fa66d9f7 streams2: Set 'readable' flag on Readable streams 2012-12-13 17:00:33 -08:00
isaacs
4b4ff2dff1 streams2: Refactor out .once() usage from Readable.pipe() 2012-12-13 17:00:33 -08:00