Commit Graph

3378 Commits

Author SHA1 Message Date
Fedor Indutny
4c36f3e7e6 buffer: truncate buffer after string decode
When our estimates for a storage size are higher than the actual length
of decoded data, the destination buffer should be truncated. Otherwise
`Buffer::Length` will give misleading information to C++ layer.

fix #7365

Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-04-11 01:20:43 +04:00
Timothy J Fontaine
632c135622 src: use monotonic time for process.uptime()
`process.uptime()` interface will return the amount of time the
current process has been running. To achieve this it was caching the
`uv_uptime` value at program start, and then on the call to
`process.uptime()` returning the delta between the two values.

`uv_uptime` is defined as the number of seconds the operating system
has been up since last boot. On sunos this interface uses `kstat`s
which can be a significantly expensive operation as it requires
exclusive access, but because of the design of `process.uptime()` node
*had* to always call this on start. As a result if you had many node
processes all starting at the same time you would suffer lock
contention as they all tried to read kstats.

Instead of using `uv_uptime` to achieve this, the libuv loop already
has a concept of current loop time in the form of `uv_now()` which is
in fact monotonically increasing, and already stored directly on the
loop. By using this value at start every platform performs at least
one fewer syscall during initialization.

Since the interface to `uv_uptime` is defined as seconds, in the call
to `process.uptime()` we now `uv_update_time` get our delta, divide by
1000 to get seconds, and then convert to an `Integer`. In 0.12 we can
move back to `Number::New` instead and not lose precision.

Caveat: For some platforms `uv_uptime` reports time monotonically
increasing regardless of system hibernation, `uv_now` interface is
also monotonically increasing but may not reflect time spent in
hibernation.
2014-04-10 10:55:02 -07:00
Fedor Indutny
592be014b6
dgram: introduce reuseAddr option
Introduce new signature for both `dgram.createSocket` method and
`dgram.Socket` constructor:

    dgram.createSocket(options, [listener])

Options should contain `type` property and may contain `reuseAddr`
property. When `reuseAddr` is `true` - SO_REUSEADDR will be issued on
socket on bind.

fix #7415

Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-04-10 19:39:49 +04:00
Saúl Ibarra Corretgé
a0a180a0ad src: fix use of uv_cwd, len includes the NULL byte 2014-04-07 16:37:29 +04:00
Saúl Ibarra Corretgé
42b9343710 src: update uv callbacks after API changes
async, timer, prepare, idle and check handles no longer get a status
parameter since they can never fail.
2014-04-07 16:37:20 +04:00
C. Scott Ananian
08a5b442e4 node: add signature to SET_PROTOTYPE_METHOD
This prevents segfaults when a native method is reassigned to a
different object (which corrupts args.This()).  When unwrapping,
clients should use args.Holder() instead of args.This().

Closes #6690.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-04-02 01:48:34 -07:00
Ben Noordhuis
c7214fe355 src: fix up after v8 upgrade
The two biggest changes are that v8::Script::New() has been removed and
that a v8::Script object now has to be explicitly bound to a context if
you want to run it from another context.

We can accommodate both changes without breaking the vm module's public
API or even the internal JS API.
2014-04-02 00:05:25 +04:00
Ben Noordhuis
490d5ab780 configure: make --v8-options switch more robust
Improve on commit b55c9d6 by not requiring that switches are comma
separated.  This commit makes `./configure --v8-options="--foo --bar"`
work and takes special care to properly escape quotes in the options
string.
2014-04-01 18:55:52 +04:00
James Pickard
e9ce8fc82a fs: improve performance of all stat functions
By building the fs.Stats object in JS, which is returned by all fs stat
functions, calls to v8::Object::Set() are removed. This also includes
creating all associated Date objects in JS, rather than using
v8::Date::New(). Both these changes have significant performance gains.

