mirror of https://github.com/grpc/grpc.git
Merge pull request #13567 from nicolasnoble/downmerge-of-master-to-1.8
Downmerge of master to 1.8pull/13564/head
commit
da62be4a3a
148 changed files with 3093 additions and 1361 deletions
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,994 @@ |
||||
# GRPC Node gyp file |
||||
# This currently builds the Node extension and dependencies |
||||
# This file has been automatically generated from a template file. |
||||
# Please look at the templates directory instead. |
||||
# This file can be regenerated from the template by running |
||||
# tools/buildgen/generate_projects.sh |
||||
|
||||
# Copyright 2015 gRPC authors. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
|
||||
# Some of this file is built with the help of |
||||
# https://n8.io/converting-a-c-library-to-gyp/ |
||||
{ |
||||
'variables': { |
||||
'runtime%': 'node', |
||||
# Some Node installations use the system installation of OpenSSL, and on |
||||
# some systems, the system OpenSSL still does not have ALPN support. This |
||||
# will let users recompile gRPC to work without ALPN. |
||||
'grpc_alpn%': 'true', |
||||
# Indicates that the library should be built with gcov. |
||||
'grpc_gcov%': 'false', |
||||
# Indicates that the library should be built with compatibility for musl |
||||
# libc, so that it can run on Alpine Linux. This is only necessary if not |
||||
# building on Alpine Linux |
||||
'grpc_alpine%': 'false' |
||||
}, |
||||
'target_defaults': { |
||||
'configurations': { |
||||
'Release': { |
||||
'cflags': [ |
||||
'-O2', |
||||
], |
||||
'defines': [ |
||||
'NDEBUG', |
||||
], |
||||
}, |
||||
'Debug': { |
||||
'cflags': [ |
||||
'-O0', |
||||
], |
||||
'defines': [ |
||||
'_DEBUG', |
||||
'DEBUG', |
||||
], |
||||
}, |
||||
}, |
||||
'cflags': [ |
||||
'-g', |
||||
'-Wall', |
||||
'-Wextra', |
||||
'-Werror', |
||||
'-Wno-long-long', |
||||
'-Wno-unused-parameter', |
||||
'-DOSATOMIC_USE_INLINED=1', |
||||
], |
||||
'ldflags': [ |
||||
'-g', |
||||
], |
||||
'cflags_c': [ |
||||
'-Werror', |
||||
'-std=c99' |
||||
], |
||||
'cflags_cc': [ |
||||
'-Werror', |
||||
'-std=c++11' |
||||
], |
||||
'include_dirs': [ |
||||
'.', |
||||
'include' |
||||
], |
||||
'defines': [ |
||||
'GPR_BACKWARDS_COMPATIBILITY_MODE', |
||||
'GRPC_ARES=0', |
||||
'GRPC_UV' |
||||
], |
||||
'conditions': [ |
||||
['grpc_gcov=="true"', { |
||||
'cflags': [ |
||||
'-O0', |
||||
'-fprofile-arcs', |
||||
'-ftest-coverage', |
||||
'-Wno-return-type', |
||||
], |
||||
'defines': [ |
||||
'_DEBUG', |
||||
'DEBUG', |
||||
'GPR_GCOV', |
||||
], |
||||
'ldflags': [ |
||||
'-fprofile-arcs', |
||||
'-ftest-coverage', |
||||
'-rdynamic', |
||||
], |
||||
}], |
||||
['grpc_alpine=="true"', { |
||||
'defines': [ |
||||
'GPR_MUSL_LIBC_COMPAT' |
||||
] |
||||
}], |
||||
['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' |
||||
] |
||||
}, { |
||||
'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" ] |
||||
}], |
||||
['grpc_alpn=="true"', { |
||||
'defines': [ |
||||
'TSI_OPENSSL_ALPN_SUPPORT=1' |
||||
], |
||||
}, { |
||||
'defines': [ |
||||
'TSI_OPENSSL_ALPN_SUPPORT=0' |
||||
], |
||||
}] |
||||
], |
||||
'include_dirs': [ |
||||
'<(node_root_dir)/deps/openssl/openssl/include', |
||||
] |
||||
}], |
||||
['OS == "win"', { |
||||
"include_dirs": [ |
||||
"third_party/zlib", |
||||
"third_party/cares/cares" |
||||
], |
||||
"defines": [ |
||||
'_WIN32_WINNT=0x0600', |
||||
'WIN32_LEAN_AND_MEAN', |
||||
'_HAS_EXCEPTIONS=0', |
||||
'UNICODE', |
||||
'_UNICODE', |
||||
'NOMINMAX', |
||||
], |
||||
"msvs_settings": { |
||||
'VCCLCompilerTool': { |
||||
'RuntimeLibrary': 1, # static debug |
||||
} |
||||
}, |
||||
"libraries": [ |
||||
"ws2_32" |
||||
] |
||||
}, { # OS != "win" |
||||
'include_dirs': [ |
||||
'<(node_root_dir)/deps/zlib', |
||||
'<(node_root_dir)/deps/cares/include' |
||||
] |
||||
}], |
||||
['OS == "mac"', { |
||||
'xcode_settings': { |
||||
'OTHER_CFLAGS': [ |
||||
'-g', |
||||
'-Wall', |
||||
'-Wextra', |
||||
'-Werror', |
||||
'-Wno-long-long', |
||||
'-Wno-unused-parameter', |
||||
'-DOSATOMIC_USE_INLINED=1', |
||||
], |
||||
'OTHER_CPLUSPLUSFLAGS': [ |
||||
'-g', |
||||
'-Wall', |
||||
'-Wextra', |
||||
'-Werror', |
||||
'-Wno-long-long', |
||||
'-Wno-unused-parameter', |
||||
'-DOSATOMIC_USE_INLINED=1', |
||||
'-stdlib=libc++', |
||||
'-std=c++11', |
||||
'-Wno-error=deprecated-declarations' |
||||
], |
||||
}, |
||||
}] |
||||
] |
||||
}, |
||||
'conditions': [ |
||||
['OS=="win" or runtime=="electron"', { |
||||
'targets': [ |
||||
{ |
||||
'target_name': 'boringssl', |
||||
'product_prefix': 'lib', |
||||
'type': 'static_library', |
||||
'dependencies': [ |
||||
], |
||||
'sources': [ |
||||
'src/boringssl/err_data.c', |
||||
'third_party/boringssl/crypto/aes/aes.c', |
||||
'third_party/boringssl/crypto/aes/key_wrap.c', |
||||
'third_party/boringssl/crypto/aes/mode_wrappers.c', |
||||
'third_party/boringssl/crypto/asn1/a_bitstr.c', |
||||
'third_party/boringssl/crypto/asn1/a_bool.c', |
||||
'third_party/boringssl/crypto/asn1/a_d2i_fp.c', |
||||
'third_party/boringssl/crypto/asn1/a_dup.c', |
||||
'third_party/boringssl/crypto/asn1/a_enum.c', |
||||
'third_party/boringssl/crypto/asn1/a_gentm.c', |
||||
'third_party/boringssl/crypto/asn1/a_i2d_fp.c', |
||||
'third_party/boringssl/crypto/asn1/a_int.c', |
||||
'third_party/boringssl/crypto/asn1/a_mbstr.c', |
||||
'third_party/boringssl/crypto/asn1/a_object.c', |
||||
'third_party/boringssl/crypto/asn1/a_octet.c', |
||||
'third_party/boringssl/crypto/asn1/a_print.c', |
||||
'third_party/boringssl/crypto/asn1/a_strnid.c', |
||||
'third_party/boringssl/crypto/asn1/a_time.c', |
||||
'third_party/boringssl/crypto/asn1/a_type.c', |
||||
'third_party/boringssl/crypto/asn1/a_utctm.c', |
||||
'third_party/boringssl/crypto/asn1/a_utf8.c', |
||||
'third_party/boringssl/crypto/asn1/asn1_lib.c', |
||||
'third_party/boringssl/crypto/asn1/asn1_par.c', |
||||
'third_party/boringssl/crypto/asn1/asn_pack.c', |
||||
'third_party/boringssl/crypto/asn1/f_enum.c', |
||||
'third_party/boringssl/crypto/asn1/f_int.c', |
||||
'third_party/boringssl/crypto/asn1/f_string.c', |
||||
'third_party/boringssl/crypto/asn1/t_bitst.c', |
||||
'third_party/boringssl/crypto/asn1/tasn_dec.c', |
||||
'third_party/boringssl/crypto/asn1/tasn_enc.c', |
||||
'third_party/boringssl/crypto/asn1/tasn_fre.c', |
||||
'third_party/boringssl/crypto/asn1/tasn_new.c', |
||||
'third_party/boringssl/crypto/asn1/tasn_typ.c', |
||||
'third_party/boringssl/crypto/asn1/tasn_utl.c', |
||||
'third_party/boringssl/crypto/asn1/time_support.c', |
||||
'third_party/boringssl/crypto/asn1/x_bignum.c', |
||||
'third_party/boringssl/crypto/asn1/x_long.c', |
||||
'third_party/boringssl/crypto/base64/base64.c', |
||||
'third_party/boringssl/crypto/bio/bio.c', |
||||
'third_party/boringssl/crypto/bio/bio_mem.c', |
||||
'third_party/boringssl/crypto/bio/connect.c', |
||||
'third_party/boringssl/crypto/bio/fd.c', |
||||
'third_party/boringssl/crypto/bio/file.c', |
||||
'third_party/boringssl/crypto/bio/hexdump.c', |
||||
'third_party/boringssl/crypto/bio/pair.c', |
||||
'third_party/boringssl/crypto/bio/printf.c', |
||||
'third_party/boringssl/crypto/bio/socket.c', |
||||
'third_party/boringssl/crypto/bio/socket_helper.c', |
||||
'third_party/boringssl/crypto/bn/add.c', |
||||
'third_party/boringssl/crypto/bn/asm/x86_64-gcc.c', |
||||
'third_party/boringssl/crypto/bn/bn.c', |
||||
'third_party/boringssl/crypto/bn/bn_asn1.c', |
||||
'third_party/boringssl/crypto/bn/cmp.c', |
||||
'third_party/boringssl/crypto/bn/convert.c', |
||||
'third_party/boringssl/crypto/bn/ctx.c', |
||||
'third_party/boringssl/crypto/bn/div.c', |
||||
'third_party/boringssl/crypto/bn/exponentiation.c', |
||||
'third_party/boringssl/crypto/bn/gcd.c', |
||||
'third_party/boringssl/crypto/bn/generic.c', |
||||
'third_party/boringssl/crypto/bn/kronecker.c', |
||||
'third_party/boringssl/crypto/bn/montgomery.c', |
||||
'third_party/boringssl/crypto/bn/montgomery_inv.c', |
||||
'third_party/boringssl/crypto/bn/mul.c', |
||||
'third_party/boringssl/crypto/bn/prime.c', |
||||
'third_party/boringssl/crypto/bn/random.c', |
||||
'third_party/boringssl/crypto/bn/rsaz_exp.c', |
||||
'third_party/boringssl/crypto/bn/shift.c', |
||||
'third_party/boringssl/crypto/bn/sqrt.c', |
||||
'third_party/boringssl/crypto/buf/buf.c', |
||||
'third_party/boringssl/crypto/bytestring/asn1_compat.c', |
||||
'third_party/boringssl/crypto/bytestring/ber.c', |
||||
'third_party/boringssl/crypto/bytestring/cbb.c', |
||||
'third_party/boringssl/crypto/bytestring/cbs.c', |
||||
'third_party/boringssl/crypto/chacha/chacha.c', |
||||
'third_party/boringssl/crypto/cipher/aead.c', |
||||
'third_party/boringssl/crypto/cipher/cipher.c', |
||||
'third_party/boringssl/crypto/cipher/derive_key.c', |
||||
'third_party/boringssl/crypto/cipher/e_aes.c', |
||||
'third_party/boringssl/crypto/cipher/e_chacha20poly1305.c', |
||||
'third_party/boringssl/crypto/cipher/e_des.c', |
||||
'third_party/boringssl/crypto/cipher/e_null.c', |
||||
'third_party/boringssl/crypto/cipher/e_rc2.c', |
||||
'third_party/boringssl/crypto/cipher/e_rc4.c', |
||||
'third_party/boringssl/crypto/cipher/e_ssl3.c', |
||||
'third_party/boringssl/crypto/cipher/e_tls.c', |
||||
'third_party/boringssl/crypto/cipher/tls_cbc.c', |
||||
'third_party/boringssl/crypto/cmac/cmac.c', |
||||
'third_party/boringssl/crypto/conf/conf.c', |
||||
'third_party/boringssl/crypto/cpu-aarch64-linux.c', |
||||
'third_party/boringssl/crypto/cpu-arm-linux.c', |
||||
'third_party/boringssl/crypto/cpu-arm.c', |
||||
'third_party/boringssl/crypto/cpu-intel.c', |
||||
'third_party/boringssl/crypto/cpu-ppc64le.c', |
||||
'third_party/boringssl/crypto/crypto.c', |
||||
'third_party/boringssl/crypto/curve25519/curve25519.c', |
||||
'third_party/boringssl/crypto/curve25519/spake25519.c', |
||||
'third_party/boringssl/crypto/curve25519/x25519-x86_64.c', |
||||
'third_party/boringssl/crypto/des/des.c', |
||||
'third_party/boringssl/crypto/dh/check.c', |
||||
'third_party/boringssl/crypto/dh/dh.c', |
||||
'third_party/boringssl/crypto/dh/dh_asn1.c', |
||||
'third_party/boringssl/crypto/dh/params.c', |
||||
'third_party/boringssl/crypto/digest/digest.c', |
||||
'third_party/boringssl/crypto/digest/digests.c', |
||||
'third_party/boringssl/crypto/dsa/dsa.c', |
||||
'third_party/boringssl/crypto/dsa/dsa_asn1.c', |
||||
'third_party/boringssl/crypto/ec/ec.c', |
||||
'third_party/boringssl/crypto/ec/ec_asn1.c', |
||||
'third_party/boringssl/crypto/ec/ec_key.c', |
||||
'third_party/boringssl/crypto/ec/ec_montgomery.c', |
||||
'third_party/boringssl/crypto/ec/oct.c', |
||||
'third_party/boringssl/crypto/ec/p224-64.c', |
||||
'third_party/boringssl/crypto/ec/p256-64.c', |
||||
'third_party/boringssl/crypto/ec/p256-x86_64.c', |
||||
'third_party/boringssl/crypto/ec/simple.c', |
||||
'third_party/boringssl/crypto/ec/util-64.c', |
||||
'third_party/boringssl/crypto/ec/wnaf.c', |
||||
'third_party/boringssl/crypto/ecdh/ecdh.c', |
||||
'third_party/boringssl/crypto/ecdsa/ecdsa.c', |
||||
'third_party/boringssl/crypto/ecdsa/ecdsa_asn1.c', |
||||
'third_party/boringssl/crypto/engine/engine.c', |
||||
'third_party/boringssl/crypto/err/err.c', |
||||
'third_party/boringssl/crypto/evp/digestsign.c', |
||||
'third_party/boringssl/crypto/evp/evp.c', |
||||
'third_party/boringssl/crypto/evp/evp_asn1.c', |
||||
'third_party/boringssl/crypto/evp/evp_ctx.c', |
||||
'third_party/boringssl/crypto/evp/p_dsa_asn1.c', |
||||
'third_party/boringssl/crypto/evp/p_ec.c', |
||||
'third_party/boringssl/crypto/evp/p_ec_asn1.c', |
||||
'third_party/boringssl/crypto/evp/p_rsa.c', |
||||
'third_party/boringssl/crypto/evp/p_rsa_asn1.c', |
||||
'third_party/boringssl/crypto/evp/pbkdf.c', |
||||
'third_party/boringssl/crypto/evp/print.c', |
||||
'third_party/boringssl/crypto/evp/sign.c', |
||||
'third_party/boringssl/crypto/ex_data.c', |
||||
'third_party/boringssl/crypto/hkdf/hkdf.c', |
||||
'third_party/boringssl/crypto/hmac/hmac.c', |
||||
'third_party/boringssl/crypto/lhash/lhash.c', |
||||
'third_party/boringssl/crypto/md4/md4.c', |
||||
'third_party/boringssl/crypto/md5/md5.c', |
||||
'third_party/boringssl/crypto/mem.c', |
||||
'third_party/boringssl/crypto/modes/cbc.c', |
||||
'third_party/boringssl/crypto/modes/cfb.c', |
||||
'third_party/boringssl/crypto/modes/ctr.c', |
||||
'third_party/boringssl/crypto/modes/gcm.c', |
||||
'third_party/boringssl/crypto/modes/ofb.c', |
||||
'third_party/boringssl/crypto/modes/polyval.c', |
||||
'third_party/boringssl/crypto/obj/obj.c', |
||||
'third_party/boringssl/crypto/obj/obj_xref.c', |
||||
'third_party/boringssl/crypto/pem/pem_all.c', |
||||
'third_party/boringssl/crypto/pem/pem_info.c', |
||||
'third_party/boringssl/crypto/pem/pem_lib.c', |
||||
'third_party/boringssl/crypto/pem/pem_oth.c', |
||||
'third_party/boringssl/crypto/pem/pem_pk8.c', |
||||
'third_party/boringssl/crypto/pem/pem_pkey.c', |
||||
'third_party/boringssl/crypto/pem/pem_x509.c', |
||||
'third_party/boringssl/crypto/pem/pem_xaux.c', |
||||
'third_party/boringssl/crypto/pkcs8/p5_pbev2.c', |
||||
'third_party/boringssl/crypto/pkcs8/p8_pkey.c', |
||||
'third_party/boringssl/crypto/pkcs8/pkcs8.c', |
||||
'third_party/boringssl/crypto/poly1305/poly1305.c', |
||||
'third_party/boringssl/crypto/poly1305/poly1305_arm.c', |
||||
'third_party/boringssl/crypto/poly1305/poly1305_vec.c', |
||||
'third_party/boringssl/crypto/pool/pool.c', |
||||
'third_party/boringssl/crypto/rand/deterministic.c', |
||||
'third_party/boringssl/crypto/rand/fuchsia.c', |
||||
'third_party/boringssl/crypto/rand/rand.c', |
||||
'third_party/boringssl/crypto/rand/urandom.c', |
||||
'third_party/boringssl/crypto/rand/windows.c', |
||||
'third_party/boringssl/crypto/rc4/rc4.c', |
||||
'third_party/boringssl/crypto/refcount_c11.c', |
||||
'third_party/boringssl/crypto/refcount_lock.c', |
||||
'third_party/boringssl/crypto/rsa/blinding.c', |
||||
'third_party/boringssl/crypto/rsa/padding.c', |
||||
'third_party/boringssl/crypto/rsa/rsa.c', |
||||
'third_party/boringssl/crypto/rsa/rsa_asn1.c', |
||||
'third_party/boringssl/crypto/rsa/rsa_impl.c', |
||||
'third_party/boringssl/crypto/sha/sha1-altivec.c', |
||||
'third_party/boringssl/crypto/sha/sha1.c', |
||||
'third_party/boringssl/crypto/sha/sha256.c', |
||||
'third_party/boringssl/crypto/sha/sha512.c', |
||||
'third_party/boringssl/crypto/stack/stack.c', |
||||
'third_party/boringssl/crypto/thread.c', |
||||
'third_party/boringssl/crypto/thread_none.c', |
||||
'third_party/boringssl/crypto/thread_pthread.c', |
||||
'third_party/boringssl/crypto/thread_win.c', |
||||
'third_party/boringssl/crypto/x509/a_digest.c', |
||||
'third_party/boringssl/crypto/x509/a_sign.c', |
||||
'third_party/boringssl/crypto/x509/a_strex.c', |
||||
'third_party/boringssl/crypto/x509/a_verify.c', |
||||
'third_party/boringssl/crypto/x509/algorithm.c', |
||||
'third_party/boringssl/crypto/x509/asn1_gen.c', |
||||
'third_party/boringssl/crypto/x509/by_dir.c', |
||||
'third_party/boringssl/crypto/x509/by_file.c', |
||||
'third_party/boringssl/crypto/x509/i2d_pr.c', |
||||
'third_party/boringssl/crypto/x509/pkcs7.c', |
||||
'third_party/boringssl/crypto/x509/rsa_pss.c', |
||||
'third_party/boringssl/crypto/x509/t_crl.c', |
||||
'third_party/boringssl/crypto/x509/t_req.c', |
||||
'third_party/boringssl/crypto/x509/t_x509.c', |
||||
'third_party/boringssl/crypto/x509/t_x509a.c', |
||||
'third_party/boringssl/crypto/x509/x509.c', |
||||
'third_party/boringssl/crypto/x509/x509_att.c', |
||||
'third_party/boringssl/crypto/x509/x509_cmp.c', |
||||
'third_party/boringssl/crypto/x509/x509_d2.c', |
||||
'third_party/boringssl/crypto/x509/x509_def.c', |
||||
'third_party/boringssl/crypto/x509/x509_ext.c', |
||||
'third_party/boringssl/crypto/x509/x509_lu.c', |
||||
'third_party/boringssl/crypto/x509/x509_obj.c', |
||||
'third_party/boringssl/crypto/x509/x509_r2x.c', |
||||
'third_party/boringssl/crypto/x509/x509_req.c', |
||||
'third_party/boringssl/crypto/x509/x509_set.c', |
||||
'third_party/boringssl/crypto/x509/x509_trs.c', |
||||
'third_party/boringssl/crypto/x509/x509_txt.c', |
||||
'third_party/boringssl/crypto/x509/x509_v3.c', |
||||
'third_party/boringssl/crypto/x509/x509_vfy.c', |
||||
'third_party/boringssl/crypto/x509/x509_vpm.c', |
||||
'third_party/boringssl/crypto/x509/x509cset.c', |
||||
'third_party/boringssl/crypto/x509/x509name.c', |
||||
'third_party/boringssl/crypto/x509/x509rset.c', |
||||
'third_party/boringssl/crypto/x509/x509spki.c', |
||||
'third_party/boringssl/crypto/x509/x509type.c', |
||||
'third_party/boringssl/crypto/x509/x_algor.c', |
||||
'third_party/boringssl/crypto/x509/x_all.c', |
||||
'third_party/boringssl/crypto/x509/x_attrib.c', |
||||
'third_party/boringssl/crypto/x509/x_crl.c', |
||||
'third_party/boringssl/crypto/x509/x_exten.c', |
||||
'third_party/boringssl/crypto/x509/x_info.c', |
||||
'third_party/boringssl/crypto/x509/x_name.c', |
||||
'third_party/boringssl/crypto/x509/x_pkey.c', |
||||
'third_party/boringssl/crypto/x509/x_pubkey.c', |
||||
'third_party/boringssl/crypto/x509/x_req.c', |
||||
'third_party/boringssl/crypto/x509/x_sig.c', |
||||
'third_party/boringssl/crypto/x509/x_spki.c', |
||||
'third_party/boringssl/crypto/x509/x_val.c', |
||||
'third_party/boringssl/crypto/x509/x_x509.c', |
||||
'third_party/boringssl/crypto/x509/x_x509a.c', |
||||
'third_party/boringssl/crypto/x509v3/pcy_cache.c', |
||||
'third_party/boringssl/crypto/x509v3/pcy_data.c', |
||||
'third_party/boringssl/crypto/x509v3/pcy_lib.c', |
||||
'third_party/boringssl/crypto/x509v3/pcy_map.c', |
||||
'third_party/boringssl/crypto/x509v3/pcy_node.c', |
||||
'third_party/boringssl/crypto/x509v3/pcy_tree.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_akey.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_akeya.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_alt.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_bcons.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_bitst.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_conf.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_cpols.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_crld.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_enum.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_extku.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_genn.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_ia5.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_info.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_int.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_lib.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_ncons.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_pci.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_pcia.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_pcons.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_pku.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_pmaps.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_prn.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_purp.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_skey.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_sxnet.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_utl.c', |
||||
'third_party/boringssl/ssl/bio_ssl.c', |
||||
'third_party/boringssl/ssl/custom_extensions.c', |
||||
'third_party/boringssl/ssl/d1_both.c', |
||||
'third_party/boringssl/ssl/d1_lib.c', |
||||
'third_party/boringssl/ssl/d1_pkt.c', |
||||
'third_party/boringssl/ssl/d1_srtp.c', |
||||
'third_party/boringssl/ssl/dtls_method.c', |
||||
'third_party/boringssl/ssl/dtls_record.c', |
||||
'third_party/boringssl/ssl/handshake_client.c', |
||||
'third_party/boringssl/ssl/handshake_server.c', |
||||
'third_party/boringssl/ssl/s3_both.c', |
||||
'third_party/boringssl/ssl/s3_lib.c', |
||||
'third_party/boringssl/ssl/s3_pkt.c', |
||||
'third_party/boringssl/ssl/ssl_aead_ctx.c', |
||||
'third_party/boringssl/ssl/ssl_asn1.c', |
||||
'third_party/boringssl/ssl/ssl_buffer.c', |
||||
'third_party/boringssl/ssl/ssl_cert.c', |
||||
'third_party/boringssl/ssl/ssl_cipher.c', |
||||
'third_party/boringssl/ssl/ssl_ecdh.c', |
||||
'third_party/boringssl/ssl/ssl_file.c', |
||||
'third_party/boringssl/ssl/ssl_lib.c', |
||||
'third_party/boringssl/ssl/ssl_privkey.c', |
||||
'third_party/boringssl/ssl/ssl_privkey_cc.cc', |
||||
'third_party/boringssl/ssl/ssl_session.c', |
||||
'third_party/boringssl/ssl/ssl_stat.c', |
||||
'third_party/boringssl/ssl/ssl_transcript.c', |
||||
'third_party/boringssl/ssl/ssl_x509.c', |
||||
'third_party/boringssl/ssl/t1_enc.c', |
||||
'third_party/boringssl/ssl/t1_lib.c', |
||||
'third_party/boringssl/ssl/tls13_both.c', |
||||
'third_party/boringssl/ssl/tls13_client.c', |
||||
'third_party/boringssl/ssl/tls13_enc.c', |
||||
'third_party/boringssl/ssl/tls13_server.c', |
||||
'third_party/boringssl/ssl/tls_method.c', |
||||
'third_party/boringssl/ssl/tls_record.c', |
||||
], |
||||
'conditions': [ |
||||
['OS == "mac"', { |
||||
'xcode_settings': { |
||||
'MACOSX_DEPLOYMENT_TARGET': '10.9' |
||||
} |
||||
}] |
||||
] |
||||
}, |
||||
], |
||||
}], |
||||
['OS == "win" and 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. |
||||
# |
||||
# This is not true of Electron, which does not have OpenSSL headers. |
||||
'target_name': 'WINDOWS_BUILD_WARNING', |
||||
'rules': [ |
||||
{ |
||||
'rule_name': 'WINDOWS_BUILD_WARNING', |
||||
'extension': 'S', |
||||
'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/'] |
||||
} |
||||
] |
||||
}, |
||||
] |
||||
}], |
||||
['OS == "win"', { |
||||
'targets': [ |
||||
# Only want to compile zlib under Windows |
||||
{ |
||||
'target_name': 'z', |
||||
'product_prefix': 'lib', |
||||
'type': 'static_library', |
||||
'dependencies': [ |
||||
], |
||||
'sources': [ |
||||
'third_party/zlib/adler32.c', |
||||
'third_party/zlib/compress.c', |
||||
'third_party/zlib/crc32.c', |
||||
'third_party/zlib/deflate.c', |
||||
'third_party/zlib/gzclose.c', |
||||
'third_party/zlib/gzlib.c', |
||||
'third_party/zlib/gzread.c', |
||||
'third_party/zlib/gzwrite.c', |
||||
'third_party/zlib/infback.c', |
||||
'third_party/zlib/inffast.c', |
||||
'third_party/zlib/inflate.c', |
||||
'third_party/zlib/inftrees.c', |
||||
'third_party/zlib/trees.c', |
||||
'third_party/zlib/uncompr.c', |
||||
'third_party/zlib/zutil.c', |
||||
] |
||||
}, |
||||
] |
||||
}] |
||||
], |
||||
'targets': [ |
||||
{ |
||||
'target_name': 'gpr', |
||||
'product_prefix': 'lib', |
||||
'type': 'static_library', |
||||
'dependencies': [ |
||||
], |
||||
'sources': [ |
||||
'src/core/lib/profiling/basic_timers.c', |
||||
'src/core/lib/profiling/stap_timers.c', |
||||
'src/core/lib/support/alloc.c', |
||||
'src/core/lib/support/arena.c', |
||||
'src/core/lib/support/atm.c', |
||||
'src/core/lib/support/avl.c', |
||||
'src/core/lib/support/backoff.c', |
||||
'src/core/lib/support/cmdline.c', |
||||
'src/core/lib/support/cpu_iphone.c', |
||||
'src/core/lib/support/cpu_linux.c', |
||||
'src/core/lib/support/cpu_posix.c', |
||||
'src/core/lib/support/cpu_windows.c', |
||||
'src/core/lib/support/env_linux.c', |
||||
'src/core/lib/support/env_posix.c', |
||||
'src/core/lib/support/env_windows.c', |
||||
'src/core/lib/support/fork.c', |
||||
'src/core/lib/support/histogram.c', |
||||
'src/core/lib/support/host_port.c', |
||||
'src/core/lib/support/log.c', |
||||
'src/core/lib/support/log_android.c', |
||||
'src/core/lib/support/log_linux.c', |
||||
'src/core/lib/support/log_posix.c', |
||||
'src/core/lib/support/log_windows.c', |
||||
'src/core/lib/support/mpscq.c', |
||||
'src/core/lib/support/murmur_hash.c', |
||||
'src/core/lib/support/stack_lockfree.c', |
||||
'src/core/lib/support/string.c', |
||||
'src/core/lib/support/string_posix.c', |
||||
'src/core/lib/support/string_util_windows.c', |
||||
'src/core/lib/support/string_windows.c', |
||||
'src/core/lib/support/subprocess_posix.c', |
||||
'src/core/lib/support/subprocess_windows.c', |
||||
'src/core/lib/support/sync.c', |
||||
'src/core/lib/support/sync_posix.c', |
||||
'src/core/lib/support/sync_windows.c', |
||||
'src/core/lib/support/thd.c', |
||||
'src/core/lib/support/thd_posix.c', |
||||
'src/core/lib/support/thd_windows.c', |
||||
'src/core/lib/support/time.c', |
||||
'src/core/lib/support/time_posix.c', |
||||
'src/core/lib/support/time_precise.c', |
||||
'src/core/lib/support/time_windows.c', |
||||
'src/core/lib/support/tls_pthread.c', |
||||
'src/core/lib/support/tmpfile_msys.c', |
||||
'src/core/lib/support/tmpfile_posix.c', |
||||
'src/core/lib/support/tmpfile_windows.c', |
||||
'src/core/lib/support/wrap_memcpy.c', |
||||
], |
||||
'conditions': [ |
||||
['OS == "mac"', { |
||||
'xcode_settings': { |
||||
'MACOSX_DEPLOYMENT_TARGET': '10.9' |
||||
} |
||||
}] |
||||
] |
||||
}, |
||||
{ |
||||
'target_name': 'grpc', |
||||
'product_prefix': 'lib', |
||||
'type': 'static_library', |
||||
'dependencies': [ |
||||
'gpr', |
||||
], |
||||
'sources': [ |
||||
'src/core/lib/surface/init.c', |
||||
'src/core/lib/channel/channel_args.c', |
||||
'src/core/lib/channel/channel_stack.c', |
||||
'src/core/lib/channel/channel_stack_builder.c', |
||||
'src/core/lib/channel/connected_channel.c', |
||||
'src/core/lib/channel/handshaker.c', |
||||
'src/core/lib/channel/handshaker_factory.c', |
||||
'src/core/lib/channel/handshaker_registry.c', |
||||
'src/core/lib/compression/compression.c', |
||||
'src/core/lib/compression/message_compress.c', |
||||
'src/core/lib/compression/stream_compression.c', |
||||
'src/core/lib/compression/stream_compression_gzip.c', |
||||
'src/core/lib/compression/stream_compression_identity.c', |
||||
'src/core/lib/debug/stats.c', |
||||
'src/core/lib/debug/stats_data.c', |
||||
'src/core/lib/http/format_request.c', |
||||
'src/core/lib/http/httpcli.c', |
||||
'src/core/lib/http/parser.c', |
||||
'src/core/lib/iomgr/call_combiner.c', |
||||
'src/core/lib/iomgr/closure.c', |
||||
'src/core/lib/iomgr/combiner.c', |
||||
'src/core/lib/iomgr/endpoint.c', |
||||
'src/core/lib/iomgr/endpoint_pair_posix.c', |
||||
'src/core/lib/iomgr/endpoint_pair_uv.c', |
||||
'src/core/lib/iomgr/endpoint_pair_windows.c', |
||||
'src/core/lib/iomgr/error.c', |
||||
'src/core/lib/iomgr/ev_epoll1_linux.c', |
||||
'src/core/lib/iomgr/ev_epollex_linux.c', |
||||
'src/core/lib/iomgr/ev_epollsig_linux.c', |
||||
'src/core/lib/iomgr/ev_poll_posix.c', |
||||
'src/core/lib/iomgr/ev_posix.c', |
||||
'src/core/lib/iomgr/ev_windows.c', |
||||
'src/core/lib/iomgr/exec_ctx.c', |
||||
'src/core/lib/iomgr/executor.c', |
||||
'src/core/lib/iomgr/fork_posix.c', |
||||
'src/core/lib/iomgr/fork_windows.c', |
||||
'src/core/lib/iomgr/gethostname_fallback.c', |
||||
'src/core/lib/iomgr/gethostname_host_name_max.c', |
||||
'src/core/lib/iomgr/gethostname_sysconf.c', |
||||
'src/core/lib/iomgr/iocp_windows.c', |
||||
'src/core/lib/iomgr/iomgr.c', |
||||
'src/core/lib/iomgr/iomgr_posix.c', |
||||
'src/core/lib/iomgr/iomgr_uv.c', |
||||
'src/core/lib/iomgr/iomgr_windows.c', |
||||
'src/core/lib/iomgr/is_epollexclusive_available.c', |
||||
'src/core/lib/iomgr/load_file.c', |
||||
'src/core/lib/iomgr/lockfree_event.c', |
||||
'src/core/lib/iomgr/network_status_tracker.c', |
||||
'src/core/lib/iomgr/polling_entity.c', |
||||
'src/core/lib/iomgr/pollset_set_uv.c', |
||||
'src/core/lib/iomgr/pollset_set_windows.c', |
||||
'src/core/lib/iomgr/pollset_uv.c', |
||||
'src/core/lib/iomgr/pollset_windows.c', |
||||
'src/core/lib/iomgr/resolve_address_posix.c', |
||||
'src/core/lib/iomgr/resolve_address_uv.c', |
||||
'src/core/lib/iomgr/resolve_address_windows.c', |
||||
'src/core/lib/iomgr/resource_quota.c', |
||||
'src/core/lib/iomgr/sockaddr_utils.c', |
||||
'src/core/lib/iomgr/socket_factory_posix.c', |
||||
'src/core/lib/iomgr/socket_mutator.c', |
||||
'src/core/lib/iomgr/socket_utils_common_posix.c', |
||||
'src/core/lib/iomgr/socket_utils_linux.c', |
||||
'src/core/lib/iomgr/socket_utils_posix.c', |
||||
'src/core/lib/iomgr/socket_utils_uv.c', |
||||
'src/core/lib/iomgr/socket_utils_windows.c', |
||||
'src/core/lib/iomgr/socket_windows.c', |
||||
'src/core/lib/iomgr/tcp_client_posix.c', |
||||
'src/core/lib/iomgr/tcp_client_uv.c', |
||||
'src/core/lib/iomgr/tcp_client_windows.c', |
||||
'src/core/lib/iomgr/tcp_posix.c', |
||||
'src/core/lib/iomgr/tcp_server_posix.c', |
||||
'src/core/lib/iomgr/tcp_server_utils_posix_common.c', |
||||
'src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c', |
||||
'src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c', |
||||
'src/core/lib/iomgr/tcp_server_uv.c', |
||||
'src/core/lib/iomgr/tcp_server_windows.c', |
||||
'src/core/lib/iomgr/tcp_uv.c', |
||||
'src/core/lib/iomgr/tcp_windows.c', |
||||
'src/core/lib/iomgr/time_averaged_stats.c', |
||||
'src/core/lib/iomgr/timer_generic.c', |
||||
'src/core/lib/iomgr/timer_heap.c', |
||||
'src/core/lib/iomgr/timer_manager.c', |
||||
'src/core/lib/iomgr/timer_uv.c', |
||||
'src/core/lib/iomgr/udp_server.c', |
||||
'src/core/lib/iomgr/unix_sockets_posix.c', |
||||
'src/core/lib/iomgr/unix_sockets_posix_noop.c', |
||||
'src/core/lib/iomgr/wakeup_fd_cv.c', |
||||
'src/core/lib/iomgr/wakeup_fd_eventfd.c', |
||||
'src/core/lib/iomgr/wakeup_fd_nospecial.c', |
||||
'src/core/lib/iomgr/wakeup_fd_pipe.c', |
||||
'src/core/lib/iomgr/wakeup_fd_posix.c', |
||||
'src/core/lib/json/json.c', |
||||
'src/core/lib/json/json_reader.c', |
||||
'src/core/lib/json/json_string.c', |
||||
'src/core/lib/json/json_writer.c', |
||||
'src/core/lib/slice/b64.c', |
||||
'src/core/lib/slice/percent_encoding.c', |
||||
'src/core/lib/slice/slice.c', |
||||
'src/core/lib/slice/slice_buffer.c', |
||||
'src/core/lib/slice/slice_hash_table.c', |
||||
'src/core/lib/slice/slice_intern.c', |
||||
'src/core/lib/slice/slice_string_helpers.c', |
||||
'src/core/lib/surface/alarm.c', |
||||
'src/core/lib/surface/api_trace.c', |
||||
'src/core/lib/surface/byte_buffer.c', |
||||
'src/core/lib/surface/byte_buffer_reader.c', |
||||
'src/core/lib/surface/call.c', |
||||
'src/core/lib/surface/call_details.c', |
||||
'src/core/lib/surface/call_log_batch.c', |
||||
'src/core/lib/surface/channel.c', |
||||
'src/core/lib/surface/channel_init.c', |
||||
'src/core/lib/surface/channel_ping.c', |
||||
'src/core/lib/surface/channel_stack_type.c', |
||||
'src/core/lib/surface/completion_queue.c', |
||||
'src/core/lib/surface/completion_queue_factory.c', |
||||
'src/core/lib/surface/event_string.c', |
||||
'src/core/lib/surface/lame_client.cc', |
||||
'src/core/lib/surface/metadata_array.c', |
||||
'src/core/lib/surface/server.c', |
||||
'src/core/lib/surface/validate_metadata.c', |
||||
'src/core/lib/surface/version.c', |
||||
'src/core/lib/transport/bdp_estimator.c', |
||||
'src/core/lib/transport/byte_stream.c', |
||||
'src/core/lib/transport/connectivity_state.c', |
||||
'src/core/lib/transport/error_utils.c', |
||||
'src/core/lib/transport/metadata.c', |
||||
'src/core/lib/transport/metadata_batch.c', |
||||
'src/core/lib/transport/pid_controller.c', |
||||
'src/core/lib/transport/service_config.c', |
||||
'src/core/lib/transport/static_metadata.c', |
||||
'src/core/lib/transport/status_conversion.c', |
||||
'src/core/lib/transport/timeout_encoding.c', |
||||
'src/core/lib/transport/transport.c', |
||||
'src/core/lib/transport/transport_op_string.c', |
||||
'src/core/lib/debug/trace.c', |
||||
'src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c', |
||||
'src/core/ext/transport/chttp2/transport/bin_decoder.c', |
||||
'src/core/ext/transport/chttp2/transport/bin_encoder.c', |
||||
'src/core/ext/transport/chttp2/transport/chttp2_plugin.c', |
||||
'src/core/ext/transport/chttp2/transport/chttp2_transport.c', |
||||
'src/core/ext/transport/chttp2/transport/flow_control.c', |
||||
'src/core/ext/transport/chttp2/transport/frame_data.c', |
||||
'src/core/ext/transport/chttp2/transport/frame_goaway.c', |
||||
'src/core/ext/transport/chttp2/transport/frame_ping.c', |
||||
'src/core/ext/transport/chttp2/transport/frame_rst_stream.c', |
||||
'src/core/ext/transport/chttp2/transport/frame_settings.c', |
||||
'src/core/ext/transport/chttp2/transport/frame_window_update.c', |
||||
'src/core/ext/transport/chttp2/transport/hpack_encoder.c', |
||||
'src/core/ext/transport/chttp2/transport/hpack_parser.c', |
||||
'src/core/ext/transport/chttp2/transport/hpack_table.c', |
||||
'src/core/ext/transport/chttp2/transport/http2_settings.c', |
||||
'src/core/ext/transport/chttp2/transport/huffsyms.c', |
||||
'src/core/ext/transport/chttp2/transport/incoming_metadata.c', |
||||
'src/core/ext/transport/chttp2/transport/parsing.c', |
||||
'src/core/ext/transport/chttp2/transport/stream_lists.c', |
||||
'src/core/ext/transport/chttp2/transport/stream_map.c', |
||||
'src/core/ext/transport/chttp2/transport/varint.c', |
||||
'src/core/ext/transport/chttp2/transport/writing.c', |
||||
'src/core/ext/transport/chttp2/alpn/alpn.c', |
||||
'src/core/ext/filters/http/client/http_client_filter.c', |
||||
'src/core/ext/filters/http/http_filters_plugin.c', |
||||
'src/core/ext/filters/http/message_compress/message_compress_filter.c', |
||||
'src/core/ext/filters/http/server/http_server_filter.c', |
||||
'src/core/lib/http/httpcli_security_connector.c', |
||||
'src/core/lib/security/context/security_context.c', |
||||
'src/core/lib/security/credentials/composite/composite_credentials.c', |
||||
'src/core/lib/security/credentials/credentials.c', |
||||
'src/core/lib/security/credentials/credentials_metadata.c', |
||||
'src/core/lib/security/credentials/fake/fake_credentials.c', |
||||
'src/core/lib/security/credentials/google_default/credentials_generic.c', |
||||
'src/core/lib/security/credentials/google_default/google_default_credentials.c', |
||||
'src/core/lib/security/credentials/iam/iam_credentials.c', |
||||
'src/core/lib/security/credentials/jwt/json_token.c', |
||||
'src/core/lib/security/credentials/jwt/jwt_credentials.c', |
||||
'src/core/lib/security/credentials/jwt/jwt_verifier.c', |
||||
'src/core/lib/security/credentials/oauth2/oauth2_credentials.c', |
||||
'src/core/lib/security/credentials/plugin/plugin_credentials.c', |
||||
'src/core/lib/security/credentials/ssl/ssl_credentials.c', |
||||
'src/core/lib/security/transport/client_auth_filter.c', |
||||
'src/core/lib/security/transport/lb_targets_info.c', |
||||
'src/core/lib/security/transport/secure_endpoint.c', |
||||
'src/core/lib/security/transport/security_connector.c', |
||||
'src/core/lib/security/transport/security_handshaker.c', |
||||
'src/core/lib/security/transport/server_auth_filter.c', |
||||
'src/core/lib/security/transport/tsi_error.c', |
||||
'src/core/lib/security/util/json_util.c', |
||||
'src/core/lib/surface/init_secure.c', |
||||
'src/core/tsi/fake_transport_security.c', |
||||
'src/core/tsi/gts_transport_security.c', |
||||
'src/core/tsi/ssl_transport_security.c', |
||||
'src/core/tsi/transport_security_grpc.c', |
||||
'src/core/tsi/transport_security.c', |
||||
'src/core/tsi/transport_security_adapter.c', |
||||
'src/core/ext/transport/chttp2/server/chttp2_server.c', |
||||
'src/core/ext/transport/chttp2/client/secure/secure_channel_create.c', |
||||
'src/core/ext/filters/client_channel/channel_connectivity.c', |
||||
'src/core/ext/filters/client_channel/client_channel.c', |
||||
'src/core/ext/filters/client_channel/client_channel_factory.c', |
||||
'src/core/ext/filters/client_channel/client_channel_plugin.c', |
||||
'src/core/ext/filters/client_channel/connector.c', |
||||
'src/core/ext/filters/client_channel/http_connect_handshaker.c', |
||||
'src/core/ext/filters/client_channel/http_proxy.c', |
||||
'src/core/ext/filters/client_channel/lb_policy.c', |
||||
'src/core/ext/filters/client_channel/lb_policy_factory.c', |
||||
'src/core/ext/filters/client_channel/lb_policy_registry.c', |
||||
'src/core/ext/filters/client_channel/parse_address.c', |
||||
'src/core/ext/filters/client_channel/proxy_mapper.c', |
||||
'src/core/ext/filters/client_channel/proxy_mapper_registry.c', |
||||
'src/core/ext/filters/client_channel/resolver.c', |
||||
'src/core/ext/filters/client_channel/resolver_factory.c', |
||||
'src/core/ext/filters/client_channel/resolver_registry.c', |
||||
'src/core/ext/filters/client_channel/retry_throttle.c', |
||||
'src/core/ext/filters/client_channel/subchannel.c', |
||||
'src/core/ext/filters/client_channel/subchannel_index.c', |
||||
'src/core/ext/filters/client_channel/uri_parser.c', |
||||
'src/core/ext/filters/deadline/deadline_filter.c', |
||||
'src/core/ext/transport/chttp2/client/chttp2_connector.c', |
||||
'src/core/ext/transport/chttp2/server/insecure/server_chttp2.c', |
||||
'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c', |
||||
'src/core/ext/transport/chttp2/client/insecure/channel_create.c', |
||||
'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c', |
||||
'src/core/ext/transport/inproc/inproc_plugin.c', |
||||
'src/core/ext/transport/inproc/inproc_transport.c', |
||||
'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c', |
||||
'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c', |
||||
'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c', |
||||
'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c', |
||||
'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c', |
||||
'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c', |
||||
'third_party/nanopb/pb_common.c', |
||||
'third_party/nanopb/pb_decode.c', |
||||
'third_party/nanopb/pb_encode.c', |
||||
'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c', |
||||
'src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c', |
||||
'src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c', |
||||
'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c', |
||||
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c', |
||||
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c', |
||||
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c', |
||||
'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c', |
||||
'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c', |
||||
'src/core/ext/filters/load_reporting/server_load_reporting_filter.c', |
||||
'src/core/ext/filters/load_reporting/server_load_reporting_plugin.c', |
||||
'src/core/ext/census/base_resources.c', |
||||
'src/core/ext/census/context.c', |
||||
'src/core/ext/census/gen/census.pb.c', |
||||
'src/core/ext/census/gen/trace_context.pb.c', |
||||
'src/core/ext/census/grpc_context.c', |
||||
'src/core/ext/census/grpc_filter.c', |
||||
'src/core/ext/census/grpc_plugin.c', |
||||
'src/core/ext/census/initialize.c', |
||||
'src/core/ext/census/intrusive_hash_map.c', |
||||
'src/core/ext/census/mlog.c', |
||||
'src/core/ext/census/operation.c', |
||||
'src/core/ext/census/placeholders.c', |
||||
'src/core/ext/census/resource.c', |
||||
'src/core/ext/census/trace_context.c', |
||||
'src/core/ext/census/tracing.c', |
||||
'src/core/ext/filters/max_age/max_age_filter.c', |
||||
'src/core/ext/filters/message_size/message_size_filter.c', |
||||
'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c', |
||||
'src/core/ext/filters/workarounds/workaround_utils.c', |
||||
'src/core/plugin_registry/grpc_plugin_registry.c', |
||||
], |
||||
'conditions': [ |
||||
['OS == "mac"', { |
||||
'xcode_settings': { |
||||
'MACOSX_DEPLOYMENT_TARGET': '10.9' |
||||
} |
||||
}] |
||||
] |
||||
}, |
||||
{ |
||||
'include_dirs': [ |
||||
"<!(node -e \"require('nan')\")" |
||||
], |
||||
'cflags': [ |
||||
'-pthread', |
||||
'-zdefs', |
||||
'-Wno-error=deprecated-declarations' |
||||
], |
||||
"conditions": [ |
||||
['OS=="win" or runtime=="electron"', { |
||||
'dependencies': [ |
||||
"boringssl", |
||||
] |
||||
}], |
||||
['OS=="win"', { |
||||
'dependencies': [ |
||||
"z", |
||||
] |
||||
}], |
||||
['OS=="linux"', { |
||||
'ldflags': [ |
||||
'-Wl,-wrap,memcpy' |
||||
] |
||||
}], |
||||
['OS == "mac"', { |
||||
'xcode_settings': { |
||||
'MACOSX_DEPLOYMENT_TARGET': '10.9' |
||||
} |
||||
}] |
||||
], |
||||
"target_name": "grpc_node", |
||||
"sources": [ |
||||
"src/node/ext/byte_buffer.cc", |
||||
"src/node/ext/call.cc", |
||||
"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/node_grpc.cc", |
||||
"src/node/ext/server.cc", |
||||
"src/node/ext/server_credentials.cc", |
||||
"src/node/ext/slice.cc", |
||||
"src/node/ext/timeval.cc", |
||||
], |
||||
"dependencies": [ |
||||
"grpc", |
||||
"gpr", |
||||
] |
||||
}, |
||||
{ |
||||
"target_name": "action_after_build", |
||||
"type": "none", |
||||
"dependencies": [ "<(module_name)" ], |
||||
"copies": [ |
||||
{ |
||||
"files": [ "<(PRODUCT_DIR)/<(module_name).node"], |
||||
"destination": "<(module_path)" |
||||
} |
||||
] |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,197 @@ |
||||
# Transport Explainer |
||||
|
||||
@vjpai |
||||
|
||||
## Existing Transports |
||||
|
||||
[gRPC |
||||
transports](https://github.com/grpc/grpc/tree/master/src/core/ext/transport) |
||||
plug in below the core API (one level below the C++ or other wrapped-language |
||||
API). You can write your transport in C or C++ though; currently (Nov 2017) all |
||||
the transports are nominally written in C++ though they are idiomatically C. The |
||||
existing transports are: |
||||
|
||||
* [HTTP/2](https://github.com/grpc/grpc/tree/master/src/core/ext/transport/chttp2) |
||||
* [Cronet](https://github.com/grpc/grpc/tree/master/src/core/ext/transport/cronet) |
||||
* [In-process](https://github.com/grpc/grpc/tree/master/src/core/ext/transport/inproc) |
||||
|
||||
Among these, the in-process is likely the easiest to understand, though arguably |
||||
also the least similar to a "real" sockets-based transport since it is only used |
||||
in a single process. |
||||
|
||||
## Transport stream ops |
||||
|
||||
In the gRPC core implementation, a fundamental struct is the |
||||
`grpc_transport_stream_op_batch` which represents a collection of stream |
||||
operations sent to a transport. (Note that in gRPC, _stream_ and _RPC_ are used |
||||
synonymously since all RPCs are actually streams internally.) The ops in a batch |
||||
can include: |
||||
|
||||
* send\_initial\_metadata |
||||
- Client: initate an RPC |
||||
- Server: supply response headers |
||||
* recv\_initial\_metadata |
||||
- Client: get response headers |
||||
- Server: accept an RPC |
||||
* send\_message (zero or more) : send a data buffer |
||||
* recv\_message (zero or more) : receive a data buffer |
||||
* send\_trailing\_metadata |
||||
- Client: half-close indicating that no more messages will be coming |
||||
- Server: full-close providing final status for the RPC |
||||
* recv\_trailing\_metadata: get final status for the RPC |
||||
- Server extra: This op shouldn't actually be considered complete until the |
||||
server has also sent trailing metadata to provide the other side with final |
||||
status |
||||
* cancel\_stream: Attempt to cancel an RPC |
||||
* collect\_stats: Get stats |
||||
|
||||
The fundamental responsibility of the transport is to transform between this |
||||
internal format and an actual wire format, so the processing of these operations |
||||
is largely transport-specific. |
||||
|
||||
One or more of these ops are grouped into a batch. Applications can start all of |
||||
a call's ops in a single batch, or they can split them up into multiple |
||||
batches. Results of each batch are returned asynchronously via a completion |
||||
queue. |
||||
|
||||
Internally, we use callbacks to indicate completion. The surface layer creates a |
||||
callback when starting a new batch and sends it down the filter stack along with |
||||
the batch. The transport must invoke this callback when the batch is complete, |
||||
and then the surface layer returns an event to the application via the |
||||
completion queue. Each batch can have up to 3 callbacks: |
||||
|
||||
* recv\_initial\_metadata\_ready (called by the transport when the |
||||
recv\_initial\_metadata op is complete) |
||||
* recv\_message\_ready (called by the transport when the recv_message op is |
||||
complete) |
||||
* on\_complete (called by the transport when the entire batch is complete) |
||||
|
||||
## Timelines of transport stream op batches |
||||
|
||||
The transport's job is to sequence and interpret various possible interleavings |
||||
of the basic stream ops. For example, a sample timeline of batches would be: |
||||
|
||||
1. Client send\_initial\_metadata: Initiate an RPC with a path (method) and authority |
||||
1. Server recv\_initial\_metadata: accept an RPC |
||||
1. Client send\_message: Supply the input proto for the RPC |
||||
1. Server recv\_message: Get the input proto from the RPC |
||||
1. Client send\_trailing\_metadata: This is a half-close indicating that the |
||||
client will not be sending any more messages |
||||
1. Server recv\_trailing\_metadata: The server sees this from the client and |
||||
knows that it will not get any more messages. This won't complete yet though, |
||||
as described above. |
||||
1. Server send\_initial\_metadata, send\_message, send\_trailing\_metadata: A |
||||
batch can contain multiple ops, and this batch provides the RPC response |
||||
headers, response content, and status. Note that sending the trailing |
||||
metadata will also complete the server's receive of trailing metadata. |
||||
1. Client recv\_initial\_metadata: The number of ops in one side of the batch |
||||
has no relation with the number of ops on the other side of the batch. In |
||||
this case, the client is just collecting the response headers. |
||||
1. Client recv\_message, recv\_trailing\_metadata: Get the data response and |
||||
status |
||||
|
||||
|
||||
There are other possible sample timelines. For example, for client-side streaming, a "typical" sequence would be: |
||||
|
||||
1. Server: recv\_initial\_metadata |
||||
- At API-level, that would be the server requesting an RPC |
||||
1. Server: recv\_trailing\_metadata |
||||
- This is for when the server wants to know the final completion of the RPC |
||||
through an `AsyncNotifyWhenDone` API in C++ |
||||
1. Client: send\_initial\_metadata, recv\_message, recv\_trailing\_metadata |
||||
- At API-level, that's a client invoking a client-side streaming call. The |
||||
send\_initial\_metadata is the call invocation, the recv\_message colects |
||||
the final response from the server, and the recv\_trailing\_metadata gets |
||||
the `grpc::Status` value that will be returned from the call |
||||
1. Client: send\_message / Server: recv\_message |
||||
- Repeat the above step numerous times; these correspond to a client issuing |
||||
`Write` in a loop and a server doing `Read` in a loop until `Read` fails |
||||
1. Client: send\_trailing\_metadata / Server: recv\_message that indicates doneness (NULL) |
||||
- These correspond to a client issuing `WritesDone` which causes the server's |
||||
`Read` to fail |
||||
1. Server: send\_message, send\_trailing\_metadata |
||||
- These correpond to the server doing `Finish` |
||||
|
||||
The sends on one side will call their own callbacks when complete, and they will |
||||
in turn trigger actions that cause the other side's recv operations to |
||||
complete. In some transports, a send can sometimes complete before the recv on |
||||
the other side (e.g., in HTTP/2 if there is sufficient flow-control buffer space |
||||
available) |
||||
|
||||
## Other transport duties |
||||
|
||||
In addition to these basic stream ops, the transport must handle cancellations |
||||
of a stream at any time and pass their effects to the other side. For example, |
||||
in HTTP/2, this triggers a `RST_STREAM` being sent on the wire. The transport |
||||
must perform operations like pings and statistics that are used to shape |
||||
transport-level characteristics like flow control (see, for example, their use |
||||
in the HTTP/2 transport). |
||||
|
||||
## Putting things together with detail: Sending Metadata |
||||
|
||||
* API layer: `map<string, string>` that is specific to this RPC |
||||
* Core surface layer: array of `{slice, slice}` pairs where each slice |
||||
references an underlying string |
||||
* [Core transport |
||||
layer](https://github.com/grpc/grpc/tree/master/src/core/lib/transport): list |
||||
of `{slice, slice}` pairs that includes the above plus possibly some general |
||||
metadata (e.g., Method and Authority for initial metadata) |
||||
* [Specific transport |
||||
layer](https://github.com/grpc/grpc/tree/master/src/core/ext/transport): |
||||
- Either send it to the other side using transport-specific API (e.g., Cronet) |
||||
- Or have it sent through the [iomgr/endpoint |
||||
layer](https://github.com/grpc/grpc/tree/master/src/core/lib/iomgr) (e.g., |
||||
HTTP/2) |
||||
- Or just manipulate pointers to get it from one side to the other (e.g., |
||||
In-process) |
||||
|
||||
## Requirements for any transport |
||||
|
||||
Each transport implements several operations in a vtbl (may change to actual |
||||
virtual functions as transport moves to idiomatic C++). |
||||
|
||||
The most important and common one is `perform_stream_op`. This function |
||||
processes a single stream op batch on a specific stream that is associated with |
||||
a specific transport: |
||||
|
||||
* Gets the 6 ops/cancel passed down from the surface |
||||
* Pass metadata from one side to the other as described above |
||||
* Transform messages between slice buffer structure and stream of bytes to pass |
||||
to other side |
||||
- May require insertion of extra bytes (e.g., per-message headers in HTTP/2) |
||||
* React to metadata to preserve expected orderings (*) |
||||
* Schedule invocation of completion callbacks |
||||
|
||||
There are other functions in the vtbl as well. |
||||
|
||||
* `perform_transport_op` |
||||
- Configure the transport instance for the connectivity state change notifier |
||||
or the server-side accept callback |
||||
- Disconnect transport or set up a goaway for later streams |
||||
* `init_stream` |
||||
- Starts a stream from the client-side |
||||
- (*) Server-side of the transport must call `accept_stream_cb` when a new |
||||
stream is available |
||||
* Triggers request-matcher |
||||
* `destroy_stream`, `destroy_transport` |
||||
- Free up data related to a stream or transport |
||||
* `set_pollset`, `set_pollset_set`, `get_endpoint` |
||||
- Map each specific instance of the transport to FDs being used by iomgr (for |
||||
HTTP/2) |
||||
- Get a pointer to the endpoint structure that actually moves the data |
||||
(wrapper around a socket for HTTP/2) |
||||
|
||||
## Book-keeping responsibilities of the transport layer |
||||
|
||||
A given transport must keep all of its transport and streams ref-counted. This |
||||
is essential to make sure that no struct disappears before it is done being |
||||
used. |
||||
|
||||
A transport must also preserve relevant orders for the different categories of |
||||
ops on a stream, as described above. A transport must also make sure that all |
||||
relevant batch operations have completed before scheduling the `on_complete` |
||||
closure for a batch. Further examples include the idea that the server logic |
||||
expects to not complete recv\_trailing\_metadata until after it actually sends |
||||
trailing metadata since it would have already found this out by seeing a NULL’ed |
||||
recv\_message. This is considered part of the transport's duties in preserving |
||||
orders. |
@ -0,0 +1,24 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2017 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPC_FORK_H |
||||
#define GRPC_FORK_H |
||||
|
||||
#include <grpc/impl/codegen/fork.h> |
||||
|
||||
#endif /* GRPC_FORK_H */ |
@ -0,0 +1,48 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2017 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPC_IMPL_CODEGEN_FORK_H |
||||
#define GRPC_IMPL_CODEGEN_FORK_H |
||||
|
||||
/**
|
||||
* gRPC applications should call this before calling fork(). There should be no |
||||
* active gRPC function calls between calling grpc_prefork() and |
||||
* grpc_postfork_parent()/grpc_postfork_child(). |
||||
* |
||||
* |
||||
* Typical use: |
||||
* grpc_prefork(); |
||||
* int pid = fork(); |
||||
* if (pid) { |
||||
* grpc_postfork_parent(); |
||||
* // Parent process..
|
||||
* } else { |
||||
* grpc_postfork_child(); |
||||
* // Child process...
|
||||
* } |
||||
*/ |
||||
|
||||
void grpc_prefork(); |
||||
|
||||
void grpc_postfork_parent(); |
||||
|
||||
void grpc_postfork_child(); |
||||
|
||||
void grpc_fork_handlers_auto_register(); |
||||
|
||||
#endif /* GRPC_IMPL_CODEGEN_FORK_H */ |
@ -0,0 +1,103 @@ |
||||
{ |
||||
"name": "grpc", |
||||
"version": "1.7.2", |
||||
"author": "Google Inc.", |
||||
"description": "gRPC Library for Node", |
||||
"homepage": "https://grpc.io/", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/grpc/grpc.git" |
||||
}, |
||||
"bugs": "https://github.com/grpc/grpc/issues", |
||||
"contributors": [ |
||||
{ |
||||
"name": "Michael Lumish", |
||||
"email": "mlumish@google.com" |
||||
} |
||||
], |
||||
"directories": { |
||||
"lib": "src/node/src" |
||||
}, |
||||
"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 --library=static_library" |
||||
}, |
||||
"bundledDependencies": [ |
||||
"node-pre-gyp" |
||||
], |
||||
"dependencies": { |
||||
"arguejs": "^0.2.3", |
||||
"lodash": "^4.15.0", |
||||
"nan": "^2.0.0", |
||||
"node-pre-gyp": "^0.6.35", |
||||
"protobufjs": "^5.0.0" |
||||
}, |
||||
"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", |
||||
"istanbul": "^0.4.4", |
||||
"jsdoc": "^3.3.2", |
||||
"jshint": "^2.5.0", |
||||
"minimist": "^1.1.0", |
||||
"mocha": "^3.0.2", |
||||
"mocha-jenkins-reporter": "^0.2.3", |
||||
"poisson-process": "^0.2.1" |
||||
}, |
||||
"engines": { |
||||
"node": ">=4" |
||||
}, |
||||
"binary": { |
||||
"module_name": "grpc_node", |
||||
"module_path": "src/node/extension_binary/{node_abi}-{platform}-{arch}", |
||||
"host": "https://storage.googleapis.com/", |
||||
"remote_path": "grpc-precompiled-binaries/node/{name}/v{version}", |
||||
"package_name": "{node_abi}-{platform}-{arch}.tar.gz" |
||||
}, |
||||
"files": [ |
||||
"LICENSE", |
||||
"src/node/README.md", |
||||
"src/proto", |
||||
"etc", |
||||
"src/node/index.js", |
||||
"src/node/src", |
||||
"src/node/ext", |
||||
"include/grpc", |
||||
"src/core", |
||||
"src/boringssl", |
||||
"src/zlib", |
||||
"third_party/nanopb", |
||||
"third_party/zlib", |
||||
"third_party/boringssl", |
||||
"binding.gyp" |
||||
], |
||||
"main": "src/node/index.js", |
||||
"license": "Apache-2.0", |
||||
"jshintConfig": { |
||||
"bitwise": true, |
||||
"curly": true, |
||||
"eqeqeq": true, |
||||
"esnext": true, |
||||
"freeze": true, |
||||
"immed": true, |
||||
"indent": 2, |
||||
"latedef": "nofunc", |
||||
"maxlen": 80, |
||||
"mocha": true, |
||||
"newcap": true, |
||||
"node": true, |
||||
"noarg": true, |
||||
"quotmark": "single", |
||||
"strict": true, |
||||
"trailing": true, |
||||
"undef": true, |
||||
"unused": "vars" |
||||
} |
||||
} |
@ -0,0 +1,88 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2017 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
#include "src/core/lib/iomgr/port.h" |
||||
|
||||
#ifdef GRPC_POSIX_FORK |
||||
|
||||
#include <string.h> |
||||
|
||||
#include <grpc/fork.h> |
||||
#include <grpc/support/log.h> |
||||
#include <grpc/support/thd.h> |
||||
#include <grpc/support/useful.h> |
||||
|
||||
#include "src/core/lib/iomgr/ev_posix.h" |
||||
#include "src/core/lib/iomgr/executor.h" |
||||
#include "src/core/lib/iomgr/timer_manager.h" |
||||
#include "src/core/lib/iomgr/wakeup_fd_posix.h" |
||||
#include "src/core/lib/support/env.h" |
||||
#include "src/core/lib/support/fork.h" |
||||
#include "src/core/lib/support/thd_internal.h" |
||||
#include "src/core/lib/surface/init.h" |
||||
|
||||
/*
|
||||
* NOTE: FORKING IS NOT GENERALLY SUPPORTED, THIS IS ONLY INTENDED TO WORK |
||||
* AROUND VERY SPECIFIC USE CASES. |
||||
*/ |
||||
|
||||
void grpc_prefork() { |
||||
if (!grpc_fork_support_enabled()) { |
||||
gpr_log(GPR_ERROR, |
||||
"Fork support not enabled; try running with the " |
||||
"environment variable GRPC_ENABLE_FORK_SUPPORT=1"); |
||||
return; |
||||
} |
||||
if (grpc_is_initialized()) { |
||||
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
||||
grpc_timer_manager_set_threading(false); |
||||
grpc_executor_set_threading(&exec_ctx, false); |
||||
grpc_exec_ctx_finish(&exec_ctx); |
||||
if (!gpr_await_threads( |
||||
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), |
||||
gpr_time_from_seconds(3, GPR_TIMESPAN)))) { |
||||
gpr_log(GPR_ERROR, "gRPC thread still active! Cannot fork!"); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void grpc_postfork_parent() { |
||||
if (grpc_is_initialized()) { |
||||
grpc_timer_manager_set_threading(true); |
||||
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
||||
grpc_executor_set_threading(&exec_ctx, true); |
||||
grpc_exec_ctx_finish(&exec_ctx); |
||||
} |
||||
} |
||||
|
||||
void grpc_postfork_child() { |
||||
if (grpc_is_initialized()) { |
||||
grpc_timer_manager_set_threading(true); |
||||
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
||||
grpc_executor_set_threading(&exec_ctx, true); |
||||
grpc_exec_ctx_finish(&exec_ctx); |
||||
} |
||||
} |
||||
|
||||
void grpc_fork_handlers_auto_register() { |
||||
if (grpc_fork_support_enabled()) { |
||||
pthread_atfork(grpc_prefork, grpc_postfork_parent, grpc_postfork_child); |
||||
} |
||||
} |
||||
|
||||
#endif // GRPC_POSIX_FORK
|
@ -0,0 +1,39 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2017 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
#include "src/core/lib/iomgr/port.h" |
||||
|
||||
#ifndef GRPC_POSIX_FORK |
||||
|
||||
#include <grpc/fork.h> |
||||
#include <grpc/support/log.h> |
||||
|
||||
/*
|
||||
* NOTE: FORKING IS NOT GENERALLY SUPPORTED, THIS IS ONLY INTENDED TO WORK |
||||
* AROUND VERY SPECIFIC USE CASES. |
||||
*/ |
||||
|
||||
void grpc_prefork() { gpr_log(GPR_ERROR, "Forking not supported on Windows"); } |
||||
|
||||
void grpc_postfork_parent() {} |
||||
|
||||
void grpc_postfork_child() {} |
||||
|
||||
void grpc_fork_handlers_auto_register() {} |
||||
|
||||
#endif // GRPC_POSIX_FORK
|
@ -0,0 +1,62 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2017 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
#include "src/core/lib/support/fork.h" |
||||
|
||||
#include <string.h> |
||||
|
||||
#include <grpc/support/alloc.h> |
||||
#include <grpc/support/useful.h> |
||||
|
||||
#include "src/core/lib/support/env.h" |
||||
|
||||
/*
|
||||
* NOTE: FORKING IS NOT GENERALLY SUPPORTED, THIS IS ONLY INTENDED TO WORK |
||||
* AROUND VERY SPECIFIC USE CASES. |
||||
*/ |
||||
|
||||
static int override_fork_support_enabled = -1; |
||||
static int fork_support_enabled; |
||||
|
||||
void grpc_fork_support_init() { |
||||
#ifdef GRPC_ENABLE_FORK_SUPPORT |
||||
fork_support_enabled = 1; |
||||
#else |
||||
fork_support_enabled = 0; |
||||
char* env = gpr_getenv("GRPC_ENABLE_FORK_SUPPORT"); |
||||
if (env != NULL) { |
||||
static const char* truthy[] = {"yes", "Yes", "YES", "true", |
||||
"True", "TRUE", "1"}; |
||||
for (size_t i = 0; i < GPR_ARRAY_SIZE(truthy); i++) { |
||||
if (0 == strcmp(env, truthy[i])) { |
||||
fork_support_enabled = 1; |
||||
} |
||||
} |
||||
gpr_free(env); |
||||
} |
||||
#endif |
||||
if (override_fork_support_enabled != -1) { |
||||
fork_support_enabled = override_fork_support_enabled; |
||||
} |
||||
} |
||||
|
||||
int grpc_fork_support_enabled() { return fork_support_enabled; } |
||||
|
||||
void grpc_enable_fork_support(int enable) { |
||||
override_fork_support_enabled = enable; |
||||
} |
@ -0,0 +1,35 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2017 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPC_CORE_LIB_SUPPORT_FORK_H |
||||
#define GRPC_CORE_LIB_SUPPORT_FORK_H |
||||
|
||||
/*
|
||||
* NOTE: FORKING IS NOT GENERALLY SUPPORTED, THIS IS ONLY INTENDED TO WORK |
||||
* AROUND VERY SPECIFIC USE CASES. |
||||
*/ |
||||
|
||||
void grpc_fork_support_init(void); |
||||
|
||||
int grpc_fork_support_enabled(void); |
||||
|
||||
// Test only: Must be called before grpc_init(), and overrides
|
||||
// environment variables/compile flags
|
||||
void grpc_enable_fork_support(int enable); |
||||
|
||||
#endif /* GRPC_CORE_LIB_SUPPORT_FORK_H */ |
@ -1,137 +0,0 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2015 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
#include "src/core/lib/support/stack_lockfree.h" |
||||
|
||||
#include <stdlib.h> |
||||
#include <string.h> |
||||
|
||||
#include <grpc/support/alloc.h> |
||||
#include <grpc/support/atm.h> |
||||
#include <grpc/support/log.h> |
||||
#include <grpc/support/port_platform.h> |
||||
|
||||
/* The lockfree node structure is a single architecture-level
|
||||
word that allows for an atomic CAS to set it up. */ |
||||
struct lockfree_node_contents { |
||||
/* next thing to look at. Actual index for head, next index otherwise */ |
||||
uint16_t index; |
||||
#ifdef GPR_ARCH_64 |
||||
uint16_t pad; |
||||
uint32_t aba_ctr; |
||||
#else |
||||
#ifdef GPR_ARCH_32 |
||||
uint16_t aba_ctr; |
||||
#else |
||||
#error Unsupported bit width architecture |
||||
#endif |
||||
#endif |
||||
}; |
||||
|
||||
/* Use a union to make sure that these are in the same bits as an atm word */ |
||||
typedef union lockfree_node { |
||||
gpr_atm atm; |
||||
struct lockfree_node_contents contents; |
||||
} lockfree_node; |
||||
|
||||
/* make sure that entries aligned to 8-bytes */ |
||||
#define ENTRY_ALIGNMENT_BITS 3 |
||||
/* reserve this entry as invalid */ |
||||
#define INVALID_ENTRY_INDEX ((1 << 16) - 1) |
||||
|
||||
struct gpr_stack_lockfree { |
||||
lockfree_node* entries; |
||||
lockfree_node head; /* An atomic entry describing curr head */ |
||||
}; |
||||
|
||||
gpr_stack_lockfree* gpr_stack_lockfree_create(size_t entries) { |
||||
gpr_stack_lockfree* stack; |
||||
stack = (gpr_stack_lockfree*)gpr_malloc(sizeof(*stack)); |
||||
/* Since we only allocate 16 bits to represent an entry number,
|
||||
* make sure that we are within the desired range */ |
||||
/* Reserve the highest entry number as a dummy */ |
||||
GPR_ASSERT(entries < INVALID_ENTRY_INDEX); |
||||
stack->entries = (lockfree_node*)gpr_malloc_aligned( |
||||
entries * sizeof(stack->entries[0]), ENTRY_ALIGNMENT_BITS); |
||||
/* Clear out all entries */ |
||||
memset(stack->entries, 0, entries * sizeof(stack->entries[0])); |
||||
memset(&stack->head, 0, sizeof(stack->head)); |
||||
|
||||
GPR_ASSERT(sizeof(stack->entries->atm) == sizeof(stack->entries->contents)); |
||||
|
||||
/* Point the head at reserved dummy entry */ |
||||
stack->head.contents.index = INVALID_ENTRY_INDEX; |
||||
/* Fill in the pad and aba_ctr to avoid confusing memcheck tools */ |
||||
#ifdef GPR_ARCH_64 |
||||
stack->head.contents.pad = 0; |
||||
#endif |
||||
stack->head.contents.aba_ctr = 0; |
||||
return stack; |
||||
} |
||||
|
||||
void gpr_stack_lockfree_destroy(gpr_stack_lockfree* stack) { |
||||
gpr_free_aligned(stack->entries); |
||||
gpr_free(stack); |
||||
} |
||||
|
||||
int gpr_stack_lockfree_push(gpr_stack_lockfree* stack, int entry) { |
||||
lockfree_node head; |
||||
lockfree_node newhead; |
||||
lockfree_node curent; |
||||
lockfree_node newent; |
||||
|
||||
/* First fill in the entry's index and aba ctr for new head */ |
||||
newhead.contents.index = (uint16_t)entry; |
||||
#ifdef GPR_ARCH_64 |
||||
/* Fill in the pad to avoid confusing memcheck tools */ |
||||
newhead.contents.pad = 0; |
||||
#endif |
||||
|
||||
/* Also post-increment the aba_ctr */ |
||||
curent.atm = gpr_atm_no_barrier_load(&stack->entries[entry].atm); |
||||
newhead.contents.aba_ctr = ++curent.contents.aba_ctr; |
||||
gpr_atm_no_barrier_store(&stack->entries[entry].atm, curent.atm); |
||||
|
||||
do { |
||||
/* Atomically get the existing head value for use */ |
||||
head.atm = gpr_atm_no_barrier_load(&(stack->head.atm)); |
||||
/* Point to it */ |
||||
newent.atm = gpr_atm_no_barrier_load(&stack->entries[entry].atm); |
||||
newent.contents.index = head.contents.index; |
||||
gpr_atm_no_barrier_store(&stack->entries[entry].atm, newent.atm); |
||||
} while (!gpr_atm_rel_cas(&(stack->head.atm), head.atm, newhead.atm)); |
||||
/* Use rel_cas above to make sure that entry index is set properly */ |
||||
return head.contents.index == INVALID_ENTRY_INDEX; |
||||
} |
||||
|
||||
int gpr_stack_lockfree_pop(gpr_stack_lockfree* stack) { |
||||
lockfree_node head; |
||||
lockfree_node newhead; |
||||
|
||||
do { |
||||
head.atm = gpr_atm_acq_load(&(stack->head.atm)); |
||||
if (head.contents.index == INVALID_ENTRY_INDEX) { |
||||
return -1; |
||||
} |
||||
newhead.atm = |
||||
gpr_atm_no_barrier_load(&(stack->entries[head.contents.index].atm)); |
||||
|
||||
} while (!gpr_atm_no_barrier_cas(&(stack->head.atm), head.atm, newhead.atm)); |
||||
|
||||
return head.contents.index; |
||||
} |
@ -1,46 +0,0 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2015 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPC_CORE_LIB_SUPPORT_STACK_LOCKFREE_H |
||||
#define GRPC_CORE_LIB_SUPPORT_STACK_LOCKFREE_H |
||||
|
||||
#include <stddef.h> |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
typedef struct gpr_stack_lockfree gpr_stack_lockfree; |
||||
|
||||
/* This stack must specify the maximum number of entries to track.
|
||||
The current implementation only allows up to 65534 entries */ |
||||
gpr_stack_lockfree* gpr_stack_lockfree_create(size_t entries); |
||||
void gpr_stack_lockfree_destroy(gpr_stack_lockfree* stack); |
||||
|
||||
/* Pass in a valid entry number for the next stack entry */ |
||||
/* Returns 1 if this is the first element on the stack, 0 otherwise */ |
||||
int gpr_stack_lockfree_push(gpr_stack_lockfree*, int entry); |
||||
|
||||
/* Returns -1 on empty or the actual entry number */ |
||||
int gpr_stack_lockfree_pop(gpr_stack_lockfree* stack); |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif /* GRPC_CORE_LIB_SUPPORT_STACK_LOCKFREE_H */ |
@ -0,0 +1,30 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2015 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPC_CORE_LIB_SUPPORT_THD_INTERNAL_H |
||||
#define GRPC_CORE_LIB_SUPPORT_THD_INTERNAL_H |
||||
|
||||
#include <grpc/support/time.h> |
||||
|
||||
/* Internal interfaces between modules within the gpr support library. */ |
||||
void gpr_thd_init(); |
||||
|
||||
/* Wait for all outstanding threads to finish, up to deadline */ |
||||
int gpr_await_threads(gpr_timespec deadline); |
||||
|
||||
#endif /* GRPC_CORE_LIB_SUPPORT_THD_INTERNAL_H */ |
@ -0,0 +1,182 @@ |
||||
#region Copyright notice and license |
||||
|
||||
// Copyright 2015 gRPC authors. |
||||
// |
||||
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||
// you may not use this file except in compliance with the License. |
||||
// You may obtain a copy of the License at |
||||
// |
||||
// http://www.apache.org/licenses/LICENSE-2.0 |
||||
// |
||||
// Unless required by applicable law or agreed to in writing, software |
||||
// distributed under the License is distributed on an "AS IS" BASIS, |
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
// See the License for the specific language governing permissions and |
||||
// limitations under the License. |
||||
|
||||
#endregion |
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics; |
||||
using System.Linq; |
||||
using System.Threading; |
||||
using System.Threading.Tasks; |
||||
using Grpc.Core; |
||||
using Grpc.Core.Internal; |
||||
using Grpc.Core.Profiling; |
||||
using Grpc.Core.Utils; |
||||
using NUnit.Framework; |
||||
|
||||
namespace Grpc.Core.Tests |
||||
{ |
||||
public class CallCancellationTest |
||||
{ |
||||
const string Host = "127.0.0.1"; |
||||
|
||||
MockServiceHelper helper; |
||||
Server server; |
||||
Channel channel; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
helper = new MockServiceHelper(Host); |
||||
server = helper.GetServer(); |
||||
server.Start(); |
||||
channel = helper.GetChannel(); |
||||
} |
||||
|
||||
[TearDown] |
||||
public void Cleanup() |
||||
{ |
||||
channel.ShutdownAsync().Wait(); |
||||
server.ShutdownAsync().Wait(); |
||||
} |
||||
|
||||
[Test] |
||||
public async Task ClientStreamingCall_CancelAfterBegin() |
||||
{ |
||||
var barrier = new TaskCompletionSource<object>(); |
||||
|
||||
helper.ClientStreamingHandler = new ClientStreamingServerMethod<string, string>(async (requestStream, context) => |
||||
{ |
||||
barrier.SetResult(null); |
||||
await requestStream.ToListAsync(); |
||||
return ""; |
||||
}); |
||||
|
||||
var cts = new CancellationTokenSource(); |
||||
var call = Calls.AsyncClientStreamingCall(helper.CreateClientStreamingCall(new CallOptions(cancellationToken: cts.Token))); |
||||
|
||||
await barrier.Task; // make sure the handler has started. |
||||
cts.Cancel(); |
||||
|
||||
try |
||||
{ |
||||
// cannot use Assert.ThrowsAsync because it uses Task.Wait and would deadlock. |
||||
await call.ResponseAsync; |
||||
Assert.Fail(); |
||||
} |
||||
catch (RpcException ex) |
||||
{ |
||||
Assert.AreEqual(StatusCode.Cancelled, ex.Status.StatusCode); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public async Task ClientStreamingCall_ServerSideReadAfterCancelNotificationReturnsNull() |
||||
{ |
||||
var handlerStartedBarrier = new TaskCompletionSource<object>(); |
||||
var cancelNotificationReceivedBarrier = new TaskCompletionSource<object>(); |
||||
var successTcs = new TaskCompletionSource<string>(); |
||||
|
||||
helper.ClientStreamingHandler = new ClientStreamingServerMethod<string, string>(async (requestStream, context) => |
||||
{ |
||||
handlerStartedBarrier.SetResult(null); |
||||
|
||||
// wait for cancellation to be delivered. |
||||
context.CancellationToken.Register(() => cancelNotificationReceivedBarrier.SetResult(null)); |
||||
await cancelNotificationReceivedBarrier.Task; |
||||
|
||||
var moveNextResult = await requestStream.MoveNext(); |
||||
successTcs.SetResult(!moveNextResult ? "SUCCESS" : "FAIL"); |
||||
return ""; |
||||
}); |
||||
|
||||
var cts = new CancellationTokenSource(); |
||||
var call = Calls.AsyncClientStreamingCall(helper.CreateClientStreamingCall(new CallOptions(cancellationToken: cts.Token))); |
||||
|
||||
await handlerStartedBarrier.Task; |
||||
cts.Cancel(); |
||||
|
||||
try |
||||
{ |
||||
await call.ResponseAsync; |
||||
Assert.Fail(); |
||||
} |
||||
catch (RpcException ex) |
||||
{ |
||||
Assert.AreEqual(StatusCode.Cancelled, ex.Status.StatusCode); |
||||
} |
||||
Assert.AreEqual("SUCCESS", await successTcs.Task); |
||||
} |
||||
|
||||
[Test] |
||||
public async Task ClientStreamingCall_CancelServerSideRead() |
||||
{ |
||||
helper.ClientStreamingHandler = new ClientStreamingServerMethod<string, string>(async (requestStream, context) => |
||||
{ |
||||
var cts = new CancellationTokenSource(); |
||||
var moveNextTask = requestStream.MoveNext(cts.Token); |
||||
cts.Cancel(); |
||||
await moveNextTask; |
||||
return ""; |
||||
}); |
||||
|
||||
var call = Calls.AsyncClientStreamingCall(helper.CreateClientStreamingCall()); |
||||
try |
||||
{ |
||||
// cannot use Assert.ThrowsAsync because it uses Task.Wait and would deadlock. |
||||
await call.ResponseAsync; |
||||
Assert.Fail(); |
||||
} |
||||
catch (RpcException ex) |
||||
{ |
||||
Assert.AreEqual(StatusCode.Cancelled, ex.Status.StatusCode); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public async Task ServerStreamingCall_CancelClientSideRead() |
||||
{ |
||||
helper.ServerStreamingHandler = new ServerStreamingServerMethod<string, string>(async (request, responseStream, context) => |
||||
{ |
||||
await responseStream.WriteAsync("abc"); |
||||
while (!context.CancellationToken.IsCancellationRequested) |
||||
{ |
||||
await Task.Delay(10); |
||||
} |
||||
}); |
||||
|
||||
var call = Calls.AsyncServerStreamingCall(helper.CreateServerStreamingCall(), ""); |
||||
await call.ResponseStream.MoveNext(); |
||||
Assert.AreEqual("abc", call.ResponseStream.Current); |
||||
|
||||
var cts = new CancellationTokenSource(); |
||||
var moveNextTask = call.ResponseStream.MoveNext(cts.Token); |
||||
cts.Cancel(); |
||||
|
||||
try |
||||
{ |
||||
// cannot use Assert.ThrowsAsync because it uses Task.Wait and would deadlock. |
||||
await moveNextTask; |
||||
Assert.Fail(); |
||||
} |
||||
catch (RpcException ex) |
||||
{ |
||||
Assert.AreEqual(StatusCode.Cancelled, ex.Status.StatusCode); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,79 @@ |
||||
#region Copyright notice and license |
||||
|
||||
// Copyright 2017 gRPC authors. |
||||
// |
||||
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||
// you may not use this file except in compliance with the License. |
||||
// You may obtain a copy of the License at |
||||
// |
||||
// http://www.apache.org/licenses/LICENSE-2.0 |
||||
// |
||||
// Unless required by applicable law or agreed to in writing, software |
||||
// distributed under the License is distributed on an "AS IS" BASIS, |
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
// See the License for the specific language governing permissions and |
||||
// limitations under the License. |
||||
|
||||
#endregion |
||||
|
||||
using System; |
||||
using Grpc.Core; |
||||
using Grpc.Core.Internal; |
||||
using Grpc.Core.Utils; |
||||
using NUnit.Framework; |
||||
|
||||
namespace Grpc.Core.Internal.Tests |
||||
{ |
||||
public class DefaultObjectPoolTest |
||||
{ |
||||
[Test] |
||||
[TestCase(10, 2)] |
||||
[TestCase(10, 1)] |
||||
[TestCase(0, 2)] |
||||
[TestCase(2, 0)] |
||||
public void ObjectIsReused(int sharedCapacity, int threadLocalCapacity) |
||||
{ |
||||
var pool = new DefaultObjectPool<TestPooledObject>(() => new TestPooledObject(), sharedCapacity, threadLocalCapacity); |
||||
var origLeased = pool.Lease(); |
||||
pool.Return(origLeased); |
||||
Assert.AreSame(origLeased, pool.Lease()); |
||||
Assert.AreNotSame(origLeased, pool.Lease()); |
||||
} |
||||
|
||||
[Test] |
||||
public void ZeroCapacities() |
||||
{ |
||||
var pool = new DefaultObjectPool<TestPooledObject>(() => new TestPooledObject(), 0, 0); |
||||
var origLeased = pool.Lease(); |
||||
pool.Return(origLeased); |
||||
Assert.AreNotSame(origLeased, pool.Lease()); |
||||
} |
||||
|
||||
[Test] |
||||
public void DisposeCleansSharedPool() |
||||
{ |
||||
var pool = new DefaultObjectPool<TestPooledObject>(() => new TestPooledObject(), 10, 0); |
||||
var origLeased = pool.Lease(); |
||||
pool.Return(origLeased); |
||||
pool.Dispose(); |
||||
Assert.AreNotSame(origLeased, pool.Lease()); |
||||
} |
||||
|
||||
[Test] |
||||
public void Constructor() |
||||
{ |
||||
Assert.Throws<ArgumentNullException>(() => new DefaultObjectPool<TestPooledObject>(null, 10, 2)); |
||||
Assert.Throws<ArgumentException>(() => new DefaultObjectPool<TestPooledObject>(() => new TestPooledObject(), -1, 10)); |
||||
Assert.Throws<ArgumentException>(() => new DefaultObjectPool<TestPooledObject>(() => new TestPooledObject(), 10, -1)); |
||||
} |
||||
|
||||
class TestPooledObject : IDisposable |
||||
{ |
||||
|
||||
public void Dispose() |
||||
{ |
||||
|
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,196 @@ |
||||
#region Copyright notice and license |
||||
|
||||
// Copyright 2017 gRPC authors. |
||||
// |
||||
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||
// you may not use this file except in compliance with the License. |
||||
// You may obtain a copy of the License at |
||||
// |
||||
// http://www.apache.org/licenses/LICENSE-2.0 |
||||
// |
||||
// Unless required by applicable law or agreed to in writing, software |
||||
// distributed under the License is distributed on an "AS IS" BASIS, |
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
// See the License for the specific language governing permissions and |
||||
// limitations under the License. |
||||
|
||||
#endregion |
||||
|
||||
using System; |
||||
using System.Threading; |
||||
using System.Collections.Generic; |
||||
using Grpc.Core.Utils; |
||||
|
||||
namespace Grpc.Core.Internal |
||||
{ |
||||
/// <summary> |
||||
/// Pool of objects that combines a shared pool and a thread local pool. |
||||
/// </summary> |
||||
internal class DefaultObjectPool<T> : IObjectPool<T> |
||||
where T : class, IDisposable |
||||
{ |
||||
readonly object myLock = new object(); |
||||
readonly Func<T> itemFactory; |
||||
|
||||
// Queue shared between threads, access needs to be synchronized. |
||||
readonly Queue<T> sharedQueue; |
||||
readonly int sharedCapacity; |
||||
|
||||
readonly ThreadLocal<ThreadLocalData> threadLocalData; |
||||
readonly int threadLocalCapacity; |
||||
readonly int rentLimit; |
||||
|
||||
bool disposed; |
||||
|
||||
/// <summary> |
||||
/// Initializes a new instance of <c>DefaultObjectPool</c> with given shared capacity and thread local capacity. |
||||
/// Thread local capacity should be significantly smaller than the shared capacity as we don't guarantee immediately |
||||
/// disposing the objects in the thread local pool after this pool is disposed (they will eventually be garbage collected |
||||
/// after the thread that owns them has finished). |
||||
/// On average, the shared pool will only be accessed approx. once for every <c>threadLocalCapacity / 2</c> rent or lease |
||||
/// operations. |
||||
/// </summary> |
||||
public DefaultObjectPool(Func<T> itemFactory, int sharedCapacity, int threadLocalCapacity) |
||||
{ |
||||
GrpcPreconditions.CheckArgument(sharedCapacity >= 0); |
||||
GrpcPreconditions.CheckArgument(threadLocalCapacity >= 0); |
||||
this.itemFactory = GrpcPreconditions.CheckNotNull(itemFactory, nameof(itemFactory)); |
||||
this.sharedQueue = new Queue<T>(sharedCapacity); |
||||
this.sharedCapacity = sharedCapacity; |
||||
this.threadLocalData = new ThreadLocal<ThreadLocalData>(() => new ThreadLocalData(threadLocalCapacity), false); |
||||
this.threadLocalCapacity = threadLocalCapacity; |
||||
this.rentLimit = threadLocalCapacity != 1 ? threadLocalCapacity / 2 : 1; |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Leases an item from the pool or creates a new instance if the pool is empty. |
||||
/// Attempts to retrieve the item from the thread local pool first. |
||||
/// If the thread local pool is empty, the item is taken from the shared pool |
||||
/// along with more items that are moved to the thread local pool to avoid |
||||
/// prevent acquiring the lock for shared pool too often. |
||||
/// The methods should not be called after the pool is disposed, but it won't |
||||
/// results in an error to do so (after depleting the items potentially left |
||||
/// in the thread local pool, it will continue returning new objects created by the factory). |
||||
/// </summary> |
||||
public T Lease() |
||||
{ |
||||
var localData = threadLocalData.Value; |
||||
if (localData.Queue.Count > 0) |
||||
{ |
||||
return localData.Queue.Dequeue(); |
||||
} |
||||
if (localData.CreateBudget > 0) |
||||
{ |
||||
localData.CreateBudget --; |
||||
return itemFactory(); |
||||
} |
||||
|
||||
int itemsMoved = 0; |
||||
T leasedItem = null; |
||||
lock(myLock) |
||||
{ |
||||
if (sharedQueue.Count > 0) |
||||
{ |
||||
leasedItem = sharedQueue.Dequeue(); |
||||
} |
||||
while (sharedQueue.Count > 0 && itemsMoved < rentLimit) |
||||
{ |
||||
localData.Queue.Enqueue(sharedQueue.Dequeue()); |
||||
itemsMoved ++; |
||||
} |
||||
} |
||||
|
||||
// If the shared pool didn't contain all rentLimit items, |
||||
// next time we try to lease we will just create those |
||||
// instead of trying to grab them from the shared queue. |
||||
// This is to guarantee we won't be accessing the shared queue too often. |
||||
localData.CreateBudget = rentLimit - itemsMoved; |
||||
|
||||
return leasedItem ?? itemFactory(); |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Returns an item to the pool. |
||||
/// Attempts to add the item to the thread local pool first. |
||||
/// If the thread local pool is full, item is added to a shared pool, |
||||
/// along with half of the items for the thread local pool, which |
||||
/// should prevent acquiring the lock for shared pool too often. |
||||
/// If called after the pool is disposed, we make best effort not to |
||||
/// add anything to the thread local pool and we guarantee not to add |
||||
/// anything to the shared pool (items will be disposed instead). |
||||
/// </summary> |
||||
public void Return(T item) |
||||
{ |
||||
GrpcPreconditions.CheckNotNull(item); |
||||
|
||||
var localData = threadLocalData.Value; |
||||
if (localData.Queue.Count < threadLocalCapacity && !disposed) |
||||
{ |
||||
localData.Queue.Enqueue(item); |
||||
return; |
||||
} |
||||
if (localData.DisposeBudget > 0) |
||||
{ |
||||
localData.DisposeBudget --; |
||||
item.Dispose(); |
||||
return; |
||||
} |
||||
|
||||
int itemsReturned = 0; |
||||
int returnLimit = rentLimit + 1; |
||||
lock (myLock) |
||||
{ |
||||
if (sharedQueue.Count < sharedCapacity && !disposed) |
||||
{ |
||||
sharedQueue.Enqueue(item); |
||||
itemsReturned ++; |
||||
} |
||||
while (sharedQueue.Count < sharedCapacity && itemsReturned < returnLimit && !disposed) |
||||
{ |
||||
sharedQueue.Enqueue(localData.Queue.Dequeue()); |
||||
itemsReturned ++; |
||||
} |
||||
} |
||||
|
||||
// If the shared pool could not accomodate all returnLimit items, |
||||
// next time we try to return we will just dispose the item |
||||
// instead of trying to return them to the shared queue. |
||||
// This is to guarantee we won't be accessing the shared queue too often. |
||||
localData.DisposeBudget = returnLimit - itemsReturned; |
||||
|
||||
if (itemsReturned == 0) |
||||
{ |
||||
localData.DisposeBudget --; |
||||
item.Dispose(); |
||||
} |
||||
} |
||||
|
||||
public void Dispose() |
||||
{ |
||||
lock (myLock) |
||||
{ |
||||
if (!disposed) |
||||
{ |
||||
disposed = true; |
||||
|
||||
while (sharedQueue.Count > 0) |
||||
{ |
||||
sharedQueue.Dequeue().Dispose(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
class ThreadLocalData |
||||
{ |
||||
public ThreadLocalData(int capacity) |
||||
{ |
||||
this.Queue = new Queue<T>(capacity); |
||||
} |
||||
|
||||
public Queue<T> Queue { get; } |
||||
public int CreateBudget { get; set; } |
||||
public int DisposeBudget { get; set; } |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,35 @@ |
||||
#region Copyright notice and license |
||||
|
||||
// Copyright 2017 gRPC authors. |
||||
// |
||||
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||
// you may not use this file except in compliance with the License. |
||||
// You may obtain a copy of the License at |
||||
// |
||||
// http://www.apache.org/licenses/LICENSE-2.0 |
||||
// |
||||
// Unless required by applicable law or agreed to in writing, software |
||||
// distributed under the License is distributed on an "AS IS" BASIS, |
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
// See the License for the specific language governing permissions and |
||||
// limitations under the License. |
||||
|
||||
#endregion |
||||
|
||||
using System; |
||||
using System.Threading; |
||||
using System.Collections.Generic; |
||||
using Grpc.Core.Utils; |
||||
|
||||
namespace Grpc.Core.Internal |
||||
{ |
||||
/// <summary> |
||||
/// Pool of objects. |
||||
/// </summary> |
||||
internal interface IObjectPool<T> : IDisposable |
||||
where T : class
|
||||
{ |
||||
T Lease(); |
||||
void Return(T item); |
||||
} |
||||
} |
@ -1,7 +1,7 @@ |
||||
<!-- This file is generated --> |
||||
<Project> |
||||
<PropertyGroup> |
||||
<GrpcCsharpVersion>1.8.0-pre1</GrpcCsharpVersion> |
||||
<GrpcCsharpVersion>1.8.0-pre2</GrpcCsharpVersion> |
||||
<GoogleProtobufVersion>3.3.0</GoogleProtobufVersion> |
||||
</PropertyGroup> |
||||
</Project> |
||||
|
@ -0,0 +1,29 @@ |
||||
{ |
||||
"name": "grpc-health-check", |
||||
"version": "1.7.2", |
||||
"author": "Google Inc.", |
||||
"description": "Health check service for use with gRPC", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/grpc/grpc.git" |
||||
}, |
||||
"bugs": "https://github.com/grpc/grpc/issues", |
||||
"contributors": [ |
||||
{ |
||||
"name": "Michael Lumish", |
||||
"email": "mlumish@google.com" |
||||
} |
||||
], |
||||
"dependencies": { |
||||
"grpc": "^1.7.2", |
||||
"lodash": "^3.9.3", |
||||
"google-protobuf": "^3.0.0" |
||||
}, |
||||
"files": [ |
||||
"LICENSE", |
||||
"health.js", |
||||
"v1" |
||||
], |
||||
"main": "src/node/index.js", |
||||
"license": "Apache-2.0" |
||||
} |
@ -0,0 +1,41 @@ |
||||
{ |
||||
"name": "grpc-tools", |
||||
"version": "1.7.2", |
||||
"author": "Google Inc.", |
||||
"description": "Tools for developing with gRPC on Node.js", |
||||
"homepage": "https://grpc.io/", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/grpc/grpc.git" |
||||
}, |
||||
"bugs": "https://github.com/grpc/grpc/issues", |
||||
"contributors": [ |
||||
{ |
||||
"name": "Michael Lumish", |
||||
"email": "mlumish@google.com" |
||||
} |
||||
], |
||||
"bin": { |
||||
"grpc_tools_node_protoc": "./bin/protoc.js", |
||||
"grpc_tools_node_protoc_plugin": "./bin/protoc_plugin.js" |
||||
}, |
||||
"scripts": { |
||||
"install": "./node_modules/.bin/node-pre-gyp install" |
||||
}, |
||||
"bundledDependencies": ["node-pre-gyp"], |
||||
"binary": { |
||||
"module_name": "grpc_tools", |
||||
"host": "https://storage.googleapis.com/", |
||||
"remote_path": "grpc-precompiled-binaries/node/{name}/v{version}", |
||||
"package_name": "{platform}-{arch}.tar.gz", |
||||
"module_path": "bin" |
||||
}, |
||||
"files": [ |
||||
"index.js", |
||||
"bin/protoc.js", |
||||
"bin/protoc_plugin.js", |
||||
"bin/google/protobuf", |
||||
"LICENSE" |
||||
], |
||||
"main": "index.js" |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue