platform/upstream/nodejs.git
10 years agohttp: make OutgoingMessage._flush inline-able
isaacs [Thu, 15 Aug 2013 15:54:49 +0000 (08:54 -0700)]
http: make OutgoingMessage._flush inline-able

10 years agohttp: Add write()/end() callbacks
isaacs [Thu, 15 Aug 2013 15:51:37 +0000 (08:51 -0700)]
http: Add write()/end() callbacks

10 years agohttp: Write hex/base64 chunks properly
isaacs [Thu, 15 Aug 2013 05:14:49 +0000 (22:14 -0700)]
http: Write hex/base64 chunks properly

This removes a dubious performance "optimization" where strings body
chunks were concatenated to one another (and to the headers) without any
regard for their encoding.

10 years agodoc: http rawHeaders/rawTrailers
isaacs [Thu, 15 Aug 2013 21:12:12 +0000 (14:12 -0700)]
doc: http rawHeaders/rawTrailers

10 years agohttp: provide access to raw headers/trailers
isaacs [Tue, 6 Aug 2013 01:41:17 +0000 (18:41 -0700)]
http: provide access to raw headers/trailers

The format is [key,value,key,value,...] because that seems to have the
lowest overhead.

Close #4844

10 years agodoc: http keepalive, agent options
isaacs [Mon, 5 Aug 2013 04:30:23 +0000 (21:30 -0700)]
doc: http keepalive, agent options

Close #5839

10 years agohttp: add agent.maxFreeSockets option
isaacs [Mon, 5 Aug 2013 03:54:52 +0000 (20:54 -0700)]
http: add agent.maxFreeSockets option

10 years agotest: update tests after internal api change
Ben Noordhuis [Thu, 15 Aug 2013 20:20:04 +0000 (22:20 +0200)]
test: update tests after internal api change

Commit 0aa1335 changes the way timeout events are dispatched. Update
two tests that still used the old way.

10 years agonode: remove duplicate infoBox checks
Trevor Norris [Thu, 15 Aug 2013 19:31:38 +0000 (12:31 -0700)]
node: remove duplicate infoBox checks

These checks are now done in C++ and don't need to also be checked in
JS. Also remove a couple unused variables.

10 years agotimers: dispatch ontimeout callback by array index
Ben Noordhuis [Thu, 15 Aug 2013 17:23:36 +0000 (19:23 +0200)]
timers: dispatch ontimeout callback by array index

Achieve a minor speed-up by looking up the timeout callback on the timer
object by using an array index rather than a named property.

Gives a performance boost of about 1% on the misc/timers benchmarks.

10 years agosrc: add MakeCallback() that takes an array index
Ben Noordhuis [Thu, 15 Aug 2013 17:22:44 +0000 (19:22 +0200)]
src: add MakeCallback() that takes an array index

Internal helper function for dispatching by array index rather than
named property.

10 years agosmalloc: don't do Has(key), then Get(key)
Ben Noordhuis [Thu, 15 Aug 2013 14:41:19 +0000 (16:41 +0200)]
smalloc: don't do Has(key), then Get(key)

Don't check for the key first before retrieving it. Just fetch it and
check that it has the type we expect.

10 years agotools: cpplint: fix NOLINT(build/include_order)
Ben Noordhuis [Thu, 15 Aug 2013 12:17:41 +0000 (14:17 +0200)]
tools: cpplint: fix NOLINT(build/include_order)

And build/include, build/include_alpha and readability/streams
probably too, though those are currently unused and therefore untested.

10 years agozlib: replace C cast with static_cast
Ben Noordhuis [Wed, 14 Aug 2013 21:49:29 +0000 (23:49 +0200)]
zlib: replace C cast with static_cast

Seems to have escaped the Eye of Sauron^WFedor in commit 8e29ce9.

10 years agotls: handle errors on socket before releasing it
Fedor Indutny [Wed, 7 Aug 2013 12:50:36 +0000 (16:50 +0400)]
tls: handle errors on socket before releasing it

Fix sudden uncatchable ECONNRESETs, when using https server.

10 years agohttp: speed up callbacks, use array indices
Ben Noordhuis [Tue, 13 Aug 2013 21:47:17 +0000 (23:47 +0200)]
http: speed up callbacks, use array indices

Use array indices rather than named properties to store callbacks on
the HTTPParser object.  Speeds up the http benchmarks by a few percent.

10 years agosrc: remove redundant symbol init in node_file.cc
Ben Noordhuis [Wed, 14 Aug 2013 15:45:40 +0000 (17:45 +0200)]
src: remove redundant symbol init in node_file.cc

