Commit Graph

2329 Commits (70cc9968f667ce110a3a99db6a24b64eb8a3c32e)

Author SHA1 Message Date
Julien Gilli 6f043940bd timers: fix timers with non-integer delay hanging.
When backporting f8193ab into v0.10, a regression was introduced. Timers
with non-integer timeout could trigger a infinite recursion with 100%
cpu usage. This commit backports 93b0624 which fixes the regression.

After backporting f8193ab, instead of using Date.now(), timers would use
Timer.now() to determine if they had expired. However, Timer.now() is
based on loop->time, which is not updated when a timer's remaining time
is > 0 and < 1. Timers would thus never timeout if their remaining time
was at some point > 0 and < 1.

With this commit, Timer.now() updates loop->time itself, and timers
always timeout eventually.

Fixes #8065 and #8068.
2014-08-04 12:00:40 -07:00
Sam Roberts 2fd7ee12d9 cluster: disconnect should not be synchronous
Callbacks in node are usually asynchronous, and should never be
sometimes synchronous, and sometimes asynchronous.

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-08-02 00:41:13 -07:00
James Halliday 8e2cc69e78 stream: fix Readable.wrap objectMode falsy values
A streams1 stream will have its falsy values such as 0, false, or ""
eaten by the upgrade to streams2, even when objectMode is enabled.

Include test for said cases.

Reviewed-by: isaacs <i@izs.me>
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-08-01 13:01:23 -07:00
Julien Gilli befbbad051 timers: backport f8193ab
Original commit message:

 timers: use uv_now instead of Date.now

 This saves a few calls to gettimeofday which can be expensive, and
 potentially subject to clock drift. Instead use the loop time which
 uses hrtime internally.

In addition to the backport, this commit:
 - keeps _idleStart timers' property which is still set to
   Date.now() to avoid breaking existing code that uses it, even if
   its use is discouraged.
 - adds automated tests. These tests use a specific branch of
   libfaketime that hasn't been submitted upstream yet. libfaketime
   is git cloned if needed when running automated tests.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-07-31 08:53:24 -07:00
Fedor Indutny 38f6fcd822 buffer: fix sign overflow in `readUIn32BE`
`|` operation takes precendence on `+`, which will result in
`new Buffer('ffffffff', 16).readUInt32BE(0)` returning `-1` instead of
`ffffffff`.
2014-07-29 12:34:49 +04:00
Fedor Indutny 338ba2bc80 test: fix test-https-foafssl 2014-07-23 23:55:24 +04:00
Fedor Indutny 93390ffc20 test: fix test-tls-server-verify
fix #7963
2014-07-23 23:51:14 +04:00
Chris Dickinson a96d6603b3 stream2: flush extant data on read of ended stream
A ReadableStream with a base64 StringDecoder backed by only
one or two bytes would fail to output its partial data before
ending. This fix adds a check to see if the `read` was triggered
by an internal `flow`, and if so, empties any remaining data.

fixes #7914.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-07-15 12:38:23 +04:00
Fedor Indutny 11337db35f deps: cherry-pick eca441b2 from OpenSSL
Original commit message:

    bn_exp.c: fix x86_64-specific crash with one-word modulus.

    PR: #3397

Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-07-03 00:46:17 +04:00
Fedor Indutny 4128d4d2ba Revert "stream: start old-mode read in a next tick"
This reverts commit 2efe4ab761.
2014-06-30 13:06:35 +04:00
Fedor Indutny a97bdef06d zlib: do not crash on write after close
fix #7767

Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-06-27 17:02:02 +04:00
Felix Geisendörfer 0da4c67165 string_bytes: Guarantee valid utf-8 output
Previously v8's WriteUtf8 function would produce invalid utf-8 output
when encountering unmatched surrogate code units [1]. The new
REPLACE_INVALID_UTF8 option fixes that by replacing invalid code points
with the unicode replacement character.

[1]: JS Strings are defined as arrays of 16 bit unsigned integers. There
is no unicode enforcement, so one can easily end up with invalid unicode
code unit sequences inside a string.
2014-06-06 15:07:29 -07:00
Felix Geisendörfer 22b839845c string_decoder: Improve test coverage
The test cases are still essentially the same, but now all possible ways
of writing a buffer into the decoder are tested, which has exposed a few
failing scenarios that had not been discovered so far!
2014-06-06 15:07:29 -07:00
Fedor Indutny 2efe4ab761 stream: start old-mode read in a next tick
Calling `.read()` in the same tick with `.on('data', ...)` may cause
users missing `error` events, because no `error` listeners were set yet.