Note that the returned value from fs.stat changes slightly for non-POSIX
systems. Whereas before the stats object would be missing blocks and
blksize keys, it now has these keys with undefined as the value.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-03-31 15:02:17 -07:00
Fedor Indutny
5d2aef17ee
crypto: move createCredentials to tls
Move `createCredentials` to `tls` module and rename it to
`createSecureContext`. Make it use default values from `tls` module:
`DEFAULT_CIPHERS` and `DEFAULT_ECDH_CURVE`.

fix #7249
2014-03-29 12:01:43 +04:00
Fedor Indutny
b55c9d68aa configure: --v8-options option
Introduce a way to set some v8 flags at compile time, the values should
be separated by comma.
2014-03-29 11:51:41 +04:00
Fedor Indutny
e781832ea1 crypto: fix lint 2014-03-26 11:52:00 +04:00
Fedor Indutny
a030c7b902 Merge remote-tracking branch 'origin/v0.10'
Conflicts:
	src/node.cc
	src/node_crypto.cc
	src/node_crypto.h
2014-03-26 11:42:57 +04:00
Ben Noordhuis
f68a116c3c src: ensure that openssl's PRNG is fully seeded
Ensure that OpenSSL has enough entropy (at least 256 bits) for its PRNG.

The entropy pool starts out empty and needs to fill up before the PRNG
can be used securely.

OpenSSL normally fills the pool automatically but not when someone
starts generating random numbers before the pool is full: in that case
OpenSSL keeps lowering the entropy estimate to thwart attackers trying
to guess the initial state of the PRNG.

When that happens, we wait until enough entropy is available, something
that normally should never take longer than a few milliseconds.

Fixes #7338.
2014-03-26 11:31:32 +04:00
Ben Noordhuis
70f198ddb1 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.

NB: This is a back-port of commit 7ac2391 from the master branch that
for some reason never got back-ported to the v0.10 branch.

The default on UNIX platforms in v0.10 is different and arguably worse
than it is with master: if no entropy source is provided, V8 3.14 calls
srandom() with a xor of the PID and the current time in microseconds.

That means that on systems with a coarse system clock, the initial
state of the PRNG may be easily guessable.

The situation on Windows is even more dire because there the PRNG is
seeded with only the current time... in milliseconds.
2014-03-26 11:31:32 +04:00
Fedor Indutny
b76a1ff940 vm: share security token between contexts
By default, each `v8::Context` has a different Security Token, which
prevents access to one context from another.

fix #7140
2014-03-21 16:16:58 +04:00
Trevor Norris
b84ebfe886 pipe_wrap: use Instantiate() method
Retrieve a new client object via PipeWrap::Instantiate(). This method
performs appropriate checks to make sure everything is as it should be.
2014-03-17 14:39:37 -07:00
Fedor Indutny
7b9771f569 headers: remove env.h from node_internals.h
`env.h` is an internal header file and should not be copied or exposed
to the users.

Additionally, export convenience `Throw*` methods with `v8::Isolate*` as
a first argument.
2014-03-18 01:16:45 +04:00
Ben Noordhuis
23dfa71dd5 src: fix tracing infrastructure after v8 upgrade
Fix up the dtrace/etw/systemtap infrastructure after the V8 upgrade in
commit 1c7bf24.  The win32 changes are untested but can hardly make
things worse because node doesn't build on windows right now.

Fixes #7313 with some luck.
2014-03-16 16:15:34 +04:00
Ben Noordhuis
c30cc4e3a5 src: don't call DecodeWrite() on Buffers
Don't call DecodeWrite() with a Buffer as its argument because it in
turn calls StringBytes::Write() and that method expects a Local<String>.

"Why then does that function take a Local<Value>?" I hear you ask.
Good question but I don't have the answer.  I added a CHECK for good
measure and what do you know, all of a sudden a large number of crypto
tests started failing.

