Commit Graph

2264 Commits (1c3863abfd40b2d95b7151a75427d9fd948e8e63)

Author SHA1 Message Date
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 c53b921648 test: disable simple/test-process-getgroups on os x
The output of `id -G` is unreliable on OS X. It uses an undocumented
Libsystem function called getgrouplist_2() that includes some auxiliary
groups that the POSIX getgroups() function does not return.

Or rather, not always. It leads to fun bug chases where the test fails
in one terminal but not in another.
2013-03-01 00:48:19 +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
Scott Blomquist 1762ba37ca test: add cleanup to long path test 2013-02-28 09:21:47 -08: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 95862b2380 core: Mark exit() calls with status codes
Also, exit with 128+n for signal exit n, as is The Unix Way.
2013-02-27 14:47:01 -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
isaacs 586e160a25 test: Use common.PORT in simple/test-http-timeout 2013-02-26 17:54:18 -08:00
isaacs 1b870b6127 test: Move test-net-connect-timeout to test/internet
It is not a valid test unless you're connected to the internet, and causes
a lot of spurious failures on Linux anyway, as it's highly dependent on
timing of things that we don't have any control over.
2013-02-26 17:39:04 -08:00
isaacs 937662b03e test: Use common.PORT to determine debugger port 2013-02-26 17:33:30 -08:00
isaacs ec378aaa69 test: Fix debugger repl tests
This makes the output of simple/test-debugger-repl and
simle/test-debugger-repl-utf8 mirror an actual debugger session, so it's
a bit easier to reason about.

Also, it uses the same code for both, and fixes it so that it doesn't
leave zombie processes lying around when it crashes.

Run 1000 times without any failures or zombies.
2013-02-26 16:49:17 -08:00
isaacs 57f9f048d3 test: catch break in simple/test-debugger-client
Handle break events that come out sometimes, by telling it to continue.

Also, send the child a SIGTERM when it times out.
2013-02-26 16:48:44 -08:00
Ben Noordhuis e505f91266 test: merge environment, don't overwrite
The CI system requires that some environment variables are set so merge
our variables into the current environment instead of blindly replacing
it.

This will probably have to be repeated for other tests. C'est la vie.
2013-02-26 19:42:08 +01:00
Timothy J Fontaine 17a812618d test: optionally set common.PORT via env variable 2013-02-26 08:07:46 -08:00
Ben Noordhuis 51f6e6a9b3 src, test: downgrade to v8 3.14 api 2013-02-25 23:45:02 +01: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
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
Ben Noordhuis 8df893c62e test: re-enable simple/test-setproctitle on darwin
The functionality is available again per joyent/libuv@14eb8b0
and joyent/libuv@e89aced.

Fixes #3687.
2013-02-24 04:07:42 +01: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
Nathan Rajlich 50c88e0ff2 test: modify async native test.js to test for #4820 2013-02-21 13:14:07 -08:00
Nathan Rajlich 4b61522f16 test: add an "async-hello-world" native addon test 2013-02-21 13:14:07 -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
isaacs 7f303707d5 test: Fix regression in tls test
Undefined reference, introduced by a77c29a.
2013-02-19 11:41:06 -08:00
isaacs a77c29a0f9 test: Fix tls tests which fail sporadically
The count of ECONNRESETs is dependent on timing, and thus unreliable,
especially on Linux machines.
2013-02-19 14:22:14 +04: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
isaacs 9299168f2a test: Bump up debugger timeouts
200ms is still short enough for occasional spurious failures.
2013-02-15 18:37:53 -08:00
Trevor Norris 86c0745a5e process: streamlining tick callback logic
* Callbacks from spinner now calls its own function, separate from the
  tickCallback logic
* MakeCallback will call a domain specific function if a domain is
  detected
* _tickCallback assumes no domains, until nextTick receives a callback
  with a domain. After that _tickCallback is overridden with the domain
  specific implementation.
* _needTickCallback runs in startup() instead of nextTick (isaacs)
* Fix bug in _fatalException where exit would be called twice (isaacs)
* Process.domain has a default value of null
* Manually track nextTickQueue.length (will be useful later)
* Update tests to reflect internal api changes
2013-02-15 18:13:01 -08:00
isaacs 95ac576bf9 Revert "Move MakeCallback to JS"
This reverts commit 0109a9f90a.

