Commit Graph

3378 Commits

Author SHA1 Message Date
Timothy J Fontaine
001f9b46e7 Merge remote-tracking branch 'upstream/v0.10'
Conflicts:
	src/stream_wrap.cc
2013-12-01 19:43:34 -08:00
Ben Noordhuis
658aeb2ca0 stream_wrap: don't call Number::New()
Replace call to Number::New() with a call to Integer::NewFromUnsigned().

Profiling a Real World(TM) application with perf(1) suggests that the
conversion of its argument from integer to double is disproportionally
costly: over 60% of CPU cycles accountable to WriteStringImpl() are
attributable to the conversion.

After changing it to Integer::NewFromUnsigned(), WriteStringImpl()
has dropped from the 'most costly functions' top ten altogether.
2013-11-27 03:53:45 +01: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
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
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
1a7d3e2b72 Now working on 0.11.10 2013-11-20 16:40:47 -08:00
Timothy J Fontaine
dcfd032bdd 2013.11.20, Version 0.11.9 (Unstable)
* uv: upgrade to v0.11.15 (Timothy J Fontaine)

* v8: upgrade to 3.22.24.5 (Timothy J Fontaine)

* buffer: remove warning when no encoding is passed (Trevor Norris)

* build: make v8 use random seed for hash tables (Ben Noordhuis)

* crypto: build with shared openssl without NPN (Ben Noordhuis)

* crypto: update root certificates (Ben Noordhuis)

* debugger: pass on v8 debug switches (Ben Noordhuis)

* domain: use AsyncListener API (Trevor Norris)

* fs: add recursive subdirectory support to fs.watch (Nick Simmons)

* fs: make fs.watch() non-recursive by default (Ben Noordhuis)

* http: cleanup freeSockets when socket destroyed (fengmk2)

* http: force socket encoding to be null (isaacs)

* http: make DELETE requests set `req.method` (Nathan Rajlich)

* node: add AsyncListener support (Trevor Norris)

* src: remove global HandleScope that hid memory leaks (Ben Noordhuis)

* tls: add ECDH ciphers support (Erik Dubbelboer)

* tls: do not default to 'localhost' servername (Fedor Indutny)

* tls: more accurate wrapping of connecting socket (Fedor Indutny)
2013-11-20 16:03:31 -08:00
Trevor Norris
aef652dc11 asyncwrap: add missing TryCatch
The TryCatch was not being checked after calling the unload asyncQueue
callback in AsyncWrap::MakeCallback.
2013-11-19 16:03:11 -08:00
Ben Noordhuis
3ac6946999 src: add ASSERT/CHECK/UNREACHABLE macros 2013-11-20 00:26:30 +01:00
Ben Noordhuis
d29fe0f2c6 src: make queue.h c++ compatible
This is a cherry-pick of commit joyent/libuv@0520464.
2013-11-20 00:26:30 +01: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
Ben Noordhuis
85c8eeb838 src: remove unused import in cares_wrap.cc 2013-11-14 01:59:07 +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
Trevor Norris
9b4aa355e3 src: add comments about implicit dependencies 2013-11-12 13:38:31 -08:00
Trevor Norris
d120d92bfe base-object: add BaseObject
BaseObject is a class that just handles the Persistent handle attached
to the class instance.

This also removed WeakObject. Reordering the inheritance chain helps
prevent unneeded calls on instances that don't call MakeCallback.
2013-11-12 13:38:31 -08:00
Trevor Norris
6cea16f2c9 async-wrap: make typenames consistent 2013-11-12 13:38:30 -08:00
Trevor Norris
4326c6d1b3 tls_wrap: move members to initialization list
They didn't need to be defined in the body of the constructor.
2013-11-12 13:38:30 -08:00
Ben Noordhuis
5235d71f89 src: use Context::Scope objects in cares_wrap.cc
Enter the context explicitly, don't rely on the fact that there is a
Context::Scope a few stack frames below because it may be gone someday
2013-11-12 22:10:57 +01:00
Ben Noordhuis
27f115d715 src: fix Context::Scope usage
env->context() may or may not create a new Local.  It currently does
not but don't depend on that behavior, create a HandleScope first.
2013-11-12 22:06:48 +01:00
Ben Noordhuis
c0d62c207e crypto: fix up implicit HandleScope abuse
Don't depend on any HandleScope objects that may or may not have been
created in src/stream_wrap.cc, create them explicitly.
2013-11-12 22:06:48 +01:00
Ben Noordhuis
fd819efbdf src: remove global HandleScope
Make it more difficult to accidentally leak handles by removing the
top-level HandleScope.  Now if there's no valid HandleScope now, V8
will complain and, in debug builds, abort.
2013-11-12 22:01:21 +01:00
Timothy J Fontaine
9142dc676f Now working on 0.10.23 2013-11-12 12:53:45 -08:00
Timothy J Fontaine
cbff8f091c 2013.11.12, Version 0.10.22 (Stable)
* npm: Upgrade to 1.3.14

* uv: Upgrade to v0.10.19

* child_process: don't assert on stale file descriptor events (Fedor Indutny)

* darwin: Fix "Not Responding" in Mavericks activity monitor (Fedor Indutny)

* debugger: Fix bug in sb() with unnamed script (Maxim Bogushevich)

* repl: do not insert duplicates into completions (Maciej Małecki)

* src: Fix memory leak on closed handles (Timothy J Fontaine)

* tls: prevent stalls by using read(0) (Fedor Indutny)

* v8: use correct timezone information on Solaris (Maciej Małecki)
2013-11-12 12:22:12 -08:00
Timothy J Fontaine
16934d9210 src: add HandleScope in HandleWrap::OnClose
Fixes a 4 byte leak on handles closing. AKA The Walmart leak.

MakeCallback doesn't have a HandleScope. That means the callers scope
will retain ownership of created handles from MakeCallback and related.
There is by default a wrapping HandleScope before uv_run, if the caller
doesn't have a HandleScope on the stack the global will take ownership
which won't be reaped until the uv loop exits.

If a uv callback is fired, and there is no enclosing HandleScope in the
cb, you will appear to leak 4-bytes for every invocation. Take heed.

cc @hueniverse
2013-11-12 11:23:19 -08:00
Ben Noordhuis
09724b311e src: fix Environment::GetCurrent() usage
Create a HandleScope before calling the Environment::GetCurrent() that
takes a v8::Isolate* as an argument because it creates a handle with
the call to v8::Isolate::CurrentContext().
2013-11-11 10:40:28 +01:00
Trevor Norris
7f09a13bba node: add HandleScope to prevent memory leak
MakeCallback can only be called from a valid v8::HandleScope.

Fixed #6487
2013-11-11 11:24:31 -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
Ben Noordhuis
a12870c823 crypto: update root certificates
Update the list of root certificates in src/node_root_certs.h with
tools/mk-ca-bundle.pl and update src/node_crypto.cc to make use of
the new format.

Fixes #6013.
2013-11-09 23:46:07 +01:00
Ben Noordhuis
0619467bd3 src: remove container_of, use CONTAINER_OF
CONTAINER_OF was introduced a while ago but was not used consistently
everywhere yet.  This commit fixes that.

Why CONTAINER_OF instead of container_of?  The former makes it crystal
clear that it's a macro, not a function.
2013-11-08 22:26:23 +01:00
Ben Noordhuis
3facd4e1dc crypto: unbreak build with no-NPN shared openssl
Unbreak the build when linking against a shared version of OpenSSL that
doesn't support NPN (Next Protocol Negotiation.)

Fixes the following build error:

  ../src/node_crypto.cc:140: error: no member function
  'AdvertiseNextProtoCallback' declared in
  'node::crypto::SSLWrap<node::TLSCallbacks>'
  ../src/node_crypto.cc:147: error: no member function
  'SelectNextProtoCallback' declared in
  'node::crypto::SSLWrap<node::TLSCallbacks>'
2013-11-08 17:50:01 +01:00
Fedor Indutny
014ab77276 crypto: try moving read head in Peek()
Otherwise it might get stall (`Peek()` will return zero-length chunk)
in following situation:

1. `Write(kBufferLength)`
2. `Read(kBufferLength)`
3. `Write(anything)`
4. `Peek()` => `len=0`
2013-11-08 17:01:02 +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
Ben Noordhuis
7acdabbf50 src: fix whitespace/braces lint error from 962686b
Silly warning.  One day I'll probably remove it altogether, see if I
don't.
2013-11-04 22:44:22 +01:00
Ben Noordhuis
962686b67b src: squelch unused variable warning
|i| and |j| arent't used when building without crypto support.  Hat tip
to Brian White.

Rename |l| to |k| while we're here because it's quite hard to discern
from |i| or |j| with some fonts.
2013-11-03 21:06:46 +01: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
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
fbe7eec1ec cares: add AsyncListener support 2013-10-31 16:34:35 -07:00
Trevor Norris
95c38107c2 crypto: convert pbkdf2_req to a class
pbkdf2_req has been renamed to PBKDF2Request and converted to a class.
It now uses AsyncWrap::MakeCallback.

Also includes, using env()->ondone_string() instead of "ondone" and
using malloc instead of new char[].
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
8b8e3b6798 async-wrap: integrate with WeakObject
Making WeakObject inherit from AsyncWrap allows us to peak into almost
all the MakeCallback calls in Node internals.
2013-10-31 14:17:51 -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
Ben Noordhuis
c4def505cb build: use zero overhead systemtap probes
Profiling suggested that on Linux sometimes over 10% of CPU time was
being spent inside the systemtap probe entry points in the binding
layer, even when the process was not actively being traced with the
`stap` tool.

That's why this commit makes it possible to use the *_ENABLED() macros
and bail out early when we're not being traced, reducing the overhead
of unused probes to (almost) zero.

Said macros were already being generated by `dtrace -h` but were not
usable because they rely on external definitions.  To remedy that, we
now generate the accompanying object files with `dtrace -G`.

This commit includes a change to libuv that has been landed upstream in
commit joyent/libuv@3c172ea.
2013-10-29 21:55:48 +01:00
Fedor Indutny
ba7c9ce964 tls: do not default to 'localhost' servername 2013-10-31 01:57:20 +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
Timothy J Fontaine
bae4c907bc Now working on 0.11.9 2013-10-30 08:55:06 -07:00
Timothy J Fontaine
f8d86e24f3 2013.10.30, Version 0.11.8 (Unstable)
* uv: Upgrade to v0.11.14

* v8: upgrade 3.21.18.3

* assert: indicate if exception message is generated (Glen Mailer)

* buffer: add buf.toArrayBuffer() API (Trevor Norris)

* cluster: fix premature 'disconnect' event (Ben Noordhuis)

* crypto: add SPKAC support (Jason Gerfen)

* debugger: count space for line numbers correctly (Alex Kocharin)

* debugger: make busy loops SIGUSR1-interruptible (Ben Noordhuis)

* debugger: repeat last command (Alex Kocharin)

* debugger: show current line, fix for #6150 (Alex Kocharin)

* dgram: send() can accept strings (Trevor Norris)

* dns: rename domain to hostname (Ben Noordhuis)

* dns: set hostname property on error object (Ben Noordhuis)

* dtrace, mdb_v8: support more string, frame types (Dave Pacheco)

* http: add statusMessage (Patrik Stutz)

* http: expose supported methods (Ben Noordhuis)

* http: provide backpressure for pipeline flood (isaacs)

* process: Add exitCode property (isaacs)

* tls: socket.renegotiate(options, callback) (Fedor Indutny)

* util: format as Error if instanceof Error (Rod Vagg)
2013-10-29 17:08:07 -07:00
Timothy J Fontaine
74a664b22f fs_event_wrap: update to new libuv api 2013-10-29 16:46:15 -07:00
Trevor Norris
613d76ef6a src: shorten Object{Wrap,Unwrap}
Going back to the original names of Wrap/Unwrap now that most all the
class members that duplicate the name and functionality have been
removed.
2013-10-29 15:09:44 -07:00
Trevor Norris
f2e3be53bc src: don't use class specific Unwrap methods
Instead use the template functions in util.h.
2013-10-29 15:09:44 -07:00
Trevor Norris
60a3e695cb src: don't use WeakObject::Unwrap
Switch out to use UnwrapObject from util.h.
2013-10-29 15:09:44 -07:00
Trevor Norris
93f75a86bf src: use function to get internal pointer
Remove the NODE_{WRAP,UNWRAP} macros and instead use template functions.
2013-10-29 15:09:44 -07:00
Trevor Norris
4b84e42f67 node: don't share state with in_tick/last_threw
There was no need to share state between C++ and JS for these two
values. So they have been moved to their respective locations. This will
help performance only a tiny bit, but it does help code complexity much
more.
2013-10-29 15:09:44 -07:00
Scott Blomquist
7a7101ac9b win: fix ObjectWrap for latest v8
We need to keep ObjectWrap around for module authors (we think), but
v8 3.21 broke node_object_wrap.h with respect to MSVC. Coincidentally,
we no longer use ObjectWrap at all in core, and native modules might
as well use their own entirely internal implementation if they need it.
2013-10-29 14:53:03 -07:00
Scott Blomquist
c137e3d249 src: Remove unused refs to node_object_wrap.h
Turns out that we don't use node_object_wrap.h any more in core,
and, with v8 3.21, it's breaking our Windows build. Removing refs
to it everywhere (and adding node.h in one case where it was the
only way node.h was being included), we have restored the Windows
build.
2013-10-29 09:38:22 -07: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
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
Ben Noordhuis
ef4a35bca5 src: update after v8 api changes 2013-10-23 09:17:31 -07:00
Ben Noordhuis
91a0e52c03 src: IsInt64() should return bool, not int 2013-10-23 13:26:25 +02:00
Timothy J Fontaine
85b2aaea3d Now working on 0.10.22 2013-10-18 15:40:32 -07:00
Timothy J Fontaine
e2da042844 2013.10.18, Version 0.10.21 (Stable)
* uv: Upgrade to v0.10.18

* crypto: clear errors from verify failure (Timothy J Fontaine)

* dtrace: interpret two byte strings (Dave Pacheco)

* fs: fix fs.truncate() file content zeroing bug (Ben Noordhuis)

* http: provide backpressure for pipeline flood (isaacs)

* tls: fix premature connection termination (Ben Noordhuis)
2013-10-18 14:26:27 -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
Timothy J Fontaine
f051b8919f http_parser: expose pause/resume method for parser 2013-10-16 17:12:34 -07:00
Fedor Indutny
2bc30f239b cpplint: disallow if one-liners 2013-10-17 00:34:19 +04:00
Fedor Indutny
7063c59b97 cpplint: disallow comma-first in C++ 2013-10-17 00:34:18 +04: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
Timothy J Fontaine
ab03745509 http_parser: expose pause/resume method for parser 2013-10-16 10:17:12 -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
Ben Noordhuis
527cae22ff cares_wrap: remove superfluous 'this' keyword 2013-10-14 11:07:14 +02:00
Trevor Norris
7503e4c882 lint: fix a cpplint error
Added a NOLINT so that cpplint won't complain about some code.
2013-10-11 12:25:42 -07:00
Trevor Norris
8a295cd520 buffer: add buf.toArrayBuffer() API 2013-10-11 12:17:23 -07:00
Trevor Norris
fe0bf6b7ac buffer: check data is not null
Because it's possible for the data within a Buffer instance to be
altered after instantiation, or in case a user attempts to do something
like the following:

Buffer.prototype.fill.call({}, 10, 0, 10);

It doesn't result in a segfault.
2013-10-11 11:57:05 -07:00
Dave Pacheco
98c57c7c07 dtrace: backport two byte string fix
This is a partial backport of 5921158

Re #6309
Closes #6319
2013-10-09 08:49:39 -07:00
Dave Pacheco
5921158cbe dtrace, mdb_v8: support more string, frame types
This change makes several improvements to the ustack helper and MDB
support:

- ustack helper and MDB: add support for two-byte strings
  (necessary to print many filenames in stacktraces in 0.10 and later).
- ustack helper: fix position numbers, which were off by a factor of two
- ustack helper: fix frames with undefined Scripts (e.g., "RegExp")
- ustack helper: add stub frames
- MDB: add support for sliced strings
- MDB: sync up with changes from the illumos version of the module

Fixes #6309
Closes #6318
2013-10-08 13:48:53 -07:00
Ben Noordhuis
406846fcc5 zlib: fix write request reference counting
Keep track of the reference count, don't make the wrapper object weak
when there are pending write requests.  Fixes a regression from c79d516.
2013-10-08 08:20:43 -07:00
Ben Noordhuis
58729f1bcd src: fix up after botched merge conflict
Mea culpa, I didn't properly resolve a merge conflict in the last two
commits.  The resulting segmentation fault only happened on Linux and
only sometimes.

Fixes #6306.
2013-10-03 19:28:01 +02:00
Ben Noordhuis
f649626c6f src: add JS start/stop methods for idle notifier
The previous commit changes the profiler idle notifier so that it only
gets started when a --prof or --prof_lazy argument is specified on the
command line.

This commit adds two internal methods to the process object that allows
one to start and stop the idle notifier programmatically.
2013-10-03 16:50:54 +02:00
Ben Noordhuis
9566fe82cd src: only start idle notifier when profiling
The previous commit adds a notifier that tells the V8 profiler when
node.js is idle, i.e. when it's about to start sleeping in the
platform's equivalent of epoll_wait().

This commit adds a heuristic that only starts the notifier when the
V8 profiler is started from the command line.
2013-10-03 16:50:54 +02:00
Ben Noordhuis
57231d5286 src: notify V8 profiler when we're idle
Inform V8's CPU profiler when we're idle.  The profiler is
sampling-based but not all samples are created equal; mark the wall
clock time spent in epoll_wait() and friends so profiling tools can
filter it out.  The samples still end up in v8.log but with state=IDLE
rather than state=EXTERNAL.
2013-10-03 16:50:54 +02:00
Ben Noordhuis
6820054d2d src: raise maximum file descriptor limit
Do a binary search for the maximum RLIMIT_NOFILE.  Works around the
low, low limits on certain high, high-priced devices from Cupertino, CA.
2013-10-03 16:27:29 +02:00
Timothy J Fontaine
d537992d57 Now working on 0.10.21 2013-09-30 15:06:14 -07:00
Timothy J Fontaine
d7234c8d50 2013.09.30, Version 0.10.20 (Stable)
* tls: fix sporadic hang and partial reads (Fedor Indutny)
  - fixes "npm ERR! cb() never called!"
2013-09-30 13:52:48 -07:00
Ben Noordhuis
994ce4c99f src: turn uv_pipe_open() failures into exceptions
uv_pipe_open() is unlikely to fail but when it does, the failure should
not be quietly ignored.  Raise the error as an exception.

See joyent/libuv#941.
2013-09-28 10:35:57 +02:00
Ben Noordhuis
c79d5163e5 src: remove ObjectWrap dependency from core
Drop the ObjectWrap dependency in favor of an internal WeakObject class.

Let's us stop worrying about API and ABI compatibility when making
changes to the way node.js deals with weakly persistent handles
internally.
2013-09-25 19:44:53 +02:00
Timothy J Fontaine
093efafce3 Now working on 0.10.20 2013-09-24 15:10:22 -07:00
Timothy J Fontaine
6b5e6a5a3e 2013.09.24, Version 0.10.19 (Stable)
* uv: Upgrade to v0.10.17

* npm: upgrade to 1.3.11

* readline: handle input starting with control chars (Eric Schrock)

* configure: add mips-float-abi (soft, hard) option (Andrei Sedoi)

* stream: objectMode transforms allow falsey values (isaacs)

* tls: prevent duplicate values returned from read (Nathan Rajlich)

* tls: NPN protocols are now local to connections (Fedor Indutny)
2013-09-24 14:10:33 -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
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
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
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
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
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
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
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
5b1a0e6ef8 Now working on 0.11.8 2013-09-04 15:18:20 -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
65ed79a6dc Now working on 0.10.19 2013-09-04 11:25:19 -07:00
Timothy J Fontaine
67a1f0c52e 2013.09.04, Version 0.10.18 (Stable)
* uv: Upgrade to v0.10.15

* stream: Don't crash on unset _events property (isaacs)

* stream: Pass 'buffer' encoding with decoded writable chunks (isaacs)
2013-09-04 10:51:53 -07:00
Ben Noordhuis
7494c84fe6 uv: upgrade to v0.11.13
This commit changes src/tcp_wrap.cc and src/udp_wrap.cc just enough to
get by (i.e. to compile and function correctly.)

The new libuv API allows for more cleanup and deduplication but I'm
saving that for another day.
2013-09-04 18:11:32 +02:00
Trevor Norris
7a235f924b string_bytes: use extern for length and write utf8
If the string is external then the length can be quickly retrieved. This
is especially faster for large strings that are being treated as UTF8.
Also, if the string is external then there's no need for a full
String::WriteUtf8 operation. A simple memcpy will do.
2013-09-03 10:04:58 -07:00
isaacs
906a175a0b process: Add internal _rawDebug() method
This is useful when we need to push some debugging messages out to
stderr, without going through the Writable class, or triggering any kind
of nextTick or callback behavior.
2013-09-02 20:15:40 -07:00
isaacs
cb53cfd8b5 src: Remove outdated comment re assert()
It's a normal function now, not a macro.
2013-09-02 20:15:40 -07:00
Ben Noordhuis
ed8d97f572 uv: upgrade to v0.11.12
* upgrade deps/uv/ to v0.11.12.
* update files in src/ after a libuv API change.
2013-09-03 01:17:58 +02:00
Ben Noordhuis
185c515c9f src: clean up CLI argument parser
* Exit with an error message when the option is not a node or V8 option.

* Remove the option_end_index global.  Needs to happen anyway for
  the multi-context work, might as well land it in master now.

* Add a smidgen of const-correctness.

* Pay off a few years of accrued technical debt.
2013-09-02 21:41:12 +02:00
Ben Noordhuis
10ccbd501f Revert "src: call uv_loop_delete() on exit in debug mode"
Don't call uv_loop_delete() until we've figured out a way to gracefully
close open handles.  See also commit 4915884 and its subsequent revert
in commit 980cbd5.

This reverts commit 556b890ad9.
2013-08-30 23:28:22 +02:00
Ben Noordhuis
bbed881ec4 Revert "src: close libuv handles on exit"
This change is not entirely ready for prime time: it's making ~50 tests
fail on Windows, mostly due to timeouts.  It's up for debate who is
at fault here: node.js or libuv.

It does however expose a libuv bug on OS X, where the event loop
sometimes gets stuck in uv__io_poll() when there is a single
UV_SHUTDOWN request left in the queue.  Needs further investigation.

This reverts commit 4915884da6.
2013-08-30 23:28:14 +02:00
Ben Noordhuis
4915884da6 src: close libuv handles on exit
Commit 556b890 added a call to uv_loop_delete() with the intent of
catching handle lifecycle bugs.  It worked because it exposed one:

    process.on('exit', function() {
      console.log('bye');  // Asserts.
    });

When run, it asserts with the following message:

    Assertion failed: (!uv__has_active_reqs(loop)), function
    uv__loop_delete, file ../deps/uv/src/unix/loop.c, line 150.

That's because libuv as of joyent/libuv@3f2d4d5 checks that there are
no in-flight requests when the event loop is destroyed.  In the test
case above, the write request for the string hasn't completed yet by
the time node.js exits: the string itself has most likely been written
but libuv hasn't had the opportunity to return the write request to
node.js.

That's why this commit adds a cleanup step right before exit where it
explicitly closes all open handles, then waits until the event loop
exits naturally.

Named pipes (UNIX domain sockets) are shut down first in order to flush
pending write requests.  Should go some way towards fixing the Windows
issue where output on stdout/stderr sometimes gets truncated.

Fixes joyent/libuv#911.
2013-08-30 18:39:37 +02:00
Ben Noordhuis
a9eb96d020 src: remove unused Persistent<FunctionTemplate> 2013-08-29 14:28:28 +02:00
Ben Noordhuis
653f62a709 crypto: remove NodeBIO::GetMethod()
Remove NodeBIO::GetMethod() and replace calls to BIO_new() with calls
to the new NodeBIO::New() function.

This commit basically reshuffles some code in order to make it explicit
that the NodeBIO BIO_METHOD is const.
2013-08-29 14:25:57 +02:00
Ben Noordhuis
8e596c4e15 crypto: make root_cert_store variable extern
Before this commit it was declared static (in a header file!), meaning
it got duplicated in every file that includes it.

A few duplicated pointers is not the end of the world but it introduces
a lot of potential for confusion because root_cert_store in file A is
not the root_cert_store in file B.

Moral of the story: don't declare static variables in header files.
2013-08-29 14:05:44 +02:00
Ben Noordhuis
21911db392 crypto: remove misleading comment 2013-08-29 14:02:11 +02:00
Ben Noordhuis
699f636d97 crypto: make error buffer non-static
Doesn't matter now but it will if/when we have support for multiple
threads.
2013-08-29 13:57:30 +02:00
Domenic Denicola
fd3657610e vm: update API to use options argument
Passing a filename is still supported in place of certain options
arguments, for backward-compatibility, but timeout and display-errors
are not translated since those were undocumented.

Also managed to eliminate an extra stack trace line by not calling
through the `createScript` export.

Added a few message tests to show how `displayErrors` works.
2013-08-28 22:27:24 -07:00
Bert Belder
de7d698df7 pipe_wrap: squelch integer type conversion warning 2013-08-28 23:36:00 +02:00
Timothy J Fontaine
93b062468b timer_wrap: Timer.now always update loop time
In `Timer.now` always update the loop time by calling uv_update_time.
Previously we were trying to cache the loop time to prevent extra
syscalls. While a noble goal, it can cause timers to fire early in
certain circumstances. Especially seen in cpu bound work loads or work
loads with synchronous file operations.
2013-08-28 11:29:33 -07:00
Ben Noordhuis
29d3624dae crypto: make randomBytes/pbkdf2 cbs domain aware
Make the crypto.randomBytes() and crypto.pbkdf2() callback functions
run inside the current domain (if any.)

Fixes #3965.
2013-08-28 12:37:49 +02:00
Domenic Denicola
9c110d8027 vm: add isContext; prevent double-contextifying
Previously, calling `vm.createContext(o)` repeatedly on the same `o`
would cause new C++ `ContextifyContext`s to be created and stored on
`o`, while the previous resident went off into leaked-memory limbo.
Now, repeatedly trying to contextify a sandbox will do nothing after
the first time.

To detect this, an independently-useful `vm.isContext(sandbox)` export
was added.
2013-08-28 12:11:09 +02:00
Domenic Denicola
a3bf3d10ef vm: use MakeWeak to fix leaking contexts
This is always something you should do when using `SetHiddenValue`,
apparently. Fixes #6115. Thanks @tjfontaine for the tips.
2013-08-28 12:11:09 +02:00
Domenic Denicola
a54f65ce75 vm: rip out ObjectWrap from ContextifyContext
This was a remnant of the original Contextify code, wherein
ContextifyContext was a user-exposed object. In vm, it is not, so all
of the ObjectWrap and function-template stuff for the ContextifyContext
constructor is now unnecessary.
2013-08-28 12:11:09 +02:00
isaacs
645418e9f1 fs: Expose birthtime on stat objects
Just do the best we can with whatever libuv gives us.

