Commit Graph

2791 Commits (bbb2dccd1b650db656918f12311f04efa2495ee6)

Author SHA1 Message Date
Timothy J Fontaine 466a9b5c78 Merge remote-tracking branch 'upstream/v0.10'
Conflicts:
	src/node_zlib.cc
2014-02-17 20:57:53 -08:00
Farid Neshat 562b015170 debugger: Fix breakpoint not showing after restart
The reason this wasn't working was because after restart, when restoring
breakpoints the scripts wasn't loaded, so the breakpoint.script was
undefined. As a fix I added another check to use breakpoint.scriptReq
instead of breakpoint.script, which is the same except when the
breakpoint is a function.

fixes #7027
2014-02-17 20:47:46 -08:00
Yazhong Liu cfe0bab85b readline: fix `line` event, if input emit 'end'
If an input stream would emit `end` event, like
`fs.createReadStream`, then readline need to get the last line
correctly even though that line isnt ended with `\n`.
2014-02-17 16:21:29 -08:00
Yazhong Liu 3ae0b17c76 repl: REPLServer inherits from readline.Interface
This exposes a setPrompt for and other readline features
2014-02-17 16:04:36 -08:00
Fedor Indutny 829a9b8cba zlib: introduce pending close state
zlib should not crash in `close()` if the write is still in progress.

fix #7101
2014-02-18 01:11:05 +04:00
Fedor Indutny 75ea11fc08 tls: introduce asynchronous `newSession`
fix #7105
2014-02-18 01:07:09 +04:00
Timothy J Fontaine a4436bab7b dgram: pass the bytes sent to the send callback
Fixes #6953
2014-02-15 19:24:42 -08:00
Fedor Indutny 940abd0b19 test: fix tls-honorcipherorder slowness
End accepted stream to prevent client fd from hanging in FIN_WAIT_1
state. The 30 second delay was caused by default non-zero SO_LINGER.
2014-02-16 01:19:54 +04:00
Alexis Campailla bb2af7dd4d test: give repl-timeout-throw more time to run
Short timeout was causing the test to fail on Windows debug builds.
2014-02-13 16:49:15 -08:00
Alexis Campailla 0f10dd4cb2 test: increase timeout in readable stream test
A slightly higher timeout is needed for the test to pass on
Windows debug builds.
2014-02-13 16:49:08 -08:00
Alexis Campailla 8f94ef46b7 test: fix assert in test-http-outgoing-finish
Given the assert message, and the fact that endCb is always true
in the assert, I am pretty sure the test author was intending
to test for finishEvent, not endCb.
2014-02-13 16:46:04 -08:00
Alexis Campailla 527cabefcb test: fix connection reset in http test
In this test, an HTTP server was ending the response before
consuming all the data sent in the PUT request.

Ending the response would cause the socket to be destroyed,
and since there is some data still to be read, an ECONNRESET is
surfaced on the client side, event though the client has already
ended its side and even seen a 'finish' event.

See:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.2.2

While it is certainly admissible for the server to send a response
before consuming the entire request, it seems reasonable to
expect that the server would close the connection afterwards
and that the ECONNRESET would be raised on the client.

So I have changed the test to wait until the entire request has been
consumed before sending the response.
2014-02-13 16:46:04 -08:00
orangemocha@github.com e7a03f1c62 test: fix test-child-process-double-pipe
On Windows, grep and sed were stripping the CR character out of CRLF.
Passing --binary will force them to preserve the CR.
2014-02-13 16:41:31 -08:00
Timothy J Fontaine e8df267674 child_process: js bits for spawnSync/execSync
This implements the user-facing APIs that lets one run a child process
and block until it exits.

Logic shared with the async counterpart of each function was refactored
to enable code reuse.

Docs and tests are included.
2014-02-10 13:35:37 -08:00
Timothy J Fontaine d58c206862 Merge remote-tracking branch 'upstream/v0.10'
Conflicts:
	lib/_stream_writable.js
2014-02-10 11:21:09 -08:00
Fedor Indutny dee5270a6c net: do not re-emit stream errors
fix #7015
2014-02-10 10:59:52 -08:00
Fedor Indutny c0d81f9099 process: allow changing `exitCode` in `on('exit')`
fix #7081
2014-02-09 15:10:38 +04:00
Kenan Sulayman 28dbc96a6c dns: validate arguments in resolver
Mitigate C++-land assertion error, add test accordingly.

Fix #7070
2014-02-09 13:38:23 +04:00
Kenan Sulayman abe4c34c86 dns: verify argument is valid function in resolve
Don't use argument as callback if it's not a valid callback function.
Throw a valid exception instead explaining the issue.

Adds to #7070 ("DNS — Throw meaningful error(s)").
2014-02-09 13:37:50 +04:00
Alexis Campailla e3ec2f7dab test: fix test-http-pipeline-flood
The number of connections achieved by the test can vary by platform
and by machine. Lowering the acceptance threshold so that the
test passes on Windows.
2014-02-09 13:33:47 +04:00
Timothy J Fontaine eadb4f5606 Merge remote-tracking branch 'upstream/v0.10'
Conflicts:
	deps/v8/src/preparser.cc
	deps/v8/src/win32-math.h
	doc/api/http.markdown
	src/node_buffer.h
	src/node_crypto.cc
	src/node_file.cc
	src/node_http_parser.cc
2014-02-08 16:45:27 -08:00
Fedor Indutny d10a68736d Revert "dns: validate arguments in resolve"
This reverts commit 56e80a37e0.
2014-02-08 02:15:33 +04:00
Kenan Sulayman 56e80a37e0 dns: validate arguments in resolve
Mitigat  C++-land assertion error, add test accordingly.

fix #7070
2014-02-08 02:08:28 +04:00
Ben Noordhuis bbd56d881d vm: don't copy Proxy object from parent context
Make vm.runInContext() and vm.runInNewContext() stop copying the Proxy
object from the parent context into the new context when --harmony or
--harmony_proxies is in effect because it overwrites the new context's
native Proxy object.

This commit also adds a regression test for Harmony symbols.  They work
okay in the current implementation and the test should ensure it stays
that way.
2014-02-06 15:30:38 +04:00
Ben Noordhuis 2b6e078833 test: don't compute knownGlobals lazily
Conditional globals like 'gc' should only be recognized when --expose_gc
is set.  The global.gc feature check works only when done eagerly, else
it lets through a leaked variable called 'gc'.
2014-02-06 15:30:38 +04:00
Nathan Rajlich 8874a31748 util: show meaningful values for boxed primitives
Before, `new String('foo')` would be inspected as `"{}"` which
is simply not very helpful. Now, a more meaningful
`"[String: 'foo']"` result will be returned from `util.inspect()`.

Boxed String, Boolean, and Number types are all supported.

Closes #7047
2014-02-06 14:19:47 +04:00
Fedor Indutny f1de13b8ab node: do not print SyntaxError hints to stderr
Try embedding the ` ... ^` lines inside the `SyntaxError` (or any other
native error) object before giving up and printing them to the stderr.

