Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
Merge nodejs/master
Browse files Browse the repository at this point in the history
Merge d4471e0 as of 2017-11-02.
This is an automatically created merge. For any problems please
contact @kunalspathak.
  • Loading branch information
chakrabot committed Nov 7, 2017
2 parents 3aa2c16 + d4471e0 commit 3331186
Show file tree
Hide file tree
Showing 18 changed files with 198 additions and 94 deletions.
9 changes: 5 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ Select a Node.js version below to view the changelog history:
* [Node.js 8](doc/changelogs/CHANGELOG_V8.md)
* [Node.js 7](doc/changelogs/CHANGELOG_V7.md)
* [Node.js 6](doc/changelogs/CHANGELOG_V6.md)
* [Node.js 5](doc/changelogs/CHANGELOG_V5.md)
* [Node.js 4](doc/changelogs/CHANGELOG_V4.md)
* [Node.js 5](doc/changelogs/CHANGELOG_V5.md),
[0.12](doc/changelogs/CHANGELOG_V012.md),
[0.10](doc/changelogs/CHANGELOG_V010.md),
[io.js](doc/changelogs/CHANGELOG_IOJS.md) and [Archive](doc/changelogs/CHANGELOG_ARCHIVE.md)
* [io.js](doc/changelogs/CHANGELOG_IOJS.md)
* [Node.js 0.12](doc/changelogs/CHANGELOG_V012.md)
* [Node.js 0.10](doc/changelogs/CHANGELOG_V010.md)
* [Archive](doc/changelogs/CHANGELOG_ARCHIVE.md)