Also, document the semantics of `ctime` and the compatibility with
Windows.
2013-08-27 10:42:18 -07:00
Ben Noordhuis
8d567f43d0 src: remove two pointless globals from node.cc
De-globalize use_npn and use_sni, they're only used in GetFeatures().
2013-08-27 16:14:46 +02:00
Ben Noordhuis
556b890ad9 src: call uv_loop_delete() on exit in debug mode
Should make tracing with valgrind a little easier on the eye and
possibly help expose libuv handle lifecycle issues.
2013-08-27 14:47:50 +02:00
Ben Noordhuis
3a87b31bfa src: remove --max-stack-size option
Ad-hoc duplicate of V8's --stack-size option.  Superfluous in other
words.  Remove it.
2013-08-27 14:09:37 +02:00
Ben Noordhuis
0523da64d2 cares_wrap: drop UV_HANDLE_FIELDS from ares_task_t
UV_HANDLE_FIELDS is a libuv implementation detail.  The ares_task_t
struct only uses the uv_loop_t* field so be explicit about that.
2013-08-27 13:20:42 +02:00
Ben Noordhuis
9fc006618f src: fix up unused/unordered imports 2013-08-27 00:13:50 +02:00
Trevor Norris
16a60ed2a3 buffer: add NativeBuffer API
Due to a lot of the util.is* checks there was much unnecessary overhead
for the most common use case of Buffer. Which is creating a new Buffer
instance for data from incoming I/O. NativeBuffer is a simple way to
bypass all the unneeded checks and simply hand back a Buffer instance
while setting the length.
2013-08-26 14:12:00 -07:00
Ben Noordhuis
9ac75d1f06 src: remove pointless node_os.h header file
src/node_os.cc doesn't export anything that's used elsewhere. Remove it.
2013-08-26 15:15:43 +02:00
Bert Belder
87405b0d98 process_wrap: don't coerce process exit code to int32_t
On windows process exit codes can be greater than INT32_MAX. This used
to be not much of a problem - greater values would just come out
negative. However since ca9eb71 a negative result value indicates that
uv_spawn() has failed, so this is no longer acceptable.
2013-08-25 18:45:38 +02:00
Trevor Norris
467e00ed02 domain: move error handling directly into instance
Instead of doing all the domain handling in core, allow the domain to
set an error handler that'll take care of it all. This way the domain
error handling can be abstracted enough for any user to use it.
2013-08-23 10:14:10 -07:00
Bert Belder
7555227a12 process_wrap: update after libuv api change
The `exit_code` argument for the `ProcessWrap::OnExit` callback changed
from int to int64_t.
2013-08-23 19:08:49 +02:00
Ben Noordhuis
48976d29f4 vm: fix Persistent<Context> leak 2013-08-23 02:07:24 +02:00
Ben Noordhuis
2891790dbd vm: remove unnecessary Persistent<FunctionTemplate> 2013-08-23 14:29:58 +02:00
isaacs
eef552774e vm: Put back display_errors flag
This is an important part of the repl use-case.

TODO: The arg parsing in vm.runIn*Context() is rather wonky.
It would be good to move more of that into the Script class,
and/or an options object.
2013-08-21 17:58:12 -07:00
Timothy J Fontaine
3c66b15789 Now working on 0.10.18 2013-08-21 16:37:43 -07:00
Domenic Denicola
7afdba6e0b vm, core, module: re-do vm to fix known issues
As documented in #3042 and in [1], the existing vm implementation has
many problems. All of these are solved by @brianmcd's [contextify][2]
package. This commit uses contextify as a conceptual base and its code
core to overhaul the vm module and fix its many edge cases and caveats.

Functionally, this fixes #3042. In particular:

- A context is now indistinguishable from the object it is based on
  (the "sandbox"). A context is simply a sandbox that has been marked
  by the vm module, via `vm.createContext`, with special internal
  information that allows scripts to be run inside of it.
- Consequently, items added to the context from anywhere are
  immediately visible to all code that can access that context, both
  inside and outside the virtual machine.

This commit also smooths over the API very slightly:

- Parameter defaults are now uniformly triggered via `undefined`, per
  ES6 semantics and previous discussion at [3].
- Several undocumented and problematic features have been removed, e.g.
  the conflation of `vm.Script` with `vm` itself, and the fact that
  `Script` instances also had all static `vm` methods. The API is now
  exactly as documented (although arguably the existence of the
  `vm.Script` export is not yet documented, just the `Script` class
  itself).

In terms of implementation, this replaces node_script.cc with
node_contextify.cc, which is derived originally from [4] (see [5]) but
has since undergone extensive modifications and iterations to expose
the most useful C++ API and use the coding conventions and utilities of
Node core.

The bindings exposed by `process.binding('contextify')`
(node_contextify.cc) replace those formerly exposed by
`process.binding('evals')` (node_script.cc). They are:

- ContextifyScript(code, [filename]), with methods:
  - runInThisContext()
  - runInContext(sandbox, [timeout])
- makeContext(sandbox)

From this, the vm.js file builds the entire documented vm module API.

node.js and module.js were modified to use this new native binding, or
the vm module itself where possible. This introduces an extra line or
two into the stack traces of module compilation (and thus into most
stack traces), explaining the changed tests.

The tests were also updated slightly, with all vm-related simple tests
consolidated as test/simple/test-vm-* (some of them were formerly
test/simple/test-script-*). At the same time they switched from
`common.debug` to `console.error` and were updated to use
`assert.throws` instead of rolling their own error-testing methods.

New tests were also added, of course, demonstrating the new
capabilities and fixes.

[1]: http://nodejs.org/docs/v0.10.16/api/vm.html#vm_caveats
[2]: https://github.com/brianmcd/contextify
[3]: https://github.com/joyent/node/issues/5323#issuecomment-20250726
[4]: bf123f3ef9/src/contextify.cc
[5]: https://gist.github.com/domenic/6068120
2013-08-21 15:52:23 -07:00
Timothy J Fontaine
469a4a5091 2013.08.21, Version 0.10.17 (Stable)
* uv: Upgrade v0.10.14

* http_parser: Do not accept PUN/GEM methods as PUT/GET (Chris Dickinson)

* tls: fix assertion when ssl is destroyed at read (Fedor Indutny)

* stream: Throw on 'error' if listeners removed (isaacs)

* dgram: fix assertion on bad send() arguments (Ben Noordhuis)

* readline: pause stdin before turning off terminal raw mode (Daniel Chatfield)
2013-08-21 15:00:56 -07:00
Timothy J Fontaine
3602d4c23b Now working on 0.11.7 2013-08-21 14:16:46 -07:00
Timothy J Fontaine
04018d4b39 2013.08.21, Version 0.11.6 (Unstable)
* uv: Upgrade to v0.11.8

* v8: upgrade v8 to 3.20.14.1

* build: disable SSLv2 by default (Ben Noordhuis)

* build: don't auto-destroy existing configuration (Ben Noordhuis)

* crypto: add TLS 1.1 and 1.2 to secureProtocol list (Matthias Bartelmeß)

* crypto: fix memory leak in randomBytes() error path (Ben Noordhuis)

* dgram: don't call into js when send cb is omitted (Ben Noordhuis)

* dgram: fix regression in string argument handling (Ben Noordhuis)

* domains: performance improvements (Trevor Norris)

* events: EventEmitter = require('events') (Jake Verbaten)

* http: Add write()/end() callbacks (isaacs)

* http: Consistent 'finish' event semantics (isaacs)

* http: Prefer 'binary' over 'ascii' (isaacs)

* http: Support legacy agent.addRequest API (isaacs)

* http: Write hex/base64 chunks properly (isaacs)

* http: add agent.maxFreeSockets option (isaacs)

* http: provide access to raw headers/trailers (isaacs)

* http: removed headers stay removed (James Halliday)

* http,timers: improve callback performance (Ben Noordhuis)

* net: family option in net.connect (Vsevolod Strukchinsky)

* readline: pause stdin before turning off terminal raw mode (Daniel Chatfield)

* smalloc: allow different external array types (Trevor Norris)

* smalloc: expose ExternalArraySize (Trevor Norris)

* stream: Short-circuit buffer pushes when flowing (isaacs)

* tls: handle errors on socket before releasing it (Fedor Indutny)

* util: fix isPrimitive check (Trevor Norris)

* util: isObject should always return boolean (Trevor Norris)
2013-08-21 13:20:50 -07:00
Trevor Norris
849cf1aa92 smalloc: consistent-ify syntax
Small syntax fixes of variable renaming and argument alignment.
2013-08-20 13:33:50 -07:00
Trevor Norris
6b5c43ed18 smalloc: length is byte size, not array length
The C++ API has been changed so the passed length is the byte size of
the data, not the length of the array.

This was done so users need to explicitly define how much memory they
want allocated.
2013-08-20 13:33:35 -07:00
Trevor Norris
ed0677f427 smalloc: expose ExternalArraySize
Useful to correctly determine the byte size of the external memory that
needs to be allocated for an external array.
2013-08-20 11:07:37 -07:00
Matthew Aynalem
c171c490f2 fixes #6031 spelling errors
explictly => explicitly
accesss => access
througput => throughput
epxression => expression
communiction => communication
becuase => because
repersent => represent
condonitions => conditions
decompresion => decompression
intentially => intentionally
eventes => events
listning => listening
resicved => received
becuase => because
fundimental => fundamental
colapse => collapse
privlages => privileges
sufficently => sufficiently
hapepns => happens
expliclitly => explicitly
thier => their
shold => should
2013-08-19 16:42:16 -07:00
Trevor Norris
f97a1267e2 buffer: lint
This and b80d11d are my fault. An unrelated test was failing, which
prevents {js,cpp}lint from running automatically.
2013-08-19 11:15:16 -07:00
Fedor Indutny
306f863438 crypto: don't touch ssl_ in Connection
`ssl_` is a property of SSLWrap class, don't touch it, and definitely
don't zero it in constructor.
2013-08-19 20:34:34 +04:00
Fedor Indutny
b9a0eb0688 tls, crypto: deduplicate code
Commit 03e008d introduced src/tls_wrap.cc and src/tls_wrap.h but
said files copied on the order of 1 kLoC from src/node_crypto.cc
and src/node_crypto.h.  This commit undoes some of the duplication.

Fixes #6024.
2013-08-19 17:52:44 +02:00
Ben Noordhuis
3e25ed905c src: move includes inside include guard
Having the includes in src/node_buffer.h outside of the include guard
is not really harmful but it's inconsistent with other header files.
2013-08-19 16:42:12 +02:00
isaacs
0e043528a1 Now working on v0.10.17 2013-08-16 12:47:29 -07:00
Trevor Norris
2dd4a745b0 buffer: don't call ByteLength for simple encodings
For several encodings the byte length is simple arithmetic. Don't call
into C++ in those cases.
2013-08-16 12:42:33 -07:00
isaacs
50b4c905a4 2013.08.16, Version 0.10.16 (Stable)
* v8: back-port fix for CVE-2013-2882

* npm: Upgrade to 1.3.8

* crypto: fix assert() on malformed hex input (Ben Noordhuis)

* crypto: fix memory leak in randomBytes() error path (Ben Noordhuis)

* events: fix memory leak, don't leak event names (Ben Noordhuis)

* http: Handle hex/base64 encodings properly (isaacs)

* http: improve chunked res.write(buf) performance (Ben Noordhuis)

* stream: Fix double pipe error emit (Eran Hammer)
2013-08-16 08:32:38 -07:00
Ben Noordhuis
f55aca6515 crypto: fix memory leak in randomBytes() error path
This is the conceptual back-port of commit ec54873 from the master
branch.
2013-08-16 16:50:01 +02:00
Ben Noordhuis
ec548734ca crypto: fix memory leak in randomBytes() error path 2013-08-16 16:47:30 +02:00
Ben Noordhuis
9475ee41ad crypto: don't mix new[] and free()
RandomBytes() allocated memory with new[] which was then handed off to
Buffer::Use() which eventually releases it again with free().