Don't lazy-init the oncomplete symbol string in the After() function,
it has already been created at module init time.

10 years agosrc: clean up FSReqWrap
Ben Noordhuis [Tue, 13 Aug 2013 10:07:49 +0000 (12:07 +0200)]
src: clean up FSReqWrap

Move the 'free FSReqWrap data?' logic into the class itself.

10 years agosrc: move ReqWrap::data_ to FSReqWrap
Ben Noordhuis [Tue, 13 Aug 2013 09:56:44 +0000 (11:56 +0200)]
src: move ReqWrap::data_ to FSReqWrap

FSReqWrap is the only ReqWrap child class that uses the data_ field so
move it out of ReqWrap and into FSReqWrap.

10 years agocrypto: add TLS 1.1 and 1.2 to secureProtocol list
Matthias Bartelmeß [Mon, 12 Aug 2013 22:21:54 +0000 (00:21 +0200)]
crypto: add TLS 1.1 and 1.2 to secureProtocol list

10 years agocrypto: use consistent conn object unwrapping
Ben Noordhuis [Mon, 12 Aug 2013 21:47:04 +0000 (23:47 +0200)]
crypto: use consistent conn object unwrapping

We use `Foo:Unwrap(args.This())` everywhere else, let's use the same
idiom for Connection::Unwrap().

10 years agocrypto: use consistent variable names
Ben Noordhuis [Mon, 12 Aug 2013 21:39:13 +0000 (23:39 +0200)]
crypto: use consistent variable names

Code cleanup: don't call a Connection object `p` in some places, `c` in
other places and `ss` in yet other places. Let's just call it `conn`.

This also fixes about a million style errors in one fell swoop.

10 years agoutil: fix isPrimitive check
Trevor Norris [Mon, 12 Aug 2013 20:41:51 +0000 (13:41 -0700)]
util: fix isPrimitive check

Previous check failed for the edge case Object.create(null). This uses
the current v8 code for the check.

10 years agocrypto: remove two unused static variables
Ben Noordhuis [Mon, 12 Aug 2013 20:38:39 +0000 (22:38 +0200)]
crypto: remove two unused static variables

10 years agosrc: fix build break from generic macro name
Trevor Norris [Mon, 12 Aug 2013 19:54:49 +0000 (12:54 -0700)]
src: fix build break from generic macro name

WRAP is too generic a macro name and causes the build to fail from
conflicts. They have been prepended with NODE_.

10 years agosrc: don't obj->Set(Integer::New(...), val)
Ben Noordhuis [Mon, 12 Aug 2013 18:34:18 +0000 (20:34 +0200)]
src: don't obj->Set(Integer::New(...), val)

Don't create an Integer when setting a numeric index on an object or an
array, use the version of v8::Object::Set() that takes an uint32_t.

Change the types of the variables from int to uint32_t and clean up
some code consistency issues while we're here.

10 years agosrc: centralize class wrap/unwrap
Trevor Norris [Tue, 6 Aug 2013 00:58:29 +0000 (17:58 -0700)]
src: centralize class wrap/unwrap

While almost all cases were handled by simple WRAP/UNWRAP macros, this
extends those to cover all known occurrences.

10 years agocares_wrap: remove unused function getHostByName()
Ben Noordhuis [Mon, 12 Aug 2013 18:04:38 +0000 (20:04 +0200)]
cares_wrap: remove unused function getHostByName()

Hasn't been used in ages. Also remove its (already disabled) test.

10 years agocares_wrap: don't set oncomplete property from c++
Ben Noordhuis [Mon, 12 Aug 2013 15:54:11 +0000 (17:54 +0200)]
cares_wrap: don't set oncomplete property from c++

Don't set the oncomplete property in src/cares_wrap.cc, we can do it
just as easily in lib/dns.js.

Switch two closures to the 'function with _this_ object' model. Makes
it impossible for an overzealous closure to capture too much context
and accidentally hold on to too much memory.

10 years agotest: fix up internet/test-dns after api change
Ben Noordhuis [Mon, 12 Aug 2013 15:28:38 +0000 (17:28 +0200)]
test: fix up internet/test-dns after api change

* The test calls an internal API that changed in commit ca9eb71.

* Trying to reverse-lookup a bogus hostname now returns EINVAL rather
  than the (bogus!) status code ENOTIMP.

10 years agostream_wrap: use v8::Integer::NewFromUnsigned()
Ben Noordhuis [Sat, 10 Aug 2013 21:25:38 +0000 (23:25 +0200)]
stream_wrap: use v8::Integer::NewFromUnsigned()

