Commit Graph

3378 Commits

Author SHA1 Message Date
Alexis Campailla
440b9e2245 src: node.cc use isolate->ThrowException
Environment doesn't have ThrowException, we meant isolate here.

Introduced in commit
75adde07f9.
2014-02-24 11:54:22 -08:00
Fedor Indutny
dbae8b569f node_internals: add missing env-inl.h include 2014-02-22 03:35:29 +04:00
Fedor Indutny
75adde07f9 src: remove node_isolate from source
fix #6899
2014-02-22 03:20:56 +04:00
Fedor Indutny
a6f89ccd76 dtrace: workaround linker bug on FreeBSD 2014-02-21 00:56:17 +04:00
Timothy J Fontaine
ae418f974d Now working on v0.10.27 2014-02-18 16:43:12 -08:00
Timothy J Fontaine
31c510ca88 2014.02.18, Version 0.10.26 (Stable)
* uv: Upgrade to v0.10.25 (Timothy J Fontaine)

* npm: upgrade to 1.4.3 (isaacs)

* v8: support compiling with VS2013 (Fedor Indutny)

* cares: backport TXT parsing fix (Fedor Indutny)

* crypto: throw on SignFinal failure (Fedor Indutny)

* crypto: update root certificates (Ben Noordhuis)

* debugger: Fix breakpoint not showing after restart (Farid Neshat)

* fs: make unwatchFile() insensitive to path (iamdoron)

* net: do not re-emit stream errors (Fedor Indutny)

* net: make Socket destroy() re-entrance safe (Jun Ma)

* net: reset `endEmitted` on reconnect (Fedor Indutny)

* node: do not close stdio implicitly (Fedor Indutny)

* zlib: avoid assertion in close (Fedor Indutny)
2014-02-18 14:55:58 -08:00
Xidorn Quan
ae02992872 os: networkInterfaces include scopeid for ipv6 2014-02-18 10:10:30 -08:00
Brian White
a226be4f76 crypto: allow custom generator for DiffieHellman 2014-02-18 15:49:23 +04:00
Timothy J Fontaine
466a9b5c78 Merge remote-tracking branch 'upstream/v0.10'
Conflicts:
	src/node_zlib.cc
2014-02-17 20:57:53 -08:00
Fedor Indutny
7589a0007c crypto: make NewSessionDoneCb public
Generic friend classes do not work well with old compiler versions (and
MSVC).
2014-02-18 03:22:18 +04:00
Fedor Indutny
829a9b8cba zlib: introduce pending close state
zlib should not crash in `close()` if the write is still in progress.

fix #7101
2014-02-18 01:11:05 +04:00
Fedor Indutny
75ea11fc08 tls: introduce asynchronous newSession
fix #7105
2014-02-18 01:07:09 +04:00
Bert Belder
fa4eb47caa bindings: add spawn_sync bindings
This implements a nested event loop that makes it possible to control
a child process, while blocking the main loop until the process exits.
2014-02-10 21:22:06 +01:00
Fedor Indutny
c0d81f9099 process: allow changing exitCode in on('exit')
fix #7081
2014-02-09 15:10:38 +04:00
Timothy J Fontaine
eadb4f5606 Merge remote-tracking branch 'upstream/v0.10'
Conflicts:
	deps/v8/src/preparser.cc
	deps/v8/src/win32-math.h
	doc/api/http.markdown
	src/node_buffer.h
	src/node_crypto.cc
	src/node_file.cc
	src/node_http_parser.cc
2014-02-08 16:45:27 -08:00
Timothy J Fontaine
5c832e44c3 src: refactor buffer bounds checking
Consolidate buffer bounds checking logic into Buffer namespace and use
it consistently throughout the source.
2014-02-08 15:31:27 -08:00
Austin Moran
4b77bd39a4 headers: fix spelling error 2014-02-08 00:19:50 +04:00
Ben Noordhuis
bbd56d881d vm: don't copy Proxy object from parent context
Make vm.runInContext() and vm.runInNewContext() stop copying the Proxy
object from the parent context into the new context when --harmony or
--harmony_proxies is in effect because it overwrites the new context's
native Proxy object.