fix #6920
fix #1310
2014-02-06 13:26:57 +04:00
iamdoron 1317032c97 fs: make unwatchFile() insensitive to path 2014-02-06 13:04:35 +04:00
Trevor Norris 6cbfcdad46 src: move AsyncListener from process to tracing
The AsyncListener API has been moved into the "tracing" module in order
to keep the process object free from unnecessary clutter.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-02-05 17:16:36 -08:00
Ben Noordhuis d23ac0ea9c src: add v8.getHeapStatistics() function
Add a one-to-one binding to v8::GetHeapStatistics().  Returns info on
the current state of the JS heap, like total size and amount used.
2014-02-05 11:49:01 -08:00
Ben Noordhuis 010222d39f src: add tracing.v8.on('gc') statistics hooks
Add a new 'tracing' module with a v8 property that lets the user
register listeners for gc events.  The listeners are invoked after
every garbage collection cycle with 'before' and 'after' statistics.
Useful for monitoring tools that want to keep track of memory usage.
2014-02-05 11:49:01 -08:00
Fedor Indutny 528a3ce3ed tls: more session configuration options, methods
Introduce `ticketKeys` server option, `session` client option,
`getSession()` and `getTLSTicket()` methods.

fix #7032
2014-02-05 23:28:34 +04:00
Fedor Indutny 5ce458032f contextify: handle infinite recursion errors
Try to be consistent with v0.10 and emit "Maximum call stack size
reached", even if it happens when allocating context or doing other
stuff.

fix #7045
2014-02-05 14:20:02 +04:00
Alexis Campailla bae545dab7 test: fix test-tcp-wrap-listen
If the call to writeBuffer completes asynchronously, we need to have
an oncomplete callback on the request object no matter what. The
writeQueueSize seems irrelvant to that regard.

Note that on Windows writeBuffer always completes asynchronously.

See related commit 9836a4eeda
2014-02-04 22:51:11 +04:00
Fedor Indutny 2315703035 zlib: separate sync/async methods 2014-02-04 01:41:02 +04:00
Fedor Indutny 9a60bf3726 tls: fix crash in SNICallback
`tls_wrap.cc` was crashing in an `Unwrap` call, when non
`SecureContext` object was passed to it. Check that the passed object
is a `SecureContext` instance before unwrapping it.

fix #7008
2014-02-04 01:35:08 +04:00
Nikolai Vavilov 9b37b83a20 zlib: add sync versions for convenience methods 2014-02-01 03:45:45 +04:00
Alexis Campailla 49c2372e68 test: delete invalid http test
The test is no longer valid for the original scenario.

It now fails intermittently because of two other issues:
1. Since the client is only processing one readable event, the
   client request is not enough to keep the process alive and the
   process can exit before the desired events have been raised.
2. Reading just 1 byte is not enough to guarantee that the parser
   will eventually consume all the data and raise the desired
   parse error. I tried postponing the server.close() to address
   the issue at [1], but then the test just hangs sometimes.
2014-01-30 21:52:07 +04:00
Fedor Indutny e796e11087 node: do not ever close stdio
Even if stdio streams are opened as file streams, we should not ever try
to close them. This could be accomplished by passing `autoClose: false`
in options on their creation.
2014-01-30 21:26:19 +04:00
Fedor Indutny fc26fd6b38 node: do not ever close stdio
Even if stdio streams are opened as file streams, we should not ever try
to close them. This could be accomplished by passing `autoClose: false`
in options on their creation.
2014-01-29 03:27:23 +04:00
Fedor Indutny 9836a4eeda stream_wrap: use `uv_try_write` where possible
Use `uv_try_write` for string and buffer writes, thus avoiding to do
allocations and copying in some of the cases.
2014-01-29 02:49:03 +04:00
Timothy J Fontaine 114bff467e test: use logical and not or in abort-fatal-error 2014-01-27 18:27:10 -08:00
Timothy J Fontaine 2f5e77f55b test: make abort-fatal-error more robust
It's saner to check exit codes or signals to determine if the process
actually aborted. On OSX and Linux the exit code is 134, on SunOS it
propagates the SIGABRT signal
2014-01-27 18:14:57 -08:00
Timothy J Fontaine cd2d3aedaa test: fix test-net-listen-fd0 for pipes
In the case of a pipe'd input, i.e. from the CI the fd will be a PIPE
and when listen() is called it will return ENOTSOCK instead of EINVAL.
2014-01-27 17:39:45 -08:00
Jacob Hoffman-Andrews f4c8020d10 crypto: honor default ciphers in client mode
Right now no default ciphers are use in, e.g. https.get, meaning that
weak export ciphers like TLS_RSA_EXPORT_WITH_DES40_CBC_SHA are
accepted.

To reproduce:

node -e "require('https').get({hostname: 'www.howsmyssl.com', \
  path: '/a/check'}, function(res) {res.on('data', \
  function(d) {process.stdout.write(d)})})"
2014-01-28 03:28:09 +04:00
Alexis Campailla dc1ffd0da6 test: race condition in test-cluster-disconnect
The test was not waiting for all the worker-created sockets
to be listening before calling cluster.disconnect().
As a result, the channels with the workers could get closed
before all the socket handles had been passed to them, leading
to various errors.
2014-01-27 11:54:53 -08:00
Timothy J Fontaine c37e1b7c4b Merge remote-tracking branch 'upstream/v0.10'
Conflicts:
	src/node_crypto.cc
	test/simple/test-crypto.js
2014-01-27 11:02:59 -08:00
Jun Ma d2de8ba34d net: make Socket destroy() re-entrance safe
So that we are free to call socket.destroy() in error event handler.

fix #6769
2014-01-27 22:12:29 +04:00
Fedor Indutny b4c4e0bbaa crypto: throw on SignFinal failure
fix #6963
2014-01-26 22:24:57 +04:00
Fedor Indutny cc4b6e6e58 crypto: clear error in GetPeerCertificate
fix #6945
2014-01-26 03:48:36 +04:00
Fedor Indutny 00efcb4cd7 net: reset `endEmitted` on reconnect
fix #6908
2014-01-25 12:20:45 -08:00
Fedor Indutny a454063ea1 http: do not emit EOF non-readable socket
Socket may become not `readable`, but http should not rely on this
property and should not think that it means that no data will ever
arrive from it. In fact, it may arrive in a next tick and, since
`this.push(null)` was already called, it will result in a error like
this:

    Error: stream.push() after EOF
        at readableAddChunk (_stream_readable.js:143:15)
        at IncomingMessage.Readable.push (_stream_readable.js:123:10)
        at HTTPParser.parserOnBody (_http_common.js:132:22)
        at Socket.socketOnData (_http_client.js:277:20)
        at Socket.EventEmitter.emit (events.js:101:17)
        at Socket.Readable.read (_stream_readable.js:367:10)
        at Socket.socketCloseListener (_http_client.js:196:10)
        at Socket.EventEmitter.emit (events.js:123:20)
        at TCP.close (net.js:479:12)

fix #6784
2014-01-25 12:03:20 -08:00
Timothy J Fontaine c1b1f31203 Merge remote-tracking branch 'upstream/v0.10'
Conflicts:
	AUTHORS
	ChangeLog
	deps/uv/AUTHORS
	deps/uv/ChangeLog
	deps/uv/src/unix/process.c
	deps/uv/src/version.c
	lib/net.js
	node.gyp
	src/node_version.h