Use v8::Integer::NewFromUnsigned() when updating the writeQueueSize
field.

Before this commit, it used v8::Integer::New() but that takes an
int32_t. It's unlikely for a write queue to grow beyond 2**31-1 bytes
but let's use the unsigned integer constructor anyway, just in case.

10 years agov8: fix openbsd build
Ben Noordhuis [Mon, 5 Aug 2013 00:50:45 +0000 (02:50 +0200)]
v8: fix openbsd build

This is [1] applied ahead of time. Summary:

    OpenBSD doesn't have <ucontext.h>. ucontext_t lives in <signal.h>
    and is a typedef for struct sigcontext. There is no uc_mcontext.

[1] https://codereview.chromium.org/21705003/

Note: the patch has been accepted upstream but hasn't made its way into
a stable release yet.

10 years agov8: upgrade v8 to 3.20.14.1
Ben Noordhuis [Sat, 10 Aug 2013 14:27:43 +0000 (16:27 +0200)]
v8: upgrade v8 to 3.20.14.1

10 years agobuild: disable SSLv2 by default
Ben Noordhuis [Sat, 10 Aug 2013 13:40:26 +0000 (15:40 +0200)]
build: disable SSLv2 by default

No one in this day and age should be using SSLv2 so disable it by
default. You can re-enable it with `./configure --with-sslv2` but
there really should be no reason for that.

10 years agobuild: fix up style issues in configure script
Ben Noordhuis [Fri, 2 Aug 2013 09:50:45 +0000 (11:50 +0200)]
build: fix up style issues in configure script

* Use single quotes consistently.
* Remove a few stray semicolons.
* Fix up some overly long lines.
* Line up a few expressions.

10 years agoconfigure: order configure switches alphabetically
Ben Noordhuis [Sat, 10 Aug 2013 11:34:57 +0000 (13:34 +0200)]
configure: order configure switches alphabetically

Alphabetical order should make it easier to find the switches you need
because we've got quite a lot of them now.

Keep --prefix at the top because that's arguably the one people will be
looking for most.

10 years ago build: make ninja build respect V=
Ben Noordhuis [Sat, 10 Aug 2013 11:17:26 +0000 (13:17 +0200)]
 build: make ninja build respect V=

 Compiling with `make V=1` (which is the default) now runs ninja in
 verbose mode. To disable, run `make V=`.

10 years agobuild: don't auto-destroy existing configuration
Ben Noordhuis [Sat, 10 Aug 2013 11:00:51 +0000 (13:00 +0200)]
build: don't auto-destroy existing configuration

Don't run configure when the configure script has been touched. Doing so
would be okay if the Makefile passed the original arguments to configure
but it doesn't - it runs configure without any arguments, effectively
destroying the current configuration.

Remove this misfeature and instead print an error message telling the
user to (re-)run configure.

10 years agodomain: share object and state with native land
Trevor Norris [Wed, 7 Aug 2013 00:01:44 +0000 (17:01 -0700)]
domain: share object and state with native land

Change process.domain to use a getter/setter and access that property
via an array index. These are much faster to get from c++, and it can be
passed to _setupDomainUse and stored as a Persistent<Array>.

InDomain() and GetDomain() as trivial ways to access the domain
information in the native layer. Important because we'll be able to
quickly access if a domain is active. Instead of just whether the domain
module has been loaded.

10 years agonode: remove domain nextTick
Trevor Norris [Tue, 6 Aug 2013 21:22:13 +0000 (14:22 -0700)]
node: remove domain nextTick

It's ridiculously cheap to check if process.domain is set. Don't bother
cluttering the code.

10 years agosrc: don't call v8::Object::SetHiddenValue()
Ben Noordhuis [Fri, 9 Aug 2013 20:35:54 +0000 (22:35 +0200)]
src: don't call v8::Object::SetHiddenValue()

Don't use v8::Object::SetHiddenValue() to keep a reference alive to the
buffer, we can just as easily do that from JS land and it's a lot faster
to boot.

Because the buffer is now a visible property of the write request
object, it's essential that we do *not* log it - we'd be effectively
serializing the whole buffer to a pretty-printed string.

10 years agotest: use common.PORT in simple/test-net-GH-5504
Ben Noordhuis [Fri, 9 Aug 2013 05:33:18 +0000 (07:33 +0200)]
test: use common.PORT in simple/test-net-GH-5504

10 years agosrc: fix windows build breakage from f674b09
Ben Noordhuis [Fri, 9 Aug 2013 15:43:10 +0000 (17:43 +0200)]
src: fix windows build breakage from f674b09