Mixing the two is technically a violation of the spec and besides, it's
generally frowned upon.
2013-08-16 16:47:08 +02:00
Trevor Norris
ab5dabf876 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.
2013-08-15 12:52:21 -07:00
Ben Noordhuis
0aa13357d6 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.
2013-08-15 19:33:34 +02:00
Ben Noordhuis
7a3f7780dc src: add MakeCallback() that takes an array index
Internal helper function for dispatching by array index rather than
named property.
2013-08-15 19:33:06 +02:00
Ben Noordhuis
9c59978f49 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.
2013-08-15 16:47:54 +02:00
Ben Noordhuis
dce02a1055 zlib: replace C cast with static_cast
Seems to have escaped the Eye of Sauron^WFedor in commit 8e29ce9.
2013-08-14 23:50:08 +02:00
Ben Noordhuis
2669966e76 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.
2013-08-14 18:08:04 +02:00
Ben Noordhuis
d684f50acb 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.
2013-08-14 18:08:04 +02:00
Ben Noordhuis
d2b80b8a60 src: clean up FSReqWrap
Move the 'free FSReqWrap data?' logic into the class itself.
2013-08-13 12:14:33 +02:00
Ben Noordhuis
ffc5d83568 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.
2013-08-13 11:56:45 +02:00
Matthias Bartelmeß
4ac6912a77 crypto: add TLS 1.1 and 1.2 to secureProtocol list 2013-08-13 11:46:07 +02:00
Ben Noordhuis
d4ad5d1151 crypto: use consistent conn object unwrapping
We use `Foo:Unwrap(args.This())` everywhere else, let's use the same
idiom for Connection::Unwrap().
2013-08-12 23:51:01 +02:00
Ben Noordhuis
4901353b98 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.
2013-08-12 23:51:01 +02:00
Ben Noordhuis
624938d052 crypto: remove two unused static variables 2013-08-12 22:42:23 +02:00
Trevor Norris
35f789b027 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_.
2013-08-12 12:54:49 -07:00
Ben Noordhuis
5725864dfd 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.
2013-08-12 20:59:35 +02:00
Trevor Norris
756ae2c536 src: centralize class wrap/unwrap
While almost all cases were handled by simple WRAP/UNWRAP macros, this
extends those to cover all known occurrences.
2013-08-12 11:49:53 -07:00
Ben Noordhuis
e0a8e1bf77 cares_wrap: remove unused function getHostByName()
Hasn't been used in ages. Also remove its (already disabled) test.
2013-08-12 20:05:16 +02:00
Ben Noordhuis
6cd7fd7d24 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.
2013-08-12 19:08:03 +02:00
Ben Noordhuis
2b5b37a3ab 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.
2013-08-11 00:11:28 +02:00
Trevor Norris
3f5d5847e2 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.
2013-08-09 16:54:45 -07:00
Trevor Norris
2ef1782bbc node: remove domain nextTick
It's ridiculously cheap to check if process.domain is set. Don't bother
cluttering the code.
2013-08-09 16:13:56 -07:00
Ben Noordhuis
f9b7714b4b 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.
2013-08-09 08:16:58 +02:00
Ben Noordhuis
78f709d0d4 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.
2013-08-09 18:56:46 +02:00
Ben Noordhuis
1449739de0 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.
2013-08-09 18:56:45 +02:00
Ben Noordhuis
f674b09f40 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.
2013-08-09 11:44:50 +02:00
Trevor Norris
cec81593d7 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.
2013-08-07 12:53:24 -07:00
Trevor Norris
cd00064566 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.
2013-08-07 12:52:56 -07:00
Ben Noordhuis
b9150344ac stream_wrap: fix long line introduced in da5ad92
Said commit was a back-port from a feature branch where it did lint.
Mea culpa.
2013-08-07 21:33:21 +02:00
Ben Noordhuis
d24decb87b src: remove no-op HandleWrap::Initialize()
It's never been used and we probably never will. Remove it.
2013-08-07 18:03:14 +02:00
Ben Noordhuis
54a9ec4ef0 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.
2013-08-07 17:27:35 +02:00
Ben Noordhuis
da5ad92ab2 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.
2013-08-07 17:16:47 +02:00
Ben Noordhuis
4692b725de 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.
2013-08-07 14:53:50 +02:00
Ben Noordhuis
c079f6e210 src: add IsEmpty() check to HasInstance()
The check has virtually zero overhead and it simplifies the call sites
because they were calling IsEmpty() anwyay.
2013-08-07 14:46:55 +02:00
Timothy J Fontaine
536037369e Now working on 0.11.6 2013-08-06 17:13:47 -07:00
Timothy J Fontaine
7aa4242844 Merge branch 'v0.11.5-release' 2013-08-06 17:13:17 -07:00
Trevor Norris
e3c5019ac7 domains: properly check if domains are being used
process.domain is almost never just undefined, so it was setting the
object property unnecessarily.
2013-08-06 15:42:47 -07:00
Timothy J Fontaine
6f92da2dd1 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)
2013-08-06 14:41:21 -07:00
Ben Noordhuis
b8a7eedea3 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.
2013-08-06 17:51:22 +02:00
Ben Noordhuis
45d056ee69 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.
2013-08-06 15:47:44 +02:00
Ben Noordhuis
576496632c 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
2013-08-06 15:39:43 +02:00
Fedor Indutny
048e0e77e0 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
2013-08-06 16:13:01 +04:00
Fedor Indutny
8e28193cc2 tls_wrap: DRY ClientHelloParser
Share ClientHelloParser code between `tls_wrap.cc` and `node_crypto.cc`.

fix #5959
2013-08-06 16:13:01 +04:00
Ben Noordhuis
5383e75885 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).
2013-08-03 22:50:16 +02:00
Ben Noordhuis
d4cc30f18c 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.
2013-08-03 22:23:28 +02:00
Fedor Indutny
e5791f74f0 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.
2013-08-03 14:04:55 +04:00
Ben Noordhuis
350fc8064e 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.
2013-08-03 01:30:42 +02:00
Trevor Norris
c80f8fa8f1 process: set key properties as ReadOnly 2013-08-02 14:17:29 -07:00
Ben Noordhuis
78d90945d6 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.
2013-08-02 23:16:00 +02:00
Trevor Norris
2dafa193ee smalloc: remove double checks
Now that values are checks in JS, no need for them to be checked in C++.
2013-08-02 13:00:54 -07:00
Ben Noordhuis
e772a7deaf 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.
2013-08-02 13:54:39 +02:00
isaacs
22c68fdc1d src: Replace macros with util functions 2013-08-01 15:08:01 -07:00
Fedor Indutny
dda22a520b tls_wrap: parse tls session ticket extension
And, if present and non-empty, don't invoke `resumeSession` callback.

fix #5872
2013-08-01 16:06:45 +04:00
Brian White
30701d6e74 os: add mac address to networkInterfaces() output 2013-08-01 12:47:05 +02:00
Ben Noordhuis
1ef1be376c src: don't include <string.h> twice in src/node.cc 2013-08-01 12:26:24 +02:00
Bert Belder
168ca527be build: un-break the windows build 2013-08-01 11:39:25 +02:00
Ben Noordhuis
02cab97490 src: more lint after cpplint tightening
Commit 847c6d9 adds a 'project headers before system headers' check
to cpplint. Update the files in src/ to make the linter pass again.
2013-07-31 23:16:26 +02:00
Fedor Indutny
6caf012d59 etw_provider: unbreak windows build 2013-07-31 22:35:46 +04:00
Fedor Indutny
8e29ce9f13 src: lint c++ code 2013-07-31 22:12:06 +04:00
Trevor Norris
6a5a7b089e node: add inTick and lastThrew to infoBox
To prevent all unnecessary calls to JS from MakeCallback, the remaining
two immediate return variables inTick and lastThrew have been added to
infoBox. Now MakeCallback should never need to call into JS unless it
absolutely has to.

Also removed Tock. Performance tests showed it was at least as fast or
faster than using a normal object, and this is more readable.
2013-07-31 09:25:19 -07:00
Ben Noordhuis
6327d67be3 crypto: fix assert() on malformed hex input
Use the StringBytes::IsValidString() function introduced in commit
dce26cc to ensure that the input string meets the expectations of the
other StringBytes functions before processing it further.

Fixes the following assertion:

    Assertion failed: (str->Length() % 2 == 0 && "invalid hex string
    length"), function StorageSize, file ../../src/string_bytes.cc,
    line 301.

Fixes #5725.
2013-07-30 14:34:19 +02:00
Ben Noordhuis
dce26ccea1 string_bytes: add StringBytes::IsValidString()
Performs a quick, non-exhaustive check on the input string to see if
it's compatible with the specified string encoding.

Curently it only checks that hex strings have a length that is a
multiple of two.
2013-07-30 14:32:47 +02:00
Trevor Norris
7ca77eaf38 fs: write strings directly to disk
Prior, strings would first be converted to a Buffer before being written
to disk. Now the intermediary step has been removed.

Other changes of note:

* Class member "must_free" was added to req_wrap so to track if the
  memory needs to be manually cleaned up after use.
* External String Resource support, so the memory will be used directly
  instead of copying out the data.
* Docs have been updated to reflect that if position is not a number
  then it will assume null. Previously it specified the argument must be
  null, but that was not how the code worked. An attempt was made to
  only support == null, but there were too many tests that assumed !=
  number would be enough.
* Docs update show some of the write/writeSync arguments are optional.
2013-07-30 14:42:30 -07:00
Trevor Norris
63fc6a63c8 string_bytes: export GetExternalParts
The method is useful elsewhere when needing to check if external and
grab data.
2013-07-30 14:41:01 -07:00
Ben Noordhuis
4cc57b4aca crypto: simplify DH modp group name matcher
* Use ARRAY_SIZE() rather than scanning until we hit a NULL entry.
* Fix `-fsigned-char -Wnarrowing` compiler warnings. Harmless but
  numerous and annoying.
* Static-ify the modp_group and mod_groups arrays.
* Const-ify the modp_groups array.
2013-07-29 20:49:28 +02:00
Ben Noordhuis
8111ca2f9f src: const-ify variables in src/node_crypto*
No functional changes, just some code tightening. Clean up some style
inconsistencies while we are here.
2013-07-30 22:03:49 +02:00
Ben Noordhuis
71b3138925 src: remove unused import in src/node_os.cc 2013-07-30 21:32:45 +02:00
Ben Noordhuis
511af4dd5f string_bytes: don't use named imports in header
It imports the definition into every source file that includes
string_bytes.h, as evidenced by the build suddenly breaking left
and right because of missing Handle/Local/String/Value imports.
2013-07-30 21:31:04 +02:00
Ben Noordhuis
b8c04b921b Merge remote-tracking branch 'origin/v0.10'
Conflicts:
	AUTHORS
	ChangeLog
	deps/uv/ChangeLog
	deps/uv/src/version.c
	deps/uv/src/win/fs.c
	src/node.cc
	src/node_crypto.cc
	src/node_os.cc
	src/node_version.h
2013-07-30 15:19:48 +02:00
Ben Noordhuis
6bd922fce8 dgram: report send errors to cb, don't pass bytes
Passing the number of sent bytes to the callback is superfluous;
datagram sockets operate in atomic mode: either the sendmsg() system
call succeeds or it fails but it never does partial writes.

Instead, report send errors to the callback. UDP error reporting is
fairly haphazard on most platforms. You should not expect reliable
delivery of anything besides EMSGSIZE and (possibly) ENETDOWN and
ENETUNREACH.

Fixes #2608.
2013-07-29 06:48:46 +02:00
Ben Noordhuis
34b0a36120 src: don't use NewExternal() with unaligned strings
V8 3.20.9 enforces that external pointers are aligned on a two-byte
boundary.

We cannot portably guarantee that for the source code strings that
tools/js2c.py generates so simply stop using String::NewExternal()
altogether (and by extension String::ExternalAsciiStringResource).

Fixes the following run-time assert:

  FATAL ERROR: v8::String::NewExternal() Pointer is not aligned
2013-07-29 05:11:00 +02:00
Ben Noordhuis
8f571b52a7 src: remove unused tick_spinner 2013-07-28 19:07:59 +02:00
Timothy J Fontaine
33267337fa Now working on 0.10.16 2013-07-25 17:03:03 -07:00
Timothy J Fontaine
2426d65af8 2013.07.25, Version 0.10.15 (Stable)
* src: fix process.getuid() return value (Ben Noordhuis)
2013-07-25 16:26:15 -07:00
Ben Noordhuis
015ec05272 src: fix process.getuid() return value
And process.getgid() too.

Commit ed80638 changed fs.chown() and fs.fchown() to only accept
unsigned integers. Make process.getuid() and process.getgid() follow
suit.

This commit should unbreak npm on OS X - it's hitting the new 'uid must
be an unsigned int' check when installing as e.g. user 'nobody' (which
has an UID of -2 in /etc/passwd or 4294967294 when cast to an uid_t.)

Fixes #5904.
2013-07-26 00:29:03 +02:00
Timothy J Fontaine
90c448de23 Now working on 0.10.15 2013-07-25 13:54:16 -07:00
Timothy J Fontaine
fdf57f811f 2013.07.25, Version 0.10.14 (Stable)
* uv: Upgrade to v0.10.13

* npm: Upgrade to v1.3.5

* os: Don't report negative times in cpu info (Ben Noordhuis)

* fs: Handle large UID and GID (Ben Noordhuis)

* url: Fix edge-case when protocol is non-lowercase (Shuan Wang)

* doc: Streams API Doc Rewrite (isaacs)

* node: call MakeDomainCallback in all domain cases (Trevor Norris)

* crypto: fix memory leak in LoadPKCS12 (Fedor Indutny)
2013-07-25 11:49:01 -07:00
Fedor Indutny
d62c2d975a tls: share tls tickets key between cluster workers
fix #5871
2013-07-25 01:16:00 +04:00
Ben Noordhuis
44ed42bd97 src: move NODE_MODULE_VERSION to node_version.h 2013-07-24 22:17:35 +02:00
Ben Noordhuis
0330bdf519 lib: macro-ify type checks
Increases the grep factor. Makes it easier to harmonize type checks
across the code base.
2013-07-24 21:49:35 +02:00
Ben Noordhuis
4b279f0092 src: rename macros.py to notrace_macros.py
This incarnation of macros.py is only used to disable the (d)trace
macros. Rename it so it better reflects its purpose. A new macros.py
will be added in a follow-up commit.
2013-07-24 21:49:18 +02:00
Ben Noordhuis
d8240769c6 src: cares_wrap: remove two unused variables 2013-07-24 18:49:47 +02:00
Trevor Norris
c76ed64348 smalloc: add external to alloc with callbacks
Forgot to actually assign cb_info to the External in smalloc::Alloc()
that accepts a callback to be run in the weak callback.
2013-07-24 09:17:10 -07:00
Ben Noordhuis
e20811a628 src: os: use Number::New() for CPU info
The return values from uv_cpu_info() don't necessarily fit in a 32 bits
signed integer.

Fixes #5732.
2013-07-23 17:12:17 +02:00
Ben Noordhuis
ed806385bf fs: uids and gids must be unsigned ints
Before this commit, fs.chown() and fs.fchown() coerced the uid and gid
arguments to signed integers which is wrong because uid_t and gid_t are
unsigned on most all platforms and IDs that don't fit in a signed
integer do exist.

This commit changes the aforementioned functions to take unsigned ints
instead.  No test because we can't assume the system has [GU]IDs that
large.

This change depends on joyent/libuv@d779eb5.

Fixes #5890.
2013-07-23 13:36:46 +02:00
Trevor Norris
35e0d60d0c buffer: slice on zero length buffer
SlowBuffer(0) passes NULL instead of doing malloc(0). So when someone
attempted to SlowBuffer(0).slice(0, 1) an assert would fail in
smalloc::SliceOnto.

It's important that the check go where it is because the resulting
Buffer needs to have external array data allocated. In the case a user
tries to slice a zero length Buffer it will also have NULL passed as the
data argument.

Also fixed where the .parent attribute was set for zero length Buffers.
There is no need to track the source of slice if the slice isn't
actually occurring.
2013-07-22 17:27:59 -07:00
Ben Noordhuis
254b711155 src: fix windows build error from 221c689e
Just forward declare struct sockaddr, the struct is never actually
dereferenced in src/node_internals.h.

