Commit Graph

9519 Commits (82c2084b4ebb431153b54e598c70ced74217af79)

Author SHA1 Message Date
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
Fedor Indutny 970bdccc38 deps: update v8 to 3.20.17.11
fix #6235
2013-09-23 20:26:57 +04:00
Ben Noordhuis 75ea566f5a src: fix v8 PRNG entropy seeding
It was pointed out by a member of the V8 team that the call to
V8::SetEntropySource() should come before V8::Initialize().

See also commit 7ac2391.
2013-09-23 14:27:35 +02:00
Ben Noordhuis 7ac23910c5 src: seed V8's random number generator at startup
The default entropy source is /dev/urandom on UNIX platforms, which is
okay but we can do better by seeding it from OpenSSL's entropy pool.

On Windows we can certainly do better; on that platform, V8 seeds the
random number generator using only the current system time.

Fixes #6250.
2013-09-20 22:11:42 +02:00
Ben Noordhuis 03738183c7 dns: fix c-ares error reporting regression
The test case from the previous commit exposed a regression in the way
that c-ares errors are reported to JS land.  Said regression was
introduced in commit 756b622 ("src: add multi-context support").

Fixes the following test failure:

    $ out/Release/node test/simple/test-dns-regress-6244
    util.js:675
      var errname = uv.errname(err);
                       ^
    Error: err >= 0
        at Object.exports._errnoException (util.js:675:20)
        at errnoException (dns.js:43:15)
        at Object.onresolve [as oncomplete] (dns.js:145:19)

lib/dns.js erroneously assumed that the error code was a libuv error
code when it's really a c-ares status code.  Libuv handles getaddrinfo()
style lookups (which is by far the most common type of lookup), that's
why this bug wasn't discovered earlier.
2013-09-20 09:39:14 -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
Ben Noordhuis 7c554a5cd0 doc: document reserved status of SIGUSR1
Fixes #1212.
2013-09-19 12:31:52 +02:00
Fedor Indutny a1cf3ada62 deps: update v8 to 3.20.17.7 2013-09-18 20:33:28 +04:00
Nathan Rajlich 5bda2bed37 doc: fix typos in the tls `NPNProtocols` option 2013-09-16 13:57:34 -07:00
Nathan Rajlich afabdf0e15 doc: specify the format of the `ca` tls option 2013-09-16 13:57:00 -07: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
Ben Noordhuis 9fad8e5dc4 doc: fix blog link in blog posts and README
Apparently Joyent decommissioned joyeur.com but at least they saved the
contents of the blog.  Update the links in the README and the nodejs.org
blog posts.

Hat tip to Eugen Pirogoff (@eugenpirogoff) for pointing it out.

Fixes #6224.
2013-09-13 14:55:08 +02: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
Trevor Norris 59dac01e4e buffer: optimize common encoding cases
String#toLowerCase() is incredibly slow and was costing a 15-30%
performance hit for Buffers less than 1KB. Now instead it'll attempt to
find the correct encoding directly from the passed encoding, only then
afterwards it'll lowercase.

The optimization for not passing any encoding at all is still at the top
of the method.

At most this may add 10% performance hit for passing a mixed case
encoding.
2013-09-09 19:39:21 -07: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
Andrei Sedoi 3546825b14 configure: add mips-float-abi (soft, hard) option 2013-09-07 22:25:50 +02:00
isaacs 1c58a07dd4 Merge remote-tracking branch 'ry/v0.10' 2013-09-07 14:31:27 -05:00
isaacs ebeae2df51 npm: upgrade to 1.3.11 2013-09-07 14:31:04 -05: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
isaacs 39aafcf801 process: Fix regression from a5dba82
Respect numeric string args to process.exit(code)
2013-09-06 18:23:15 -07:00
isaacs 6808706c3b process: Use exit code 8 consistently
This should always be used in the case of an uncaughtException
2013-09-06 17:08:56 -07:00
isaacs a5dba82ee2 process: Add exitCode property
This allows one to set a specific status code, while still letting the
process exit gracefully once all async operations are completed.
2013-09-06 16:51:51 -07:00
Ben Noordhuis b89b97dded src: fix multi-base class ObjectWrap::Unwrap<T>()
Fix pointer unwrapping when T is a class with more than one base class.