This commit also adds a regression test for Harmony symbols.  They work
okay in the current implementation and the test should ensure it stays
that way.
2014-02-06 15:30:38 +04:00
Fedor Indutny
f1de13b8ab node: do not print SyntaxError hints to stderr
Try embedding the ` ... ^` lines inside the `SyntaxError` (or any other
native error) object before giving up and printing them to the stderr.

fix #6920
fix #1310
2014-02-06 13:26:57 +04:00
Trevor Norris
6cbfcdad46 src: move AsyncListener from process to tracing
The AsyncListener API has been moved into the "tracing" module in order
to keep the process object free from unnecessary clutter.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-02-05 17:16:36 -08:00
Trevor Norris
d9e1e4c661 env: add watched_providers for AsyncListener
Now the second field in asyncFlags will tell if the provider is
currently being watched, or listened for.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-02-05 13:31:00 -08:00
Trevor Norris
4a9af3fecb async_wrap: add provider types/pass to constructor
These will be used to allow users to filter for which types of calls
they wish their callbacks to run.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-02-05 13:30:56 -08:00
Trevor Norris
c9abb59638 node: make AsyncListenerInst field more explicit
"flags" could mean one of many things, and multiple flag types could be
checked. So make the field more explicit on what type of flags are being
stored.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-02-05 13:30:24 -08:00
Ben Noordhuis
d23ac0ea9c src: add v8.getHeapStatistics() function
Add a one-to-one binding to v8::GetHeapStatistics().  Returns info on
the current state of the JS heap, like total size and amount used.
2014-02-05 11:49:01 -08:00
Ben Noordhuis
010222d39f src: add tracing.v8.on('gc') statistics hooks
Add a new 'tracing' module with a v8 property that lets the user
register listeners for gc events.  The listeners are invoked after
every garbage collection cycle with 'before' and 'after' statistics.
Useful for monitoring tools that want to keep track of memory usage.
2014-02-05 11:49:01 -08:00
Ben Noordhuis
4dc6f4adf4 src: fix MakeCallback() handle leak
Create a new HandleScope before looking up the object context with
v8::Object::CreationContext(), else we leak the Local<Context> into
the current HandleScope.

That's relatively harmless unless the HandleScope is long-lived and
MakeCallback() is called a lot.  In a scenario like that, we may end
up leaking a lot of memory.

What is unfortunate about this change is that we're trying hard to
eradicate the node_isolate global.  Longer term, we will probably have
to change the MakeCallback() prototype to one that requires an explicit
v8::Isolate* argument.
2014-02-05 11:49:01 -08:00
Ben Noordhuis
1f2f3fa83a src: update MakeCallback() function prototype
Make it possible to invoke MakeCallback() on a v8::Value but only for
the variant that takes a v8::Function as the thing to call.

The const char* and v8::String variants still require a v8::Object
because the function to call is looked up as a property on the receiver,
but that only works when the receiver is an object, not a primitive.
2014-02-05 11:49:00 -08:00
Fedor Indutny
528a3ce3ed tls: more session configuration options, methods
Introduce `ticketKeys` server option, `session` client option,
`getSession()` and `getTLSTicket()` methods.

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

fix #7045
2014-02-05 14:20:02 +04:00
Ben Noordhuis
09c51d5e40 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.
2014-02-04 01:42:52 +04:00
Fedor Indutny
9a60bf3726 tls: fix crash in SNICallback
`tls_wrap.cc` was crashing in an `Unwrap` call, when non
`SecureContext` object was passed to it. Check that the passed object
is a `SecureContext` instance before unwrapping it.

fix #7008
2014-02-04 01:35:08 +04:00
Nikolai Vavilov
9b37b83a20 zlib: add sync versions for convenience methods 2014-02-01 03:45:45 +04:00
Fedor Indutny
643a7d8c16 dtrace: fix arguments warning
Add enough arguments to `NODE_NET_SOCKET_READ()` and
`NODE_NET_SOCKET_WRITE()` stubs.
2014-02-01 00:45:55 +04:00
Fedor Indutny
e796e11087 node: do not ever close stdio
Even if stdio streams are opened as file streams, we should not ever try
to close them. This could be accomplished by passing `autoClose: false`
in options on their creation.
2014-01-30 21:26:19 +04:00
Timothy J Fontaine
c8c26f12e4 src: move header inclusion out of namespace
The placement of a previous fix to include proper size_t types in
addons was erroneously placed inside a namespace, move to just before.