Before this commit, it included sys/socket.h but that header doesn't
exist on Windows.
2013-07-20 21:45:24 +02:00
Ben Noordhuis
ca9eb718fb src, lib: update after internal api change
Libuv now returns errors directly.  Make everything in src/ and lib/
follow suit.

The changes to lib/ are not strictly necessary but they remove the need
for the abominations that are process._errno and node::SetErrno().
2013-07-20 12:09:29 +02:00
Ben Noordhuis
0161ec87af src, lib: deduplicate errnoException 2013-07-20 12:04:35 +02:00
Ben Noordhuis
d4c14c1fe5 src: add libuv bindings module
Exports:

* all UV_E* error codes
* a uv_err_name() binding
2013-07-20 12:04:35 +02:00
Ben Noordhuis
221c689ebb udp_wrap, tcp_wrap: add out arg to AddressToJS
Prep work for removing process._errno. The handle.getsockname() function
will return a status code in the future and set the address and port
properties on the object that's passed in from JS land.
2013-07-19 23:41:35 +02:00
Ben Noordhuis
d11e7c2075 src: ReqWrap now optionally accepts a wrap object 2013-07-19 23:41:35 +02:00
Trevor Norris
4a34c69cbf buffer: return offset for end of last write 2013-07-19 14:05:46 -07:00
Ben Noordhuis
2bedf6efb1 src: fix persistent handle lifecycle issue
Commit 636ca7c adds an optimization that casts strong Persistent<T>
handles directly to Local<T> handles to avoid the overhead of creating
new HandleScope-rooted Local<T> handles all the time.

One gotcha that I missed is that it's no longer legal to reference the
Local<T> after calling Persistent<T>::Dispose(). This commit addresses
that.
2013-07-19 22:56:28 +02:00
Ben Noordhuis
db13983e68 src: add IsFunction() assert to MakeCallback
Helps catch bugs early on. Without it, V8 throws the fairly
unhelpful exception "TypeError: undefined is not a function" -
unhelpful because there is no stack trace.
2013-07-19 22:56:28 +02:00
Trevor Norris
d817843d2e smalloc: create separate module
It will be confusing if later on we add Buffer#dispose(), and smalloc is
its own cpp api anyways. So instead create a new require('smalloc') to
expose the previous Buffer.alloc/dispose methods, and expose copyOnto
and kMaxLength as well.

Other changes:
* Added documentation and additional tests.
* smalloc::CopyOnto has changed from using assert() to throwing errors
  on bad argument values because it is not exposed to the user.
* Minor style fixes.
2013-07-19 13:36:13 -07:00
Trevor Norris
46d11510ad node: always set function name
For easier debugging it's helpful to always have the function name.
These were not set for methods coming from cc.
2013-07-19 12:47:06 -07:00
Trevor Norris
be940b4501 smalloc: remove NULL assert check
In fa10b75 the assert to check if data == NULL was remove for
smalloc::Alloc with no callback. It should have also been removed where
a callback is accepted.

No sense in making sure that length == 0 if data == NULL because devs
already have to be responsible for checking that length is the same as
the char* they're passing in.
2013-07-15 11:08:23 -07:00
Ben Noordhuis
2c47030174 src: remove Buffer::Data(Persistent<T>&)
It hits a compiler bug in gcc <= 4.4 similar to the issue that was
recently addressed in commit 157d2bc:

    ../deps/v8/include/v8.h: In function ‘char*
    node::Buffer::Data(v8::Persistent&) [with TypeName = v8::Object]’:
    ../src/node_crypto.cc:1123: instantiated from here
    ../deps/v8/include/v8.h:876: error: ‘class v8::Data’ is not a
    function,
    ../src/node_internals.h:356: error: conflict with ‘template char*
    node::Buffer::Data(v8::Persistent&)’
    ../src/node_internals.h:357: error: in call to ‘Data’

Remove the helper function, it was only used in a couple of places.
Should fix the build on Ubuntu 10.04.

Fixes #5844.
2013-07-13 14:08:23 +02:00
Timothy J Fontaine
81c2a36439 Now working on 0.11.5 2013-07-12 15:17:16 -07:00
Timothy J Fontaine
48c542db52 Merge remote-tracking branch 'upstream/v0.10'
Conflicts:
	AUTHORS
	ChangeLog
	deps/npm/Makefile
	deps/npm/doc/api/npm-commands.md
	deps/npm/doc/api/npm-deprecate.md
	deps/npm/doc/api/npm-init.md
	deps/npm/doc/api/npm-owner.md
	deps/npm/doc/api/npm-publish.md
	deps/npm/doc/api/npm-run-script.md
	deps/npm/doc/cli/npm-adduser.md
	deps/npm/doc/cli/npm-bin.md
	deps/npm/doc/cli/npm-bugs.md
	deps/npm/doc/cli/npm-build.md
	deps/npm/doc/cli/npm-cache.md
	deps/npm/doc/cli/npm-completion.md
	deps/npm/doc/cli/npm-deprecate.md
	deps/npm/doc/cli/npm-docs.md
	deps/npm/doc/cli/npm-edit.md
	deps/npm/doc/cli/npm-explore.md
	deps/npm/doc/cli/npm-help-search.md
	deps/npm/doc/cli/npm-help.md
	deps/npm/doc/cli/npm-init.md
	deps/npm/doc/cli/npm-install.md
	deps/npm/doc/cli/npm-link.md
	deps/npm/doc/cli/npm-ls.md
	deps/npm/doc/cli/npm-outdated.md
	deps/npm/doc/cli/npm-owner.md
	deps/npm/doc/cli/npm-pack.md
	deps/npm/doc/cli/npm-prefix.md
	deps/npm/doc/cli/npm-prune.md
	deps/npm/doc/cli/npm-publish.md
	deps/npm/doc/cli/npm-restart.md
	deps/npm/doc/cli/npm-rm.md
	deps/npm/doc/cli/npm-root.md
	deps/npm/doc/cli/npm-run-script.md
	deps/npm/doc/cli/npm-search.md
	deps/npm/doc/cli/npm-shrinkwrap.md
	deps/npm/doc/cli/npm-start.md
	deps/npm/doc/cli/npm-stop.md
	deps/npm/doc/cli/npm-submodule.md
	deps/npm/doc/cli/npm-tag.md
	deps/npm/doc/cli/npm-test.md
	deps/npm/doc/cli/npm-uninstall.md
	deps/npm/doc/cli/npm-unpublish.md
	deps/npm/doc/cli/npm-update.md
	deps/npm/doc/cli/npm-version.md
	deps/npm/doc/cli/npm-view.md
	deps/npm/doc/cli/npm-whoami.md
	deps/npm/doc/files/npm-folders.md
	deps/npm/doc/files/package.json.md
	deps/npm/doc/misc/npm-coding-style.md
	deps/npm/doc/misc/npm-config.md
	deps/npm/doc/misc/npm-developers.md
	deps/npm/doc/misc/npm-disputes.md
	deps/npm/doc/misc/npm-faq.md
	deps/npm/doc/misc/npm-registry.md
	deps/npm/doc/misc/npm-scripts.md
	deps/npm/doc/misc/semver.md
	deps/npm/html/doc/README.html
	deps/npm/html/doc/api/npm-bin.html
	deps/npm/html/doc/api/npm-bugs.html
	deps/npm/html/doc/api/npm-commands.html
	deps/npm/html/doc/api/npm-config.html
	deps/npm/html/doc/api/npm-deprecate.html
	deps/npm/html/doc/api/npm-docs.html
	deps/npm/html/doc/api/npm-edit.html
	deps/npm/html/doc/api/npm-explore.html
	deps/npm/html/doc/api/npm-help-search.html
	deps/npm/html/doc/api/npm-init.html
	deps/npm/html/doc/api/npm-install.html
	deps/npm/html/doc/api/npm-link.html
	deps/npm/html/doc/api/npm-load.html
	deps/npm/html/doc/api/npm-ls.html
	deps/npm/html/doc/api/npm-outdated.html
	deps/npm/html/doc/api/npm-owner.html
	deps/npm/html/doc/api/npm-pack.html
	deps/npm/html/doc/api/npm-prefix.html
	deps/npm/html/doc/api/npm-prune.html
	deps/npm/html/doc/api/npm-publish.html
	deps/npm/html/doc/api/npm-rebuild.html
	deps/npm/html/doc/api/npm-restart.html
	deps/npm/html/doc/api/npm-root.html
	deps/npm/html/doc/api/npm-run-script.html
	deps/npm/html/doc/api/npm-search.html
	deps/npm/html/doc/api/npm-shrinkwrap.html
	deps/npm/html/doc/api/npm-start.html
	deps/npm/html/doc/api/npm-stop.html
	deps/npm/html/doc/api/npm-submodule.html
	deps/npm/html/doc/api/npm-tag.html
	deps/npm/html/doc/api/npm-test.html
	deps/npm/html/doc/api/npm-uninstall.html
	deps/npm/html/doc/api/npm-unpublish.html
	deps/npm/html/doc/api/npm-update.html
	deps/npm/html/doc/api/npm-version.html
	deps/npm/html/doc/api/npm-view.html
	deps/npm/html/doc/api/npm-whoami.html
	deps/npm/html/doc/api/npm.html
	deps/npm/html/doc/cli/npm-adduser.html
	deps/npm/html/doc/cli/npm-bin.html
	deps/npm/html/doc/cli/npm-bugs.html
	deps/npm/html/doc/cli/npm-build.html
	deps/npm/html/doc/cli/npm-bundle.html
	deps/npm/html/doc/cli/npm-cache.html
	deps/npm/html/doc/cli/npm-completion.html
	deps/npm/html/doc/cli/npm-config.html
	deps/npm/html/doc/cli/npm-dedupe.html
	deps/npm/html/doc/cli/npm-deprecate.html
	deps/npm/html/doc/cli/npm-docs.html
	deps/npm/html/doc/cli/npm-edit.html
	deps/npm/html/doc/cli/npm-explore.html
	deps/npm/html/doc/cli/npm-help-search.html
	deps/npm/html/doc/cli/npm-help.html
	deps/npm/html/doc/cli/npm-init.html
	deps/npm/html/doc/cli/npm-install.html
	deps/npm/html/doc/cli/npm-link.html
	deps/npm/html/doc/cli/npm-ls.html
	deps/npm/html/doc/cli/npm-outdated.html
	deps/npm/html/doc/cli/npm-owner.html
	deps/npm/html/doc/cli/npm-pack.html
	deps/npm/html/doc/cli/npm-prefix.html
	deps/npm/html/doc/cli/npm-prune.html
	deps/npm/html/doc/cli/npm-publish.html
	deps/npm/html/doc/cli/npm-rebuild.html
	deps/npm/html/doc/cli/npm-restart.html
	deps/npm/html/doc/cli/npm-rm.html
	deps/npm/html/doc/cli/npm-root.html
	deps/npm/html/doc/cli/npm-run-script.html
	deps/npm/html/doc/cli/npm-search.html
	deps/npm/html/doc/cli/npm-shrinkwrap.html
	deps/npm/html/doc/cli/npm-star.html
	deps/npm/html/doc/cli/npm-stars.html
	deps/npm/html/doc/cli/npm-start.html
	deps/npm/html/doc/cli/npm-stop.html
	deps/npm/html/doc/cli/npm-submodule.html
	deps/npm/html/doc/cli/npm-tag.html
	deps/npm/html/doc/cli/npm-test.html
	deps/npm/html/doc/cli/npm-uninstall.html
	deps/npm/html/doc/cli/npm-unpublish.html
	deps/npm/html/doc/cli/npm-update.html
	deps/npm/html/doc/cli/npm-version.html
	deps/npm/html/doc/cli/npm-view.html
	deps/npm/html/doc/cli/npm-whoami.html
	deps/npm/html/doc/cli/npm.html
	deps/npm/html/doc/files/npm-folders.html
	deps/npm/html/doc/files/npm-global.html
	deps/npm/html/doc/files/npm-json.html
	deps/npm/html/doc/files/npmrc.html
	deps/npm/html/doc/files/package.json.html
	deps/npm/html/doc/index.html
	deps/npm/html/doc/misc/npm-coding-style.html
	deps/npm/html/doc/misc/npm-config.html
	deps/npm/html/doc/misc/npm-developers.html
	deps/npm/html/doc/misc/npm-disputes.html
	deps/npm/html/doc/misc/npm-faq.html
	deps/npm/html/doc/misc/npm-index.html
	deps/npm/html/doc/misc/npm-registry.html
	deps/npm/html/doc/misc/npm-scripts.html
	deps/npm/html/doc/misc/removing-npm.html
	deps/npm/html/doc/misc/semver.html
	deps/npm/man/man1/npm-README.1
	deps/npm/man/man1/npm-adduser.1
	deps/npm/man/man1/npm-bin.1
	deps/npm/man/man1/npm-bugs.1
	deps/npm/man/man1/npm-build.1
	deps/npm/man/man1/npm-bundle.1
	deps/npm/man/man1/npm-cache.1
	deps/npm/man/man1/npm-completion.1
	deps/npm/man/man1/npm-dedupe.1
	deps/npm/man/man1/npm-deprecate.1
	deps/npm/man/man1/npm-docs.1
	deps/npm/man/man1/npm-edit.1
	deps/npm/man/man1/npm-explore.1
	deps/npm/man/man1/npm-help-search.1
	deps/npm/man/man1/npm-help.1
	deps/npm/man/man1/npm-init.1
	deps/npm/man/man1/npm-install.1
	deps/npm/man/man1/npm-link.1
	deps/npm/man/man1/npm-ls.1
	deps/npm/man/man1/npm-outdated.1
	deps/npm/man/man1/npm-owner.1
	deps/npm/man/man1/npm-pack.1
	deps/npm/man/man1/npm-prefix.1
	deps/npm/man/man1/npm-prune.1
	deps/npm/man/man1/npm-publish.1
	deps/npm/man/man1/npm-rebuild.1
	deps/npm/man/man1/npm-restart.1
	deps/npm/man/man1/npm-rm.1
	deps/npm/man/man1/npm-root.1
	deps/npm/man/man1/npm-run-script.1
	deps/npm/man/man1/npm-search.1
	deps/npm/man/man1/npm-shrinkwrap.1
	deps/npm/man/man1/npm-star.1
	deps/npm/man/man1/npm-stars.1
	deps/npm/man/man1/npm-start.1
	deps/npm/man/man1/npm-stop.1
	deps/npm/man/man1/npm-submodule.1
	deps/npm/man/man1/npm-tag.1
	deps/npm/man/man1/npm-test.1
	deps/npm/man/man1/npm-uninstall.1
	deps/npm/man/man1/npm-unpublish.1
	deps/npm/man/man1/npm-update.1
	deps/npm/man/man1/npm-version.1
	deps/npm/man/man1/npm-view.1
	deps/npm/man/man1/npm-whoami.1
	deps/npm/man/man1/npm.1
	deps/npm/man/man3/npm-bin.3
	deps/npm/man/man3/npm-bugs.3
	deps/npm/man/man3/npm-commands.3
	deps/npm/man/man3/npm-config.3
	deps/npm/man/man3/npm-deprecate.3
	deps/npm/man/man3/npm-docs.3
	deps/npm/man/man3/npm-edit.3
	deps/npm/man/man3/npm-explore.3
	deps/npm/man/man3/npm-help-search.3
	deps/npm/man/man3/npm-init.3
	deps/npm/man/man3/npm-install.3
	deps/npm/man/man3/npm-link.3
	deps/npm/man/man3/npm-load.3
	deps/npm/man/man3/npm-ls.3
	deps/npm/man/man3/npm-outdated.3
	deps/npm/man/man3/npm-owner.3
	deps/npm/man/man3/npm-pack.3
	deps/npm/man/man3/npm-prefix.3
	deps/npm/man/man3/npm-prune.3
	deps/npm/man/man3/npm-publish.3
	deps/npm/man/man3/npm-rebuild.3
	deps/npm/man/man3/npm-restart.3
	deps/npm/man/man3/npm-root.3
	deps/npm/man/man3/npm-run-script.3
	deps/npm/man/man3/npm-search.3
	deps/npm/man/man3/npm-shrinkwrap.3
	deps/npm/man/man3/npm-start.3
	deps/npm/man/man3/npm-stop.3
	deps/npm/man/man3/npm-submodule.3
	deps/npm/man/man3/npm-tag.3
	deps/npm/man/man3/npm-test.3
	deps/npm/man/man3/npm-uninstall.3
	deps/npm/man/man3/npm-unpublish.3
	deps/npm/man/man3/npm-update.3
	deps/npm/man/man3/npm-version.3
	deps/npm/man/man3/npm-view.3
	deps/npm/man/man3/npm-whoami.3
	deps/npm/man/man3/npm.3
	deps/npm/man/man5/npm-folders.5
	deps/npm/man/man5/npm-global.5
	deps/npm/man/man5/npm-json.5
	deps/npm/man/man7/npm-coding-style.7
	deps/npm/man/man7/npm-config.7
	deps/npm/man/man7/npm-developers.7
	deps/npm/man/man7/npm-disputes.7
	deps/npm/man/man7/npm-faq.7
	deps/npm/man/man7/npm-registry.7
	deps/npm/man/man7/npm-scripts.7
	deps/npm/man/man7/removing-npm.7
	deps/npm/man/man7/semver.7
	deps/npm/package.json
	deps/uv/AUTHORS
	deps/uv/ChangeLog
	deps/uv/src/version.c
	deps/uv/test/test-fs.c
	deps/uv/test/test-list.h
	lib/http.js
	lib/tls.js
	src/node_version.h