fix #7618
2014-06-05 21:12:07 -07:00
Greg Sabia Tucker 92875501d2 child_process: spawn() does not throw TypeError
Ensure TypeError is thrown, fix a bug where `env` option was
assuming the option was actually an object.

This case is especially bad because it then sets `env == null`
instead of using `process.env`.

Fix #7456

Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-05-13 12:25:00 +04:00
Ben Noordhuis 17fbdc18b8 lib: name EventEmitter prototype methods
Before this commit the EventEmitter methods were anonymous functions.
V8 tries to infer names for anonymous functions based on the execution
context but it frequently gets it wrong and when that happens, the
stack trace is usually confusing and unhelpful.  This commit names all
methods so V8 can fall back to the method.name property.

The above gotcha applies to all anonymous functions but is exacerbated
for EventEmitter methods because those are invoked with a plenitude of
different receivers.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-05-07 12:11:57 -07:00
Rod Vagg 250782d139 util: format as Error if instanceof Error
Conflicts:
	lib/util.js
	test/simple/test-util-format.js

This is a backport to fix #7253

Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-04-26 00:52:49 +04:00
isaacs 9520adeb37 url: treat \ the same as /
See https://code.google.com/p/chromium/issues/detail?id=25916

Parse URLs with backslashes the same as web browsers, by replacing all
backslashes with forward slashes, except those that occur after the
first # character.
2014-04-15 15:30:43 -07:00
Fedor Indutny 1bd4f3a605 child_process: fix deadlock when sending handles
Fix possible deadlock, when handles are sent in both direction
simultaneously. In such rare cases, both sides may queue their
`NODE_HANDLE_ACK` replies and wait for them.

fix #7465
2014-04-14 20:15:09 +04:00
Fedor Indutny f2b297cc7c 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-04-08 00:40:22 +04:00
Fedor Indutny f0d870501e crypto: do not lowercase cipher/hash names
`crypto.getCiphers()` and `crypto.getHashes()` should prefer lower-case
variants of names, but should not introduce them.

fix #7282
2014-03-11 01:08:43 +04:00
Benoit Vallée a9d24fa40d test: test sending a handle twice
Added test-cluster-send-handle-twice.js testing to send a handle
twice to the parent process.
2014-03-05 09:36:32 -08:00
Greg Brail 6eb4d1d15c timer: don't reschedule timer bucket in a domain
If two timers run on the same tick, and the first timer uses a domain,
and then catches an exception and disposes of the domain, then the
second timer never runs. (And even if the first timer does not dispose
of the domain, the second timer could run under the wrong domain.)

This happens because timer.js uses "process.nextTick()" to schedule
continued processing of the timers for that tick. However, there was
an exception inside a domain, then "process.nextTick()" runs under
the domain of the first timer function, and will do nothing if
the domain has been disposed.

To avoid this, we temporarily save the value of "process.domain"
before calling nextTick so that it does not run inside any domain.
2014-03-03 17:46:49 -08:00
Timothy J Fontaine 06453a94a7 src: domain should not replace nextTick function
Previously if you cached process.nextTick and then require('domain')
subsequent nextTick() calls would not be caught because enqueued
functions were taking the wrong path. This keeps nextTick to a single
function reference and changes the implementation details after domain
has been required.
2014-03-03 16:27:58 -08:00
Nathan Rajlich 47abdd9c43 test: add `agent: null` http client request test
This is just the test portion from #7012 / #7189,
but targetted for the v0.10 branch.
2014-02-26 11:39:53 -08:00
Nathan Rajlich 0a01a42e87 http: invoke createConnection when no agent
This makes it so that the user may pass in a
`createConnection()` option, and they don't have
to pass `agent: false` at the same time.

Also adding a test for the `createConnection` option,
since none was in place before.

See #7014.
2014-02-26 11:14:32 -08:00
Mike Pennisi aae51ecf7d assert: Ensure reflexivity of deepEqual
Ensure that the behavior of `assert.deepEqual` does not depend on
argument ordering  when comparing an `arguments` object with a
non-`arguments` object.
2014-02-25 20:32:49 +04:00
Timothy J Fontaine 3e6e63406d test: make test-net-error-twice less racey 2014-02-18 13:10:09 -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
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 dee5270a6c net: do not re-emit stream errors
fix #7015
2014-02-10 10:59:52 -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
iamdoron 1317032c97 fs: make unwatchFile() insensitive to path 2014-02-06 13:04:35 +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
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 00efcb4cd7 net: reset `endEmitted` on reconnect
fix #6908
2014-01-25 12:20:45 -08: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
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 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
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
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
Timothy J Fontaine 6f8aa24d1e test: fix test-cluster-eaccess to work on windows 2013-12-31 11:57:13 -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
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 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
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