Also included:  Port all the changes to process._makeCallback into the
C++ version.  Immediate nextTick, etc.

This yields a slight boost in several benchmarks.  V8 is optimizing and
deoptimizing process._makeCallback repeatedly.
2013-02-15 18:13:01 -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
Fedor Indutny c34326b286 test: fix tests after ECONNRESET patch 2013-02-12 15:00:13 +04:00
Victor Costan e235bce2ba Fix crypto.hmac behavior with empty keys.
node 0.9.6 introduced Buffer changes that cause the key argument of
Hmac::HmacInit (used in crypto.createHmac) to be NULL when the key is
empty. This argument is passed to OpenSSL's HMAC_Init, which does not
like NULL keys.

This change works around the issue by passing an empty string to
HMAC_Init when the key is empty, and adds crypto.createHmac tests for
the edge cases of empty keys and values.
2013-02-12 14:11:22 +04:00
isaacs 02374d0c17 tls: Cycle data when underlying socket drains 2013-02-11 16:43:10 -08:00
Ben Noordhuis f5f9e8da71 crypto: improve cipher/decipher error messages
Throw the OpenSSL error string instead of the rather less informative
error message "fail".
2013-02-11 23:19:48 +01:00
isaacs 862b164209 test: update http tests for ECONNRESET change 2013-02-11 12:31:21 -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
Ben Noordhuis ed3d553d82 typed arrays: make call-as-function work for ctors
Turn call-as-function calls into constructor calls. Makes the following
snippet work:

  var buf = ArrayBuffer(32);  // no 'new' but does the right thing
2013-02-11 17:38:32 +01:00
Ben Noordhuis d5a5ae3c11 test: fix common.mustCall
Don't run the 'has function been called?' checks if the test is exiting
with an error because a failed check will mask the real exception.

v0.8 doesn't have the _fatalException machinery in src/node.js and
src/node.cc so it doesn't have this issue.
2013-02-11 13:37:33 +01:00
Ben Noordhuis 5a9d30bb86 typed arrays: copy Buffer in typed array constructor
Convert the Buffer to an ArrayBuffer. The typed_array.buffer property
should be an ArrayBuffer to avoid confusion: a Buffer doesn't have a
byteLength property and more importantly, its slice() method works
subtly different.

That means that before this commit:

  var buf = new Buffer(1);
  var arr = new Int8Array(buf);
  assert.equal(arr.buffer, buf);
  assert(arr.buffer instanceof Buffer);

And now:

  var buf = new Buffer(1);
  var arr = new Int8Array(buf);
  assert.notEqual(arr.buffer, buf);
  assert(arr.buffer instanceof ArrayBuffer);
2013-02-10 21:31:41 +01:00
Ben Noordhuis fe103357ae typed arrays: make DataView throw on non-ArrayBuffer
Make the DataView constructor throw an exception when the first
argument is not an ArrayBuffer. Follows the spec and the browsers.
2013-02-10 15:22:40 +01:00
Ben Noordhuis 234551a22a buffer: fix Buffer::HasInstance() check
It was returning true for typed arrays. Check that the object was
instantiated with the Buffer constructor.
2013-02-10 15:22:40 +01:00
Ben Noordhuis 144e21ed30 Revert "typed arrays: only share ArrayBuffer backing store"
We're going to fix this differently. The real bug is that
Buffer::HasInstance() returns true for typed arrays.

This reverts commit 01ee551e70.
2013-02-10 15:22:27 +01:00
Ben Noordhuis fd9d8b5e4a Revert "typed arrays: copy non-ArrayBuffer in DataView ctor"
We're going to follow browser behavior here.

This reverts commit 7b0770bff5.
2013-02-10 15:22:27 +01:00
Ben Noordhuis c4f418d035 test: disable simple/test-dgram-send-error
It's not a good citizen, it spams random IP addresses with UDP packets.

Fixes #4730.
2013-02-08 01:33:33 +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
Ben Noordhuis 7b0770bff5 typed arrays: copy non-ArrayBuffer in DataView ctor
This is commit 01ee551, except for the DataView type this time.

Make the behavior of DataView consistent with that of typed arrays:
make a copy of the backing store.
2013-02-06 22:26:50 +01: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
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
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
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
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 5e7e51c2fe cluster: support datagram sockets 2013-01-28 22:12:21 +01: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
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
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 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
Andy Burke 595b5974d7 Add bytesWritten to tls.CryptoStream
This adds a proxy for bytesWritten to the tls.CryptoStream.  This
change makes the connection object more similar between HTTP and
HTTPS requests in an effort to avoid confusion.