Please use the following table to find the changelog for a specific Node.js
release.
Expand Down
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@
'cflags': [ '-pthread', ],
'ldflags': [ '-pthread' ],
}],
[ 'OS in "linux freebsd openbsd solaris android aix"', {
[ 'OS in "linux freebsd openbsd solaris android aix cloudabi"', {
'cflags': [ '-Wall', '-Wextra', '-Wno-unused-parameter', ],
'cflags_cc': [ '-fno-rtti', '-fno-exceptions', '-std=gnu++0x' ],
'ldflags': [ '-rdynamic' ],
Expand Down
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ from gyp_node import run_gyp
parser = optparse.OptionParser()

valid_os = ('win', 'mac', 'solaris', 'freebsd', 'openbsd', 'linux',
'android', 'aix')
'android', 'aix', 'cloudabi')
valid_arch = ('arm', 'arm64', 'ia32', 'mips', 'mipsel', 'mips64el', 'ppc',
'ppc64', 'x32','x64', 'x86', 's390', 's390x')
valid_arm_float_abi = ('soft', 'softfp', 'hard')
Expand Down
10 changes: 10 additions & 0 deletions doc/api/child_process.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ changes:
* `gid` {number} Sets the group identity of the process (see setgid(2)).
* `windowsHide` {boolean} Hide the subprocess console window that would
normally be created on Windows systems. **Default:** `false`.
* `windowsVerbatimArguments` {boolean} No quoting or escaping of arguments is
done on Windows. Ignored on Unix. **Default:** `false`.
* `callback` {Function} Called with the output when process terminates.
* `error` {Error}
* `stdout` {string|Buffer}
Expand Down Expand Up @@ -338,6 +340,8 @@ changes:
When this option is provided, it overrides `silent`. If the array variant
is used, it must contain exactly one item with value `'ipc'` or an error
will be thrown. For instance `[0, 1, 2, 'ipc']`.
* `windowsVerbatimArguments` {boolean} No quoting or escaping of arguments is
done on Windows. Ignored on Unix. **Default:** `false`.
* `uid` {number} Sets the user identity of the process (see setuid(2)).
* `gid` {number} Sets the group identity of the process (see setgid(2)).
* Returns: {ChildProcess}
Expand Down Expand Up @@ -404,6 +408,9 @@ changes:
`'/bin/sh'` on UNIX, and `process.env.ComSpec` on Windows. A different
shell can be specified as a string. See [Shell Requirements][] and
[Default Windows Shell][]. **Default:** `false` (no shell).
* `windowsVerbatimArguments` {boolean} No quoting or escaping of arguments is
done on Windows. Ignored on Unix. This is set to `true` automatically
when `shell` is specified. **Default:** `false`.
* `windowsHide` {boolean} Hide the subprocess console window that would
normally be created on Windows systems. **Default:** `false`.
* Returns: {ChildProcess}
Expand Down Expand Up @@ -813,6 +820,9 @@ changes:
`'/bin/sh'` on UNIX, and `process.env.ComSpec` on Windows. A different
shell can be specified as a string. See [Shell Requirements][] and
[Default Windows Shell][]. **Default:** `false` (no shell).
* `windowsVerbatimArguments` {boolean} No quoting or escaping of arguments is
done on Windows. Ignored on Unix. This is set to `true` automatically
when `shell` is specified. **Default:** `false`.
* `windowsHide` {boolean} Hide the subprocess console window that would
normally be created on Windows systems. **Default:** `false`.
* Returns: {Object}
Expand Down
1 change: 1 addition & 0 deletions doc/api/crypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -1969,6 +1969,7 @@ added: v6.6.0
- `a` {Buffer | TypedArray | DataView}
- `b` {Buffer | TypedArray | DataView}

This function is based on a constant-time algorithm.
Returns true if `a` is equal to `b`, without leaking timing information that
would allow an attacker to guess one of the values. This is suitable for
comparing HMAC digests or secret values like authentication cookies or
Expand Down
5 changes: 5 additions & 0 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,11 @@ Used when attempting to perform an operation outside the bounds of a `Buffer`.
Used when an attempt has been made to create a `Buffer` larger than the
maximum allowed size.

<a id="ERR_CANNOT_WATCH_SIGINT"></a>
### ERR_CANNOT_WATCH_SIGINT

Used when Node.js is unable to watch for the `SIGINT` signal.

<a id="ERR_CHILD_CLOSED_BEFORE_REPLY"></a>
### ERR_CHILD_CLOSED_BEFORE_REPLY

Expand Down
14 changes: 12 additions & 2 deletions doc/api/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,13 @@ Will generate:

`heapTotal` and `heapUsed` refer to V8's memory usage.
`external` refers to the memory usage of C++ objects bound to JavaScript
objects managed by V8.
objects managed by V8. `rss`, Resident Set Size, is the amount of space
occupied in the main memory device (that is a subset of the total allocated
memory) for the process, which includes the _heap_, _code segment_ and _stack_.

The _heap_ is where objects, strings and closures are stored. Variables are
stored in the _stack_ and the actual JavaScript code resides in the
_code segment_.

## process.nextTick(callback[, ...args])
<!-- YAML
Expand Down Expand Up @@ -1438,7 +1444,11 @@ tarball.
compiling Node.js native add-ons. _This property is only present on Windows
builds of Node.js and will be missing on all other platforms._
* `lts` {string} a string label identifying the [LTS][] label for this release.
If the Node.js release is not an LTS release, this will be `undefined`.
This property only exists for LTS releases and is `undefined` for all other
release types, including _Current_ releases. Currently the valid values are:
- `'Argon'` for the v4.x LTS line beginning with v4.2.0.
- `'Boron'` for the v6.x LTS line beginning with v6.9.0.
- `'Carbon'` for the v8.x LTS line beginning with v8.9.1.

For example:

Expand Down
1 change: 1 addition & 0 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ E('ERR_ASYNC_TYPE', (s) => `Invalid name for async "type": ${s}`);
E('ERR_BUFFER_OUT_OF_BOUNDS', bufferOutOfBounds);
E('ERR_BUFFER_TOO_LARGE',
`Cannot create a Buffer larger than 0x${kMaxLength.toString(16)} bytes`);
E('ERR_CANNOT_WATCH_SIGINT', 'Cannot watch for SIGINT signals');
E('ERR_CHILD_CLOSED_BEFORE_REPLY', 'Child closed before reply received');
E('ERR_CONSOLE_WRITABLE_STREAM',
'Console expects a writable stream instance for %s');
Expand Down
19 changes: 12 additions & 7 deletions lib/internal/util.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
'use strict';

const errors = require('internal/errors');
const binding = process.binding('util');
const { signals } = process.binding('constants').os;

const { createPromise, promiseResolve, promiseReject } = binding;
const {
createPromise,
getHiddenValue,
promiseResolve,
promiseReject,
setHiddenValue,
arrow_message_private_symbol: kArrowMessagePrivateSymbolIndex,
decorated_private_symbol: kDecoratedPrivateSymbolIndex
} = process.binding('util');

const kArrowMessagePrivateSymbolIndex = binding['arrow_message_private_symbol'];
const kDecoratedPrivateSymbolIndex = binding['decorated_private_symbol'];
const noCrypto = !process.versions.openssl;

function isError(e) {
Expand Down Expand Up @@ -66,14 +71,14 @@ function deprecate(fn, msg, code) {

function decorateErrorStack(err) {
if (!(isError(err) && err.stack) ||
binding.getHiddenValue(err, kDecoratedPrivateSymbolIndex) === true)
getHiddenValue(err, kDecoratedPrivateSymbolIndex) === true)
return;

const arrow = binding.getHiddenValue(err, kArrowMessagePrivateSymbolIndex);
const arrow = getHiddenValue(err, kArrowMessagePrivateSymbolIndex);

if (arrow) {
err.stack = arrow + err.stack;
binding.setHiddenValue(err, kDecoratedPrivateSymbolIndex, true);
setHiddenValue(err, kDecoratedPrivateSymbolIndex, true);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ function afterShutdown(status, handle, req) {
// if the writable side has ended already, then clean everything
// up.
function onSocketEnd() {
// XXX Should not have to do as much crap in this function.
// XXX Should not have to do as much in this function.
// ended should already be true, since this is called *after*
// the EOF errno and onread has eof'ed
debug('onSocketEnd', this._readableState);
Expand Down
6 changes: 4 additions & 2 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ function REPLServer(prompt,
if (self.breakEvalOnSigint) {
// Start the SIGINT watchdog before entering raw mode so that a very
// quick Ctrl+C doesn't lead to aborting the process completely.
utilBinding.startSigintWatchdog();
if (!utilBinding.startSigintWatchdog())
throw new errors.Error('ERR_CANNOT_WATCH_SIGINT');
previouslyInRawMode = self._setRawMode(false);
}

Expand Down Expand Up @@ -288,7 +289,8 @@ function REPLServer(prompt,
const top = replMap.get(self);
const pstrace = Error.prepareStackTrace;
Error.prepareStackTrace = prepareStackTrace(pstrace);
internalUtil.decorateErrorStack(e);
if (typeof e === 'object')
internalUtil.decorateErrorStack(e);
Error.prepareStackTrace = pstrace;
const isError = internalUtil.isError(e);
if (e instanceof SyntaxError && e.stack) {
Expand Down
59 changes: 42 additions & 17 deletions src/cares_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
#include <vector>
#include <unordered_set>

#ifdef __POSIX__
# include <netdb.h>
#endif // __POSIX__

#if defined(__ANDROID__) || \
defined(__MINGW32__) || \
defined(__OpenBSD__) || \
Expand Down Expand Up @@ -1227,7 +1231,9 @@ class QueryAnyWrap: public QueryWrap {
CHECK_EQ(naddrttls, a_count);
for (int i = 0; i < a_count; i++) {
Local<Object> obj = Object::New(env()->isolate());
obj->Set(context, env()->address_string(), ret->Get(i)).FromJust();
obj->Set(context,
env()->address_string(),
ret->Get(context, i).ToLocalChecked()).FromJust();
obj->Set(context,
env()->ttl_string(),
Integer::New(env()->isolate(), addrttls[i].ttl)).FromJust();
Expand All @@ -1239,7 +1245,9 @@ class QueryAnyWrap: public QueryWrap {
} else {
for (int i = 0; i < a_count; i++) {
Local<Object> obj = Object::New(env()->isolate());
obj->Set(context, env()->value_string(), ret->Get(i)).FromJust();
obj->Set(context,
env()->value_string(),
ret->Get(context, i).ToLocalChecked()).FromJust();
obj->Set(context,
env()->type_string(),
env()->dns_cname_string()).FromJust();
Expand Down Expand Up @@ -1268,7 +1276,9 @@ class QueryAnyWrap: public QueryWrap {
CHECK_EQ(aaaa_count, naddr6ttls);
for (uint32_t i = a_count; i < ret->Length(); i++) {
Local<Object> obj = Object::New(env()->isolate());
obj->Set(context, env()->address_string(), ret->Get(i)).FromJust();
obj->Set(context,
env()->address_string(),
ret->Get(context, i).ToLocalChecked()).FromJust();
obj->Set(context,
env()->ttl_string(),
Integer::New(env()->isolate(), addr6ttls[i].ttl)).FromJust();
Expand All @@ -1295,7 +1305,9 @@ class QueryAnyWrap: public QueryWrap {
}
for (uint32_t i = old_count; i < ret->Length(); i++) {
Local<Object> obj = Object::New(env()->isolate());
obj->Set(context, env()->value_string(), ret->Get(i)).FromJust();
obj->Set(context,
env()->value_string(),
ret->Get(context, i).ToLocalChecked()).FromJust();
obj->Set(context,
env()->type_string(),
env()->dns_ns_string()).FromJust();
Expand All @@ -1321,7 +1333,9 @@ class QueryAnyWrap: public QueryWrap {
status = ParseGeneralReply(env(), buf, len, &type, ret);
for (uint32_t i = old_count; i < ret->Length(); i++) {
Local<Object> obj = Object::New(env()->isolate());
obj->Set(context, env()->value_string(), ret->Get(i)).FromJust();
obj->Set(context,
env()->value_string(),
ret->Get(context, i).ToLocalChecked()).FromJust();
obj->Set(context,
env()->type_string(),
env()->dns_ptr_string()).FromJust();
Expand Down Expand Up @@ -1941,10 +1955,14 @@ void GetAddrInfo(const FunctionCallbackInfo<Value>& args) {
Local<Object> req_wrap_obj = args[0].As<Object>();
node::Utf8Value hostname(env->isolate(), args[1]);

int32_t flags = (args[3]->IsInt32()) ? args[3]->Int32Value() : 0;
int32_t flags = 0;
if (args[3]->IsInt32()) {
flags = args[3]->Int32Value(env->context()).FromJust();
}

int family;

switch (args[2]->Int32Value()) {
switch (args[2]->Int32Value(env->context()).FromJust()) {
case 0:
family = AF_UNSPEC;
break;
Expand Down Expand Up @@ -1988,7 +2006,7 @@ void GetNameInfo(const FunctionCallbackInfo<Value>& args) {
CHECK(args[2]->IsUint32());
Local<Object> req_wrap_obj = args[0].As<Object>();
node::Utf8Value ip(env->isolate(), args[1]);
const unsigned port = args[2]->Uint32Value();
const unsigned port = args[2]->Uint32Value(env->context()).FromJust();
struct sockaddr_storage addr;

CHECK(uv_ip4_addr(*ip, port, reinterpret_cast<sockaddr_in*>(&addr)) == 0 ||
Expand Down Expand Up @@ -2065,17 +2083,23 @@ void SetServers(const FunctionCallbackInfo<Value>& args) {
int err;

for (uint32_t i = 0; i < len; i++) {
CHECK(arr->Get(i)->IsArray());
CHECK(arr->Get(env->context(), i).ToLocalChecked()->IsArray());

Local<Array> elm = Local<Array>::Cast(arr->Get(i));
Local<Array> elm =
Local<Array>::Cast(arr->Get(env->context(), i).ToLocalChecked());

CHECK(elm->Get(0)->Int32Value());
CHECK(elm->Get(1)->IsString());
CHECK(elm->Get(2)->Int32Value());
CHECK(elm->Get(env->context(),
0).ToLocalChecked()->Int32Value(env->context()).FromJust());
CHECK(elm->Get(env->context(), 1).ToLocalChecked()->IsString());
CHECK(elm->Get(env->context(),
2).ToLocalChecked()->Int32Value(env->context()).FromJust());

int fam = elm->Get(0)->Int32Value();
node::Utf8Value ip(env->isolate(), elm->Get(1));
int port = elm->Get(2)->Int32Value();
int fam = elm->Get(env->context(), 0)
.ToLocalChecked()->Int32Value(env->context()).FromJust();
node::Utf8Value ip(env->isolate(),
elm->Get(env->context(), 1).ToLocalChecked());
int port = elm->Get(env->context(), 2)
.ToLocalChecked()->Int32Value(env->context()).FromJust();

ares_addr_port_node* cur = &servers[i];

Expand Down Expand Up @@ -2125,7 +2149,8 @@ void Cancel(const FunctionCallbackInfo<Value>& args) {

void StrError(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
const char* errmsg = ares_strerror(args[0]->Int32Value());
const char* errmsg = ares_strerror(args[0]->Int32Value(env->context())
.FromJust());
args.GetReturnValue().Set(OneByteString(env->isolate(), errmsg));
}

Expand Down
17 changes: 11 additions & 6 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ typedef int mode_t;
#include <unistd.h> // setuid, getuid
#endif

#if defined(__POSIX__) && !defined(__ANDROID__)
#if defined(__POSIX__) && !defined(__ANDROID__) && !defined(__CloudABI__)
#include <pwd.h> // getpwnam()
#include <grp.h> // getgrnam()
#endif
Expand Down Expand Up @@ -1012,7 +1012,7 @@ Local<Value> UVException(Isolate* isolate,

// Look up environment variable unless running as setuid root.
bool SafeGetenv(const char* key, std::string* text) {
#ifndef _WIN32
#if !defined(__CloudABI__) && !defined(_WIN32)
if (linux_at_secure || getuid() != geteuid() || getgid() != getegid())
goto fail;
#endif
Expand Down Expand Up @@ -2132,7 +2132,7 @@ static void Umask(const FunctionCallbackInfo<Value>& args) {
}


#if defined(__POSIX__) && !defined(__ANDROID__)
#if defined(__POSIX__) && !defined(__ANDROID__) && !defined(__CloudABI__)

static const uid_t uid_not_found = static_cast<uid_t>(-1);
static const gid_t gid_not_found = static_cast<gid_t>(-1);
Expand Down Expand Up @@ -2451,7 +2451,7 @@ static void InitGroups(const FunctionCallbackInfo<Value>& args) {
}
}

#endif // __POSIX__ && !defined(__ANDROID__)
#endif // __POSIX__ && !defined(__ANDROID__) && !defined(__CloudABI__)


static void WaitForInspectorDisconnect(Environment* env) {
Expand Down Expand Up @@ -3534,6 +3534,11 @@ void SetupProcessObject(Environment* env,
READONLY_PROPERTY(release, "name",
OneByteString(env->isolate(), NODE_RELEASE));

#if NODE_VERSION_IS_LTS
READONLY_PROPERTY(release, "lts",
OneByteString(env->isolate(), NODE_VERSION_LTS_CODENAME));
#endif

// if this is a release build and no explicit base has been set
// substitute the standard release download URL
#ifndef NODE_RELEASE_URLBASE
Expand Down Expand Up @@ -3744,7 +3749,7 @@ void SetupProcessObject(Environment* env,

env->SetMethod(process, "umask", Umask);

#if defined(__POSIX__) && !defined(__ANDROID__)
#if defined(__POSIX__) && !defined(__ANDROID__) && !defined(__CloudABI__)
env->SetMethod(process, "getuid", GetUid);
env->SetMethod(process, "geteuid", GetEUid);
env->SetMethod(process, "setuid", SetUid);
Expand All @@ -3758,7 +3763,7 @@ void SetupProcessObject(Environment* env,
env->SetMethod(process, "getgroups", GetGroups);
env->SetMethod(process, "setgroups", SetGroups);
env->SetMethod(process, "initgroups", InitGroups);
#endif // __POSIX__ && !defined(__ANDROID__)
#endif // __POSIX__ && !defined(__ANDROID__) && !defined(__CloudABI__)

env->SetMethod(process, "_kill", Kill);

Expand Down
Loading

0 comments on commit 3331186

Please sign in to comment.