Calling DecodeWrite(BINARY) on a buffer is nonsensical anyway: if you
want the contents of the buffer, just copy out the data, there is no
need to decode it - and that's exactly what this commit does.

Fixes a great many instances of the following run-time error in debug
builds:

    FATAL ERROR: v8::String::Cast() Could not convert to string
2014-03-16 16:15:34 +04:00
Ben Noordhuis
e87ceb2b42 src: fix up smalloc weak persistent usage
Fix a regression that was introduced in commit ce04c726 after the
upgrade to V8 3.24.

The new weak persistent handle API no longer gives you the original
persistent but still requires that you clear it inside your weak
callback.

Rearrange the code in src/smalloc.cc to keep track of the persistent
handle with the least amount of pain and try hard to share as much
code as possible between the 'just free it' and 'invoke my callback'
versions of the smalloc API.

Fixes #7309.
2014-03-16 16:15:34 +04:00
Ben Noordhuis
ad15d75750 src: add CHECK_{GE,GT,LE,LT} macros
Conform to the Google styleguide more and make cpplint happy, add more
CHECK macros.

Preemptively addresses cpplint's readability/check warnings ("Consider
using CHECK_GT instead of CHECK(a > b)".)
2014-03-16 16:15:34 +04:00
Ben Noordhuis
8eb76075cf src: deduplicate CHECK_EQ/CHECK_NE macros
DRY the macros, there is no need to define them twice depending on
whether NDEBUG is defined or not.
2014-03-16 16:15:33 +04:00
Ben Noordhuis
f6ea0c203a src: fix segfaults, fix 32 bits integer negation
Make calls to v8::Isolate::AdjustAmountOfExternalAllocatedMemory() take
special care when negating 32 bits unsigned types like size_t.

Before this commit, values were negated before they got promoted to
64 bits, meaning that on 32 bits architectures, a value like 42 got
cast to 4294967254 instead of -42.

That in turn made the garbage collector start scavenging like crazy
because it thought the system was out of memory.

That's bad enough but calls to AdjustAmountOfExternalAllocatedMemory()
were made from weak callbacks, i.e. at a time when the garbage collector
was already busy.  It triggered asserts in debug builds and caused
random crashes and memory corruption in release builds.

The behavior in release builds is arguably a V8 bug and should perhaps
be reported upstream.

Partially fixes #7309 but requires further bug fixes to src/smalloc.cc
that I'll address in a follow-up commit.
2014-03-16 16:15:33 +04:00
Ben Noordhuis
a3dca9a3a6 src: squelch -Wmaybe-uninitialized warning
The variable isn't actually used uninitialized but g++ 4.8 doesn't know
that.  Set it to NULL to silence the following compiler warning:

    ../src/string_bytes.cc:247:29: warning: 'data' may be used
    uninitialized in this function [-Wmaybe-uninitialized]
         unsigned a = hex2bin(src[i * 2 + 0]);
                                  ^
    ../src/string_bytes.cc:299:15: note: 'data' was declared here
       const char* data;
                   ^
2014-03-16 16:15:33 +04:00
Ben Noordhuis
91b4a561df src: remove unused ExternString constructor
Remove an unused (and unsafe) constructor.  Unsafe because it doesn't
initialize the data_ field.
2014-03-16 16:15:33 +04:00
Ben Noordhuis
1f17f88071 src, test: fix up ObjectWrap, make test-addons
V8 was upgraded from 3.22 to 3.24 in commit 1c7bf24.  Upgrade source
files in test/addons/ and automatically generated tests from
doc/api/addons.markdown to the new V8 API.