2013-07-12 13:26:56 -07:00
Ben Noordhuis
c679ac8f00 build: fix windows build
Be very careful with forward declarations, MSVC is quite picky and
rather stupid about it.

Fixes #5810.
2013-07-11 15:37:02 +02:00
Trevor Norris
6d91bd3707 node: call MakeDomainCallback in all domain cases
Previously there was no way to pass a Function callback directly to
MakeCallback and support domains. The check has been added so that users
never have to worry about supporting domains while using MakeCallback.
2013-07-10 10:46:48 -07:00
Fedor Indutny
610269295b crypto: fix memory leak in LoadPKCS12
X509_STORE_add_cert increment reference of passed `x509` cert,
`X509_free` must be called to avoid memory leak.

This is a back-port of commit c1db1ec from the master branch.
2013-07-10 10:10:29 +02:00
Timothy J Fontaine
8a7e2b9da6 Now working v0.10.14 2013-07-09 14:28:37 -07:00
Timothy J Fontaine
e32660a984 2013.07.09, Version 0.10.13 (Stable)
* uv: Upgrade to v0.10.12

* npm: Upgrade to 1.3.2

* windows: get proper errno (Ben Noordhuis)

* tls: only wait for finish if we haven't seen it (Timothy J Fontaine)

* http: Dump response when request is aborted (isaacs)

* http: use an unref'd timer to fix delay in exit (Peter Rust)

* zlib: level can be negative (Brian White)

* zlib: allow zero values for level and strategy (Brian White)

* buffer: add comment explaining buffer alignment (Ben Noordhuis)

* string_bytes: properly detect 64bit (Timothy J Fontaine)