2014-01-24 19:13:50 -08:00
Fedor Indutny 640912d18a tls_wrap: propagate errors to write callbacks
fix #6903
2014-01-24 22:09:42 +04:00
Fedor Indutny d019eac5b5 tls: emit `clientError` on early socket close
fix #6903
2014-01-24 22:09:17 +04:00
Alexis Campailla 42cd468901 test: fix http-incoming-pipelined-socket-destroy
The test was calling server.close() after write on the socket
had completed. However the fact that the write had completed was
not valid indication that the server had received the data.

This would result in a premutaure closing of the server and
an ECONNRESET event on the client.
2014-01-23 12:42:56 -08:00
Alexis Campailla 5d4f4ee310 test: fix http-many-ended-pipelines server close
The test was calling server.close() without waiting for the server
to have received all the requests. This would cause an ECONNRESET.
2014-01-23 12:42:36 -08:00
Fedor Indutny c79c304ead tls: process accumulated input
When creating TLSSocket on top of the regular socket that already
contains some received data, `_tls_wrap.js` should try to write all that
data to the internal `SSL*` instance.

fix #6940
2014-01-23 20:39:32 +04:00
Ben Noordhuis 6514a4128c test: fix array sorting bug
`a === a.sort()` is always true because Array#sort() does an in-place
sort.  Make a copy of the array first.
2014-01-22 15:58:07 +04:00
Ben Noordhuis 74d9aa49d5 crypto: support custom pbkdf2 digest methods
Make the HMAC digest method configurable.  Update crypto.pbkdf2() and
crypto.pbkdf2Sync() to take an extra, optional digest argument.

Before this commit, SHA-1 (admittedly the most common method) was used
exclusively.

Fixes #6553.
2014-01-22 15:58:07 +04:00
Trevor Norris f32c1ffe56 node: only run same AL once on error
Should have been included with 60fcc11 as it is the same type of fix.

Signed-off-by: Forrest L Norvell <ogd@aoaioxxysz.net>
2014-01-21 17:11:48 -08:00
Fedor Indutny cdde9a386a crypto: add newline to cert and key if not present
After one of OpenSSL updates we have stopped accepting PEM private keys
and certificates that doesn't end with a newline (`\n`) character.
Handle this regression in `crypto.js` to make less trouble to our users.

fix #6892
2014-01-22 02:42:04 +04:00
Fedor Indutny 1442c1c6de addons: build and test examples
fix #6910
2014-01-22 00:39:13 +04:00
Alexis Campailla 2a0b619f7b text: give more time to test-next-tick-error-spin
The previous timeout was too short for certain execution conditions
(Windows, debug build, first execution).
2014-01-21 10:23:16 -08:00
Alexis Campailla 22879e749e test: give test-net-GH-5504 more time to run
On Windows debug builds, the test was failing because the timeout
was too short.
2014-01-21 10:21:50 -08:00
Trevor Norris 60fcc11be2 node: ensure same AL inst only runs once
It was possible that the same AL instance was run twice if it were both
attached to the currentContext then again added to the new asyncQueue
generated for the new stack.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-01-21 10:20:14 -08:00
Trevor Norris 63ccfc3536 async_wrap/timers: remove Add/RemoveAsyncListener
The ability to add/remove an AsyncListener to an object after its
creation was an artifact of trying to get AL working with the domain
module. Now that is no longer necessary and other features are going to
be implemented that would be affected by this functionality. So the code
will be removed for now to simplify the implementation process.

In the future this code will likely be reintroduced, but after some
other more important matters have been addressed.

None of this functionality was documented, as is was meant specifically
for domain specific implementation work arounds.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-01-21 10:20:07 -08:00
Alexis Campailla 5393d02c0c test: relax timing in test-http-exit-delay
This test was originally intended to guard against regressions for
commit 16b59cbc74.

As such, it only needs to ensure that process exit has not been held up
by the date cache timer, which would fire on the next second.
2014-01-20 09:14:42 -08:00
Alexis Campailla edfc0d9ffe test: debug-signal-cluster increase timeouts
The test needs a little more time to run so that it passes for all
builds (eg: Windows, debug)
2014-01-20 09:00:14 -08:00
Alexis Campailla e12e72eb58 debug client: connect after child is ready
We now wait to connect to the debuggee until we know that
its error stream has data, to ensure that the output message
"connecting..... ok" appears after "Debugger listening on port xyz"

I also increased the test timeout to let the more complex
tests finish in time on Windows

This change fixes the following unit tests on Windows:
 test-debugger-repl.js
 test-debugger-repl-term.js
 test-debugger-repl-utf8.js
 test-debugger-repl-restart.js
2014-01-20 09:00:14 -08:00
Timothy J Fontaine 574f71444c test: move debugger repl into own section 2014-01-20 09:00:13 -08:00
Timothy J Fontaine 6cc95b06ea test: refactor to use common testcfg 2014-01-20 09:00:13 -08:00
Fedor Indutny 442d2d0cde test: ignore tests when built without OpenSSL CLI
fix #6880
2014-01-20 20:55:54 +04:00
Fedor Indutny 7f9b01509f lib: introduce `.setMaxSendFragment(size)`
fix #6889
2014-01-20 20:39:57 +04:00
Ben Noordhuis db5abd726f tls: make cert/pfx optional in tls.createServer()
Not all ciphers require the presence of a certificate.  Remove the
check in lib/_tls_wrap.js.

Fixes #6887.
2014-01-17 18:55:33 +00:00
Ben Noordhuis 262a752c29 tls: show human-readable error messages
Before this commit, verification exceptions had err.message set to the
OpenSSL error code (e.g. 'UNABLE_TO_VERIFY_LEAF_SIGNATURE').

This commit moves the error code to err.code and replaces err.message
with a human-readable error.  Example:

    // before
    {
      message: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'
    }

    // after
    {
      code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
      message: 'unable to verify the first certificate'
    }

UNABLE_TO_VERIFY_LEAF_SIGNATURE is a good example of why you want this:
the error code suggests that it's the last certificate that fails to
validate while it's actually the first certificate in the chain.

Going by the number of mailing list posts and StackOverflow questions,
it's a source of confusion to many people.
2014-01-17 18:51:25 +00:00
Trevor Norris 24856f04b2 Merge remote-tracking branch 'origin/v0.10'
Conflicts:
	lib/domain.js
2014-01-15 13:49:55 -08:00
Ryan Graham 7f81ca2c47 domains: exit() only affects active domains
domain.create().exit() should not clear the domain stack if the domain
instance does not exist within the stack.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-01-15 12:27:10 -08:00
Alexis Campailla 2e3da9be84 test: terminate gracefully in cluster-net-send
Killing the worker without ensuring the socket was closed
was causing intermittent ECONNRESET errors.
2014-01-13 15:15:10 -08:00
Timothy J Fontaine 429b58701a Merge remote-tracking branch 'upstream/v0.10'
Conflicts:
	deps/uv/ChangeLog
	deps/uv/build.mk
	deps/uv/src/version.c
	deps/uv/test/test-ipc.c
	deps/v8/src/objects.cc
	src/node.cc
	src/node_os.cc