Fix #6992
2014-01-29 09:37:29 -08:00
Timothy J Fontaine
e63268e433 Now working on 0.11.12 2014-01-28 19:46:17 -08:00
Timothy J Fontaine
b46e774215 2014.01.29, Version 0.11.11 (Unstable)
* v8: Upgrade to 3.22.24.19

* http_parser: Upgrade to 2.2.1

* openssl: Upgrade to 1.0.1f

* uv: Upgrade to 0.11.18

* async-listener: revamp of subsystem (Trevor Norris)

* node: do not ever close stdio (Fedor Indutny)

* http: use writev on chunked encoding (Trevor Norris)

* async_wrap/timers: remove Add/RemoveAsyncListener (Trevor Norris)

* child_process: better error reporting for exec (Fedor Indutny)

* crypto: add newline to cert and key if not present (Fedor Indutny)

* crypto: clear error in GetPeerCertificate (Fedor Indutny)

* crypto: honor default ciphers in client mode (Jacob Hoffman-Andrews)

* crypto: introduce .setEngine(engine, [flags]) (Fedor Indutny)

* crypto: support custom pbkdf2 digest methods (Ben Noordhuis)

* domain: fix off-by-one in Domain.exit() (Ryan Graham)

* http: concatenate duplicate headers by default (Alex Kocharin)

* http: do not emit EOF non-readable socket (Fedor Indutny)

* node: fix argument parsing with -p arg (Alexis Campailla)

* path: improve POSIX path.join() performance (Jo Liss)

* tls: emit `clientError` on early socket close (Fedor Indutny)

* tls: introduce `.setMaxSendFragment(size)` (Fedor Indutny)

* tls: make cert/pfx optional in tls.createServer() (Ben Noordhuis)

* tls: process accumulated input (Fedor Indutny)

* tls: show human-readable error messages (Ben Noordhuis)

* util: handle escaped forward slashes correctly (Tom Gallacher)
2014-01-28 17:29:56 -08:00
Fedor Indutny
fc26fd6b38 node: do not ever close stdio
Even if stdio streams are opened as file streams, we should not ever try
to close them. This could be accomplished by passing `autoClose: false`
in options on their creation.
2014-01-29 03:27:23 +04:00
Timothy J Fontaine
ab54e32bbd src: only define ssize_t on windows if undefined
This matches how libuv handles the definition of ssize_t, by
typedef'ing intptr_t to ssize_t.

However, in the future we will use portable types from stddef.h
2014-01-28 15:07:40 -08:00
Fedor Indutny
9836a4eeda stream_wrap: use uv_try_write where possible
Use `uv_try_write` for string and buffer writes, thus avoiding to do
allocations and copying in some of the cases.
2014-01-29 02:49:03 +04:00
Fedor Indutny
eaf76648a6 node: explicitly include sys/types.h for size_t
fix #6724
2014-01-28 12:38:02 +04:00
Keith M Wesolowski
76b98462e5 node: register modules from DSO constructors
Built-in modules should be automatically registered, replacing the
static module list.  Add-on modules should also be automatically
registered via DSO constructors.  This improves flexibility in adding
built-in modules and is also a prerequisite to pure-C addon modules.
2014-01-27 15:52:50 -08:00
Alexis Campailla
14d6df8702 node: fix argument parsing with -p arg
node -p would cause an access violation.