* src: fix memory leak in UsingDomains() (Ben Noordhuis)
2013-07-09 13:51:24 -07:00
Ben Noordhuis
6acde2152f src: remove unnecessary calls to Local<T>::New() 2013-07-07 14:34:49 +02:00
Ben Noordhuis
636ca7c684 src: cast strong persistent handles to locals
Avoids the overhead of creating a new Local every time we unwrap a
Persistent handle.
2013-07-07 14:24:18 +02:00
Ben Noordhuis
3220bc4254 smalloc: don't take address of stack var 2013-07-07 13:30:20 +02:00
Nathan Rajlich
567c72b8c5 configure: fix the --without-ssl option
Closes #5807.
2013-07-09 11:27:37 -07:00
Timothy J Fontaine
2fc34d75d9 tls_wrap: return Error not throw for missing cert 2013-07-09 00:13:02 +00:00
Trevor Norris
ead8e26b5b smalloc: call callback if set on AllocDispose
Fix bug where if dev passed a callback to Alloc then called AllocDispose
it wouldn't bother to pass the data to the callback and instead would
just free it.
2013-07-08 11:09:09 -07:00
Trevor Norris
aa8c4a0766 smalloc: zero size allocs may need to be free'd
Zero size allocations don't necessarily mean that data == NULL. So
instead check each value seperately and perform necessary operations.
2013-07-08 09:17:22 -07:00
Ben Noordhuis
0693d22f86 src: enable native v8 typed arrays
This commit removes our homegrown typed arrays implementation and
enables V8's built-in typed arrays implementation.
2013-07-06 17:44:45 +02:00
Ben Noordhuis
c56a96c25c src: abort() on fatal error in debug mode
abort() generates a nice core dump and makes it easy to catch fatal
errors in one's debugger of choice.
2013-07-06 17:44:44 +02:00
Ben Noordhuis
8985bb8bfd string_bytes: stop using String::AsciiValue
Debug builds of V8 now actively check that the string only contains
ASCII characters (i.e. doesn't contain bytes with the high bit set.)
2013-07-06 17:44:44 +02:00
Ben Noordhuis
110a9cd8db lib, src: upgrade after v8 api change
This is a big commit that touches just about every file in the src/
directory. The V8 API has changed in significant ways. The most
important changes are:

* Binding functions take a const v8::FunctionCallbackInfo<T>& argument
  rather than a const v8::Arguments& argument.

* Binding functions return void rather than v8::Handle<v8::Value>. The
  return value is returned with the args.GetReturnValue().Set() family
  of functions.

* v8::Persistent<T> no longer derives from v8::Handle<T> and no longer
  allows you to directly dereference the object that the persistent
  handle points to. This means that the common pattern of caching
  oft-used JS values in a persistent handle no longer quite works,
  you first need to reconstruct a v8::Local<T> from the persistent
  handle with the Local<T>::New(isolate, persistent) factory method.

A handful of (internal) convenience classes and functions have been
added to make dealing with the new API a little easier.

The most visible one is node::Cached<T>, which wraps a v8::Persistent<T>
with some template sugar. It can hold arbitrary types but so far it's
exclusively used for v8::Strings (which was by far the most commonly
cached handle type.)
2013-07-06 17:44:44 +02:00
Trevor Norris
eec43351c4 smalloc: revert change to use pointer indirection
Better to compare fixed addresses than to use pointer indirection.
2013-07-06 15:05:04 -07:00
Fedor Indutny
f0a05e4bc3 buffer: use macro 2013-07-06 15:55:46 +04:00
Fedor Indutny
28609d1779 smalloc: fix style, use macro 2013-07-06 03:52:30 +04:00
Ben Noordhuis
30e7d08d93 Merge remote-tracking branch 'origin/v0.10'
Conflicts:
	lib/buffer.js
	lib/http.js
	src/node.cc
2013-07-05 02:40:39 +02:00
Ben Noordhuis
806e300878 src: fix memory leak in UsingDomains()
UsingDomains() assigned process_tickCallback when it had already
been set by MakeCallback() a few frames down the call stack.

Dispose the handle first or we'll retain whatever is in the lexical
closure of the old process._tickCallback function.

Fixes #5795.
2013-07-05 02:20:39 +02:00
Trevor Norris
278183a902 {stream,udp,tls}_wrap: remove unused offset/length
The function arguments offset and length are now no longer used since
all I/O requests now use discretely allocated memory.
2013-07-03 15:03:41 -07:00
Trevor Norris
fa10b757f5 smalloc: use malloc instead of new
To use realloc the implementation had to be changed to use malloc/free.
2013-07-03 15:03:24 -07:00
Trevor Norris
ec90e6e80a slab_allocator: remove SlabAllocator
Now that Buffer instantiation has improved, the SlabAllocator is an
unnecessary layer of complexity preventing further performance
optimizations.

Currently there is a small performance loss with very small stream
requests, but this will soon be addressed.
2013-07-03 14:56:27 -07:00
Fedor Indutny
c1db1ecd15 crypto: fix memory leak in LoadPKCS12
X509_STORE_add_cert increment reference of passed `x509` cert,
`X509_free` must be called to avoid memory leak.
2013-07-03 16:16:44 +04:00
Brian White
dc3c2d12c8 zlib: level can be negative
This is a back-port of commit e945903 from the master branch.
2013-07-01 19:37:50 +02:00
Brian White
9b09c9eedd zlib: allow changing of level and strategy 2013-07-01 13:08:09 +02:00
Brian White
e945903671 zlib: level can be negative 2013-07-01 13:08:09 +02:00
isaacs
38c0c47bbe 2013.06.26, Version 0.11.3 (Unstable)
* uv: Upgrade to v0.11.5

* c-ares: upgrade to 1.10.0

* v8: upgrade to v3.19.13

* punycode: update to v1.2.3 (Mathias Bynens)

* debugger: break on uncaught exception (Miroslav Bajtos)

* child_process: emit 'disconnect' asynchronously (Ben Noordhuis)

* dtrace: enable uv's probes if enabled (Timothy J Fontaine)

* dtrace: unify dtrace and systemtap interfaces (Timothy J Fontaine)

* buffer: New API for backing data store (Trevor Norris)

* buffer: return `this` in fill() for chainability (Brian White)

* build: fix include order for building on windows (Timothy J Fontaine)

* build: add android support (Linus Mårtensson)

* readline: strip ctrl chars for prompt width calc (Krzysztof Chrapka)

* tls: introduce TLSSocket based on tls_wrap binding (Fedor Indutny)

* tls: add localAddress and localPort properties (Ben Noordhuis)

* crypto: free excessive memory in NodeBIO (Fedor Indutny)

* process: remove maxTickDepth (Trevor Norris)

* timers: use uv_now instead of Date.now (Timothy J Fontaine)

* util: Add debuglog, deprecate console lookalikes (isaacs)

* module: use path.sep instead of a custom solution (Robert Kowalski)

* http: don't escape request path, reject bad chars (Ben Noordhuis)

* net: emit dns 'lookup' event before connect (Ben Noordhuis)

* dns: add getServers and setServers (Timothy J Fontaine)
2013-06-26 11:15:10 -07:00
Miroslav Bajtos
c16963b977 src: break on uncaught exception
Most TryCatch blocks have SetVerbose flag on, this tells V8 to report
uncaught exceptions to debugger.

FatalException handler is called from V8 Message listener instead from
the place where TryCatch was used. Otherwise uncaught exceptions are
logged twice.

See comment in `deps/v8/include/v8.h` for explanation of SetVerbose
flag:

>  By default, exceptions that are caught by an external exception
>  handler are not reported.  Call SetVerbose with true on an
>  external exception handler to have exceptions caught by the
>  handler reported as if they were not caught.

The flag is used by `Isolate::ShouldReportException()`, which is called
by `Isolate::DoThrow()` to decide whether an exception is considered
uncaught.
2013-06-26 19:54:31 +02:00
Fedor Indutny
4ae96c885b crypto: do not move half-filled write head
Might cause write head running over read head, when there were no
allocation and `Commit()` was called. Source of at least one test
failure on windows (`simple/test-https-drain.js`).
2013-06-26 12:36:56 +02:00
isaacs
adf9b67e59 Merge remote-tracking branch 'ry/v0.10' into master
Conflicts:
	ChangeLog
	deps/uv/ChangeLog
	deps/uv/src/unix/stream.c
	deps/uv/src/version.c
	deps/v8/build/common.gypi
	deps/v8/src/frames.h
	deps/v8/src/runtime.cc
	deps/v8/test/mjsunit/debug-set-variable-value.js
	lib/http.js
	src/node_version.h
2013-06-25 11:12:33 -07:00
Ben Noordhuis
157d2bcc04 buffer: fix gcc 4.2 build breakage
gcc 4.2 on OS X gets confused about the call to node::Buffer::Data().
Fully qualify the function name to help it along.

Fixes the following build error:

    ../../deps/v8/include/v8.h: In function ‘char*
    node::Buffer::Data(v8::Handle<v8::Value>)’:
    ../../deps/v8/include/v8.h:900: error: ‘class v8::Data’
    is not a function,
    ../../src/node_buffer.h:38: error:
    conflict with ‘char* node::Buffer::Data(v8::Handle<v8::Object>)’
    ../../src/node_buffer.cc:94: error:
    in call to ‘Data’
2013-06-20 13:23:12 +02:00
Timothy J Fontaine
a2c4ca09ed string_bytes: properly detect 64bit 2013-06-19 17:16:35 -07:00
Trevor Norris
f5e13ae9b5 buffer: write strings directly from call
Buffer(<String>) used to pass the string to js where it would then be
passed back to cpp for processing. Now only the buffer object
instantiation is done in js and the string is processed in cpp.

Also added a Buffer api that also accepts the encoding.
2013-06-19 13:15:05 -07:00
Fedor Indutny
bf8dc0762a crypto: change assertion to condition in bio
Read head can be the same as write head, even if there's some data to
read.
2013-06-19 22:03:07 +02:00
Trevor Norris
7373c4ddb7 buffer: proper API export for Windows
So that Windows users can properly include smalloc and node_buffer,
NODE_EXTERN was added to the headers that export this functionality.
2013-06-18 15:41:16 -07:00
Trevor Norris
4b40358841 buffer: implement new fill behavior
Old fill would take the char code of the first character and wrap around
the int to fit in the 127 range. Now fill will duplicate whatever string
is given through the entirety of the buffer.

Note: There is one bug around ending on a partial fill of any character
outside the ASCII range.
2013-06-18 15:41:03 -07:00
Trevor Norris
56869d9ae7 buffer: remove c-style casts 2013-06-18 15:39:32 -07:00
Trevor Norris
3a2f273bd7 buffer: use smalloc as backing data store
Memory allocations are now done through smalloc. The Buffer cc class has
been removed completely, but for backwards compatibility have left the
namespace as Buffer.

The .parent attribute is only set if the Buffer is a slice of an
allocation. Which is then set to the alloc object (not a Buffer).

The .offset attribute is now a ReadOnly set to 0, for backwards
compatibility. I'd like to remove it in the future (pre v1.0).

A few alterations have been made to how arguments are either coerced or
thrown. All primitives will now be coerced to their respective values,
and (most) all out of range index requests will throw.

The indexes that are coerced were left for backwards compatibility. For
example: Buffer slice operates more like Array slice, and coerces
instead of throwing out of range indexes. This may change in the future.

The reason for wanting to throw for out of range indexes is because
giving js access to raw memory has high potential risk. To mitigate that
it's easier to make sure the developer is always quickly alerted to the
fact that their code is attempting to access beyond memory bounds.

Because SlowBuffer will be deprecated, and simply returns a new Buffer
instance, all tests on SlowBuffer have been removed.

Heapdumps will now show usage under "smalloc" instead of "Buffer".

ParseArrayIndex was added to node_internals to support proper uint
argument checking/coercion for external array data indexes.

SlabAllocator had to be updated since handle_ no longer exists.
2013-06-18 15:39:13 -07:00
Trevor Norris
252cdfa43b smalloc: add api to manually dispose Persistent
If the user knows the allocation is no longer needed then the memory can
be manually released.

Currently this will not ClearWeak the Persistent, so the callback will
still run.

If the user passed a ClearWeak callback, and then disposed the object,
the buffer callback argument will == NULL.
2013-06-18 15:38:06 -07:00
Trevor Norris
8f3f9f7830 smalloc: initial implementation
smalloc is a simple utility for quickly allocating external memory onto
js objects. This will be used to centralize how memory is managed in
node, and will become the backer for Buffers. So in the future crypto's
SlabBuffer, stream's SlabAllocator will be removed.

Note on the js API: because no arguments are optional the order of
arguments have been placed to match their cc counterparts as closely as
possible.
2013-06-18 15:37:51 -07:00
isaacs
637acb2b34 Now working on 0.10.13 2013-06-18 11:14:57 -07:00
isaacs
a088cf4f93 2013.06.18, Version 0.10.12 (Stable)
* npm: Upgrade to 1.2.32

* readline: make `ctrl + L` clear the screen (Yuan Chuan)

* v8: add setVariableValue debugger command (Ben Noordhuis)

* net: Do not destroy socket mid-write (isaacs)

* v8: fix build for mips32r2 architecture (Andrei Sedoi)

* configure: fix cross-compilation host_arch_cc() (Andrei Sedoi)
2013-06-18 09:50:53 -07:00
Bert Belder
1bf6d78980 stream_wrap: remove bogus assert
Libuv may provide a NULL buffer to the uv_read callback in case of an
error, so with this assert we'd be using the api incorrectly. None of
the current DoRead implementations rely on this constraint, either.
2013-06-18 01:15:25 +02:00
Ben Noordhuis
b9165252e3 src: clean up using directives
Remove the unused ones and alphabetically sort the ones that remain.
2013-06-17 23:32:19 +02:00
Timothy J Fontaine
c0281f1b30 build: fix include order for building on windows
fallout from the tls_wrap feature landing
2013-06-17 10:41:48 -07:00
Linus Mårtensson
5e4e8ec429 build: add android support
Resolves minor discrepancies between android and standard POSIX systems.
In addition, some configure parameters were added, and a helper-script
for android configuration. Ideally, this script should be merged into
the standard configure script.

To build for android, source the android-configure script with an NDK
path:

    source ./android-configure ~/android-ndk-r8d

This will create an android standalone toolchain and export the
necessary environment parameters.

After that, build as normal:

    make -j8

After the build, you should now have android-compatible NodeJS binaries.
2013-06-17 17:21:56 +02:00
Fedor Indutny
212e9cd8c9 tls: session API returns 2013-06-17 14:00:26 +02:00
Ben Noordhuis
0581f5cb60 stream_wrap: fix signed/unsigned comparison warning 2013-06-17 01:23:57 +02:00
Ben Noordhuis
70a75cd41e cares: fix uninitialized variable warning
Suppress the following warning:

  ../../src/cares_wrap.cc: In function ‘v8::Handle<v8::Value>
  node::cares_wrap::SetServers(const v8::Arguments&)’:
  ../../src/cares_wrap.cc:1017:5: warning: ‘uv_ret.uv_err_s::code’
  may be used uninitialized in this function [-Wuninitialized]
2013-06-17 01:22:41 +02:00
Fedor Indutny
03e008ddb8 tls_wrap: embed TLS encryption into streamwrap 2013-06-16 09:30:14 +02:00
Fedor Indutny
4c48a39c65 stream_wrap: introduce StreamWrapCallbacks
StreamWrapCallbacks is a helper class for incepting into uv_stream_t*
management process.
2013-06-15 21:44:51 +02:00
Fedor Indutny
6978e998ee process: abstract out HandleToStream
Originally contributed by @tjfontaine, but modified to be faster and
more generic.
2013-06-15 21:44:50 +02:00
Fedor Indutny
0495b7031c crypto: clear error on return in AddCRL 2013-06-15 21:44:50 +02:00
Fedor Indutny
5dd155a3bb crypto: ensure that read head is always non-empty 2013-06-15 21:43:24 +02:00
Fedor Indutny
4536b27ac1 crypto: do not deallocate embedded buffer 2013-06-14 17:10:04 +02:00
Fedor Indutny
56d9c48573 crypto: fix excessive buffer allocation
Allocate buffer only if the next one isn't free.
2013-06-14 17:10:04 +02:00
isaacs
17d00f1657 Now working on 0.10.12 2013-06-13 11:37:04 -07:00
isaacs
d9d5bc4654 2013.06.13, Version 0.10.11 (Stable)
* uv: upgrade to 0.10.11

* npm: Upgrade to 1.2.30

* openssl: add missing configuration pieces for MIPS (Andrei Sedoi)

* Revert "http: remove bodyHead from 'upgrade' events" (isaacs)

* v8: fix pointer arithmetic undefined behavior (Trevor Norris)

* crypto: fix utf8/utf-8 encoding check (Ben Noordhuis)

* net: Fix busy loop on POLLERR|POLLHUP on older linux kernels (Ben Noordhuis, isaacs)
2013-06-13 10:35:30 -07:00
Trevor Norris
e92f4879eb string_bytes: write strings using new API
StringBytes::Write now uses new v8 API and also does preliminary check
if the string is external, then will use external memory instead.
2013-06-12 14:43:37 -07:00
Trevor Norris
642ea2b668 string_bytes: use external for large strings
When large strings are used they cause v8's GC to spend a lot more time
cleaning up. In these cases it's much faster to use external string
resources.

UTF8 strings do not use external string resources because only one and
two byte external strings are supported.

EXTERN_APEX is the value at which v8's GC overtakes performance.

The following table has the type and buffer size that use to encode the
strings as rough estimates of the percentage of performance gain from
this patch (UTF8 is missing because they cannot be externalized).

encoding  128KB    1MB    5MB
-----------------------------
ASCII       58%   208%   250%
HEX         15%    74%    86%
BASE64      11%    74%    71%
UCS2         2%   225%   398%
BINARY    2234%  1728%  2305%

BINARY is so much faster across the board because of using the new v8
WriteOneByte API.
2013-06-12 14:43:24 -07:00
Trevor Norris
87624ab911 string_bytes: implement new v8 API
v8 has a new API to write out strings to memory. This has been
implemented.

One other change of note is BINARY encoded strings have a new
implementation. This has improved performance substantially.
2013-06-11 15:42:50 -07:00
Trevor Norris
45a08cb216 lint: add mising isolates and minor style fixes 2013-06-11 15:42:49 -07:00
Ben Noordhuis
393d33e7ea src: upgrade after v8 api change
The prototype of v8::Persistent<T>::MakeWeak() has changed. Update the
code in src/ to follow suit.
2013-06-12 00:07:28 +02:00
Fedor Indutny
9ae1d182ba crypto: free excessive memory in NodeBIO
Before this commit NodeBIO never shrank, possibly consuming a lot of
memory (depending on reader's haste).

All buffers between write_head's child and read_head should be
deallocated on read, leaving only space left in write_head and in the
next buffer.
2013-06-08 15:40:57 +04:00
Ben Noordhuis
4bb4f734b3 src: unexport node_isolate
Commit 0bba5902 accidentally (or maybe erroneously) added node_isolate
to src/node.h and src/node_object_wrap.h.

Undo that, said variable is not for public consumption. Add-on authors
should use v8::Isolate::GetCurrent() instead.

I missed that while reviewing. Mea culpa.

Fixes #5639.
2013-06-07 17:01:16 +02:00
isaacs
6ada73383c Now working on v0.10.11 2013-06-04 14:38:41 -07:00
isaacs
25e51c396a 2013.06.04, Version 0.10.10 (Stable)
* uv: Upgrade to 0.10.10

* npm: Upgrade to 1.2.25

* url: Properly parse certain oddly formed urls (isaacs)

* stream: unshift('') is a noop (isaacs)
2013-06-04 12:13:46 -07:00
Ben Noordhuis
a7820a15e7 src: replace ngx-queue.h with queue.h
No functional changes, just one less entry in the LICENSE file.
2013-06-04 12:22:03 +02:00
Nick Desaulniers
72b92e92d3 src: wrap macros in do {...} while (0)
Wrapped two macros in do {...} while (0) blocks and lined up
backslashes.  Uses up semicolon in contexts where a dangling semicolon
is erroneous.
2013-06-04 11:54:05 +02:00
Trevor Norris
4b31a2d8da process: use Tock for nextTickQueue items
v8 plays very well with constructed objects, so we're using one in the
nextTickQueue.
2013-05-30 16:51:41 -07:00
Trevor Norris
bcb85a1d31 src: remove old comment code
Now that maxTickDepth no longer exists there's no depth index on
infoBox. Forgot to remove the comment about this.
2013-05-30 15:09:50 -07:00
Trevor Norris
b846842aff process: remove spinner
Remove the need to call start/stop the uv_idle spinner between
MakeCallbacks. The one place where the tick processor needs to be kicked
is where a user catches uncaughtException. For that we'll now use
setImmediate, which accomplishes the same task.
2013-05-30 14:51:40 -07:00
isaacs
ce54f4ae50 Now working on v0.10.10 2013-05-30 11:28:07 -07:00
isaacs
878ffdbe6a 2013.05.30, Version 0.10.9 (Stable)
* npm: Upgrade to 1.2.24

* uv: Upgrade to v0.10.9

* repl: fix JSON.parse error check (Brian White)

* tls: proper .destroySoon (Fedor Indutny)

* tls: invoke write cb only after opposite read end (Fedor Indutny)

* tls: ignore .shutdown() syscall error (Fedor Indutny)
2013-05-30 10:31:07 -07:00
Trevor Norris
9a6c0853bc process: remove max tick check for domains
maxTickDepth checks have been removed for domains and replaced with a
flag that checks if the last callback threw. If it did then execution of
the remaining tickQueue is deferred to the spinner.

This is to prevent domains from entering a continuous loop when an error
callback also throws an error.
2013-05-30 09:33:21 -07:00
Trevor Norris
0761c90204 process: remove maxTickDepth from _tickCallback
Removes the check for maxTickDepth for non-domain callbacks. So a user
can starve I/O by setting a recursive nextTick.

The domain case is more complex and will be addressed in another commit.
2013-05-30 09:30:19 -07:00
Trevor Norris
5b636feaa8 process: relocate needSpinner calls
It's only necessary to request the spinner once tickDone has been
called, and not on every nextTick.
2013-05-30 09:29:15 -07:00
Andrew Paprocki
49e3fcd058 vm: fix race condition in watchdog cleanup
Previous code was calling uv_loop_delete() directly on a running loop,
which led to race condition aborts/segfaults within libuv.  This change
changes the watchdog thread to call uv_run() with UV_RUN_ONCE so that
the call exits after either the timer times out or uv_async_send() is
called from the main thread in Watchdog::Destroy().  The timer/async
handles are then closed and uv_run() with UV_RUN_DEFAULT is called so
that libuv has a chance to cleanup before the thread exits.  The main
thread meanwhile calls uv_thread_join() and then uv_loop_delete() to
complete the cleanup.
2013-05-30 15:57:25 +02:00
Ben Noordhuis
c188a75103 buffer: guard against integer overflow 2013-05-30 00:13:05 +02:00
Ben Noordhuis
36ebff0470 buffer: simplify ReadFloatGeneric offset checks 2013-05-30 00:13:04 +02:00
Ben Noordhuis
ef0926ce42 os: use IsBigEndian() in GetEndianness() function 2013-05-30 00:13:04 +02:00
Ben Noordhuis
d02f228263 buffer: guard against pointer aliasing issues 2013-05-30 00:12:57 +02:00
Ben Noordhuis
7890a69e4d src: add endianness helper functions 2013-05-30 00:12:57 +02:00
Ben Noordhuis
448adaa456 src: simplify HandleWrap initialization 2013-05-30 00:12:49 +02:00
Ben Noordhuis
4d68daea0f src: replace c-style casts with c++-style casts 2013-05-30 00:12:49 +02:00
Ben Noordhuis
28659aba37 Merge remote-tracking branch 'origin/v0.10'
Conflicts:
	deps/uv/ChangeLog
	deps/uv/src/unix/stream.c
	deps/uv/src/version.c
	lib/tls.js
2013-05-29 23:12:11 +02:00
Fedor Indutny
fa170dd2b2 tls: ignore .shutdown() syscall error
Quote from SSL_shutdown man page:

  The output of SSL_get_error(3) may be misleading,
  as an erroneous SSL_ERROR_SYSCALL may be flagged even though
  no error occurred.

Also, handle all other errors to prevent assertion in `ClearError()`.
2013-05-28 20:14:44 +04:00
isaacs
ba048e72b0 Merge remote-tracking branch 'ry/v0.10'
Conflicts:
	AUTHORS
	ChangeLog
	configure
	deps/uv/ChangeLog
	deps/uv/src/unix/darwin.c
	deps/uv/src/unix/stream.c
	deps/uv/src/version.c
	deps/v8/src/isolate.cc
	deps/v8/src/version.cc
	lib/http.js
	src/node_version.h
2013-05-27 14:46:52 -07:00
isaacs
ccb77e1c9d Now working on 0.10.9 2013-05-24 15:45:46 -07:00
isaacs
30d9e9fdd9 2013.05.24, Version 0.10.8 (Stable)
* v8: update to 3.14.5.9

* uv: upgrade to 0.10.8

* npm: Upgrade to 1.2.23

* http: remove bodyHead from 'upgrade' events (Nathan Zadoks)

* http: Return true on empty writes, not false (isaacs)

* http: save roundtrips, convert buffers to strings (Ben Noordhuis)

* configure: respect the --dest-os flag consistently (Nathan Rajlich)

* buffer: throw when writing beyond buffer (Trevor Norris)

* crypto: Clear error after DiffieHellman key errors (isaacs)

* string_bytes: strip padding from base64 strings (Trevor Norris)
2013-05-24 15:06:33 -07:00
Timothy J Fontaine
007e63bb13 buffer: special case empty string writes
Prior to 119354f we specifically handled passing a zero length string
to write on a buffer, restore that functionality.
2013-05-23 16:32:04 -07:00
Timothy J Fontaine
17e696c312 systemtap: add tapset for node user probes
This makes systemtap tracing prettier, you can do things like `stap -e
'probe node_http_server_request { println(probestr); }'`
2013-05-22 20:19:31 -07:00
Timothy J Fontaine
23509eb9e8 dtrace: unify dtrace and systemtap interfaces 2013-05-22 20:19:31 -07:00
Timothy J Fontaine
f8193ab3c4 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.

fixes #5497
2013-05-22 20:13:14 -07:00
Trevor Norris
f58eb8f5db src: remove unused comment
Now that Context::New(Isolate*) returns Local, the removed comment is
no longer applicable that there is a Persistent which will need to be
disposed.
2013-05-22 16:09:06 -07:00
Trevor Norris
2868bf94b6 src: upgrade to new v8 api
Small change that Context::New requires an isolate and returns Local
instead of Persistent.
2013-05-22 14:12:25 -07:00
isaacs
0fefcc1690 Merge remote-tracking branch ry/v0.10 into master
Conflicts:
	AUTHORS
	ChangeLog
	src/node_crypto.cc
	src/node_version.h
2013-05-20 14:43:14 -07:00
isaacs
3a2b5030ae crypto: Clear error after DiffieHellman key errors
Fixes #5499
2013-05-20 14:27:32 -07:00
Trevor Norris
d5d5170c35 string_bytes: strip padding from base64 strings
Because of variations in different base64 implementation, it's been
decided to strip all padding from the end of a base64 string and
calculate its size from that.
2013-05-20 13:40:58 -07:00
isaacs
f57ff787aa src: Remove superfluous static_cast 2013-05-17 16:58:05 -07:00
isaacs
bae6d089a4 Now working on 0.10.8 2013-05-17 14:37:44 -07:00
isaacs
61c9f78c63 Merge remote-tracking branch 'ry/v0.10' into master
Conflicts:
	AUTHORS
	ChangeLog
	deps/uv/ChangeLog
	deps/uv/config-unix.mk
	deps/uv/src/unix/stream.c
	deps/uv/src/version.c
	deps/uv/uv.gyp
	src/node.cc
	src/node_buffer.cc
	src/node_crypto.cc
	src/node_version.h
	src/stream_wrap.cc
	src/stream_wrap.h
2013-05-17 14:04:54 -07:00
isaacs
d2fdae197a 2013.05.17, Version 0.10.7 (Stable)
* uv: upgrade to v0.10.7

* npm: Upgrade to 1.2.21

* crypto: Don't ignore verify encoding argument (isaacs)

* buffer, crypto: fix default encoding regression (Ben Noordhuis)

* timers: fix setInterval() assert (Ben Noordhuis)
2013-05-17 13:59:10 -07:00
isaacs
199fa9f8dd crypto: Don't ignore verify encoding argument 2013-05-17 13:55:29 -07:00
Trevor Norris
7998843807 fs_event: use cached Persistent syms instead
Instead of String::New every time, use a Persistent sym. This can be
accomplished in two ways:

1) Local<String> str = *persistent_str_sym;

2) Handle<String> str = persistent_str_sym;