2014-01-13 14:56:12 -08:00
Alexis Campailla 1b74892807 test: close debug client in test-debugger-client
Killing the debuggee without first closing the socket can result
in an ECONNRESET error.
2014-01-13 13:16:25 -08:00
Alex Kocharin ec57ecc982 http: concatenate duplicate headers by default 2014-01-13 17:29:58 +00:00
Tom Gallacher 38a07a929b util: handle escaped forward slashes correctly
Fixes #6835
2014-01-10 21:13:46 +00:00
Ryan Graham 5106cadffb domain: fix off-by-one in Domain.exit()
We want to clear the found domain and the domains after it.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-01-09 15:25:58 -08:00
Jeff Barczewski 82c2084b4e test: check RR scheduler has necessary methods
The RR cluster scheduler replaces the normal StreamWrap handle. Because
of this the AsyncListener method failed to be in place when domains were
in use.

The issue was resolved in 828f145 by reverting having domains use
AsyncListeners.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-01-09 14:17:13 -08:00
Timothy J Fontaine 270c2deb84 src: OnFatalError handler must abort()
We are in an unrecoverable state if v8 throws a FatalError, actually
ask the operating system to dump core in this case.

Fixes #6836
2014-01-09 14:01:53 -08:00
Fedor Indutny 730e511b35 child_process: better error reporting for exec
Report path to executable and argv on error, stderr is not enough in
many cases.

fix #6796
2014-01-09 00:00:30 +04:00
ayanamist b922b5e90d stream: writes may return false but forget to emit drain
If a write is above the highWaterMark, _write still manages to
fully send it synchronously, _writableState.length will be adjusted down
to 0 synchronously with the write returning false, but 'drain' will
not be emitted until process.nextTick.

If another small write which is below highWaterMark is issued before
process.nextTick happens, _writableState.needDrain will be reset to false,
and the drain event will never be fired.

So we should check needDrain before setting it up, which prevents it
from inproperly resetting to false.
2014-01-05 19:44:45 +04:00
Trevor Norris a40b463674 node: properly check uid when adding AsyncListener
Instead of checking the uid on the array index of the queue, instead the
object property "uid" was checked on the queue iteself. Because this
will always evaluate to "undefined" the same listener could be added
multiple times to the same context.
2014-01-03 16:48:11 -08:00
Trevor Norris d9fc6af32a node: change AsyncListener API
There was a flaw in the old API that has been fixed. Now the
asyncListener callback is now the "create" object property in the
callback object, and is optional.
2014-01-03 13:20:23 -08:00
Tuğrul Topuz bddea032b7 dns: add resolveSoa and 'SOA' rrtype
You can now query for SOA records by either passing 'SOA' to `resolve`
or by using the new `resolveSoa`
2013-12-31 14:30:40 -08:00
Timothy J Fontaine 13de0f1d27 Merge remote-tracking branch 'upstream/v0.10'
Conflicts:
	lib/cluster.js
	lib/dgram.js
	lib/net.js
2013-12-31 13:56:15 -08:00
Timothy J Fontaine 6f8aa24d1e test: fix test-cluster-eaccess to work on windows 2013-12-31 11:57:13 -08:00
Sam Roberts cb1646f44e test: fix assumption of worker exit on disconnect
Master was disconnecting its workers as soon as they both started up.
Meanwhile, the workers were trying to listen. Its a race, sometimes the
disconnect would happen between when worker gets the response message,
and acks that message with a 'listening'. This worked OK after v0.11
introduced a behaviour where disconnect would always exit the worker,
but once that backwards-incompatible behaviour is removed, the worker
lives long enough to try and respond to the master, and child_process
errors at the attempt to send from a disconnected child.
2013-12-31 11:43:44 -08:00
Sam Roberts 876d3bd85a cluster: do not synchronously emit 'setup' event
This is a problem present in both v0.10, and v0.11, where the 'setup'
event is synchronously emitted by `cluster.setupMaster()`, a mostly
harmless anti-pattern.
2013-12-31 11:43:44 -08:00
Sam Roberts dce35146e0 cluster: only forcibly exit worker on unclean exit
Fix inadvertent v0.11 changes to the definition of suicide, particularly
the relationship between suicide state, the disconnect event, and when
exit should occur.

In v0.10, workers don't forcibly exit on disconnect, it doesn't give
them time to do a graceful finish of open client connections, they exit
under normal node rules - when there is nothing left to do. But on
unexpected disconnect they do exit so the workers aren't left around
after the master.

Note that a test as-written was invalid, it failed against the v0.10
cluster API, demonstrating that it was an undocumented API change.
2013-12-31 11:43:43 -08:00
Sam Roberts 6f40abe2d4 cluster: disconnect callback should always occur
Fixes issue in 0.11 where callback doesn't occur if worker count is
currently zero.  In 0.10 callback occurs after worker count is zero, and
occurs in next tick if worker count is currently zero.
2013-12-31 11:43:43 -08:00
Fedor Indutny 3e9f2e61db cluster: report more errors to workers
Some errors for listening and binding to a socket were not properly
delivered to workers.

fix #6767
2013-12-31 09:47:33 -08:00
Yorkie 8d3bc88bbe querystring: remove `name` from `stringify()`
QueryString.stringify() allowed a fourth argument that was used as a
conditional in the return value, but was undocumented, not used by core
and always was always false/undefiend. So the argument and conditional
have been removed.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2013-12-30 11:41:37 -08:00
Vladimir Kurchatkin 055f7e9da9 src: only access stack of non-null errors
Avoid segmentation fault when `null` is thrown
2013-12-23 15:08:11 +04:00
Trevor Norris 87cde44280 Revert "util: more strict check for bool/number/string"
This reverts commit 95ee84fabe.
2013-12-20 13:44:56 -08:00
Alexis Campailla f030d8426a test: fix flaky unit test test-fs-realpath.js
The test was not performing proper cleanup and so it would
fail if run more than one time on the same machine.
2013-12-20 20:40:28 +04:00
Alexis Campailla ea18aecc82 test: case insensitve path comparison on Windows
Windows needs case insensitive comparison when it comes to
path strings.
2013-12-20 19:23:34 +04:00
Cam Swords 7ffe2ad616 http: parse the status message in a http response. 2013-12-20 17:55:08 +04:00
Yorkie 95ee84fabe util: more strict check for bool/number/string 2013-12-18 17:58:02 +04:00
Lalit Kapoor 4d5489667c test: use s_client instead of curl
fixes #6647
2013-12-12 21:31:59 +04:00
Fedor Indutny 6f3d60388e gyp: build openssl-cli tool and use it in tests
fix #6663
2013-12-11 21:21:10 +04:00
Alexis Campailla c5d49ba9c2 test: test-os fix win32 localhost assumption
The test is expecting an invalid result for the loopback
interface network mask, but this issue was fixed in
libuv commit 1d5c61a8b31257733c41fb507762d3eb56eecb2d

Closes #5262 #6673
2013-12-10 22:16:24 -08:00
Alexis Campailla ceea1e845a test: test-os win32 adhere standard tmp resolution
The test is making the wrong assumptions about the
value of os.tmpdir() on Windows
2013-12-10 22:13:05 -08:00
Fedor Indutny ba706bacf3 Merge branch 'v0.10'
Conflicts:
	src/node_file.cc