See issue #4650 for more background information.
2013-01-24 16:48:49 -08:00
isaacs 6e05faa3d0 test: Add transform objectMode test 2013-01-24 10:12:19 -08:00
Fedor Indutny 82f1d340c1 tls: make slab buffer's size configurable
see #4636
2013-01-24 08:47:07 -08:00
isaacs 5d3c51d937 test: Add test for negative stream drain counter 2013-01-24 07:49:27 -08:00
isaacs 782149ddc3 streams2: Handle sync read callbacks nicely 2013-01-24 07:49:27 -08:00
Raynos 444bbd4fa7 streams: Support objects other than Buffers
We detect for non-string and non-buffer values in onread and
turn the stream into an "objectMode" stream.

If we are in "objectMode" mode then howMuchToRead will
always return 1, state.length will always have 1 appended
to it when there is a new item and fromList always takes
the first value from the list.

This means that for object streams, the n in read(n) is
ignored and read() will always return a single value

Fixed a bug with unpipe where the pipe would break because
the flowing state was not reset to false.

Fixed a bug with sync cb(null, null) in _read which would
forget to end the readable stream
2013-01-24 07:49:27 -08:00
Ben Noordhuis 4a7a98fd0a http: close connection on 204 and chunked encoding
This is similar to commit 2cbf458 but this time for 204 No Content
instead of 304 Not Modified responses.

When the user sends a 204 response with a Transfer-Encoding: chunked
header, suppress sending the zero chunk and force the connection to
close.
2013-01-24 11:23:36 +01:00
Ben Noordhuis 2cbf4586df http: close connection on 304 and chunked encoding
Force the connection to close when the response is a 304 Not Modified
and the user has set a "Transfer-Encoding: chunked" header.

RFC 2616 mandates that 304 responses MUST NOT have a body but node.js
used to send out a zero chunk anyway to accommodate clients that don't
have special handling for 304 responses.

It was pointed out that this might confuse reverse proxies to the point
of creating security liabilities, so suppress the zero chunk and force
the connection to close.
2013-01-23 01:47:24 +01:00
Ben Noordhuis d7bf7ed993 zlib: don't assert on malformed dictionary
Handle Z_DATA_ERROR errors from inflateSetDictionary() gracefully.
Fixes the following assertion:

  node: ../src/node_zlib.cc:167: static void node::ZCtx::Process
  (uv_work_t*): Assertion `ctx->err_ == 0 && "Failed to set
  dictionary"' failed.
  Aborted (core dumped)

Fixes #4632.
2013-01-22 13:34:43 +01:00
Ben Noordhuis 1c32eb4ae2 zlib: don't assert on missing dictionary
Handle Z_NEED_DICT errors graciously. Fixes the following assertion:

  node: ../src/node_zlib.cc:161: static void node::ZCtx::Process
  (uv_work_t*): Assertion`ctx->dictionary_ != __null && "Stream
  has no dictionary"' failed.
  Aborted (core dumped)

Fixes #4632.
2013-01-22 13:34:43 +01:00
Ben Noordhuis 2dd373894f typed arrays: fix DataView endianness regression
Fix an off-by-one error introduced in 9fe3734 that caused a regression
in the default endianness used for writes in DataView::setGeneric().

Fixes #4626.
2013-01-20 00:29:01 +01:00
Fedor Indutny 00abc243dd child_process: remove .track option
Since net.Server's `connection` property is deprecated now, we don't
need API to track socket's state to keep `connection`s value up-to-date.
2013-01-20 02:23:42 +04:00
isaacs 539bf1d7b7 console: Support formatting options in trace()
Fix #4589
2013-01-18 15:39:08 -08:00
Dave Olszewski 14c911de77 domain: empty stack on all exceptions
Due to the nature of asyncronous programming, it's impossible to know
what will run on the next tick.  Because of this, it's not correct to
maintain domain stack state between ticks

Since the _fatalException handler is only invoked after the stack is
unwound, once it exits the tick will end.  The only reasonable thing to
do in that case is to exit *all* domains.
2013-01-18 13:26:40 -08:00
isaacs 3d7818fc42 Merge remote-tracking branch 'ry/v0.8' into master
Conflicts:
	AUTHORS
	ChangeLog
	src/node_version.h
	test/simple/test-buffer.js