The TWO_BYTE_BUFFER macro never made it into the final version of
the patch that got landed in commit f674b09.

10 years agodgram: don't call into js when send cb is omitted
Ben Noordhuis [Fri, 9 Aug 2013 02:48:10 +0000 (04:48 +0200)]
dgram: don't call into js when send cb is omitted

Speed up dgram.Socket#send()-heavy code a little by omitting the call
into JS land when the user doesn't pass us a completion callback.

10 years agodgram: fix regression in string argument handling
Ben Noordhuis [Fri, 9 Aug 2013 00:33:40 +0000 (02:33 +0200)]
dgram: fix regression in string argument handling

v0.10 allows strings for the offset, length and port arguments to
dgram.send() and dgram.sendto() but master before this commit would
abort with the following assert:

    node: ../../src/udp_wrap.cc:227: static void
    node::UDPWrap::DoSend(const v8::FunctionCallbackInfo<v8::Value>&,
    int): Assertion `args[2]->IsUint32()' failed.

Go beyond what v0.10 does and also add range checks: offset and length
should be >= 0, port should be between 1 and 65535.

That particular change needs to be back-ported to v0.10 because passing
a negative offset or length number aborts with the following assertions:

    node: ../../src/udp_wrap.cc:264: static v8::Handle<v8::Value>
    node::UDPWrap::DoSend(const v8::Arguments&, int): Assertion
    `offset < Buffer::Length(buffer_obj)' failed.