2013-12-10 23:36:41 +04:00
Fedor Indutny f16edd2632 fs: report correct path when EEXIST
When `symlink`, `link` or `rename` report EEXIST, ENOTEMPTY or EPERM -
the destination file name should be included in the error message,
instead of source file name.

fix #6510
2013-12-10 23:17:00 +04:00
Fedor Indutny 1e066e4a4a Merge branch 'v0.10'
Conflicts:
	lib/tls.js
	src/node_crypto.cc
	src/node_crypto.h
2013-12-10 23:06:56 +04:00
Fedor Indutny 4a2792cd2f tls: emit 'end' on .receivedShutdown
NOTE: Also removed `.receivedShutdown` method of `Connection` it wasn't
documented anywhere, and was rewritten with `true` after receiving
`close_notify`.

fix #6638
2013-12-10 22:56:01 +04:00
Fedor Indutny 78cd4533d9 test: make fs-watch-recursive less racy
FSEventStream may emit events that happened right before it has started.
Ignore changes emitted for the directory itself, since they may come
from the stale events.
2013-12-10 22:08:41 +04:00
Vladimir Kurchatkin 259d449622 src: only access stack of defined errors
Avoid segmentation fault when `undefined` is thrown
2013-12-10 09:33:33 -08:00
Alexis Campailla f9e3364a47 test: fix create-file test fixture
This was failing if the file didn't already exist.

Fixes unit tests on Windows:

* test\simple\test-http-curl-chunk-problem.js
* test\simple\test-pipe-file-to-http.js
2013-12-10 20:09:07 +04:00
Ingmar Runge e0d31ea2db crypto: support GCM authenticated encryption mode.
This adds two new member functions getAuthTag and setAuthTag that
are useful for AES-GCM encryption modes. Use getAuthTag after
Cipheriv.final, transmit the tag along with the data and use
Decipheriv.setAuthTag to have the encrypted data verified.
2013-12-08 00:00:02 +04:00
Timothy J Fontaine fcca3585fe Merge remote-tracking branch 'upstream/v0.10'
Conflicts:
	lib/tls.js
	src/node.js
2013-12-06 21:27:18 -08:00
Lalit Kapoor aef09601b4 http: DELETE shouldn't default to chunked encoding 2013-12-06 16:25:42 -08:00
Alexis Campailla 0da4e0e843 child_process: don't crash process on internal ops
1. Swallow errors when sending internal NODE_HANDLE_ACK messages, so
   they don't crash the process.
2. Queue process.disconnect() if there are any pending queued messages.

Fixes test-child-process-fork-net2.js on win.
2013-12-06 16:17:52 -08:00
Fedor Indutny f572b91c3e tls: fix handling of asterisk in SNI context
Wildcard server names should not match subdomains.

Quote from RFC2818:

   ...Names may contain the wildcard
   character * which is considered to match any single domain name
   component or component fragment. E.g., *.a.com matches foo.a.com but
   not bar.foo.a.com. f*.com matches foo.com but not bar.com.

fix #6610
2013-12-05 19:45:19 -08:00
Kai Groner 98be8df571 crypto: Make Decipher._flush() emit errors.
When Decipher processes a stream using an incorrect key, the
DecipherFinal() method throws an unhandled exception at the end of the
stream.
2013-12-04 19:52:15 +04:00
Fedor Indutny 60f777d343 tls: fix pool usage race
When calling `encOut` in loop, `maybeInitFinished()` may invoke
`clearOut`'s loop, leading to the writing of interleaved data
(encrypted and cleartext) into the one shared pool.

Move `maybeInitFinished()` out of the loop and add assertion for
future.
2013-12-02 15:18:04 -08:00
Sam Roberts 8aac118b69 process: document kill(0), disallow kill(O_RDWR)
The null signal test existed, but only tested the case where the target
process existed, not when it did not exist.

Also clarified that SIGUSR1 is reserved by Node.js only for receiveing,
its not at all reserved when sending a signal with kill().

kill(pid, 'O_RDWR'), or any other node constant, "worked". I fixed this
by also checking for 'SIG'. The same as done in the isSignal() function.
Now the signal names supported by process.kill() are the same as those
supported by process.on().
2013-12-02 10:41:37 -08:00
Fedor Indutny 4bd5f35889 Merge branch 'v0.10'
Conflicts:
	src/node_crypto.cc
	src/node_crypto.h
2013-12-02 15:04:47 +04:00
Fedor Indutny 9b8fcff435 tls: reset NPN callbacks after SNI
SNI callback selects a new SSL_CTX for the connection, which doesn't
have NPN callbacks set up.
2013-12-02 14:48:14 +04:00
Fedor Indutny 5ce4eed54d http: fix parser double-free in _http_client.js
HTTP Parser instance was freed twice, leading to the reusal of it
in several different requests simultaneously.

The flow:

`socketCloseListener` is firing, which calls `socket.read()` to flush
any queued data, `socket.buffer` has data which emits and fires
`socketOnData` in sync, this triggers a parser error which frees the
parser, `socketCloseListener` resumes execution only to have the wrong
parser associated with the socket.

The fix is to only cache the parser after the flushing from the socket,
and to assert in `socketOnData` that `socket === parser.socket`

fix #6451
2013-11-27 15:37:56 -08:00
Alexis Campailla c749a841cd test: use os.EOL when checking output 2013-11-27 10:56:24 -08:00
Timothy J Fontaine 85c19175ed Merge remote-tracking branch 'upstream/v0.10' 2013-11-26 08:41:09 -08:00
Ben Noordhuis 84c03a984a tls: add serialNumber to getPeerCertificate()
Add a 'serialNumber' property to the object that is returned by
tls.CryptoStream#getPeerCertificate().  Contains the certificate's
serial number encoded as a hex string.  The format is identical to
`openssl x509 -serial -in path/to/certificate`.

Fixes #6583.
2013-11-26 14:24:37 +01:00
David Chan b3e4fc6a48 util: Format negative zero as '-0'
Format negative zero as '-0' instead of as '0', as it does not behave
identically to positive zero. ((-0).toString() still returns '0' as
required by ES5 9.8.1.2).

Fixes joyent/node#6548.
Closes joyent/node#6550.
2013-11-25 11:28:30 -08:00
Vladimir Kurchatkin 16a402c0b5 node: fix removing AsyncListener in callback
context._asyncQueue shouldn't be exposed as asyncQueue, as it allows
modification of queues already attached to an event. Which is not
supposed to happend. Instead context._asyncQueue should be copied.
2013-11-23 11:16:16 -08:00
Jeremy Martin 71aabedad4 events: fix TypeError in removeAllListeners
Check that `listeners` is actually an array before trying to manipulate it
because it won't be if no regular event listeners have been registered yet
but there are 'removeListener' event listeners.
2013-11-22 17:42:34 +01:00
Trevor Norris 5757642e91 node: allow nextTick infinite recursion
Removing the depth counter while processing the nextTickQueue made it
possible to run out of memory if in an infinite recursive loop using
nextTick(). There was also an edge case where too many callbacks were
pushed onto the nextTickQueue, while not actually being recursive.

