Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
},
},
'conditions': [
['OS in "linux freebsd openbsd solaris android"', {
['OS!="aix"', {
'ldflags': [
'-Wl,--whole-archive,<(OBJ_DIR)/<(STATIC_LIB_PREFIX)'
'<(node_core_target_name)<(STATIC_LIB_SUFFIX)',
Expand Down
62 changes: 60 additions & 2 deletions node.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,32 @@
}],
[ 'node_shared_zlib=="false"', {
'dependencies': [ 'deps/zlib/zlib.gyp:zlib' ],
'conditions': [
[ 'force_load=="true"', {
'xcode_settings': {
'OTHER_LDFLAGS': [
'-Wl,-force_load,<(PRODUCT_DIR)/<(STATIC_LIB_PREFIX)'
'zlib<(STATIC_LIB_SUFFIX)',
],
},
'msvs_settings': {
'VCLinkerTool': {
'AdditionalOptions': [
'/WHOLEARCHIVE:<(PRODUCT_DIR)\\lib\\zlib<(STATIC_LIB_SUFFIX)',
],
},
},
'conditions': [
['OS!="aix" and node_shared=="false"', {
'ldflags': [
'-Wl,--whole-archive,<(OBJ_DIR)/deps/zlib/<(STATIC_LIB_PREFIX)'
'zlib<(STATIC_LIB_SUFFIX)',
'-Wl,--no-whole-archive',
],
}],
],
}],
],
}],

[ 'node_shared_http_parser=="false"', {
Expand All @@ -119,6 +145,32 @@

[ 'node_shared_libuv=="false"', {
'dependencies': [ 'deps/uv/uv.gyp:libuv' ],
'conditions': [
[ 'force_load=="true"', {
'xcode_settings': {
'OTHER_LDFLAGS': [
'-Wl,-force_load,<(PRODUCT_DIR)/<(STATIC_LIB_PREFIX)'
'uv<(STATIC_LIB_SUFFIX)',
],
},
'msvs_settings': {
'VCLinkerTool': {
'AdditionalOptions': [
'/WHOLEARCHIVE:<(PRODUCT_DIR)\\lib\\libuv<(STATIC_LIB_SUFFIX)',
],
},
},
'conditions': [
['OS!="aix" and node_shared=="false"', {
'ldflags': [
'-Wl,--whole-archive,<(OBJ_DIR)/deps/uv/<(STATIC_LIB_PREFIX)'
'uv<(STATIC_LIB_SUFFIX)',
'-Wl,--no-whole-archive',
],
}],
],
}],
],
}],

[ 'node_shared_nghttp2=="false"', {
Expand Down Expand Up @@ -240,12 +292,18 @@
'-Wl,-force_load,<(PRODUCT_DIR)/<(OPENSSL_PRODUCT)',
],
},
'msvs_settings': {
'VCLinkerTool': {
'AdditionalOptions': [
'/WHOLEARCHIVE:<(PRODUCT_DIR)\\lib\\<(OPENSSL_PRODUCT)',
],
},
},
'conditions': [
['OS in "linux freebsd" and node_shared=="false"', {
'ldflags': [
'-Wl,--whole-archive,'
'<(OBJ_DIR)/deps/openssl/'
'<(OPENSSL_PRODUCT)',
'<(OBJ_DIR)/deps/openssl/<(OPENSSL_PRODUCT)',
'-Wl,--no-whole-archive',
],
}],
Expand Down
10 changes: 10 additions & 0 deletions shas
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
de0ed84f04
469036add4
2caa1f5458
e83adf87f5
808c05858a
1e57a8d117
0089860757
92bf2492cd
7514eb3cff
6934792eb3
14 changes: 9 additions & 5 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,12 @@ static void InternalModuleReadFile(const FunctionCallbackInfo<Value>& args) {
return;
}

std::shared_ptr<void> defer_close(nullptr, [fd, loop] (...) {
uv_fs_t close_req;
CHECK_EQ(0, uv_fs_close(loop, &close_req, fd, nullptr));
uv_fs_req_cleanup(&close_req);
});

const size_t kBlockSize = 32 << 10;
std::vector<char> chars;
int64_t offset = 0;
Expand All @@ -502,14 +508,12 @@ static void InternalModuleReadFile(const FunctionCallbackInfo<Value>& args) {
numchars = uv_fs_read(loop, &read_req, fd, &buf, 1, offset, nullptr);
uv_fs_req_cleanup(&read_req);

CHECK_GE(numchars, 0);
if (numchars < 0)
return;

offset += numchars;
} while (static_cast<size_t>(numchars) == kBlockSize);

uv_fs_t close_req;
CHECK_EQ(0, uv_fs_close(loop, &close_req, fd, nullptr));
uv_fs_req_cleanup(&close_req);

size_t start = 0;
if (offset >= 3 && 0 == memcmp(&chars[0], "\xEF\xBB\xBF", 3)) {
start = 3; // Skip UTF-8 BOM.
Expand Down
Empty file.
7 changes: 7 additions & 0 deletions test/parallel/test-module-loading-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,10 @@ common.expectsError(
code: 'ERR_ASSERTION',
message: /^path must be a string$/
});

common.expectsError(
() => { require('../fixtures/packages/is-dir'); },
{
code: 'MODULE_NOT_FOUND',
message: 'Cannot find module \'../fixtures/packages/is-dir\''
});
35 changes: 35 additions & 0 deletions test/parallel/test-stdio-pipe-access.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
'use strict';
require('../common');

// Test if Node handles acessing process.stdin if it is a redirected
// pipe without deadlocking
const { spawn, spawnSync } = require('child_process');

const numTries = 5;
const who = process.argv.length <= 2 ? 'runner' : process.argv[2];

switch (who) {
case 'runner':
for (let num = 0; num < numTries; ++num) {
spawnSync(process.argv0,
[process.argv[1], 'parent'],
{ 'stdio': 'inherit' });
}
break;
case 'parent':
const middle = spawn(process.argv0,
[process.argv[1], 'middle'],
{ 'stdio': 'pipe' });
middle.stdout.on('data', () => {});
break;
case 'middle':
spawn(process.argv0,
[process.argv[1], 'bottom'],
{ 'stdio': [ process.stdin,
process.stdout,
process.stderr ] });
break;
case 'bottom':
process.stdin;
break;
}
38 changes: 38 additions & 0 deletions test/parallel/test-stdio-pipe-redirect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'use strict';
require('../common');

// Test if Node handles redirecting one child process stdout to another
// process stdin without crashing.
const spawn = require('child_process').spawn;

const writeSize = 100;
const totalDots = 10000;

const who = process.argv.length <= 2 ? 'parent' : process.argv[2];

switch (who) {
case 'parent':
const consumer = spawn(process.argv0, [process.argv[1], 'consumer'], {
stdio: ['pipe', 'ignore', 'inherit'],
});
const producer = spawn(process.argv0, [process.argv[1], 'producer'], {
stdio: ['pipe', consumer.stdin, 'inherit'],
});
process.stdin.on('data', () => {});
producer.on('exit', process.exit);
break;
case 'producer':
const buffer = Buffer.alloc(writeSize, '.');
let written = 0;
const write = () => {
if (written < totalDots) {
written += writeSize;
process.stdout.write(buffer, write);
}
};
write();
break;
case 'consumer':
process.stdin.on('data', () => {});
break;
}