I've chosen to use the latter method for simplicity's sake.

Other small changes include creating syms on Initialize and removing
unnecessary Local casting on return values.
2013-05-16 16:06:01 -07:00
Trevor Norris
999ee45d36 src: add node_isolates
Few primitives weren't being passed node_isolate. Adding them for
consistency.
2013-05-16 15:58:33 -07:00
Ben Noordhuis
f59ab10a64 buffer, crypto: fix default encoding regression
The default encoding is 'buffer'. When the input is a string, treat it
as 'binary'. Fixes the following assertion:

  node: ../src/string_bytes.cc:309: static size_t
  node::StringBytes::StorageSize(v8::Handle<v8::Value>, node::encoding):
  Assertion `0 && "buffer encoding specified but string provided"'
  failed.

Introduced in 64fc34b2.

Fixes #5482.
2013-05-16 17:25:24 +02:00
isaacs
ef2b2a3f52 Now working on v0.10.7 2013-05-14 14:33:56 -07:00
Timothy J Fontaine
8886c6bf62 dns: add getServers and setServers
getServers returns an array of ips that are currently being used for
resolution

setServers takes an array of ips that are to be used for resolution,
this will throw if there's invalid input but preserve the original
configuration
2013-05-14 14:15:24 -07:00
isaacs
5deb1672f2 2013.05.14, Version 0.10.6 (Stable)
* module: Deprecate require.extensions (isaacs)

* stream: make Readable.wrap support objectMode, empty streams (Daniel Moore)

* child_process: fix handle delivery (Ben Noordhuis)

* crypto: Fix performance regression (isaacs)

* src: DRY string encoding/decoding (isaacs)
2013-05-14 13:51:43 -07:00
isaacs
a241deb19a crypto: Pass encodings for Hmac digest 2013-05-14 13:51:43 -07:00
isaacs
c1e8c8de1c crypto: Pass encodings to C++ for Sign/Verify 2013-05-14 13:51:43 -07:00
isaacs
430dc39e87 crypto: use StringBytes::Encode 2013-05-14 13:51:43 -07:00
isaacs
a1eacdf12a crypto: Pass strings to binding layer directly 2013-05-14 13:51:43 -07:00
isaacs
119354f735 buffer: DRY string encoding using StringBytes
This also templatizes the Buffer::*Slice functions, and the template
function probably cannot be safely used outside of Node.  However, it
also SHOULD not be used outside of Node, so this is arguably a feature
as well as a caveat.
2013-05-14 13:51:42 -07:00
isaacs
4e8cddddcb src: use StringBytes for DecodeWrite/DecodeBytes/Encode
Bonus: this makes node::Encode actually work properly with base64,
ucs2, hex, etc.
2013-05-14 13:51:42 -07:00
isaacs
69dac92c36 src: Use StringBytes in StreamWrap 2013-05-14 13:51:42 -07:00
isaacs
64fc34b270 src: Add StringBytes static util class
Four functions:

- StringBytes::StorageSize()
- StringBytes::Size()
- StringBytes::Write()
- StringBytes::Encode()
2013-05-14 13:51:24 -07:00
isaacs
458c8bb9f8 Now working on 0.11.3 2013-05-13 15:54:19 -07:00
isaacs
5d3dc0e4c3 2013.05.13, Version 0.11.2 (Unstable)
* uv: Upgrade to 0.11.2

* V8: Upgrade to 3.19.0

* npm: Upgrade to 1.2.21

* build: Makefile should respect configure --prefix (Timothy J Fontaine)

* cluster: use round-robin load balancing (Ben Noordhuis)

* debugger, cluster: each worker has new debug port (Miroslav Bajtoš)

* debugger: `restart` with custom debug port (Miroslav Bajtoš)

* debugger: breakpoints in scripts not loaded yet (Miroslav Bajtoš)

* event: EventEmitter#setMaxListeners() returns this (Sam Roberts)

* events: add EventEmitter.defaultMaxListeners (Ben Noordhuis)

* install: Support $(PREFIX) install target directory prefix (Olof Johansson)

* os: Include netmask in os.networkInterfaces() (Ben Kelly)

* path: add path.isAbsolute(path) (Ryan Doenges)

* stream: Guarantee ordering of 'finish' event (isaacs)

* streams: introduce .cork/.uncork/._writev (Fedor Indutny)

* vm: add support for timeout argument (Andrew Paprocki)
2013-05-13 14:54:38 -07:00
Ben Noordhuis
7349667467 stream_wrap: MayContainNonAscii() is deprecated
V8 3.19.0 deprecates v8::String::MayContainNonAscii(). It always returns
true so there is not much point in keeping the call site around.
2013-05-13 04:40:14 +02:00
Ben Kelly
8a407f58b9 os: Include netmask in os.networkInterfaces()
re #3765 and #5432
fixes #4743
2013-05-08 17:04:29 -07:00
Miroslav Bajtoš
fbf4641462 src: initialize debug-related uv_async_t handles
uv_async_t handles for dispatching of debug messages and
emitting NODE_DEBUG_ENABLED used to be initialized every time
node::EnableDebug() was called, which happened every time
user sends a SIGUSR1.

Now they are initialized only once from node::Init() during
application start.
2013-05-08 16:53:53 -07:00
Miroslav Bajtoš
43ec1b1c2e debugger, cluster: each worker has new debug port
Implement support for debugging cluster workers. Each worker process
is assigned a new debug port in an increasing sequence.

I.e. when master process uses port 5858, then worker 1 uses port 5859,
worker 2 uses port 5860, and so on.

Introduce new command-line parameter '--debug-port=' which sets debug_port
but does not start debugger. This option works for all node processes, it
is not specific to cluster workers.

Fixes joyent/node#5318.
2013-05-08 16:53:52 -07:00
Brian White
aca275f58d stream_wrap: fix memory leak on early return 2013-05-07 15:05:54 -07:00
Trevor Norris
b7f6e6b42f stream_wrap: remove unused arg from WriteBuffer
WriteBuffer was changed in the cork/uncork implementation (60ed2c54).
The unused argument has been removed.
2013-05-07 14:44:40 -07:00
Andrew Paprocki
c081809344 vm: add support for timeout argument
Add a watchdog class which executes a timer in a separate event loop in
a separate thread that will terminate v8 execution if it expires.

Add timeout argument to functions in vm module which use the watchdog
if a non-zero timeout is specified.
2013-04-29 23:38:19 +02:00
Ben Noordhuis
af1ed99ce2 Merge remote-tracking branch 'origin/v0.10'
Conflicts:
	AUTHORS
	ChangeLog
	deps/uv/ChangeLog
	deps/uv/src/version.c
	lib/http.js
	src/node_crypto.cc
	src/node_os.cc
	src/node_version.h
	test/simple/helper-debugger-repl.js
2013-04-29 14:08:51 +02:00
Fedor Indutny
60ed2c5434 net: implement ._writev for .cork/uncork() support
Add Writev method to StreamWrap class for writing mixed array of strings
and buffers. Expose this method for TCP class.
2013-04-27 21:03:40 +04:00
isaacs
ec5577cf9d Now working on 0.10.6 2013-04-23 14:07:23 -07:00