Fixes test\message\stdin_messages.js on Windows.
2014-01-27 11:54:53 -08:00
Fedor Indutny
64d33a7519 deps: update uv to 0.11.18 2014-01-27 21:30:51 +04:00
Fedor Indutny
b4c4e0bbaa crypto: throw on SignFinal failure
fix #6963
2014-01-26 22:24:57 +04:00
Fedor Indutny
cc4b6e6e58 crypto: clear error in GetPeerCertificate
fix #6945
2014-01-26 03:48:36 +04:00
Fedor Indutny
640912d18a tls_wrap: propagate errors to write callbacks
fix #6903
2014-01-24 22:09:42 +04:00
Trevor Norris
74656ca189 lint: use reinterpret_cast, not C-style casts 2014-01-23 13:01:53 -08:00
Timothy J Fontaine
eb7c7be7da Now working on 0.10.26 2014-01-23 11:44:32 -08:00
Fedor Indutny
c79c304ead tls: process accumulated input
When creating TLSSocket on top of the regular socket that already
contains some received data, `_tls_wrap.js` should try to write all that
data to the internal `SSL*` instance.

fix #6940
2014-01-23 20:39:32 +04:00
Timothy J Fontaine
bc2f31ae1d 2014.01.23, Version 0.10.25 (Stable)
* uv: Upgrade to v0.10.23

* npm: Upgrade to v1.3.24

* v8: Fix enumeration for objects with lots of properties

* child_process: fix spawn() optional arguments (Sam Roberts)

* cluster: report more errors to workers (Fedor Indutny)

* domains: exit() only affects active domains (Ryan Graham)

* src: OnFatalError handler must abort() (Timothy J Fontaine)

* stream: writes may return false but forget to emit drain (Yang Tianyang)
2014-01-22 21:03:08 -08:00
Trevor Norris
56ebf308dc node: clear nextTickQueue when using domains
When the domain specific code was reintroduced in 828f145 the
conditional to check and clear the nextTickQueue if many items had run
was not introduced. This allows for the application to run out of memory
if domains are being used in an infinite recursive loop.
2014-01-22 13:33:16 -08:00
Yorkie
c7f5c98ee9 crypto: remove duplicate ERR_load_crypto_strings()
ERR_load_crypto_strings() registers the error strings for
all libcrypto functions, SSL_load_error_strings() does the
same, but also registers the libssl error strings.
2014-01-22 22:55:52 +04:00
Ben Noordhuis
74d9aa49d5 crypto: support custom pbkdf2 digest methods
Make the HMAC digest method configurable.  Update crypto.pbkdf2() and
crypto.pbkdf2Sync() to take an extra, optional digest argument.

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

Fixes #6553.
2014-01-22 15:58:07 +04:00
Trevor Norris
e6016dae34 node: remove asyncStack
Now that the context stores the active execution stack, and because
removeAsyncListener() always removed the AsyncListener from the queue
and the stack, there's no need to keep a stack around anymore. Instead
the active asyncQueue and the currentContext is able to handle it all.

Signed-off-by: Forrest L Norvell <ogd@aoaioxxysz.net>
2014-01-21 17:12:40 -08:00
Trevor Norris
f32c1ffe56 node: only run same AL once on error
Should have been included with 60fcc11 as it is the same type of fix.

Signed-off-by: Forrest L Norvell <ogd@aoaioxxysz.net>
2014-01-21 17:11:48 -08:00
Fedor Indutny
661190af13 crypto: throw only in direct C++ methods
Do not throw in internal C++ methods, that clobbers logic and may lead
to the situations, where both exception was thrown and the value was
returned (via `args.GetReturnValue().Set()`). That doesn't play nicely
with v8.