2013-01-18 12:58:16 -08:00
Dan Milon 7295bb9435 dns: make error message match errno 2013-01-18 12:13:32 +01:00
Fedor Indutny 31583be042 tls: follow RFC6125 more stricly
* Allow wildcards only in left-most part of hostname identifier.
* Do not match CN if altnames are present
2013-01-18 03:48:05 +04:00
Fedor Indutny 4488a69fac child_process: do not keep list of sent sockets
Keeping list of all sockets that were sent to child process causes memory
leak and thus unacceptable (see #4587). However `server.close()` should
still work properly.

This commit introduces two options:

* child.send(socket, { track: true }) - will send socket and track its status.
  You should use it when you want to receive `close` event on sent sockets.
* child.send(socket) - will send socket without tracking it status. This
  performs much better, because of smaller number of RTT between master and
  child.

With both of these options `server.close()` will wait for all sent
sockets to get closed.
2013-01-18 03:13:41 +04:00
Fedor Indutny 44cd121c63 Revert "child_process: do not keep list of sent sockets"
This reverts commit db5ee0b3de.
2013-01-18 03:13:10 +04:00
Fedor Indutny db5ee0b3de child_process: do not keep list of sent sockets
Keeping list of all sockets that were sent to child process causes memory
leak and thus unacceptable (see #4587). However `server.close()` should
still work properly.

This commit introduces two options:

* child.send(socket, { track: true }) - will send socket and track its status.
  You should use it when you want `server.connections` to be a reliable
  number, and receive `close` event on sent sockets.
* child.send(socket) - will send socket without tracking it status. This
  performs much better, because of smaller number of RTT between master and
  child.

With both of these options `server.close()` will wait for all sent
sockets to get closed.
2013-01-17 13:46:31 -08:00
isaacs b7d76a1a7b Revert "events: Don't crash on events named __proto__"
Unfortunately, it's just too slow to do this in events.js.  Users will
just have to live with not having events named __proto__ or toString.

This reverts commit b48e303af0.
2013-01-17 13:20:22 -08:00
isaacs 1528de2373 stdio: Set readable/writable flags properly
Set the readable/writable flags properly in net streams that have
a handle passed in (such as TTY streams).

Fix #4606
2013-01-17 10:42:44 -08:00
isaacs b48e303af0 events: Don't crash on events named __proto__
This prefixes all event names internally with 'ev'.
2013-01-17 09:21:45 -08:00
Ben Noordhuis 08ac9fe016 test: add cluster 'bind twice' test
This test starts two clustered HTTP servers on the same port.
It expects the first cluster to succeed and the second cluster
to fail with EADDRINUSE.

Reapplies commit cacd3ae, accidentally reverted in a2851b6.
2013-01-17 13:37:23 +01:00
Ben Noordhuis 498200b87c buffer: reject negative SlowBuffer offsets
Reject negative offsets in SlowBuffer::MakeFastBuffer(), it allows
the creation of buffers that point to arbitrary addresses.

Reported by Trevor Norris.
2013-01-17 01:22:11 +01:00
isaacs 47f3fc9a26 test: add module-loading test with empty string 2013-01-16 12:27:53 -08:00
Felix Böhm 7465cf911a module: assert that require() is called with a string
as requested in #4577
2013-01-16 12:25:06 -08:00
isaacs 14e8f806de stream: Properly handle large reads from push-streams
Problem 1: If stream.push() triggers a 'readable' event, and the user
calls `read(n)` with some n > the highWaterMark, then the push() will
return false (indicating that they should not push any more), but no
future 'readable' event is coming (because we're above the
highWaterMark).

Solution: return true from push() when needReadable is set.

Problem 2: A read(n) for n != 0, after the stream had encountered an
EOF, would not trigger the 'end' event if the EOF was pushed in
synchronously by the _read() function.

Solution: Check for ended in stream.read() and schedule an end event if
the length now equals 0.

Fix #4585
2013-01-16 10:45:11 -08:00
Trevor Norris 22b84e6216 buffer: floating point read/write improvements
Improvements:
* floating point operations are approx 4x's faster
* Now write quiet NaN's
* all read/write on floating point now done in C, so no more need for
  lib/buffer_ieee754.js
* float values have more accurate min/max value checks
* add additional benchmarks for buffers read/write
* created benchmark/_bench_timer.js which is a simple library that
  can be included into any benchmark and provides an intelligent tracker
  for sync and async tests
* add benchmarks for DataView set methods
* add checks and tests to make sure offset is greater than 0
2013-01-16 10:17:20 -08:00
Ben Noordhuis 9668df8b39 v8: work around String::WriteAscii segfault
See http://code.google.com/p/v8/issues/detail?id=2493 for details.
Once the patch lands in upstream V8, this commit can be reverted.
2013-01-15 23:46:30 +01:00
Fedor Indutny b4b750b6a5 tls: follow RFC6125 more stricly
* Allow wildcards only in left-most part of hostname identifier.
* Do not match CN if altnames are present
2013-01-14 17:18:30 -08:00
isaacs 20a3c5d09c streams2: Do not allow hwm < lwm
There was previously an assert() in there, but this part of the code is
so high-volume that the added cost made a measurable dent in http_simple.

Just checking inline is fine, though, and prevents a lot of potential
hazards.
2013-01-14 16:03:38 -08:00
isaacs 27fafd4648 stream: Do not call endReadable on a non-empty stream
Say that a stream's current read queue has 101 bytes in it, and the
underlying resource has ended (ie, reached EOF).

If you do something like this:

    stream.read(100); // leave a byte behind
    stream.read(0); // read(0) for some reason

then the read(0) will get 0 from the howMuchToRead function.  Since the
stream was ended, this was incorrectly treating the 0 as a "there is no
more in the buffer", and emitting 'end' before that last byte was read.

Why have the read(0) in the first place?  We do this in some cases to
trigger the last few bytes of a net socket (such as a child process's
stdio pipes).  This was causing issues when piping a `git archive` job
to a file: the resulting tarball was incomplete, because it occasionally
was not getting the last chunk.
2013-01-14 15:22:42 -08:00
Ben Noordhuis f3e78bd3c2 http: fix "Cannot call method 'emit' of null"
Fix the following exception:

  http.js:974
    this._httpMessage.emit('close');
                      ^
  TypeError: Cannot call method 'emit' of null
      at Socket.onServerResponseClose (http.js:974:21)
      at Socket.EventEmitter.emit (events.js:124:20)
      at net.js:421:10
      at process._tickCallback (node.js:386:13)
      at process._makeCallback (node.js:304:15)

Fixes #4586.
2013-01-14 17:28:32 +01:00
Felix Böhm 9bce5e8f3e repl: make built-in modules available by default
Closes #3564.
Closes #4578.
2013-01-12 12:10:29 -08:00
isaacs 97db62b4d9 Merge remote-tracking branch 'ry/v0.8' into master
Conflicts:
	AUTHORS
	ChangeLog
	Makefile
	src/node_version.h
2013-01-11 10:18:07 -08:00
Bert Belder 6a91eab097 path: make basename and extname ignore trailing slashes
Fixes #4536
2013-01-11 18:50:09 +01:00
isaacs 3383d77c61 test: child process { stdio:'inherit' } 2013-01-11 09:14:09 -08:00
Bert Belder 7be27240b5 Revert "path: fix bugs related to paths with trailing slashes"
It only does the right thing on unix, and the implementation
isn't great either.

This reverts commit bb1c03989f.
2013-01-11 16:19:21 +01:00
Andreas Madsen bb1c03989f path: fix bugs related to paths with trailing slashes 2013-01-10 17:58:37 -08:00
isaacs b43e544140 stream: Use push() for Transform._output()
This also slightly changes the semantics, in that a 'readable'
event may be triggered by the first write() call, even if a
user has not yet called read().

This happens because the Transform _write() handler is calling
read(0) to start the flow of data.  Technically, the new behavior
is more 'correct', since it is more in line with the semantics
of the 'readable' event in other streams.
2013-01-10 13:49:54 -08:00
isaacs a993f740f0 stream: Add readable.push(chunk) method 2013-01-10 13:49:53 -08:00
Ben Noordhuis ed825f4888 typed arrays: fix 32 bit size/index overflow
Fix an out-of-bound read/write bug due to integer wrapping. Reported by
Dean McNamee.
2013-01-10 00:55:27 +01:00
Fedor Indutny 45941811dc streams: set listener first, emit 'data' later
When switching into compatibility mode by setting `data` event listener,
`_read()` method will be called immediately. If method implementation
invokes callback in the same tick - all emitted `data` events will be
discarded, because `data` listener wasn't set yet.
2013-01-08 22:13:09 +04:00
Shigeki Ohtsu 9b363b022f net: fix bufferSize include writableStream length
socket.bufferSize missed to include the length of internal buffers in
writableStream.
2013-01-08 04:59:50 +01:00
Ben Noordhuis ad6769fc92 dgram: don't assert on send('string')
Raise a TypeError when the argument to send() or sendto() is anything
but a Buffer.

Fixes the following assertion:

  $ node -e 'require("dgram").createSocket("udp4").send("BAM")'
  node: ../../src/udp_wrap.cc:220: static v8::Handle<v8::Value>
  node::UDPWrap::DoSend(const v8::Arguments&, int): Assertion
  `Buffer::HasInstance(args[0])' failed.
  Aborted (core dumped)

Fixes #4496.
2013-01-08 04:32:40 +01:00
Ben Noordhuis 879efb3338 test: fix simple/test-http-client-timeout-with-data
The test was failing in debug mode because the timeouts were set too
low. Fix that by increasing the timeouts. Admittedly not a great fix.
If this test keeps playing up, it's probably best to remove it.

Fixes #4528.
2013-01-07 16:04:33 +01:00
Ben Noordhuis 4e1a2f9a89 test: disable simple/test-debug-brk-file
This test is timing sensitive and hence quite unreliable with debug
builds. What's worse is that it leaves a stray child process behind
that listens on the default test port and that makes all the tests
that come after it fail with EADDRINUSE errors.
2013-01-07 03:40:12 +01:00
Bradley Meck 70ad9bbcbd child_process: make fork() execPath configurable
Allows for arbitrary path to executable spawned using `fork`. This
fixes some issues around running multiple versions of node with workers
and allows arbitrary IPC with compatible executables.

Fixes #3248.
2013-01-06 22:55:30 +01:00
James Hight 3f76419a04 net: add localAddress and localPort to Socket 2013-01-05 17:05:13 +01:00
Nirk Niggler 0459a23063 REPL: fix floating point number parsing
In JS, the expression ".1" is a floating point number.  Issue 4268 concerns the
REPL interpreting floating point numbers that lead with a "." as keywords.  The
original bugfix worked for this specific case but not for the general case:

    var x = [
        .1,
        .2,
        .3
    ];

The attached change and test (`.1+.1` should be `.2`) fix the bug.

Closes #4513.
2013-01-03 17:11:54 -08:00
Ben Noordhuis aad2013508 repl: allow overriding builtins
Don't give names of built-in libraries special treatment.
Changes the REPL's behavior from this:

  > var path = 42
  > path
  A different "path" already exists globally

To this:

  > var path = 42
  > path
  42

Fixes #4512.
2013-01-03 19:58:47 +01:00
Fedor Indutny 8a96bb42c6 test: make tests work with newer v8 2013-01-02 12:13:47 +04:00
Ben Noordhuis 9e32c2ef3e dgram: fix double implicit bind error
Calling send() on an unbound socket forces an implicit bind to
a random port.

332fea5 made the 'listening' event asynchronous. Unfortunately,
it also introduced a bug where the implicit bind was tried more
than once if send() was called again before the first bind operation
completed.

Address that by keeping track of the bind status and making sure that
bind() is called only once.

Fixes #4499.
2012-12-31 17:53:00 +01:00
isaacs 6c80ef01c1 node: emit 'exit' when exiting with error
Fix #3555
2012-12-29 16:53:23 -08:00
isaacs ba94f9d6f8 timers: Move list.ontimeout to separate function 2012-12-29 15:32:25 -08:00
lukebayes ae1b0ca7a5 assert: improve support for new execution contexts
More detailed information in GH-693
2012-12-29 11:19:14 -08:00
isaacs 1c2910d94c test-message: Add setTimeout and nextTick message tests 2012-12-29 10:37:31 -08:00
isaacs ec8ebaf300 domain: use camelCase instead of snake_case
While it's true that error objects have a history of getting snake_case
properties attached by the host system, it's a point of confusion to
Node users that comes up a lot.  It's still 'experimental', so best to
change this sooner rather than later.
2012-12-29 10:37:31 -08:00
isaacs 4401bb47bf domain: Do not use uncaughtException handler
This adds a process._fatalException method which is called into from
C++ in order to either emit the 'uncaughtException' method, or emit
'error' on the active domain.

The 'uncaughtException' event is an implementation detail that it would
be nice to deprecate one day, so exposing it as part of the domain
machinery is not ideal.

Fix #4375
2012-12-29 10:37:30 -08:00
Ben Noordhuis 910e24b53d fs: remove fs.sendfile()
Said function has been broken (and useless) since v0.6.0. Remove it altogether.

Fixes #3854.
2012-12-28 18:24:35 +01:00
bentaber e576208eba net: socket.readyState corrections
socket.readyState, .readable, and .writable behavior changed as
a result of the new streaming interfaces. Updated to be backwards
compatible with current API and adds regression test.

closes #4461
2012-12-27 17:53:28 -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
Ben Noordhuis d2e7ca0449 test: add regression test for #4463 2012-12-25 22:18:57 +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 0edd93dcc1 test: Fix simple/test-http-localaddress 2012-12-21 16:59:20 +00:00
Farid Neshat dcaebec208 fs: add autoClose=true option to fs.createReadStream 2012-12-20 11:25:39 +01:00
isaacs f63af64eb8 test-pummel: Add call validation in net-write-callbacks 2012-12-19 10:55:23 -08:00
isaacs f3f4e290e0 test: 2 resume() calls needed to flush streams 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
isaacs 945f877d30 test: Fix test-https-localaddress*
Fix #4418
2012-12-16 14:40:24 -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 cd51fa8f5a test: Update message tests for streams2 2012-12-14 17:46:24 -08:00
isaacs abbd47e4a3 test: Update simple/test-fs-{write,read}-stream-err for streams2
Streams2 style streams might have already kicked off a read() or write()
before emitting 'data' events.  Make the test less dependent on ordering
of when data events occur.
2012-12-14 17:46:23 -08:00
isaacs 19ecc3a4a6 test updates for streams2 2012-12-14 17:46:23 -08:00
isaacs 0977638ffb test: Fix many tests for http streams2 refactor 2012-12-14 17:46:23 -08:00
isaacs b4df1e62de test updates 2012-12-14 10:52:30 -08:00
isaacs 695abba5ac test: Fix many tests for streams2 net refactor 2012-12-14 10:52:30 -08:00
isaacs f8bb031bdc test: Sync writables may emit finish before callbacks 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 e0c600e00e test: Tests for streaming crypto interfaces 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 3d3a0b3046 test: Writable stream end() method doesn't take a callback 2012-12-14 10:52:26 -08:00
isaacs 70461c39be test: simple/test-file-write-stream needs to use 0 lowWaterMark 2012-12-14 10:52:26 -08:00
isaacs 79fd9620f5 test: Fix test-repl-autolibs inspect call 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 49ea653363 streams2: Remove pipe if the dest emits error 2012-12-13 17:00:34 -08:00
isaacs 2ff499c022 streams2: Do multipipe without always using forEach
The Array.forEach call is too expensive.
2012-12-13 17:00:32 -08:00
isaacs c2f62d496a test: Update stream2 transform for corrected behavior 2012-12-13 17:00:32 -08:00
isaacs acfb0ef908 test: fixture for streams2 testing 2012-12-13 17:00:28 -08:00
isaacs f3e71eb417 test: Writable bufferizing, non-bufferizing, and callbacks 2012-12-13 17:00:27 -08:00
isaacs 9b1b85490b streams2: Tests of new interfaces 2012-12-13 17:00:26 -08:00
isaacs 77ed12fe7a Merge remote-tracking branch 'ry/v0.8' into master
Conflicts:
	AUTHORS
	ChangeLog
	deps/uv/test/test-spawn.c
	deps/uv/uv.gyp
	src/cares_wrap.cc
	src/node.cc
	src/node_version.h
	test/simple/test-buffer.js
	tools/gyp/pylib/gyp/common.py
	tools/install.py
2012-12-13 16:57:58 -08:00
Ben Noordhuis d65832ccd0 fs: fix WriteStream fd leak
Close the file descriptor when a write operation fails.

Fixes #4387.
2012-12-12 09:46:22 +01:00
Ben Noordhuis 6e97b2cc17 fs: fix ReadStream fd leak
Close the file descriptor when a read operation fails.

Fixes #4387.
2012-12-12 09:46:22 +01:00
Ben Noordhuis 65d824b488 test: add common.mustCall function
Verifies that the callback gets invoked <n> times during the lifetime of the
test script.

This is a back-port of commit d0e6c3f from the master branch.
2012-12-12 09:46:09 +01:00
Ryunosuke SATO eb502205d5 events: setMaxListeners() should not have side effects
This object initialization has been unnecessary since 12cf730b.

Ref #3803.
2012-12-10 13:07:35 +01:00
Bert Belder 3c293ba272 http: protect against response splitting attacks 2012-12-07 17:13:51 -08:00
isaacs 33fa740577 fs: Raise error when null bytes detected in paths
Reworking of @bnoordhuis's more aggressive approach.
2012-12-07 16:52:46 -08:00
Ben Noordhuis 5b65638124 tls, https: add tls handshake timeout
Don't allow connections to stall indefinitely if the SSL/TLS handshake does
not complete.

Adds a new tls.Server and https.Server configuration option, handshakeTimeout.

Fixes #4355.
2012-12-06 17:39:24 +01:00
Ben Noordhuis 3ece130ea2 process: add getgroups(), setgroups(), initgroups()
DRY the getuid(), getgid(), etc. functions while we're at it.
2012-12-06 17:14:58 +01:00
Ben Noordhuis c81dec70e6 test: remove simple/test-child-process-fork2
The test assumes the parent and the child are scheduled fairly. Probably true
most of the time but not always, making it fail spuriously.

Bad test, remove it.
2012-12-05 05:46:20 +01:00
Shigeki Ohtsu 1c8a5269c5 test: fix simple/test-debug-brk-file race condition
V8 debug agent needs some time to be ready and no longer sends the first event
break response to a debug client. We wait some time to connect the agent and
check its break status by obtaining breakpoint list and seeing if it exists on
line 0.
2012-12-05 04:31:22 +01:00
Ben Noordhuis 1f76a2eddc fs: add long stacktrace debugging facility
Enable long stacktraces if NODE_DEBUG=fs is set in the environment. Only
applies to the default rethrow callback; it's to help you find places where
you forgot to pass in a callback.
2012-12-04 08:12:12 +01:00
Ben Noordhuis 9d02bfbc25 test: fix simple/test-setproctitle on freebsd 2012-12-03 03:08:19 +01:00
isaacs 4de274cbee test: TTY only has writeBuffer(), not write()
This test is only passing because it's skipped normally.
2012-12-01 11:17:51 -08:00
Trevor Norris 6772308883 buffer: Don't double-negate numeric buffer arg
Fix #4331

Using double negate forces values into 32bit space. Because of this
Math.ceil needs to be used. Since NaN comparisons are always false, use
that to our advantage to return 0 if it is.

Also added two tests to verify the changes.
2012-11-30 16:23:49 -08:00
Joshua Erickson c9f2531ae0 net: More accurate IP address validation and IPv6 dotted notation.
* Added isIP method to make use of inet_pton to cares_wrap.cc
* Modified net.isIP() to make use of new C++ isIP method.
* Added new tests to test-net-isip.js.

This is a back-port of commit fb6377e from the master branch.
2012-11-28 21:51:27 +01:00
Chad Rhyner 8fc578b631 test: disable eio-race tests
Disabled the following unit tests:

* test-eio-race.js
* test-eio-race2.js
* test-eio-race4.js

These tests are known to fail on busy boxes due to being timing sensitive,
and are deemed not meaningful tests.

See https://github.com/joyent/node/issues/4272

Fixes #4272.
2012-11-27 07:18:00 +01:00
Ben Noordhuis 121ed91331 tls: fix tls.connect() resource leak
The 'secureConnect' event listener was attached with .on(), which blocked it
from getting garbage collected. Use .once() instead.

Fixes #4308.
2012-11-26 01:51:05 +01:00
Ben Noordhuis 4cb17cb219 net: fix net.connect() resource leak
The 'connect' event listener was attached with .on(), which blocked it from
getting garbage collected. Use .once() instead.

Fixes #4308.
2012-11-24 15:27:14 +01:00
Scott Blomquist f657ce685d windows: add tracing with performance counters
Patch by Henry Rawas and Scott Blomquist.
2012-11-21 01:21:53 +01:00