This is being done to prevent possible cryptic FATAL ERROR messages from
popping up, and issues being posted about them.
2013-11-21 15:01:53 -08:00
Timothy J Fontaine eaba9417b1 Merge remote-tracking branch 'upstream/v0.10'
Conflicts:
	lib/events.js
	src/udp_wrap.cc
2013-11-20 15:45:50 -08:00
Fedor Indutny fce0eb416b events: do not accept NaN in setMaxListeners 2013-11-19 13:14:01 +04:00
Fedor Indutny 5ce50ece16 dgram: fix abort when getting `fd` of closed dgram
v8's `messages.js` file's `CallSiteGetMethodName` is running through all
object properties and getter to figure out method name of function that
appears in stack trace. This run-through will also read `fd` property of
`UDPWrap` instance's javascript object, making `UNWRAP()` fail.

As a simple alternative to the test case above, one could just keep
reference to the dgram handle and try accessing `handle.fd` after it has
been fully closed.

fix #6536
2013-11-19 12:44:06 +04:00
Timothy J Fontaine 2329a254b4 Merge remote-tracking branch 'upstream/v0.10'
Conflicts:
	AUTHORS
	ChangeLog
	deps/uv/AUTHORS
	deps/uv/ChangeLog
	deps/uv/README.md
	deps/uv/build.mk
	deps/uv/src/unix/core.c
	deps/uv/src/unix/darwin-proctitle.c
	deps/uv/src/unix/darwin.c
	deps/uv/src/unix/fsevents.c
	deps/uv/src/unix/udp.c
	deps/uv/src/version.c
	deps/v8/src/platform-solaris.cc
	deps/v8/test/cctest/test-api.cc
	lib/tls.js
	src/node.h
	src/node_version.h
2013-11-18 13:41:17 -08:00
Ben Noordhuis bd9c66668c debugger: pass on v8 debug switches
Before this commit, passing --debugger and other V8 debug switches to
node.js made node print a usage message and exit.

Rewrite the debug argument parser so it only consumes switches that we
understand and pass everything else as-is to V8.

A side effect of this change is that switches like --debugger_agent and
--debugger_port now work.  That kind of obsoletes our debugger switches
because they implement pretty much the same functionality but let's
leave them in for now for the sake of convenience and backwards
compatibility.

Fixes #6526.
2013-11-16 14:53:56 +01:00
Trevor Norris c414ec1c2c smalloc: check if object has external memory
Add HasExternalData API to check if Object has externally allocated
memory, and accompanying tests.
2013-11-13 15:29:50 -08:00
Fedor Indutny 65b127572f tls: handle `ssl.start()` errors 2013-11-13 17:09:25 +04:00
Tim Wood c9d93f3431 events: don't call once twice
Emitting an event within a `EventEmitter#once` callback of the same
event name will cause subsequent `EventEmitter#once` listeners of the
same name to be called multiple times.

    var emitter = new EventEmitter();

    emitter.once('e', function() {
      emitter.emit('e');
      console.log(1);
    });

    emitter.once('e', function() {
      console.log(2);
    });

    emitter.emit('e');

    // Output
    // 2
    // 1
    // 2

Fix the issue, by calling the listener method only if it was not
already called.
2013-11-13 03:21:04 +04:00
Maciej Małecki 568072ceae repl: do not insert duplicates into completions
Fix invalid `hasOwnProperty` function usage.

For example, before in the REPL:

```
> Ar<Tab>
Array

Array        ArrayBuffer
```

Now:

```
> Ar<Tab>
Array

ArrayBuffer
```

Fixes #6255.
Closes #6498.
2013-11-11 15:45:09 -08:00
Ben Noordhuis f230a1cf74 v8: upgrade to 3.22.24
This commit removes the simple/test-event-emitter-memory-leak test for
being unreliable with the new garbage collector: the memory pressure
exerted by the test case is too low for the garbage collector to kick
in.  It can be made to work again by limiting the heap size with the
--max_old_space_size=x flag but that won't be very reliable across
platforms and architectures.
2013-11-11 02:40:36 +01:00
Fedor Indutny ac2263b77f tls: prevent stalls by using read(0)
Do not `.push()` the same data as just passed to `.ondata()`, it
may be read by 'data' event listeners.

fix #6277
2013-11-09 02:07:36 +04:00
isaacs ea8feced87 http: force socket encoding to be null
Otherwise the string triggers an assertion error in node_http_parser.c,
line 370:

    assert(Buffer::HasInstance(args[0]) == true);

because the first argument is not a Buffer object.
2013-11-07 08:24:50 -08:00
fengmk2 1ce5db4d95 http: cleanup freeSockets when socket destroyed
If the socket was destroyed, we need to remove it from the agent's
`freeSockets` list, otherwise dead socket could be reused by new
request.
2013-11-07 11:42:41 +04:00
Fedor Indutny a6ddfe20d2 tls: more accurate wrapping of connecting socket
When socket, passed in `tls.connect()` `options` argument is not yet
connected to the server, `_handle` gets assigned to a `net.Socket`,
instead of `TLSSocket`.

When socket is connecting to the remote server (i.e. not yet connected,
but already past dns resolve phase), derive `_connecting` property from
it, because otherwise `afterConnect()` will throw an assertion.

fix #6443
2013-11-05 18:14:28 +04:00
Ben Noordhuis 515607a740 fs: make fs.watch() non-recursive by default
Fixes a behavioral regression introduced in commit 691b9eb.
2013-11-05 08:27:05 +01:00
Nathan Rajlich 9bc53d887a http: make DELETE requests set `req.method`
Fixes #6461.
2013-11-04 09:39:29 -08:00
Erik Dubbelboer bb909ad642 tls: add ECDH ciphers support
Switch test fixtures to 1024 bit keys.
2013-10-30 08:34:47 +01:00
Trevor Norris d2a600200e test: fix async listener test for windows 2013-11-01 16:36:23 -07:00
Jacob Groundwater 005cc05a56 test: add additional async listener tests 2013-10-31 17:10:23 -07:00
Trevor Norris bc39bdd995 domain: use AsyncListener API
The domain module has been switched over to use the domain module API as
much as currently possible. There are still some hooks in the
EventEmitter, but hopefully we can remove those in the future.
2013-10-31 16:34:35 -07:00
Trevor Norris 66d908f09a crypto: convert RandomBytesRequest to a class
Since RandomBytesRequest makes a call to MakeCallback, needed it to be
a class so AsyncWrap could handle any async listeners.

Also added a simple test for an issue had during implementation where
the memory was being released and returned.
2013-10-31 16:34:35 -07:00
Trevor Norris ccec14b568 async-wrap: add methods to udp/tcp/pipe/timers
Now it's possible to add/remove an async listener to an individual
handle created by UDP, TCP, Pipe or Timer.
2013-10-31 16:34:11 -07:00
Trevor Norris efa62fd9cc node: add AsyncListener support
AsyncListener is a JS API that works in tandem with the AsyncWrap class
to allow the user to be alerted to key events in the life cycle of an
asynchronous event. The AsyncWrap class has its own MakeCallback
implementation that core will be migrated to use, and uses state sharing
techniques to allow quicker communication between JS and C++ whether the
async event callbacks need to be called.
2013-10-31 14:17:51 -07:00
Fedor Indutny 21fbbd5790 test: fix tls-client-reject after ba7c9ce96 2013-10-31 23:39:43 +04:00
Fedor Indutny 5977cba985 tls: reuse hostname from underlying net.Socket
When `tls.connect()` is called with `socket` option, it should try to
reuse hostname previously passed to `net.connect()` and only after that
fall back to `'localhost'`.