fix #6912
2014-01-22 02:25:14 +04:00
Fedor Indutny
e57ab7ba06 node: EmitExit should not call exit()
Before this commit `RunAtExit` and `env->Dispose()` were never reached,
because `EmitExit` was always colling `exit`.
2014-01-22 00:39:13 +04:00
Trevor Norris
bf08ac462e node: compare AsyncListener instances, not uid's
Now that process.createAsyncListener() returns a unique object instance
it is no longer necessary to compare the uid's of the objects.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-01-21 10:20:22 -08:00
Trevor Norris
60fcc11be2 node: ensure same AL inst only runs once
It was possible that the same AL instance was run twice if it were both
attached to the currentContext then again added to the new asyncQueue
generated for the new stack.

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

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

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

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-01-21 10:20:07 -08:00
Fedor Indutny
159da758e4 crypto: remove most of the node_isolate uses
All C++ code should be using `args.GetIsolate()` or `env->isolate()`.
Using static `node_isolate` var limits possible future functionality
(like multi-isolate support).
2014-01-20 23:29:58 +04:00
Fedor Indutny
7f9b01509f lib: introduce .setMaxSendFragment(size)
fix #6889
2014-01-20 20:39:57 +04:00
Ben Noordhuis
cda41f8775 src: don't mark addon_register_func as dllimport
addon_register_func and its cousin addon_context_register_func are type
definitions, dllimport and dllexport are name mangling directives, i.e.
they're quite unrelated concepts.  MinGW complains about mixing them
when cross-compiling native add-ons.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
Signed-off-by: Bert Belder <bertbelder@gmail.com>
2014-01-17 15:37:20 -08:00
Ben Noordhuis
262a752c29 tls: show human-readable error messages
Before this commit, verification exceptions had err.message set to the
OpenSSL error code (e.g. 'UNABLE_TO_VERIFY_LEAF_SIGNATURE').

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

    // before
    {
      message: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'
    }

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

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

Going by the number of mailing list posts and StackOverflow questions,
it's a source of confusion to many people.
2014-01-17 18:51:25 +00:00
Timothy J Fontaine
429b58701a Merge remote-tracking branch 'upstream/v0.10'
Conflicts:
	deps/uv/ChangeLog
	deps/uv/build.mk
	deps/uv/src/version.c
	deps/uv/test/test-ipc.c
	deps/v8/src/objects.cc
	src/node.cc
	src/node_os.cc
2014-01-13 14:56:12 -08:00
Timothy J Fontaine
8753bb3859 src: return empty set on ENOSYS for interfaces
If node was compiled with --no-ifaddrs to support older operating
systems, don't throw instead simply return an empty object

Fixes #6846
2014-01-12 10:04:21 -08:00
Timothy J Fontaine
270c2deb84 src: OnFatalError handler must abort()
We are in an unrecoverable state if v8 throws a FatalError, actually
ask the operating system to dump core in this case.

Fixes #6836
2014-01-09 14:01:53 -08:00
Trevor Norris
646ac18d79 node: AsyncListener use separate storage mechanism
Before when an AsyncListener object was created and the "create"
callback returned a value, it was necessary to construct a new Object
with the same callbacks but add a place for the new storage value.

Now, instead, a separate storage array is kept on the context which is
used for any return value of the "create" callback. This significantly
reduces the number of Objects that need to be created.

Also added a flags property to the context to quickly check if a
specific callback was available either on the context or on the
AsyncListener instance itself.

Few other minor changes for readability that were difficult to separate
into their own commit.

This has not been optimized yet.
2014-01-09 13:47:03 -08:00
Trevor Norris
828f14556e src: revert domain using AsyncListeners
This is a slightly modified revert of bc39bdd.

Getting domains to use AsyncListeners became too much of a challenge
with many edge cases. While this is still a goal, it will have to be
deferred for now until more test coverage can be provided.
2014-01-09 13:25:20 -08:00
Fedor Indutny
92b6417098 crypto: introduce .setEngine(engine, [flags]) 2014-01-05 16:42:33 +04:00
Trevor Norris
a40b463674 node: properly check uid when adding AsyncListener
Instead of checking the uid on the array index of the queue, instead the
object property "uid" was checked on the queue iteself. Because this
will always evaluate to "undefined" the same listener could be added
multiple times to the same context.
2014-01-03 16:48:11 -08:00
Trevor Norris
d9fc6af32a node: change AsyncListener API
There was a flaw in the old API that has been fixed. Now the
asyncListener callback is now the "create" object property in the
callback object, and is optional.
2014-01-03 13:20:23 -08:00
Timothy J Fontaine
c3e26d64f8 Now working on 0.11.11 2013-12-31 16:21:08 -08:00
Timothy J Fontaine
66931791f0 2013.12.31, Version 0.11.10 (Unstable)
* http_parser: update to 2.2

