From b636f3134ef43a32919f1133f69d780165962625 Mon Sep 17 00:00:00 2001 From: Carlos O'Ryan Date: Mon, 19 Feb 2018 15:02:43 -0500 Subject: [PATCH 01/11] Fix typo in constant name. s/Allignment/Alignment/ (not the double-l). --- src/core/lib/gprpp/memory.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/lib/gprpp/memory.h b/src/core/lib/gprpp/memory.h index f7cd6424afd..646c1355139 100644 --- a/src/core/lib/gprpp/memory.h +++ b/src/core/lib/gprpp/memory.h @@ -28,12 +28,12 @@ namespace grpc_core { // The alignment of memory returned by gpr_malloc(). -constexpr size_t kAllignmentForDefaultAllocationInBytes = 8; +constexpr size_t kAlignmentForDefaultAllocationInBytes = 8; // Alternative to new, since we cannot use it (for fear of libstdc++) template inline T* New(Args&&... args) { - void* p = alignof(T) > kAllignmentForDefaultAllocationInBytes + void* p = alignof(T) > kAlignmentForDefaultAllocationInBytes ? gpr_malloc_aligned(sizeof(T), alignof(T)) : gpr_malloc(sizeof(T)); return new (p) T(std::forward(args)...); @@ -43,7 +43,7 @@ inline T* New(Args&&... args) { template inline void Delete(T* p) { p->~T(); - if (alignof(T) > kAllignmentForDefaultAllocationInBytes) { + if (alignof(T) > kAlignmentForDefaultAllocationInBytes) { gpr_free_aligned(p); } else { gpr_free(p); From efce74b5253d8418d0621e1f30993325e1b2a22e Mon Sep 17 00:00:00 2001 From: Carlos Valera <2501087+cookyt@users.noreply.github.com> Date: Wed, 21 Feb 2018 14:44:15 -0800 Subject: [PATCH 02/11] Print trailing metadata in the "grpc_cli call" command. This often includes important debugging information when the RPC returns a non-OK status. --- test/cpp/util/grpc_tool.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/cpp/util/grpc_tool.cc b/test/cpp/util/grpc_tool.cc index 30c43b206f7..e9dd7512c4b 100644 --- a/test/cpp/util/grpc_tool.cc +++ b/test/cpp/util/grpc_tool.cc @@ -747,6 +747,8 @@ bool GrpcTool::CallMethod(int argc, const char** argv, } } Status status = call.Finish(&server_trailing_metadata); + PrintMetadata(server_trailing_metadata, + "Received trailing metadata from server:"); if (status.ok()) { fprintf(stderr, "Rpc succeeded with OK status\n"); return true; From dca52e515c428f97d8c49c8eaad00e001b730a7d Mon Sep 17 00:00:00 2001 From: ncteisen Date: Mon, 26 Feb 2018 17:19:27 -0800 Subject: [PATCH 03/11] Remain consitant with #14493 --- src/core/lib/gpr/cpu_posix.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/gpr/cpu_posix.cc b/src/core/lib/gpr/cpu_posix.cc index 7a77f7ab64b..915fd4976c2 100644 --- a/src/core/lib/gpr/cpu_posix.cc +++ b/src/core/lib/gpr/cpu_posix.cc @@ -37,7 +37,7 @@ static long ncpus = 0; static pthread_key_t thread_id_key; static void init_ncpus() { - ncpus = sysconf(_SC_NPROCESSORS_ONLN); + ncpus = sysconf(_SC_NPROCESSORS_CONF); if (ncpus < 1 || ncpus > INT32_MAX) { gpr_log(GPR_ERROR, "Cannot determine number of CPUs: assuming 1"); ncpus = 1; From 4d7744948079c4493faab726363aaacb0feef427 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 2 Mar 2018 16:38:50 +0100 Subject: [PATCH 04/11] add useful resources for unity/xamarin support --- src/csharp/experimental/README.md | 16 ++++++++ .../build_native_ext_for_android.sh | 37 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 src/csharp/experimental/README.md create mode 100755 src/csharp/experimental/build_native_ext_for_android.sh diff --git a/src/csharp/experimental/README.md b/src/csharp/experimental/README.md new file mode 100644 index 00000000000..f892a2ee95a --- /dev/null +++ b/src/csharp/experimental/README.md @@ -0,0 +1,16 @@ +This directory contains useful resources for getting gRPC C# to work on +not-yet-supported platforms. + +# Unity & Xamarin +gRPC C# currently doesn't support Unity or Xamarin, but some proof-of-concept +work has been done. Some of the resources are shared in this directory to +ease community work on Unity & Xamarin support. + +## Crosscompiling `grpc_csharp_ext` for Android + +* Install [Android NDK](https://developer.android.com/ndk/index.html) +* Run `./build_native_ext_for_android.sh` to crosscompile using cmake. + +## Crosscompiling `grpc_csharp_ext` for iOS + +TBD diff --git a/src/csharp/experimental/build_native_ext_for_android.sh b/src/csharp/experimental/build_native_ext_for_android.sh new file mode 100755 index 00000000000..d84b68a90fb --- /dev/null +++ b/src/csharp/experimental/build_native_ext_for_android.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# Copyright 2018 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. + +# Helper script to crosscompile grpc_csharp_ext native extension for Android. + +cd "$(dirname "$0")/../../../cmake" + +mkdir -p build +cd build + +# set to the location where Android SDK is installed +ANDROID_NDK_PATH="$HOME/android-ndk-r16b" + +cmake ../.. \ + -DCMAKE_SYSTEM_NAME=Android \ + -DCMAKE_SYSTEM_VERSION=15 \ + -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a \ + -DCMAKE_ANDROID_NDK=${ANDROID_NDK_PATH} \ + -DCMAKE_ANDROID_STL_TYPE=c++_static \ + -DRUN_HAVE_POSIX_REGEX=0 \ + -DRUN_HAVE_STD_REGEX=0 \ + -DRUN_HAVE_STEADY_CLOCK=0 \ + -DCMAKE_BUILD_TYPE=Release + +make grpc_csharp_ext From c35e52e2a562761da6b074d5426d0b89ba4bde7f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 2 Mar 2018 16:54:52 +0100 Subject: [PATCH 05/11] cmake: dont use rt and pthread for Android --- CMakeLists.txt | 4 ++++ templates/CMakeLists.txt.template | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 09306d4df60..2d875e3c86e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,6 +78,8 @@ if(UNIX) set(_gRPC_PLATFORM_LINUX ON) elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(_gRPC_PLATFORM_MAC ON) + elseif(${CMAKE_SYSTEM_NAME} MATCHES "Android") + set(_gRPC_PLATFORM_ANDROID ON) else() set(_gRPC_PLATFORM_POSIX ON) endif() @@ -120,6 +122,8 @@ endif() if(_gRPC_PLATFORM_MAC) set(_gRPC_ALLTARGETS_LIBRARIES ${CMAKE_DL_LIBS} m pthread) +elseif(_gRPC_PLATFORM_ANDROID) + set(_gRPC_ALLTARGETS_LIBRARIES ${CMAKE_DL_LIBS} m) elseif(UNIX) set(_gRPC_ALLTARGETS_LIBRARIES ${CMAKE_DL_LIBS} rt m pthread) endif() diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index c279bef51f1..f83577fb548 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -125,6 +125,8 @@ set(_gRPC_PLATFORM_LINUX ON) elseif(<%text>${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(_gRPC_PLATFORM_MAC ON) + elseif(<%text>${CMAKE_SYSTEM_NAME} MATCHES "Android") + set(_gRPC_PLATFORM_ANDROID ON) else() set(_gRPC_PLATFORM_POSIX ON) endif() @@ -168,6 +170,8 @@ if(_gRPC_PLATFORM_MAC) set(_gRPC_ALLTARGETS_LIBRARIES <%text>${CMAKE_DL_LIBS} m pthread) + elseif(_gRPC_PLATFORM_ANDROID) + set(_gRPC_ALLTARGETS_LIBRARIES <%text>${CMAKE_DL_LIBS} m) elseif(UNIX) set(_gRPC_ALLTARGETS_LIBRARIES <%text>${CMAKE_DL_LIBS} rt m pthread) endif() From 0f97a36f2d758a8068cf17a12c3cdb95ce82050e Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 2 Mar 2018 17:18:19 +0100 Subject: [PATCH 06/11] address comments --- src/csharp/experimental/build_native_ext_for_android.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/csharp/experimental/build_native_ext_for_android.sh b/src/csharp/experimental/build_native_ext_for_android.sh index d84b68a90fb..3063d78efa2 100755 --- a/src/csharp/experimental/build_native_ext_for_android.sh +++ b/src/csharp/experimental/build_native_ext_for_android.sh @@ -27,7 +27,7 @@ cmake ../.. \ -DCMAKE_SYSTEM_NAME=Android \ -DCMAKE_SYSTEM_VERSION=15 \ -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a \ - -DCMAKE_ANDROID_NDK=${ANDROID_NDK_PATH} \ + -DCMAKE_ANDROID_NDK="${ANDROID_NDK_PATH}" \ -DCMAKE_ANDROID_STL_TYPE=c++_static \ -DRUN_HAVE_POSIX_REGEX=0 \ -DRUN_HAVE_STD_REGEX=0 \ From 6fc5aba81a6506088cbd7eeb38e7ecc9132e396d Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Fri, 2 Mar 2018 14:38:51 -0800 Subject: [PATCH 07/11] Fix asan failure in fake_resolver_test. --- test/core/client_channel/resolvers/fake_resolver_test.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/core/client_channel/resolvers/fake_resolver_test.cc b/test/core/client_channel/resolvers/fake_resolver_test.cc index 03af8954e1b..14caa3ea5df 100644 --- a/test/core/client_channel/resolvers/fake_resolver_test.cc +++ b/test/core/client_channel/resolvers/fake_resolver_test.cc @@ -234,6 +234,11 @@ static void test_fake_resolver() { grpc_timeout_milliseconds_to_deadline(100)) == nullptr); // Clean up. + // Note: Need to explicitly unref the resolver and flush the exec_ctx + // to make sure that the final resolver callback (with error set to + // "Resolver Shutdown") is invoked before on_res_arg goes out of scope. + resolver.reset(); + grpc_core::ExecCtx::Get()->Flush(); GRPC_COMBINER_UNREF(combiner, "test_fake_resolver"); } From 2bd7bf15044d771566bf67d04dcbf24bcad98b73 Mon Sep 17 00:00:00 2001 From: Emmanuel T Odeke Date: Fri, 2 Mar 2018 17:15:20 -0800 Subject: [PATCH 08/11] doc: fix minor typo in spelling "mechanism" s/mechanisim/mechanism/g --- doc/PROTOCOL-HTTP2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/PROTOCOL-HTTP2.md b/doc/PROTOCOL-HTTP2.md index 107a8e88242..bdd00ca3632 100644 --- a/doc/PROTOCOL-HTTP2.md +++ b/doc/PROTOCOL-HTTP2.md @@ -191,7 +191,7 @@ grpc-java-android/0.9.1 (gingerbread/1.2.4; nexus5; tmobile) Unless explicitly defined to be, gRPC Calls are not assumed to be idempotent. Specifically: * Calls that cannot be proven to have started will not be retried. -* There is no mechanisim for duplicate suppression as it is not necessary. +* There is no mechanism for duplicate suppression as it is not necessary. * Calls that are marked as idempotent may be sent multiple times. From 89ce16b6daaad4caeb1c9ba670c6c4b62ea1a93c Mon Sep 17 00:00:00 2001 From: Naresh Date: Sun, 4 Mar 2018 02:21:36 +0000 Subject: [PATCH 09/11] Update Dockerfiles for python artifacts to use latest git version Due to a recent change (Feb 2018) in Github's policy to discontinue support for weak cryptographic standards, older git versions stopped working with Github repositories. The Dockerfiles for building python artifacts currently uses git 2.0.5, that fails with an error `tlsv1 alert protocol version`. The CentOS image by the latest source Dockerfile, `manylinux` comes with the latest version of git as well, removing the need to manually build git from source. --- .../grpc_artifact_python_manylinux_x64/Dockerfile | 13 ------------- .../grpc_artifact_python_manylinux_x86/Dockerfile | 13 ------------- 2 files changed, 26 deletions(-) diff --git a/tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile b/tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile index 6f61e17b4ab..096eba9d04f 100644 --- a/tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile +++ b/tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile @@ -19,19 +19,6 @@ FROM quay.io/pypa/manylinux1_x86_64 # Update the package manager RUN yum update -y -############################################################# -# Update Git to allow cloning submodules with --reference arg -RUN yum remove -y git -RUN yum install -y curl-devel expat-devel gettext-devel linux-headers openssl-devel zlib-devel gcc -RUN cd /usr/src && \ - curl -O -L https://kernel.org/pub/software/scm/git/git-2.0.5.tar.gz && \ - tar xzf git-2.0.5.tar.gz -RUN cd /usr/src/git-2.0.5 && \ - make prefix=/usr/local/git all && \ - make prefix=/usr/local/git install -ENV PATH /usr/local/git/bin:$PATH -RUN source /etc/bashrc - ################################### # Install Python build requirements RUN /opt/python/cp27-cp27m/bin/pip install cython diff --git a/tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile b/tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile index 5c3c35188fd..216b7435d11 100644 --- a/tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile +++ b/tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile @@ -19,19 +19,6 @@ FROM quay.io/pypa/manylinux1_i686 # Update the package manager RUN yum update -y -############################################################# -# Update Git to allow cloning submodules with --reference arg -RUN yum remove -y git -RUN yum install -y curl-devel expat-devel gettext-devel linux-headers openssl-devel zlib-devel gcc -RUN cd /usr/src && \ - curl -O -L https://kernel.org/pub/software/scm/git/git-2.0.5.tar.gz && \ - tar xzf git-2.0.5.tar.gz -RUN cd /usr/src/git-2.0.5 && \ - make prefix=/usr/local/git all && \ - make prefix=/usr/local/git install -ENV PATH /usr/local/git/bin:$PATH -RUN source /etc/bashrc - ################################### # Install Python build requirements RUN /opt/python/cp27-cp27m/bin/pip install cython From 39a4746ca6f811b5daf202e4b8e1898f6969da32 Mon Sep 17 00:00:00 2001 From: ZhouyihaiDing Date: Thu, 30 Nov 2017 14:11:38 -0800 Subject: [PATCH 10/11] update php plugin with protobuf 3.5.0 --- src/compiler/php_generator.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/compiler/php_generator.cc b/src/compiler/php_generator.cc index d9705e80778..ca084cccbdf 100644 --- a/src/compiler/php_generator.cc +++ b/src/compiler/php_generator.cc @@ -18,10 +18,12 @@ #include +#include #include "src/compiler/config.h" #include "src/compiler/generator_helpers.h" #include "src/compiler/php_generator_helpers.h" +using google::protobuf::compiler::php::GeneratedClassName; using grpc::protobuf::Descriptor; using grpc::protobuf::FileDescriptor; using grpc::protobuf::MethodDescriptor; @@ -55,8 +57,10 @@ grpc::string MessageIdentifierName(const grpc::string& name, const FileDescriptor* file) { std::vector tokens = grpc_generator::tokenize(name, "."); std::ostringstream oss; - oss << PackageName(file) << "\\" - << grpc_generator::CapitalizeFirstLetter(tokens[tokens.size() - 1]); + if (PackageName(file) != "") { + oss << PackageName(file) << "\\"; + } + oss << grpc_generator::CapitalizeFirstLetter(tokens[tokens.size() - 1]); return oss.str(); } @@ -67,9 +71,9 @@ void PrintMethod(const MethodDescriptor* method, Printer* out) { vars["service_name"] = method->service()->full_name(); vars["name"] = method->name(); vars["input_type_id"] = - MessageIdentifierName(input_type->full_name(), input_type->file()); - vars["output_type_id"] = - MessageIdentifierName(output_type->full_name(), output_type->file()); + MessageIdentifierName(GeneratedClassName(input_type), input_type->file()); + vars["output_type_id"] = MessageIdentifierName( + GeneratedClassName(output_type), output_type->file()); out->Print("/**\n"); out->Print(GetPHPComments(method, " *").c_str()); From 32f7c48dad71cac7af652bf994ab1dde3ddb0607 Mon Sep 17 00:00:00 2001 From: Naresh Date: Mon, 5 Mar 2018 20:50:45 +0000 Subject: [PATCH 11/11] Revert removals from python artifact dockerfiles 89ce16b removed a few package installations from the dockerfiles for building python artifacts. Revert them. Revert certain package install removal from python artifact dockerfiles --- tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile | 1 + tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile | 1 + 2 files changed, 2 insertions(+) diff --git a/tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile b/tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile index 096eba9d04f..07604c7c424 100644 --- a/tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile +++ b/tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile @@ -18,6 +18,7 @@ FROM quay.io/pypa/manylinux1_x86_64 # Update the package manager RUN yum update -y +RUN yum install -y curl-devel expat-devel gettext-devel linux-headers openssl-devel zlib-devel gcc ################################### # Install Python build requirements diff --git a/tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile b/tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile index 216b7435d11..96ab515efe0 100644 --- a/tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile +++ b/tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile @@ -18,6 +18,7 @@ FROM quay.io/pypa/manylinux1_i686 # Update the package manager RUN yum update -y +RUN yum install -y curl-devel expat-devel gettext-devel linux-headers openssl-devel zlib-devel gcc ################################### # Install Python build requirements