Before this commit, the wrapped void* pointer was cast directly to T*
without going through ObjectWrap* first, possibly leading to a class
instance pointer that points to the wrong vtable.

This change required some cleanup in various files; some classes
used private rather than public inheritance, others didn't derive
from ObjectWrap at all...

Fixes #6188.
2013-09-06 21:19:55 +02:00
Ben Noordhuis 756b622295 src: add multi-context support
This commit makes it possible to use multiple V8 execution contexts
within a single event loop.  Put another way, handle and request wrap
objects now "remember" the context they belong to and switch back to
that context when the time comes to call into JS land.

This could have been done in a quick and hacky way by calling
v8::Object::GetCreationContext() on the wrap object right before
making a callback but that leaves a fairly wide margin for bugs.

Instead, we make the context explicit through a new Environment class
that encapsulates everything (or almost everything) that belongs to
the context.  Variables that used to be a static or a global are now
members of the aforementioned class.  An additional benefit is that
this approach should make it relatively straightforward to add full
isolate support in due course.

There is no JavaScript API yet but that will be added in the near
future.

This work was graciously sponsored by GitHub, Inc.
2013-09-06 05:51:42 +02:00
Ben Noordhuis 81655a224a test: don't call process.exit() in debugger tests
process.exit() tends to hide bugs, both in tests and node.js.
Rewrite the tests so that the event loop exits naturally.
2013-09-06 04:40:24 +02:00
isaacs aaf4f8d685 Merge remote-tracking branch 'ry/v0.10'
Conflicts:
	deps/uv/ChangeLog
	deps/uv/src/version.c
	deps/uv/src/win/fs.c
	lib/_stream_transform.js
2013-09-05 17:16:17 -07:00
isaacs 1be09dfc25 npm: upgrade to v1.3.10 2013-09-05 17:13:50 -07:00
Trevor Norris f218d94af4 handle_wrap: properly don't abort on unwrap
From commit 756ae2c all the WRAP/UNWRAP were moved to a single location
for ease of use. In a single location NO_ABORT should have been used but
wasn't. This caused HandleWrap::Close to abort. Below is the applicable
code change as demonstration there was no abort specified when
unwrapping the object.

 void HandleWrap::Close(const FunctionCallbackInfo<Value>& args) {
    HandleScope scope(node_isolate);

     -  HandleWrap *wrap = static_cast<HandleWrap*>(
     -      args.This()->GetAlignedPointerFromInternalField(0));
     +  HandleWrap* wrap;
     +  UNWRAP(args.This(), HandleWrap, wrap);

Also included a test that will reproduce the abort.
2013-09-05 15:56:34 -07:00
isaacs 1da7bcc22c stream: objectMode transforms allow falsey values
Closes #6183
2013-09-05 13:19:23 -07:00
Ben Noordhuis 6df4741f84 src: fix solaris 10 build error
Stop gcc from getting confused, explicitly cast the return value from
getuid() and getgid() to uint32_t.  Fixes the following build error:

    ../src/node.cc: In function 'void node::GetUid(const
    v8::FunctionCallbackInfo<v8::Value>&)':
    ../src/node.cc:1552:37: error: call of overloaded 'Set(uid_t)' is
    ambiguous
    ../src/node.cc:1552:37: note: candidates are:
    ../deps/v8/include/v8.h:5939:6: note: void
    v8::ReturnValue<T>::Set(bool) [with T = v8::Value]
    ../deps/v8/include/v8.h:5909:6: note: void
    v8::ReturnValue<T>::Set(double) [with T = v8::Value]
    ../deps/v8/include/v8.h:5915:6: note: void
    v8::ReturnValue<T>::Set(int32_t) [with T = v8::Value, int32_t = int]
    ../deps/v8/include/v8.h:5926:6: note: void
    v8::ReturnValue<T>::Set(uint32_t) [with T = v8::Value, uint32_t =
    unsigned int]

Fixes #6182.
2013-09-05 21:47:10 +02:00
Ben Noordhuis b4b3a4deaf test: move slow test from simple/ to pummel/
Move simple/test-http-many-keep-alive-connections to the pummel/
directory, it takes about 2.5 seconds to complete.
2013-09-05 21:04:31 +02:00
Bert Belder 6301613ff5 uv: upgrade to v0.10.16 2013-09-05 16:50:47 +02:00
Fedor Indutny af76b08666 tls: socket.renegotiate(options, callback)
This utility function allows renegotiaion of secure connection after
establishing it.