fix #6409
2013-10-31 01:57:17 +04:00
Nick Simmons 691b9ebc8c fs: add recursive subdirectory support to fs.watch
Currently fs.watch does not have an option to specify if a directory
should be recursively watched for events across all subdirectories.

Several file watcher APIs support this. FSEvents on OS X > 10.5 is
one example. libuv has added support for FSEvents, but fs.watch had
no way to specify that a recursive watch was required.

fs.watch now has an additional boolean option 'recursive'. When set
to true, and when supported, fs.watch will return notifications for
the entire directory tree hierarchy rooted at the specified path.
2013-10-31 01:13:44 +04:00
Thom Seddon f755ecf484 src: accept passphrase when crypto signing with private key
Previous behaviour was to drop to an openssl prompt
("Enter PEM pass phrase:") when supplying a private key with a
passphrase. This change adds a fourth, optional, paramter that
will be used as the passphrase.
To include this parameter in a backwards compatible way it was
necessary to expose the previously undocumented (and unexposed)
feature of being able to explitly setting the output encoding.
2013-10-29 14:19:47 +04:00
Trevor Norris 8130744044 dgram: send() can accept strings
Strings passed to Socket#send() will be passed to Buffer and parsed as
UTF8.
2013-10-28 16:18:18 -07:00
isaacs 3c5ea410ca vm: Copy missing properties from context
This addresses a current shortcoming of the V8 SetNamedPropertyHandler
function.

It does not provide a way to intercept Object.defineProperty(..) calls.
As a result, these properties are not copied onto the contextified
sandbox when a new global property is added via either a function
declaration or a Object.defineProperty(global, ...) call.

Note that any function declarations or Object.defineProperty() globals
that are created asynchronously (in a setTimeout, callback, etc.) will
happen AFTER the call to copy properties, and thus not be caught.

The way to properly fix this is to add some sort of a
Object::SetNamedDefinePropertyHandler() function that takes a callback,
which receives the property name and property descriptor as arguments.

Luckily, such situations are rare, and asynchronously-added globals
weren't supported by Node's VM module until 0.12 anyway.  But, this
should be fixed properly in V8, and this copy function should be removed
once there is a better way.

Fix #6416
2013-10-28 08:43:43 -07:00
Ben Noordhuis 4c0195e034 http: remove MethodToString()
The list of supported HTTP methods is available in JS land now so there
is no longer any need to pass a stringified version of the method to the
parser callback, it can look up the method name for itself.

Saves a call to v8::Eternal::Get() in the common case and a costly
v8::String::NewFromOneByte() in the uncommon case.
2013-10-28 13:57:22 +01:00
Ben Noordhuis 610022851a http: expose supported methods
Expose the list of supported HTTP methods as a property on the 'http'
module object.

Fixes #6422.
2013-10-28 13:35:34 +01:00
Timothy J Fontaine 61ccaf9a97 Merge remote-tracking branch 'upstream/v0.10'
Conflicts:
	ChangeLog
	deps/uv/ChangeLog
	deps/uv/include/uv-darwin.h
	deps/uv/src/unix/fsevents.c
	deps/uv/src/unix/process.c
	deps/uv/src/version.c
	doc/api/addons.markdown
	doc/api/cluster.markdown
	doc/api/http.markdown
	lib/http.js
	lib/tls.js
	src/node_crypto.cc
	src/node_http_parser.cc
	src/node_version.h
	src/pipe_wrap.cc
	src/v8abbr.h
	src/v8ustack.d
	test/simple/test-http-pipeline-flood.js
2013-10-25 11:26:05 -07:00
isaacs f153d6da45 http client: pull last chunk on socket close
When the socket closes, the client's http incoming message object was
emitting an 'aborted' event if it had not yet been ended.

However, it's possible, when a response is being repeatedly paused and
resumed (eg, if piped to a slow FS write stream), that there will be a
final chunk remaining in the js-land buffer when the socket is torn
down.

When that happens, the socketCloseListener function detects that we have
not yet reached the end of the response message data, and treats this as
an abrupt abort, immediately (and forcibly) ending the incoming message
data stream, and discarding that final chunk of data.

The result is that, for example, npm will have problems because tarballs
are missing a few bytes off the end, every time.

Closes GH-6402
2013-10-23 13:39:05 -07:00
Ben Noordhuis 0079e575e0 test: fix up weakref.cc after v8 api change 2013-10-23 09:17:32 -07:00
Ben Noordhuis ef4a35bca5 src: update after v8 api changes 2013-10-23 09:17:31 -07:00
Timothy J Fontaine 5e41c022af crypto: clear errors from verify failure
OpenSSL will push errors onto the stack when a verify fails, which can
disrupt TLS and other routines if we don't clear the error stack

Fixes #6304
2013-10-18 14:14:21 -07:00
Patrik Stutz 54910044b3 http: add statusMessage
Now the status message can be set via req.statusMessage = 'msg';
2013-10-16 18:34:52 -07:00
isaacs b97c28f59e http: provide backpressure for pipeline flood
If a client sends a lot more pipelined requests than we can handle, then
we need to provide backpressure so that the client knows to back off.
Do this by pausing both the stream and the parser itself when the
responses are not being read by the downstream client.

Backport of 085dd30
2013-10-16 17:12:34 -07:00
Ben Noordhuis a2d1cbef6b dns: set hostname property on error object
Make debugging and logging easier: when a DNS lookup for a hostname
fails, set the hostname as a property on the error object.

Fixes #5393.
2013-10-16 21:56:16 +02:00
Ben Noordhuis 4234bcce48 debugger: fix SIGUSR1 bootstrap race condition
Before this commit, the SIGUSR1 signal handler wasn't installed until
late in the bootstrapping process and we were prone to miss signals
sent by other processes.

This commit installs an early-boot signal handler that merely records
the fact that we received a signal.  Once the debugger infrastructure
is in place, the signal is re-raised, kickstarting the debugger.

Among other things, this means that simple/test-debugger-client is
now _much_ less likely to fail.
2013-10-16 20:24:14 +02:00
Ben Noordhuis ca363cf1ae debugger: make busy loops SIGUSR1-interruptible
Commit 30e5366b ("core: Use a uv_signal for debug listener") changed
SIGUSR1 handling from a signal handler to libuv's uv_signal_*()
functionality to fix a race condition (and possible hang) in the
signal handler.

While a good change in itself, it made it impossible to interrupt
long running scripts.  When a script is stuck in a busy loop, control
never returns to the event loop, which in turn means the signal
callback - and therefore the debugger - is never invoked.