* uv: Upgrade to v0.11.17

* v8: Upgrade to 3.22.24.10

* buffer: optimize writeInt* methods (Paul Loyd)

* child_process: better error handling (Alexis Campailla)

* cluster: do not synchronously emit 'setup' event (Sam Roberts)

* cluster: restore backwards compatibility and various fixes (Sam Roberts)

* crypto: remove unnecessary OpenSSL_add_all_digests (Yorkie)

* crypto: support GCM authenticated encryption mode. (Ingmar Runge)

* dns: add resolveSoa and 'SOA' rrtype (Tuğrul Topuz)

* events: move EE c'tor guts to EventEmitter.init (Bert Belder)

* http: DELETE shouldn't default to chunked encoding (Lalit Kapoor)

* http: parse the status message in a http response. (Cam Swords)

* node: fix removing AsyncListener in callback (Vladimir Kurchatkin)

* node: follow specification, zero-fill ArrayBuffers (Trevor Norris)

* openssl: use ASM optimized routines (Fedor Indutny)

* process: allow nextTick infinite recursion (Trevor Norris)

* querystring: remove `name` from `stringify()` (Yorkie)

* timers: setImmediate v8 optimization fix (pflannery)

* tls: add serialNumber to getPeerCertificate() (Ben Noordhuis)

* tls: reintroduce socket.encrypted (Fedor Indutny)

* tls: fix handling of asterisk in SNI context (Fedor Indutny)

* util: Format negative zero as '-0' (David Chan)

* vm: fix race condition in timeout (Alexis Campailla)

* windows: fix dns lookup of localhost with ipv6 (Alexis Campailla)
2013-12-31 15:37:12 -08:00
Tuğrul Topuz
bddea032b7 dns: add resolveSoa and 'SOA' rrtype
You can now query for SOA records by either passing 'SOA' to `resolve`
or by using the new `resolveSoa`
2013-12-31 14:30:40 -08:00
Vladimir Kurchatkin
055f7e9da9 src: only access stack of non-null errors
Avoid segmentation fault when `null` is thrown
2013-12-23 15:08:11 +04:00
Fedor Indutny
82098bb97b util: introduce CHECK_EQ/CHECK_NE 2013-12-20 18:57:46 -08:00
Cam Swords
7ffe2ad616 http: parse the status message in a http response. 2013-12-20 17:55:08 +04:00
Timothy J Fontaine
00e28ee6a8 Now working on 0.10.25 2013-12-19 09:05:14 -08:00
Yorkie
59fb0185ec crypto: remove unnecessary OpenSSL_add_all_digests
`OpenSSL_add_all_algorithms` implicitly adds both digests and
ciphers. No need in calling `OpenSSL_add_all_digests` after it.
2013-12-19 15:43:21 +04:00
Timothy J Fontaine
b7fd6bc899 2013.12.18, Version 0.10.24 (Stable)
* uv: Upgrade to v0.10.21

* npm: upgrade to 1.3.21

* v8: backport fix for CVE-2013-{6639|6640}

* build: unix install node and dep library headers (Timothy J Fontaine)

* cluster, v8: fix --logfile=%p.log (Ben Noordhuis)

* module: only cache package main (Wyatt Preul)
2013-12-18 15:49:45 -08:00
Alexis Campailla
cdc038ceb6 vm: fix race condition in timeout
Eliminate a race condition between uv_async_send and the closing of the
corresponding handle.

Also made errors in Watchdog constructor call abort()

Fixes #6088
2013-12-18 15:16:36 -08:00
Ahamed Nafeez
8a79cca80c crypto: comment change on disabling compression
This is a comment change, where it originally says disabling TLS
Compression protects against BEAST attack. But in fact, it is the
CRIME attack(Compression Ratio Info-leak Made Easy) that makes use
of TLS Compression and not BEAST.

BEAST(Browser Exploit Against SSL/TLS) is an entirely another variant
making use of the chosen boundary attack against CBC mode in
encryption.