This coincidentally fixes a bug in src/node_object_wrap.h where it was
still using the old V8 weak persistent handle interface, which is gone
in 3.24.
2014-03-14 00:41:04 +04:00
Fedor Indutny
d0ff900a65 node: fix exported signatures of MakeCallback
fix #7302
2014-03-13 21:14:54 +04:00
Fedor Indutny
ce04c726a3 src: update to v8 3.24 APIs 2014-03-13 20:56:55 +04:00
Timothy J Fontaine
9bd934cb96 Now working on 0.11.13 2014-03-12 07:56:42 -07:00
Timothy J Fontaine
7d6b8db40f src: accommodate uv_cwd including null on win32 2014-03-11 14:49:48 -07:00
Timothy J Fontaine
0c2e28d68f 2014.03.11, Version 0.11.12 (Unstable)
* uv: Upgrade to v0.11.22 (Timothy J Fontaine)

* buffer: allow toString to accept Infinity for end (Brian White)

* child_process: add spawnSync/execSync (Bert Belder, Timothy J Fontaine)

* cluster: handle bind errors on Windows (Alexis Campailla)

* contextify: handle infinite recursion errors (Fedor Indutny)

* crypto: allow custom generator for DiffieHellman (Brian White)

* crypto: allow setting add'l authenticated data (Brian White)

* crypto: fix CipherFinal return value check (Brian White)

* crypto: make NewSessionDoneCb public (Fedor Indutny)

* dgram: pass the bytes sent to the send callback (Timothy J Fontaine)

* dns: validate arguments in resolver (Kenan Sulayman)

* dns: verify argument is valid function in resolve (Kenan Sulayman)

* http: avoid duplicate keys in writeHead (David Björklund)

* net: add localPort to connect options (Timothy J Fontaine)

* node: do not print SyntaxError hints to stderr (Fedor Indutny)

* node: invoke `beforeExit` again if loop was active (Fedor Indutny)

* node: make AsyncListenerInst field more explicit (Trevor Norris)

* os: networkInterfaces include scopeid for ipv6 (Xidorn Quan)

* process: allow changing `exitCode` in `on('exit')` (Fedor Indutny)

* readline: fix `line` event, if input emit 'end' (Yazhong Liu)

* src: add tracing.v8.on('gc') statistics hooks (Ben Noordhuis)

* src: add v8.getHeapStatistics() function (Ben Noordhuis)

* src: emit 'beforeExit' event on process object (Ben Noordhuis)

* src: move AsyncListener from process to tracing (Trevor Norris)

* tls: fix crash in SNICallback (Fedor Indutny)

* tls: introduce asynchronous `newSession` (Fedor Indutny)

* util: show meaningful values for boxed primitives (Nathan Rajlich)

* vm: don't copy Proxy object from parent context (Ben Noordhuis)

* windows: make stdout/sterr pipes blocking (Alexis Campailla)

* zlib: add sync versions for convenience methods (Nikolai Vavilov)
2014-03-11 13:49:52 -07:00
Timothy J Fontaine
e2fcfea46e src: update from uv_read2_start removal
Previously if you wanted to be notified of pending handles for pipes
you needed to use uv_read2_start, however in v0.11.22 you can query for
pending handles independently.
2014-03-10 17:51:47 -07:00
Saúl Ibarra Corretgé
d2f2a32b89 src: adapt to API change in uv_cwd 2014-03-10 17:01:47 -07:00
Timothy J Fontaine
b444392a98 Merge remote-tracking branch 'upstream/v0.10'
Conflicts:
	src/node.cc
	src/node.js
	test/message/max_tick_depth_trace.out
2014-03-10 16:50:00 -07:00
Ben Noordhuis
bd8a5755dc src: add default visibility to NODE_MODULE
It's currently not really possible to compile native add-ons with
-fvisibility=hidden because that also hides the struct containing
the module definition.

The NODE_MODULE() and NODE_MODULE_DECL() macros are structured in
a way that makes it impossible to add a visibility attribute manually
so there is no escape hatch there.