This commit changes SIGUSR1 handling back to a normal signal handler
but one that treads _very_ carefully.
2013-10-16 20:24:13 +02:00
isaacs 085dd30e93 http: provide backpressure for pipeline flood
If a client sends a lot more pipelined requests than we can handle, then
we need to provide backpressure so that the client knows to back off.
Do this by pausing both the stream and the parser itself when the
responses are not being read by the downstream client.

Fix GH-6214
2013-10-16 11:01:33 -07:00
Jason Gerfen 7bf46ba4ce crypto: add SPKAC support
Implements new class 'Certificate' within crypto object for working
with SPKAC's (signed public key & challenge) natively.
2013-10-16 09:43:19 -07:00
isaacs d9b4cc323f Revert "crypto: add SPKAC support"
This reverts commit 7f66e44dc1.
2013-10-15 15:58:58 -07:00
Jason Gerfen 7f66e44dc1 crypto: add SPKAC support
Implements new class 'Certificate' within crypto object for working
with SPKAC's (signed public key & challenge) natively.
2013-10-13 10:31:20 +02:00
Rod Vagg 684dd28a6c util: format as Error if instanceof Error 2013-10-15 10:30:58 +02:00
Ben Noordhuis 45885a1e8c cluster: fix premature 'disconnect' event
Don't emit the 'disconnect' event until all workers have gone away.
Before this commit, the event was emitted when all open handles were
closed, which usually - but not always - amounts to the same thing.

Fixes #6346.
2013-10-14 11:46:09 +02:00
Trevor Norris 8a295cd520 buffer: add buf.toArrayBuffer() API 2013-10-11 12:17:23 -07:00
Glen Mailer 66b8c3c5a0 assert: indicate if exception message is generated
AssertionError.generatedMessage is now true when
AssertionError.message was generated from expected and actual

Fixes #5836, #6206
2013-10-11 10:15:03 -07:00
Dave Pacheco 720675e7db test: use proper findjsobjects output format
Closes #6329
2013-10-10 15:45:25 -07:00
Ben Noordhuis b011811a9f fs: fix fs.truncate() file content zeroing bug
fs.truncate() and its synchronous sibling are implemented in terms of
open() + ftruncate().  Unfortunately, it opened the target file with
mode 'w' a.k.a. 'write-only and create or truncate at open'.

The subsequent call to ftruncate() then moved the end-of-file pointer
from zero to the requested offset with the net result of a file that's
neatly truncated at the right offset and filled with zero bytes only.

This bug was introduced in commit 168a5557 but in fairness, before that
commit fs.truncate() worked like fs.ftruncate() so it seems we've never
had a working fs.truncate() until now.

Fixes #6233.
2013-10-08 11:35:12 +02:00
Ben Noordhuis f311963ff9 test: update require path after file move
Commit 204228b moved a few slow tests to pummel but I forgot to update
the require() path in pummel/test-debugger-repl-break-in-module.  Mea
culpa.
2013-10-01 02:55:32 +02:00
Alex Kocharin 60a1dbddd2 debugger: repeat last command
Regression introduced by commit 9ef9a9d.
2013-10-01 11:13:58 +02:00
Timothy J Fontaine eb091458c0 test: add regression test for #6235 2013-09-26 10:07:18 -07:00
Timothy J Fontaine 42af62f33a Merge remote-tracking branch 'upstream/v0.10'
Conflicts:
	AUTHORS
	ChangeLog
	configure
	deps/uv/ChangeLog
	deps/uv/src/version.c
	lib/tls.js
	src/node_version.h
2013-09-24 16:49:01 -07:00
Fedor Indutny 42acbf809b tls: wrap tls inside tls using legacy API
Allow wrapping TLSSocket inside another TLSSocket, emulate it using
SecurePair in legacy APIs.

fix #6204
2013-09-24 20:46:59 +04:00
Eric Schrock 35ae696822 readline: handle input starting with control chars
Handle control characters only when there is a single byte in the
stream, otherwise fall through to the standard multibyte handling.
2013-09-23 14:22:37 -07:00
Ben Noordhuis a0f79867dc src: initialize c-ares task list on env init
Don't forget to initialize the c-ares task tree head when creating a
new Environment.  Oversight from the multi-context work that landed
in commit 756b622.

Fixes #6244.
2013-09-20 09:39:14 -07:00
Maciej Małecki d80d131c75 net: add a port validation to `connect`
Fix "Assertion failed" when trying to connect to non-int ports:

    Assertion failed: (args[2]->Uint32Value()), function Connect,
    file ../src/tcp_wrap.cc, line 379.
    Abort trap: 6
2013-09-19 12:38:29 +02:00
Fedor Indutny 59a075e108 contextify: fix ContextifyContext leak
Apparently, context->Global() won't be destroyed if the context itself
isn't marked as weak and independent.

Also, the weakness flag should be cleared once the weak callback is
executed, otherwise we'll get crashes in Debug builds.

fix #6115 and #6201
2013-09-15 00:56:11 +04:00
Nathan Rajlich f31037ddfe http: don't pass the request options to Agent
The `options` that were being passed in before here are specific to a
single request, which kinda defeats the purpose of using an Agent in the
first place.

On a worse note, these `options` have not yet been "processed" by the
`http.ClientRequest` class, so if `port: null` is set (like it is as the
result of a `url.parse()` call), then they take preference over the
processed values since the agent's "options" get mixed in last in the
`createSocket()` function.

Fixes #6197.
Fixes #6199.
Closes #6231.
2013-09-14 12:29:48 -07:00
Nathan Rajlich 7196742852 tls: don't push() incoming data when ondata is set
Otherwise the data ends up "on the wire" twice, and
switching between consuming the stream using `ondata`
vs. `read()` would yield duplicate data, which was bad.
2013-09-13 10:08:35 -07:00
Fedor Indutny 3d4c663ee6 contextify: dealloc only after global and sandbox
Functions created using: `vm.runInNewContext('(function() { })')` will
reference only `proxy_global_` object and not `sandbox_`. Thus in case,
where there're no references to sandbox (such as in example above),
`ContextifyContext` will be destroyed and use-after-free might happen.
2013-09-12 19:40:43 +04:00
Fedor Indutny 1c3863abfd tls: fix setting NPN protocols
The NPN protocols was set on `require('tls')` or `global` object instead
of being a local property. This fact lead to strange persistence of NPN
protocols, and sometimes incorrect protocol selection (when no NPN
protocols were passed in client options).

fix #6168
2013-09-09 18:18:05 +04:00
Ben Noordhuis 204228b57f test: move slow tests to test/pummel/
Slowness being somewhat subjective but determined by running the
test suite a few times and picking off everything that consistently
clocks in at 2 seconds or more.

Honorable mention for simple/test-tls-server-large-request, it often
runs for 10 (!) seconds or more.
2013-09-09 11:05:40 +02:00
isaacs b30a03eda0 process: use exit 1 for uncaughtException
Since it is Unix tradition to use exit code 1 for general-purpose script
bail-out, and the way of doing that in Node is to throw an exception and
not catch it, it makes the most sense to exit with 1 when an exception
goes uncaught.

Move the `Invalid Argument` exit to 9, so that it's something specific,
and clear that it's a node internal error.

Also, document the exit codes that we use.
2013-09-06 18:23:15 -07:00