* 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.
Don't wait a full second before starting the watcher, 10 ms ought to be
more than enough time. Reduces running time from 1250 ms to 250 ms on
my system.
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.
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.
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.
Fixesjoyent/libuv#911.
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.
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.
- The caveats no longer apply.
- Document options arguments, including `displayErrors` and the
different things it means in each place.
- Re-did examples to be more on point, e.g. `runInContext` example
runs multiple scripts in the same context.
- Documented how `vm.createContext`s meaning has substantially changed,
and is now more of a "contextifier" than a "creator."
- Reordered vm functions to be readable in order; the concept of
contextifying needs to come before `runInContext` and
`runInNewContext`.
- Documented new `vm.isContext`.
- Documented the `vm.Script` constructor, instead of `createScript`,
since factory methods are silly and we wanted to document the class's
methods anyway.
- Documented `script.runInContext`.
- Change stability to stable, if I may be so bold.
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.
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.
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.
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.
There's no need to create a new Buffer instance if we're just going to
immediately call toString() at the end anyway. Better to create a
string up front, and setEncoding() on the streams, and do a string
concatenation instead.
Since the encoding is no longer relevant once it is decoded to a Buffer,
it is confusing and incorrect to pass the encoding as 'utf8' or whatever
in those cases.
Closes#6119
Length arguments passed to SlowBuffer were coerced to Int32, not Uint32,
so passing a negative number would throw the following:
node: ../src/smalloc.cc:244: void node::smalloc::Alloc(): Assertion `length <= kMaxLength' failed.
Aborted (core dumped)
That has been fixed by coercing to Uint32 and comparing the value
against kMaxLength.
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.
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.