That's why this commit adds an explicit visibility attribute to
the module definition.  It doesn't help with node.js releases that
are already out there but at least it improves the situation going
forward.
2014-03-05 15:26:09 +04:00
Brian White
31ce34887f crypto: allow setting add'l authenticated data 2014-03-04 12:42:03 +04:00
Brian White
caca4f33aa crypto: fix CipherFinal return value check 2014-03-04 12:42:03 +04:00
Timothy J Fontaine
06453a94a7 src: domain should not replace nextTick function
Previously if you cached process.nextTick and then require('domain')
subsequent nextTick() calls would not be caught because enqueued
functions were taking the wrong path. This keeps nextTick to a single
function reference and changes the implementation details after domain
has been required.
2014-03-03 16:27:58 -08:00
Fedor Indutny
78d245f5b2 Merge remote-tracking branch 'origin/v0.10'
Conflicts:
	configure
	lib/_stream_readable.js
	lib/http.js
	src/node_dtrace.cc
2014-03-02 23:54:19 +04:00
Fedor Indutny
34bf6e46be smalloc: remove env.h include
Since `smalloc.h` is included in a `node_buffer.h`, including private
headers in it is strictly prohibited.

fix #7206
2014-03-02 12:05:13 +04:00
Fedor Indutny
5596f936d8 node: invoke beforeExit again if loop was active
When `setImmediate(cb)` is called in `beforeExit` event handler the
consequent `uv_run(..., UV_RUN_NOWAIT)` may return `0`, even if there
was some active handles at start.

Fixes simple/test-beforeexit-event.js.
2014-03-01 21:30:17 +04:00
Fedor Indutny
3b88dc6f19 stream_wrap: don't write twice on uv_try_write err
fix #7155
2014-02-28 18:02:02 +04:00
Ben Noordhuis
a2eeb43ded src: emit 'beforeExit' event on process object
Unlike the 'exit' event, this event allows the user to schedule more
work and thereby postpone the exit.  That also means that the
'beforeExit' event may be emitted many times, see the attached test
case for an example.

Refs #6305.
2014-02-28 14:43:30 +04:00
Saúl Ibarra Corretgé
6e1eac744b src: use new loop API
uv_loop_new and uv_loop_delete are considered deprecated now.
2014-02-28 14:01:52 +04:00
Saúl Ibarra Corretgé
269de79fbf src: spawn_sync should close handles upon exit
When the exit callback is fired for the child process we should close
the handle associated with it.
2014-02-26 18:16:07 -08:00
Timothy J Fontaine
afc29ed397 src: update to latest libuv api
libuv gyp builds now require you to define the library disposition
(static or shared).

Also, libuv now supports vectored IO for file system reads and writes,
update to those function signatures
2014-02-26 18:15:07 -08:00
Alexis Campailla
20176a9841 src: make stdout/sterr pipes blocking
Expose `setBlocking` on Pipe's and if a pipe is being created for stdio
on windows then make the pipes blocking.

This fixes test-stream2-stderr-sync.js on Windows.

Fixes #3584
2014-02-26 10:36:58 -08:00
Maxwell Krohn
a22a2d8656 tls: stop NodeBIO::Gets from reading off end of buffer
NodeBIO::Gets was reading off the end of a buffer if it
didn't find a "\n" before the EOF.  This behavior
was causing X509 certificates passed to `https.Agent`
via the "ca" option to be silently discarded. It also
was causing improper parsing of certs and keys
passed to https.Agent, but those problems were worked
around in cdde9a3.

Backed out workaround in `lib/crypto.js` from ccde9a3,
which now isn't needed.  But keep the test introduced
in that commit, which tests properly for this
bug.

This bug was first introduced in a58f93f

Gist containing test code, bisection log, and notes:
   https://gist.github.com/maxtaco/9211605
2014-02-26 17:33:10 +04:00
Alexis Campailla
b5f9779c2f windows: fix module registration
The linker was optimizing the static variables that were supposed
to trigger module initialization.

I am making them non-static, and dllexport so that they don't get
optimized away.

Fixes #7116
2014-02-25 13:44:38 -08:00
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