Just making sure, that the exact reason for disabling TLS compression
must be made clear and not be misleading with some other attack.
2013-12-15 14:24:51 +04:00
Timothy J Fontaine
bb1575b4c4 Now working on 0.10.24 2013-12-11 22:11:19 -08:00
Timothy J Fontaine
0462bc2356 2013.12.12, Version 0.10.23 (Stable)
* uv: Upgrade to v0.10.20 (Timothy J Fontaine)

* npm: Upgrade to 1.3.17 (isaacs)

* gyp: update to 78b26f7 (Timothy J Fontaine)

* build: include postmortem symbols on linux (Timothy J Fontaine)

* crypto: Make Decipher._flush() emit errors. (Kai Groner)

* dgram: fix abort when getting `fd` of closed dgram (Fedor Indutny)

* events: do not accept NaN in setMaxListeners (Fedor Indutny)

* events: avoid calling `once` functions twice (Tim Wood)

* events: fix TypeError in removeAllListeners (Jeremy Martin)

* fs: report correct path when EEXIST (Fedor Indutny)

* process: enforce allowed signals for kill (Sam Roberts)

* tls: emit 'end' on .receivedShutdown (Fedor Indutny)

* tls: fix potential data corruption (Fedor Indutny)

* tls: handle `ssl.start()` errors appropriately (Fedor Indutny)

* tls: reset NPN callbacks after SNI (Fedor Indutny)
2013-12-11 21:20:06 -08:00
Fedor Indutny
ba706bacf3 Merge branch 'v0.10'
Conflicts:
	src/node_file.cc
2013-12-10 23:36:41 +04:00
Fedor Indutny
f16edd2632 fs: report correct path when EEXIST
When `symlink`, `link` or `rename` report EEXIST, ENOTEMPTY or EPERM -
the destination file name should be included in the error message,
instead of source file name.

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

fix #6638
2013-12-10 22:56:01 +04:00
Fedor Indutny
c17449df16 tls_wrap: bump kClearOutChunkSize to 16kb 2013-12-10 22:28:26 +04:00
Vladimir Kurchatkin
259d449622 src: only access stack of defined errors
Avoid segmentation fault when `undefined` is thrown
2013-12-10 09:33:33 -08:00
Trevor Norris
7222539936 node: follow specification, zero-fill ArrayBuffers
Fixes #6664
2013-12-09 17:11:38 -08:00
Ingmar Runge
e0d31ea2db crypto: support GCM authenticated encryption mode.
This adds two new member functions getAuthTag and setAuthTag that
are useful for AES-GCM encryption modes. Use getAuthTag after
Cipheriv.final, transmit the tag along with the data and use
Decipheriv.setAuthTag to have the encrypted data verified.
2013-12-08 00:00:02 +04:00
Timothy J Fontaine
fcca3585fe Merge remote-tracking branch 'upstream/v0.10'
Conflicts:
	lib/tls.js
	src/node.js
2013-12-06 21:27:18 -08:00
Fedor Indutny
06b1945298 crypto: fix moving read head
Fix various possible stalls of read head (i.e. try moving it after every
write head update).

NOTE: This is actually backported from `bud`.
2013-12-07 03:48:43 +04:00
Fedor Indutny
03747f69fb tls_wrap: use writev when possible
Try writing multiple chunks from NodeBIO if possible.
2013-12-07 03:47:57 +04:00
Sam Roberts
8aac118b69 process: document kill(0), disallow kill(O_RDWR)
The null signal test existed, but only tested the case where the target
process existed, not when it did not exist.

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

kill(pid, 'O_RDWR'), or any other node constant, "worked". I fixed this
by also checking for 'SIG'. The same as done in the isSignal() function.
Now the signal names supported by process.kill() are the same as those
supported by process.on().
2013-12-02 10:41:37 -08:00
Fedor Indutny
4bd5f35889 Merge branch 'v0.10'
Conflicts:
	src/node_crypto.cc
	src/node_crypto.h
2013-12-02 15:04:47 +04:00
Fedor Indutny
9b8fcff435 tls: reset NPN callbacks after SNI
SNI callback selects a new SSL_CTX for the connection, which doesn't
have NPN callbacks set up.
2013-12-02 14:48:14 +04:00
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