fix #2496
2013-09-05 18:10:31 +04:00
Timothy J Fontaine 8ee50cea40 Merge remote-tracking branch 'upstream/v0.10'
Conflicts:
	ChangeLog
	src/node_version.h
2013-09-04 15:34:32 -07:00
Timothy J Fontaine 8b05206665 blog: Post for v0.11.7 2013-09-04 15:27:06 -07:00
Timothy J Fontaine 5b1a0e6ef8 Now working on 0.11.8 2013-09-04 15:18:20 -07:00
Timothy J Fontaine 5a6b2853c3 Merge branch 'v0.11.7-release' 2013-09-04 15:18:09 -07:00
Timothy J Fontaine be52549bfa 2013.08.21, Version 0.11.7 (Unstable)
* uv: upgrade to v0.11.13

* v8: upgrade to 3.20.17

* buffer: adhere to INSPECT_MAX_BYTES (Timothy J Fontaine)

* buffer: fix regression for large buffer creation (Trevor Norris)

* buffer: don't throw if slice length too long (Trevor Norris)

* buffer: Buffer(buf) constructor copies into the proper buffer (Ben Noordhuis)

* cli: remove --max-stack-size (Ben Noordhuis)

* cli: unknown command line options are errors (Ben Noordhuis)

* child_process: exec accept buffer as an encoding (Seth Fitzsimmons)

* crypto: make randomBytes/pbkdf2 callbacks domain aware (Ben Noordhuis)

* domain: deprecate domain.dispose(). (Forrest L Norvell)

* fs: Expose birthtime on stat objects (isaacs)

* http: Only send connection:keep-alive if necessary (isaacs)

* repl: Catch syntax errors better (isaacs, Nathan Rajlich)

* stream: change default highWaterMark for objectMode to 16 (Mathias Buus)

* stream: make setEncoding/pause/resume chainable (Julian Gruber, isaacs)

* util: pass opts to custom inspect functions (Timothy J Fontaine)

* vm: rewritten to behave like Contextify (Domenic Denicola)
2013-09-04 14:01:26 -07:00
Timothy J Fontaine 9c19c1e19c blog: Post for v0.10.18 2013-09-04 11:25:19 -07:00
Timothy J Fontaine 65ed79a6dc Now working on 0.10.19 2013-09-04 11:25:19 -07:00
Timothy J Fontaine 86d881f888 Merge branch 'v0.10.18-release' into v0.10 2013-09-04 11:25:04 -07:00
isaacs 15a5a4a945 http: Only send connection:keep-alive if necessary
In cases where the Agent has maxSockets=Infinity, and
keepAlive=false, there's no case where we won't immediately close the
connection after the response is completed.

Since we're going to close it anyway, send a `connection:close` header
rather than a `connection:keep-alive` header.  Still send the
`connection:keep-alive` if the agent will actually reuse the socket,
however.

Closes #5838
2013-09-04 11:19:39 -07:00
isaacs 689e5c9d3d stream: return this from pause()/resume() 2013-09-04 11:17:28 -07:00
Julian Gruber f91b047891 stream: make setEncoding chainable 2013-09-04 11:15:55 -07:00
isaacs 9ef9a9dee5 repl: Simplify paren wrap, continuation-detection
This simplifies the logic that was in isSyntaxError, as well as the
choice to wrap command input in parens to coerce to an expression
statement.

1. Rather than a growing blacklist of allowed-to-throw syntax errors,
just sniff for the one we really care about ("Unexpected end of input")
and let all the others pass through.

2. Wrapping {a:1} in parens makes sense, because blocks and line labels
are silly and confusing and should not be in JavaScript at all.
However, wrapping functions and other types of programs in parens is
weird and required yet *more* hacking to work around.  By only wrapping
statements that start with { and end with }, we can handle the confusing
use-case, without having to then do extra work for functions and other
cases.

This also fixes the repl wart where `console.log)(` works in the repl,
but only by virtue of the fact that it's wrapped in parens first, as
well as potential side effects of double-running the commands, such as:

    > x = 1
    1
    > eval('x++; throw new SyntaxError("e")')
    ... ^C
    > x
    3
2013-09-04 11:13:41 -07:00