Skip to content

Commit

Permalink
Merge github.com:grpc/grpc into bwest
Browse files Browse the repository at this point in the history
  • Loading branch information
ctiller committed Jan 17, 2017
2 parents d425712 + c2079f3 commit a66243d
Show file tree
Hide file tree
Showing 85 changed files with 5,323 additions and 515 deletions.
134 changes: 121 additions & 13 deletions Makefile

Large diffs are not rendered by default.

144 changes: 89 additions & 55 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,68 @@
# Some of this file is built with the help of
# https://n8.io/converting-a-c-library-to-gyp/
{
'variables': {
'runtime%': 'node'
},
'target_defaults': {
'include_dirs': [
'.',
'include'
],
'defines': [
'GRPC_UV'
'GPR_BACKWARDS_COMPATIBILITY_MODE'
],
'conditions': [
['runtime=="node"', {
'defines': [
'GRPC_UV'
]
}],
['OS!="win" and runtime=="electron"', {
"defines": [
'OPENSSL_NO_THREADS'
]
}],
# This is the condition for using boringssl
['OS=="win" or runtime=="electron"', {
"include_dirs": [
"third_party/boringssl/include"
],
"defines": [
'OPENSSL_NO_ASM'
]
}, {
# Based on logic above, we know that this must be a non-Windows system
'variables': {
# The output of "node --version" is "v[version]". We use cut to
# remove the first character.
'target%': '<!(node --version | cut -c2-)'
},
# Empirically, Node only exports ALPN symbols if its major version is >0.
# io.js always reports versions >0 and always exports ALPN symbols.
# Therefore, Node's major version will be truthy if and only if it
# supports ALPN. The target is "[major].[minor].[patch]". We split by
# periods and take the first field to get the major version.
'defines': [
'TSI_OPENSSL_ALPN_SUPPORT=<!(echo <(target) | cut -d. -f1)'
],
'include_dirs': [
'<(node_root_dir)/deps/openssl/openssl/include',
],
'conditions': [
["target_arch=='ia32'", {
"include_dirs": [ "<(node_root_dir)/deps/openssl/config/piii" ]
}],
["target_arch=='x64'", {
"include_dirs": [ "<(node_root_dir)/deps/openssl/config/k8" ]
}],
["target_arch=='arm'", {
"include_dirs": [ "<(node_root_dir)/deps/openssl/config/arm" ]
}]
]
}],
['OS == "win"', {
"include_dirs": [
"third_party/boringssl/include",
"third_party/zlib"
],
"defines": [
Expand All @@ -58,8 +108,6 @@
'UNICODE',
'_UNICODE',
'NOMINMAX',
'OPENSSL_NO_ASM',
'GPR_BACKWARDS_COMPATIBILITY_MODE'
],
"msvs_settings": {
'VCCLCompilerTool': {
Expand All @@ -72,21 +120,8 @@
}, { # OS != "win"
'variables': {
'config': '<!(echo $CONFIG)',
# The output of "node --version" is "v[version]". We use cut to
# remove the first character.
'target%': '<!(node --version | cut -c2-)'
},
# Empirically, Node only exports ALPN symbols if its major version is >0.
# io.js always reports versions >0 and always exports ALPN symbols.
# Therefore, Node's major version will be truthy if and only if it
# supports ALPN. The target is "[major].[minor].[patch]". We split by
# periods and take the first field to get the major version.
'defines': [
'TSI_OPENSSL_ALPN_SUPPORT=<!(echo <(target) | cut -d. -f1)',
'GPR_BACKWARDS_COMPATIBILITY_MODE'
],
'include_dirs': [
'<(node_root_dir)/deps/openssl/openssl/include',
'<(node_root_dir)/deps/zlib'
],
'conditions': [
Expand All @@ -101,47 +136,14 @@
'-fprofile-arcs'
]
}
],
["target_arch=='ia32'", {
"include_dirs": [ "<(node_root_dir)/deps/openssl/config/piii" ]
}],
["target_arch=='x64'", {
"include_dirs": [ "<(node_root_dir)/deps/openssl/config/k8" ]
}],
["target_arch=='arm'", {
"include_dirs": [ "<(node_root_dir)/deps/openssl/config/arm" ]
}]
]
]
}]
]
},
'conditions': [
['OS == "win"', {
['OS=="win" or runtime=="electron"', {
'targets': [
{
# IMPORTANT WINDOWS BUILD INFORMATION
# This library does not build on Windows without modifying the Node
# development packages that node-gyp downloads in order to build.
# Due to https://github.com/nodejs/node/issues/4932, the headers for
# BoringSSL conflict with the OpenSSL headers included by default
# when including the Node headers. The remedy for this is to remove
# the OpenSSL headers, from the downloaded Node development package,
# which is typically located in `.node-gyp` in your home directory.
'target_name': 'WINDOWS_BUILD_WARNING',
'actions': [
{
'action_name': 'WINDOWS_BUILD_WARNING',
'inputs': [
'package.json'
],
'outputs': [
'ignore_this_part'
],
'action': ['echo', 'IMPORTANT: Due to https://github.com/nodejs/node/issues/4932, to build this library on Windows, you must first remove <(node_root_dir)/include/node/openssl/']
}
]
},
# Only want to compile BoringSSL and zlib under Windows
{
'cflags': [
'-std=c99',
Expand Down Expand Up @@ -453,6 +455,34 @@
'third_party/boringssl/ssl/tls_record.c',
]
},
]
}],
['OS == "win"', {
'targets': [
{
# IMPORTANT WINDOWS BUILD INFORMATION
# This library does not build on Windows without modifying the Node
# development packages that node-gyp downloads in order to build.
# Due to https://github.com/nodejs/node/issues/4932, the headers for
# BoringSSL conflict with the OpenSSL headers included by default
# when including the Node headers. The remedy for this is to remove
# the OpenSSL headers, from the downloaded Node development package,
# which is typically located in `.node-gyp` in your home directory.
'target_name': 'WINDOWS_BUILD_WARNING',
'actions': [
{
'action_name': 'WINDOWS_BUILD_WARNING',
'inputs': [
'package.json'
],
'outputs': [
'ignore_this_part'
],
'action': ['echo', 'IMPORTANT: Due to https://github.com/nodejs/node/issues/4932, to build this library on Windows, you must first remove <(node_root_dir)/include/node/openssl/']
}
]
},
# Only want to compile zlib under Windows
{
'cflags': [
'-std=c99',
Expand Down Expand Up @@ -808,6 +838,11 @@
'-g'
],
"conditions": [
['OS=="win" or runtime=="electron"', {
'dependencies': [
"boringssl",
]
}],
['OS=="mac"', {
'xcode_settings': {
'MACOSX_DEPLOYMENT_TARGET': '10.9',
Expand All @@ -819,7 +854,6 @@
}],
['OS=="win"', {
'dependencies': [
"boringssl",
"z",
]
}],
Expand All @@ -836,8 +870,8 @@
"src/node/ext/call_credentials.cc",
"src/node/ext/channel.cc",
"src/node/ext/channel_credentials.cc",
"src/node/ext/completion_queue.cc",
"src/node/ext/completion_queue_async_worker.cc",
"src/node/ext/completion_queue_threadpool.cc",
"src/node/ext/completion_queue_uv.cc",
"src/node/ext/node_grpc.cc",
"src/node/ext/server.cc",
"src/node/ext/server_credentials.cc",
Expand Down
42 changes: 39 additions & 3 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2351,6 +2351,43 @@ targets:
- mac
- linux
- posix
- name: memory_profile_client
build: test
run: false
language: c
src:
- test/core/memory_usage/client.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
- name: memory_profile_server
build: test
run: false
language: c
src:
- test/core/memory_usage/server.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
- name: memory_profile_test
cpu_cost: 1.5
build: test
language: c
src:
- test/core/memory_usage/memory_usage_test.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
platforms:
- mac
- linux
- posix
- name: message_compress_test
build: test
language: c
Expand Down Expand Up @@ -3863,7 +3900,6 @@ node_modules:
- src/node/ext/channel.h
- src/node/ext/channel_credentials.h
- src/node/ext/completion_queue.h
- src/node/ext/completion_queue_async_worker.h
- src/node/ext/server.h
- src/node/ext/server_credentials.h
- src/node/ext/timeval.h
Expand All @@ -3882,8 +3918,8 @@ node_modules:
- src/node/ext/call_credentials.cc
- src/node/ext/channel.cc
- src/node/ext/channel_credentials.cc
- src/node/ext/completion_queue.cc
- src/node/ext/completion_queue_async_worker.cc
- src/node/ext/completion_queue_threadpool.cc
- src/node/ext/completion_queue_uv.cc
- src/node/ext/node_grpc.cc
- src/node/ext/server.cc
- src/node/ext/server_credentials.cc
Expand Down
3 changes: 3 additions & 0 deletions include/grpc/impl/codegen/grpc_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ typedef struct {
a data frame or header frame) */
#define GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA \
"grpc.http2.max_pings_without_data"
/** How much data are we willing to queue up per stream if
GRPC_WRITE_BUFFER_HINT is set? This is an upper bound */
#define GRPC_ARG_HTTP2_WRITE_BUFFER_SIZE "grpc.http2.write_buffer_size"
/** Default authority to pass if none specified on call construction. A string.
* */
#define GRPC_ARG_DEFAULT_AUTHORITY "grpc.default_authority"
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"scripts": {
"lint": "node ./node_modules/jshint/bin/jshint src/node/src src/node/test src/node/interop src/node/index.js --exclude-path=src/node/.jshintignore",
"test": "./node_modules/.bin/mocha src/node/test && npm run-script lint",
"electron-build": "./node_modules/.bin/node-pre-gyp configure build --runtime=electron --disturl=https://atom.io/download/atom-shell",
"gen_docs": "./node_modules/.bin/jsdoc -c src/node/jsdoc_conf.json",
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha src/node/test",
"install": "./node_modules/.bin/node-pre-gyp install --fallback-to-build"
Expand All @@ -38,6 +39,7 @@
"devDependencies": {
"async": "^2.0.1",
"body-parser": "^1.15.2",
"electron-mocha": "^3.1.1",
"express": "^4.14.0",
"google-auth-library": "^0.9.2",
"google-protobuf": "^3.0.0",
Expand Down
33 changes: 23 additions & 10 deletions src/core/ext/transport/chttp2/transport/chttp2_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#define DEFAULT_WINDOW 65535
#define DEFAULT_CONNECTION_WINDOW_TARGET (1024 * 1024)
#define MAX_WINDOW 0x7fffffffu

#define MAX_WRITE_BUFFER_SIZE (64 * 1024 * 1024)
#define DEFAULT_MAX_HEADER_LIST_SIZE (16 * 1024)

#define MAX_CLIENT_STREAM_ID 0x7fffffffu
Expand Down Expand Up @@ -290,6 +290,7 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
window -- this should by rights be 0 */
t->force_send_settings = 1 << GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE;
t->sent_local_settings = 0;
t->write_buffer_size = DEFAULT_WINDOW;

if (is_client) {
grpc_slice_buffer_add(&t->outbuf, grpc_slice_from_copied_string(
Expand Down Expand Up @@ -351,6 +352,11 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
(grpc_integer_options){DEFAULT_MIN_TIME_BETWEEN_PINGS_MS, 0,
INT_MAX}),
GPR_TIMESPAN);
} else if (0 == strcmp(channel_args->args[i].key,
GRPC_ARG_HTTP2_WRITE_BUFFER_SIZE)) {
t->write_buffer_size = (uint32_t)grpc_channel_arg_get_integer(
&channel_args->args[i],
(grpc_integer_options){0, 0, MAX_WRITE_BUFFER_SIZE});
} else {
static const struct {
const char *channel_arg_name;
Expand Down Expand Up @@ -921,15 +927,22 @@ static bool contains_non_ok_status(grpc_metadata_batch *batch) {
return false;
}

static void maybe_become_writable_due_to_send_msg(grpc_exec_ctx *exec_ctx,
grpc_chttp2_transport *t,
grpc_chttp2_stream *s) {
if (s->id != 0 && (!s->write_buffering ||
s->flow_controlled_buffer.length > t->write_buffer_size)) {
grpc_chttp2_become_writable(exec_ctx, t, s, true, "op.send_message");
}
}

static void add_fetched_slice_locked(grpc_exec_ctx *exec_ctx,
grpc_chttp2_transport *t,
grpc_chttp2_stream *s) {
s->fetched_send_message_length +=
(uint32_t)GRPC_SLICE_LENGTH(s->fetching_slice);
grpc_slice_buffer_add(&s->flow_controlled_buffer, s->fetching_slice);
if (s->id != 0) {
grpc_chttp2_become_writable(exec_ctx, t, s, true, "op.send_message");
}
maybe_become_writable_due_to_send_msg(exec_ctx, t, s);
}

static void continue_fetching_send_locked(grpc_exec_ctx *exec_ctx,
Expand Down Expand Up @@ -1122,14 +1135,13 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
(int64_t)len;
s->complete_fetch_covered_by_poller = op->covered_by_poller;
if (flags & GRPC_WRITE_BUFFER_HINT) {
/* allow up to 64kb to be buffered */
/* TODO(ctiller): make this configurable */
s->next_message_end_offset -= 65536;
s->next_message_end_offset -= t->write_buffer_size;
s->write_buffering = true;
} else {
s->write_buffering = false;
}
continue_fetching_send_locked(exec_ctx, t, s);
if (s->id != 0) {
grpc_chttp2_become_writable(exec_ctx, t, s, true, "op.send_message");
}
maybe_become_writable_due_to_send_msg(exec_ctx, t, s);
}
}

Expand All @@ -1138,6 +1150,7 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
on_complete->next_data.scratch |= CLOSURE_BARRIER_MAY_COVER_WRITE;
s->send_trailing_metadata_finished = add_closure_barrier(on_complete);
s->send_trailing_metadata = op->send_trailing_metadata;
s->write_buffering = false;
const size_t metadata_size =
grpc_metadata_batch_size(op->send_trailing_metadata);
const size_t metadata_peer_limit =
Expand Down
Loading

0 comments on commit a66243d

Please sign in to comment.