Or:

    node: ../../src/udp_wrap.cc:265: static v8::Handle<v8::Value>
    node::UDPWrap::DoSend(const v8::Arguments&, int): Assertion
    `length <= Buffer::Length(buffer_obj) - offset' failed.

Interestingly enough, a negative port number is accepted in v0.10 but
is silently ignored.

This commit exposed a bug in the simple/test-dgram-close test which
has also been fixed.

10 years agosrc: use v8::String::NewFrom*() functions
Ben Noordhuis [Wed, 7 Aug 2013 19:50:41 +0000 (21:50 +0200)]
src: use v8::String::NewFrom*() functions

* Change calls to String::New() and String::NewSymbol() to their
  respective one-byte, two-byte and UTF-8 counterparts.

* Add a FIXED_ONE_BYTE_STRING macro that takes a string literal and
  turns it into a v8::Local<v8::String>.

* Add helper functions that make v8::String::NewFromOneByte() easier to
  work with. Said function expects a `const uint8_t*` but almost every
  call site deals with `const char*` or `const unsigned char*`. Helps
  us avoid doing reinterpret_casts all over the place.

* Code that handles file system paths keeps using UTF-8 for backwards
  compatibility reasons. At least now the use of UTF-8 is explicit.

* Remove v8::String::NewSymbol() entirely. Almost all call sites were
  effectively minor de-optimizations. If you create a string only once,
  there is no point in making it a symbol. If you are create the same
  string repeatedly, it should probably be cached in a persistent
  handle.

10 years agostream: Short-circuit buffer pushes when flowing
isaacs [Sat, 27 Jul 2013 00:05:36 +0000 (17:05 -0700)]
stream: Short-circuit buffer pushes when flowing

When a stream is flowing, and not in the middle of a sync read, and
the read buffer currently has a length of 0, we can just emit a 'data'
event rather than push it onto the array, emit 'readable', and then
automatically call read().

As it happens, this is quite a frequent occurrence!  Making this change
brings the HTTP benchmarks back into a good place after the removal of
the .ondata/.onend socket kludge methods.

10 years agohttp: Use streams3 directly, not .ondata/end
isaacs [Fri, 26 Jul 2013 02:33:15 +0000 (19:33 -0700)]
http: Use streams3 directly, not .ondata/end

10 years agosmalloc: allow different external array types
Trevor Norris [Fri, 19 Jul 2013 23:15:25 +0000 (16:15 -0700)]
smalloc: allow different external array types

smalloc.alloc now accepts an optional third argument which allows
specifying the type of array that should be allocated. All available
types are now located on smalloc.Types.

10 years agosmalloc: cleanup checks/conversions
Trevor Norris [Fri, 2 Aug 2013 17:11:35 +0000 (10:11 -0700)]
smalloc: cleanup checks/conversions

* Moved the ToObject check out of smalloc::Alloc and into JS. Direct
  usage of that method is for internal use only and so can bypass the
  possible coercion.
* Same has been done with smalloc::SliceOnto.
* smalloc::CopyOnto will now throw if passed argument is not an object.
* Remove extra TargetFreeCallback function. There was a use for it when
  it was working with a Local<T>, but that code has been removed making
  the function superfluous.

10 years agostream_wrap: fix long line introduced in da5ad92
Ben Noordhuis [Wed, 7 Aug 2013 19:30:46 +0000 (21:30 +0200)]
stream_wrap: fix long line introduced in da5ad92

Said commit was a back-port from a feature branch where it did lint.
Mea culpa.

10 years agohttp: Support legacy agent.addRequest API
isaacs [Wed, 7 Aug 2013 17:23:45 +0000 (10:23 -0700)]
http: Support legacy agent.addRequest API

There are some agent subclasses using this today.

Despite the addRequest function being undocumented internal API, it's
easy enough to just support the old signature for backwards
compatibility.

10 years agosrc: remove no-op HandleWrap::Initialize()
Ben Noordhuis [Wed, 7 Aug 2013 16:03:13 +0000 (18:03 +0200)]
src: remove no-op HandleWrap::Initialize()

It's never been used and we probably never will. Remove it.

10 years agostream_wrap: add handle type checkers
Ben Noordhuis [Wed, 7 Aug 2013 15:21:25 +0000 (17:21 +0200)]
stream_wrap: add handle type checkers

Add is_named_pipe(), is_named_pipe_ipc() and is_tcp() and update the
code base to use those rather than `stream->type == UV_FOO` and
`reinterpret_cast<uv_pipe_t*>(handle)->ipc` style checks.

10 years agostream_wrap: use getters, not direct field access
Ben Noordhuis [Wed, 7 Aug 2013 15:14:16 +0000 (17:14 +0200)]
stream_wrap: use getters, not direct field access

Hide member fields behind getters. Make the fields themselves const
in the sense that the pointer is non-assignable - the pointed to object
remains mutable.

Makes reasoning about lifecycle and mutability a little easier.

10 years agosrc: constify WITH_GENERIC_STREAM macro
Ben Noordhuis [Wed, 7 Aug 2013 12:53:49 +0000 (14:53 +0200)]
src: constify WITH_GENERIC_STREAM macro

Make the pointer-to-wrap const (i.e. mutable but not assignable) to
prevent accidental reassignment in the macro body.

10 years agosrc: add IsEmpty() check to HasInstance()
Ben Noordhuis [Wed, 7 Aug 2013 12:45:37 +0000 (14:45 +0200)]
src: add IsEmpty() check to HasInstance()

The check has virtually zero overhead and it simplifies the call sites
because they were calling IsEmpty() anwyay.

10 years agoNow working on 0.11.6
Timothy J Fontaine [Wed, 7 Aug 2013 00:13:47 +0000 (17:13 -0700)]
Now working on 0.11.6

10 years agoMerge branch 'v0.11.5-release'
Timothy J Fontaine [Wed, 7 Aug 2013 00:13:17 +0000 (17:13 -0700)]
Merge branch 'v0.11.5-release'

10 years agodomains: properly check if domains are being used
Trevor Norris [Tue, 6 Aug 2013 22:42:47 +0000 (15:42 -0700)]
domains: properly check if domains are being used

process.domain is almost never just undefined, so it was setting the
object property unnecessarily.

10 years ago2013.08.06, Version 0.11.5 (Unstable) v0.11.5
Timothy J Fontaine [Tue, 6 Aug 2013 21:41:21 +0000 (14:41 -0700)]
2013.08.06, Version 0.11.5 (Unstable)

* v8: upgrade to 3.20.11

* uv: upgrade to v0.11.7

* buffer: return offset for end of last write (Trevor Norris)

* build: embed the mdb_v8.so into the binary (Timothy J Fontaine)

* build: fix --without-ssl build (Ben Noordhuis)

* child_process: add 'shell' option to .exec() (Ben Noordhuis)

* dgram: report send errors to cb, don't pass bytes (Ben Noordhuis)

* fs: write strings directly to disk (Trevor Norris)

* https: fix default port (Koichi Kobayashi)

* openssl: use asm for sha, md5, rmd (Fedor Indutny)

* os: add mac address to networkInterfaces() output (Brian White)

* smalloc: introduce smalloc module (Trevor Norris)

* stream: Simplify flowing, passive data listening (streams3) (isaacs)

* tls: asynchronous SNICallback (Fedor Indutny)

* tls: share tls tickets key between cluster workers (Fedor Indutny)

* util: don't throw on circular %j input to format() (Ben Noordhuis)

10 years agouv: Upgrade to v0.11.7
Timothy J Fontaine [Tue, 6 Aug 2013 21:35:33 +0000 (14:35 -0700)]
uv: Upgrade to v0.11.7

10 years agotls: fix lazy initialization of clienthello parser
Fedor Indutny [Tue, 6 Aug 2013 16:30:21 +0000 (20:30 +0400)]
tls: fix lazy initialization of clienthello parser

`server.SNICallback` was initialized with `SNICallback.bind(this)`, and
therefore check `this.SNICallback === SNICallback` was always false, and
`_tls_wrap.js` always thought that it was a custom callback instead of
default one. Which in turn was causing clienthello parser to be enabled
regardless of presence of SNI contexts.

10 years agoMerge remote-tracking branch 'upstream/v0.10'
Timothy J Fontaine [Tue, 6 Aug 2013 18:54:28 +0000 (11:54 -0700)]
Merge remote-tracking branch 'upstream/v0.10'

Conflicts:
deps/v8/test/cctest/test-api.cc
lib/events.js
lib/http.js

10 years agoprocess_wrap: omit superfluous Number creation
Ben Noordhuis [Tue, 6 Aug 2013 15:42:28 +0000 (17:42 +0200)]
process_wrap: omit superfluous Number creation

Don't create a superfluous Number object, just use the version of
v8::Object::Get() that takes an unsigned int. Convert the index to
unsigned int while we're here.

10 years agostream: Fix double pipe error emit
Eran Hammer [Mon, 5 Aug 2013 09:56:40 +0000 (02:56 -0700)]
stream: Fix double pipe error emit

If an error listener is added to a stream using once() before it is
piped, it is invoked and removed during pipe() but before pipe() sees it
which causes it to be emitted again.

Fixes #4155 #4978

10 years agosrc: fix WITH_GENERIC_STREAM() type check bug
Ben Noordhuis [Tue, 6 Aug 2013 13:47:42 +0000 (15:47 +0200)]
src: fix WITH_GENERIC_STREAM() type check bug

The handle object was checked against the wrong constructor template.
Put another way, it was unwrapped as the wrong StreamWrap type.

10 years agocrypto: fix signed/unsigned comparison warning
Ben Noordhuis [Tue, 6 Aug 2013 13:36:12 +0000 (15:36 +0200)]
crypto: fix signed/unsigned comparison warning

The type of the expression `(uint16_t) server_names_len + 2` gets
implicitly widened to int. Change the type of server_names_len to
uint32_t to avoid the following warnings:

    ../../src/node_crypto_clienthello.cc:144: warning: comparison
    between signed and unsigned integer expressions
    ../../src/node_crypto_clienthello.cc:146: warning: comparison
    between signed and unsigned integer expressions

10 years agotls: asynchronous SNICallback
Fedor Indutny [Sat, 3 Aug 2013 17:29:54 +0000 (21:29 +0400)]
tls: asynchronous SNICallback

Make ClientHelloParser handle SNI extension, and extend `_tls_wrap.js`
to support loading SNI Context from both hello, and resumed session.

fix #5967

10 years agotls_wrap: DRY ClientHelloParser
Fedor Indutny [Fri, 2 Aug 2013 12:16:13 +0000 (16:16 +0400)]
tls_wrap: DRY ClientHelloParser

Share ClientHelloParser code between `tls_wrap.cc` and `node_crypto.cc`.

fix #5959

10 years agorepl: Add 'smalloc' to list of known modules
isaacs [Mon, 5 Aug 2013 21:09:32 +0000 (14:09 -0700)]
repl: Add 'smalloc' to list of known modules

10 years agodoc: add a missing word in streams doc
Evan Solomon [Fri, 2 Aug 2013 16:57:46 +0000 (09:57 -0700)]
doc: add a missing word in streams doc

Ignore encoding *if* chunk is a buffer

10 years agobuild: fix ia32 sunos, elfwrap only needs -64
Timothy J Fontaine [Mon, 5 Aug 2013 21:33:55 +0000 (14:33 -0700)]
build: fix ia32 sunos, elfwrap only needs -64

10 years agobuild: embed the mdb_v8.so into the binary
Timothy J Fontaine [Wed, 17 Jul 2013 20:46:25 +0000 (20:46 +0000)]
build: embed the mdb_v8.so into the binary

This builds and includes the mdb_v8.so in the binary of node so mdb
can be sure to always use the latest version

10 years agodoc: Update LICENSE for npm's Artistic 2.0
isaacs [Mon, 5 Aug 2013 20:56:05 +0000 (13:56 -0700)]
doc: Update LICENSE for npm's Artistic 2.0

10 years agotest: Move test-http-default-port from disabled to simple
isaacs [Mon, 5 Aug 2013 19:55:31 +0000 (12:55 -0700)]
test: Move test-http-default-port from disabled to simple

10 years agohttps: fix default port
Koichi Kobayashi [Sun, 4 Aug 2013 06:39:50 +0000 (15:39 +0900)]
https: fix default port

https.get('https://github.com/') should use port 443, not 80.

10 years agohttp: Fix overlooked agent.globalAgent export
isaacs [Mon, 5 Aug 2013 19:33:19 +0000 (12:33 -0700)]
http: Fix overlooked agent.globalAgent export

Noticed by @bnoordhuis in https://github.com/joyent/node/pull/5991#discussion_r5575946

10 years agov8: back-port fix for CVE-2013-2882
mstarzinger@chromium.org [Mon, 15 Jul 2013 11:41:41 +0000 (11:41 +0000)]
v8: back-port fix for CVE-2013-2882

Quoting the CVE:

    Google V8, as used in Google Chrome before 28.0.1500.95, allows
    remote attackers to cause a denial of service or possibly have
    unspecified other impact via vectors that leverage "type confusion."

Likely has zero impact on node.js because it only runs local, trusted
code but let's apply it anyway.

This is a back-port of upstream commit r15665. Original commit log:

    Use internal array as API function cache.

    R=yangguo@chromium.org
    BUG=chromium:260106
    TEST=cctest/test-api/Regress260106

    Review URL: https://codereview.chromium.org/19159003

Fixes #5973.

10 years agodoc: document domain.enter() and domain.exit()
Forrest L Norvell [Thu, 14 Mar 2013 20:31:18 +0000 (13:31 -0700)]
doc: document domain.enter() and domain.exit()

Adds the documentation requested in #5017.

10 years agodoc: fs.open, fix flag/mode confusion, etc.
Sam Roberts [Fri, 2 Aug 2013 19:41:24 +0000 (12:41 -0700)]
doc: fs.open, fix flag/mode confusion, etc.

Flags and modes aren't the same, symlinks are followed in all of the
path but the last component, docs should say something about what the
mode argument is for and when its used, fs.openSync should point to the
function that contains the docs for its args, as fs.writeSync does.

10 years agov8: fix openbsd build
Ben Noordhuis [Mon, 5 Aug 2013 00:50:45 +0000 (02:50 +0200)]
v8: fix openbsd build

This is [1] applied ahead of time. Summary:

    OpenBSD doesn't have <ucontext.h>. ucontext_t lives in <signal.h>
    and is a typedef for struct sigcontext. There is no uc_mcontext.

[1] https://codereview.chromium.org/21705003/

10 years agotls: fix handling of `SNICallback` server option
Fedor Indutny [Fri, 2 Aug 2013 16:11:17 +0000 (20:11 +0400)]
tls: fix handling of `SNICallback` server option

It shouldn't ignore it!

There're two possibile cases, which should be handled properly:

1. Having a default `SNICallback` which is using contexts, added with
  `server.addContext(...)` routine
2. Having a custom `SNICallback`.

In first case we may want to opt-out setting `.onsniselect` method (and
thus save some CPU time), if there're no contexts added. But, if custom
`SNICallback` is used, `.onsniselect` should always be set, because
server contexts don't affect it.

10 years agosrc: use static_cast for void-to-T casts
Ben Noordhuis [Sat, 3 Aug 2013 20:50:15 +0000 (22:50 +0200)]
src: use static_cast for void-to-T casts

Code cleanup, replace a few uses of reinterpret_cast<T*>(void_ptr) with
static_cast<T*>(void_ptr).

10 years agosrc: use PersistentToLocal() in a few more places
Ben Noordhuis [Sat, 3 Aug 2013 20:18:35 +0000 (22:18 +0200)]
src: use PersistentToLocal() in a few more places

Update a few more `Local<T>::New(isolate, persistent)` call sites to
`PersistentToLocal(isolate, persistent)` - the latter has a fast path
for non-weak persistent references.

10 years agocrypto: fix another over-run in bio
Fedor Indutny [Sat, 3 Aug 2013 09:09:02 +0000 (13:09 +0400)]
crypto: fix another over-run in bio

When doing `FreeEmpty`, `NodeBIO` skips pre-allocated `head_` buffer.
However this might lead to double-freeing buffers since in `~NodeBIO()`
we're starting deallocation from `head_` buffer.

10 years agosrc: remove non-isolate PersistentToLocal(), v2
Ben Noordhuis [Fri, 2 Aug 2013 23:28:51 +0000 (01:28 +0200)]
src: remove non-isolate PersistentToLocal(), v2

Commit 78d9094 updated src/*.cc to use the version of PersistentToLocal
that takes a v8::Isolate* as its first argument. This commit removes
the non-isolate version.

10 years agonpm: Upgrade to 1.3.7
isaacs [Fri, 2 Aug 2013 21:55:01 +0000 (14:55 -0700)]
npm: Upgrade to 1.3.7

10 years agoprocess: set key properties as ReadOnly
Trevor Norris [Thu, 1 Aug 2013 21:53:52 +0000 (14:53 -0700)]
process: set key properties as ReadOnly

10 years agosrc: remove non-isolate PersistentToLocal()
Ben Noordhuis [Fri, 2 Aug 2013 21:12:56 +0000 (23:12 +0200)]
src: remove non-isolate PersistentToLocal()

There is no need for it and it's a tiny bit slower than the version of
PersistentToLocal() that takes a v8::Isolate* as its first argument.

10 years agosmalloc: remove double checks
Trevor Norris [Fri, 2 Aug 2013 20:00:54 +0000 (13:00 -0700)]
smalloc: remove double checks

Now that values are checks in JS, no need for them to be checked in C++.

10 years agosmalloc: fix assertion fails/segfault
Trevor Norris [Fri, 2 Aug 2013 19:52:43 +0000 (12:52 -0700)]
smalloc: fix assertion fails/segfault

* Numeric values passed to alloc were converted to int32, not uint32
  before the range check, which allows wrap around on ToUint32. This
  would cause massive malloc calls and v8 fatal errors.
* dispose would not check if value was an Object, causing segfault if a
  Primitive was passed.
* kMaxLength was not enumerable.

10 years agoutil: add isPrimitive check
Trevor Norris [Fri, 2 Aug 2013 19:52:34 +0000 (12:52 -0700)]
util: add isPrimitive check

10 years agobuild: fix --without-ssl build
Ben Noordhuis [Fri, 2 Aug 2013 11:52:20 +0000 (13:52 +0200)]
build: fix --without-ssl build

Build breakage accidentally introduced in 8e29ce9 during code cleanup.

HAVE_OPENSSL is always defined (as either 0 or 1) so use #if rather
than #ifdef.

Fixes #5979.

10 years agosrc: Replace macros with util functions
isaacs [Fri, 26 Jul 2013 21:38:08 +0000 (14:38 -0700)]
src: Replace macros with util functions

10 years agobenchmark: update misc to new v8 API
Trevor Norris [Thu, 1 Aug 2013 22:02:38 +0000 (15:02 -0700)]
benchmark: update misc to new v8 API

10 years agotest: add mac to test-os
Trevor Norris [Thu, 1 Aug 2013 20:53:19 +0000 (13:53 -0700)]
test: add mac to test-os

Fix test from 30701d6.

10 years agotest: future-proof simple/test-event-emitter-memory-leak
Ben Noordhuis [Thu, 1 Aug 2013 14:09:42 +0000 (16:09 +0200)]
test: future-proof simple/test-event-emitter-memory-leak

Run the garbage collector before running the actual test. It doesn't
matter now but if in the future something in node.js core creates a lot
of reclaimable garbage, that will break the test's expectation.

10 years agotest: fix pummel/test-net-connect-memleak
Ben Noordhuis [Thu, 1 Aug 2013 14:00:40 +0000 (16:00 +0200)]
test: fix pummel/test-net-connect-memleak

* Run the garbage collector before creating the big array. It doesn't
  matter now but if in the future something in node.js core creates
  a lot of reclaimable garbage, that will break the test's expectation.

* The first RSS check was being done too late. The garbage collector
  might have run before the check, throwing off the 'reclaimed memory'
  calculation.

* Due to changes in how V8 represents the big array internally, the
  actual memory usage is just below 256 MB on x64. Update the test's
  expectation.

10 years agoevents: fix memory leak, don't leak event names
Ben Noordhuis [Thu, 1 Aug 2013 12:35:13 +0000 (14:35 +0200)]
events: fix memory leak, don't leak event names

Before this commit, events were set to undefined rather than deleted
from the EventEmitter's backing dictionary for performance reasons:
`delete obj.key` causes a transition of the dictionary's hidden class
and that can be costly.

Unfortunately, that introduces a memory leak when many events are added
and then removed again. The strings containing the event names are never
reclaimed by the garbage collector because they remain part of the
dictionary.

That's why this commit makes EventEmitter delete events again. This
effectively reverts commit 0397223.

Fixes #5970.