From 5101b3f7cf87c9b2f9e6c5c4bb4c1023dcb999b2 Mon Sep 17 00:00:00 2001 From: Matt Kwong Date: Mon, 10 Apr 2017 14:34:39 -0700 Subject: [PATCH 1/9] Pin Bazel version to 0.4.4 in Dockerfile --- tools/dockerfile/test/bazel/Dockerfile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/dockerfile/test/bazel/Dockerfile b/tools/dockerfile/test/bazel/Dockerfile index cc413848337..6ea8ef316c6 100644 --- a/tools/dockerfile/test/bazel/Dockerfile +++ b/tools/dockerfile/test/bazel/Dockerfile @@ -72,6 +72,13 @@ RUN curl https://bazel.build/bazel-release.pub.gpg | apt-key add - RUN apt-get -y update RUN apt-get -y install bazel +# Pin Bazel to 0.4.4 +# Installing Bazel via apt-get first is required before installing 0.4.4 to +# allow gRPC to build without errors. See https://github.com/grpc/grpc/issues/10553 +RUN curl -fSsL -O https://github.com/bazelbuild/bazel/releases/download/0.4.4/bazel-0.4.4-installer-linux-x86_64.sh +RUN chmod +x ./bazel-0.4.4-installer-linux-x86_64.sh +RUN ./bazel-0.4.4-installer-linux-x86_64.sh + RUN mkdir -p /var/local/jenkins # Define the default command. From d6dd46a1d9558c32ed17f1e9ce1726b272b06404 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Mon, 10 Apr 2017 16:45:02 -0700 Subject: [PATCH 2/9] fix flakey race in ruby tests --- src/ruby/spec/generic/rpc_server_pool_spec.rb | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/src/ruby/spec/generic/rpc_server_pool_spec.rb b/src/ruby/spec/generic/rpc_server_pool_spec.rb index 69e8222cb97..75b40225680 100644 --- a/src/ruby/spec/generic/rpc_server_pool_spec.rb +++ b/src/ruby/spec/generic/rpc_server_pool_spec.rb @@ -52,27 +52,36 @@ describe GRPC::Pool do expect(p.ready_for_work?).to be(false) end - it 'it stops being ready after all workers jobs waiting or running' do + it 'it stops being ready after all workers are busy, ' \ + 'and it becomes ready again after jobs complete' do p = Pool.new(5) p.start - job = proc { sleep(3) } # sleep so workers busy when done scheduling - 5.times do - expect(p.ready_for_work?).to be(true) - p.schedule(&job) + + wait_mu = Mutex.new + wait_cv = ConditionVariable.new + wait = true + + job = proc do + wait_mu.synchronize do + wait_cv.wait(wait_mu) while wait + end end - expect(p.ready_for_work?).to be(false) - end - it 'it becomes ready again after jobs complete' do - p = Pool.new(5) - p.start - job = proc {} 5.times do expect(p.ready_for_work?).to be(true) p.schedule(&job) end + expect(p.ready_for_work?).to be(false) - sleep 5 # give the pool time do get at least one task done + + wait_mu.synchronize do + wait = false + wait_cv.broadcast + end + + # There's a potential race here but it shouldn't ever be + # reached with a 5 second sleep. + sleep 5 expect(p.ready_for_work?).to be(true) end end @@ -105,13 +114,13 @@ describe GRPC::Pool do it 'stops jobs when there are long running jobs' do p = Pool.new(1) p.start - o, q = Object.new, Queue.new + job_running = Queue.new job = proc do - sleep(5) # long running - q.push(o) + job_running.push(Object.new) + sleep(5000) end p.schedule(&job) - sleep(1) # should ensure the long job gets scheduled + job_running.pop expect { p.stop }.not_to raise_error end end From 9b020019497f5fb9fb035027d55d350450fb4ed0 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Tue, 11 Apr 2017 10:14:13 -0700 Subject: [PATCH 3/9] get rid of racey sleep 5 and use a cv to wait forever --- src/ruby/spec/generic/rpc_server_pool_spec.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/ruby/spec/generic/rpc_server_pool_spec.rb b/src/ruby/spec/generic/rpc_server_pool_spec.rb index 75b40225680..0803ca74ed6 100644 --- a/src/ruby/spec/generic/rpc_server_pool_spec.rb +++ b/src/ruby/spec/generic/rpc_server_pool_spec.rb @@ -52,8 +52,7 @@ describe GRPC::Pool do expect(p.ready_for_work?).to be(false) end - it 'it stops being ready after all workers are busy, ' \ - 'and it becomes ready again after jobs complete' do + it 'it stops being ready after all workers are busy' do p = Pool.new(5) p.start @@ -78,11 +77,6 @@ describe GRPC::Pool do wait = false wait_cv.broadcast end - - # There's a potential race here but it shouldn't ever be - # reached with a 5 second sleep. - sleep 5 - expect(p.ready_for_work?).to be(true) end end @@ -114,10 +108,17 @@ describe GRPC::Pool do it 'stops jobs when there are long running jobs' do p = Pool.new(1) p.start + + wait_forever_mu = Mutex.new + wait_forever_cv = ConditionVariable.new + wait_forever = true + job_running = Queue.new job = proc do job_running.push(Object.new) - sleep(5000) + wait_forever_mu.synchronize do + wait_forever_cv.wait while wait_forever + end end p.schedule(&job) job_running.pop From a03d204dd73621f87043b0f63ab646ba92169a8d Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Tue, 11 Apr 2017 16:09:31 -0700 Subject: [PATCH 4/9] Update credentials test after #9328 --- test/core/security/credentials_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core/security/credentials_test.c b/test/core/security/credentials_test.c index c0933c64a68..9bdce71ba0c 100644 --- a/test/core/security/credentials_test.c +++ b/test/core/security/credentials_test.c @@ -582,7 +582,7 @@ static void on_oauth2_creds_get_metadata_failure( static void validate_compute_engine_http_request( const grpc_httpcli_request *request) { GPR_ASSERT(request->handshaker != &grpc_httpcli_ssl); - GPR_ASSERT(strcmp(request->host, "metadata") == 0); + GPR_ASSERT(strcmp(request->host, "metadata.google.internal") == 0); GPR_ASSERT( strcmp(request->http.path, "/computeMetadata/v1/instance/service-accounts/default/token") == From c611e60da200ee7ee1b8c5b54ab41c8386284a7e Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 11 Apr 2017 19:03:42 -0700 Subject: [PATCH 5/9] Fix include --- src/core/lib/surface/lame_client.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/lib/surface/lame_client.cc b/src/core/lib/surface/lame_client.cc index 7a64726edb2..88f4eaac08f 100644 --- a/src/core/lib/surface/lame_client.cc +++ b/src/core/lib/surface/lame_client.cc @@ -34,7 +34,6 @@ #include #include -#include #include #include From a566685f99d423f34c69678b2b7cbca85d974210 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 11 Apr 2017 22:20:22 -0700 Subject: [PATCH 6/9] Public headers must be c89 --- include/grpc/impl/codegen/port_platform.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h index bac409e514d..a828f6c188f 100644 --- a/include/grpc/impl/codegen/port_platform.h +++ b/include/grpc/impl/codegen/port_platform.h @@ -293,8 +293,8 @@ #if defined(__has_include) #if __has_include() #define GRPC_HAS_CXX11_ATOMIC -#endif // __has_include() -#endif // defined(__has_include) +#endif /* __has_include() */ +#endif /* defined(__has_include) */ #ifndef GPR_PLATFORM_STRING #warning "GPR_PLATFORM_STRING not auto-detected" From 90ce723aca9d1527d410bd36f14b40424b0c6534 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 12 Apr 2017 06:53:09 -0700 Subject: [PATCH 7/9] Fixes --- build.yaml | 6 +++--- gRPC-Core.podspec | 6 ++++++ grpc.gemspec | 3 +++ include/grpc/impl/codegen/port_platform.h | 4 ++-- package.xml | 3 +++ src/core/lib/support/atomic_with_atm.h | 2 +- tools/doxygen/Doxyfile.core.internal | 3 +++ tools/run_tests/generated/sources_and_headers.json | 6 ++++++ tools/run_tests/run_tests.py | 5 +++-- vsprojects/vcxproj/gpr/gpr.vcxproj | 3 +++ vsprojects/vcxproj/gpr/gpr.vcxproj.filters | 9 +++++++++ 11 files changed, 42 insertions(+), 8 deletions(-) diff --git a/build.yaml b/build.yaml index cf22f19a988..6fa285b5466 100644 --- a/build.yaml +++ b/build.yaml @@ -86,13 +86,13 @@ filegroups: headers: - src/core/lib/profiling/timers.h - src/core/lib/support/arena.h + - src/core/lib/support/atomic.h + - src/core/lib/support/atomic_with_atm.h + - src/core/lib/support/atomic_with_std.h - src/core/lib/support/backoff.h - src/core/lib/support/block_annotate.h - src/core/lib/support/env.h - src/core/lib/support/memory.h - - src/core/lib/support/atomic.h - - src/core/lib/support/atomic_with_atm.h - - src/core/lib/support/atomic_with_std.h - src/core/lib/support/mpscq.h - src/core/lib/support/murmur_hash.h - src/core/lib/support/spinlock.h diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index db6a4974c78..5d9063d9ece 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -197,6 +197,9 @@ Pod::Spec.new do |s| # To save you from scrolling, this is the last part of the podspec. ss.source_files = 'src/core/lib/profiling/timers.h', 'src/core/lib/support/arena.h', + 'src/core/lib/support/atomic.h', + 'src/core/lib/support/atomic_with_atm.h', + 'src/core/lib/support/atomic_with_std.h', 'src/core/lib/support/backoff.h', 'src/core/lib/support/block_annotate.h', 'src/core/lib/support/env.h', @@ -696,6 +699,9 @@ Pod::Spec.new do |s| ss.private_header_files = 'src/core/lib/profiling/timers.h', 'src/core/lib/support/arena.h', + 'src/core/lib/support/atomic.h', + 'src/core/lib/support/atomic_with_atm.h', + 'src/core/lib/support/atomic_with_std.h', 'src/core/lib/support/backoff.h', 'src/core/lib/support/block_annotate.h', 'src/core/lib/support/env.h', diff --git a/grpc.gemspec b/grpc.gemspec index cb6c51f898e..0889f2f0c2b 100755 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -82,6 +82,9 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/impl/codegen/sync_windows.h ) s.files += %w( src/core/lib/profiling/timers.h ) s.files += %w( src/core/lib/support/arena.h ) + s.files += %w( src/core/lib/support/atomic.h ) + s.files += %w( src/core/lib/support/atomic_with_atm.h ) + s.files += %w( src/core/lib/support/atomic_with_std.h ) s.files += %w( src/core/lib/support/backoff.h ) s.files += %w( src/core/lib/support/block_annotate.h ) s.files += %w( src/core/lib/support/env.h ) diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h index a828f6c188f..e12f6f4e998 100644 --- a/include/grpc/impl/codegen/port_platform.h +++ b/include/grpc/impl/codegen/port_platform.h @@ -293,8 +293,8 @@ #if defined(__has_include) #if __has_include() #define GRPC_HAS_CXX11_ATOMIC -#endif /* __has_include() */ -#endif /* defined(__has_include) */ +#endif /* __has_include() */ +#endif /* defined(__has_include) */ #ifndef GPR_PLATFORM_STRING #warning "GPR_PLATFORM_STRING not auto-detected" diff --git a/package.xml b/package.xml index 247e4ee76a8..6e601b4d984 100644 --- a/package.xml +++ b/package.xml @@ -91,6 +91,9 @@ + + + diff --git a/src/core/lib/support/atomic_with_atm.h b/src/core/lib/support/atomic_with_atm.h index 6ad375736f9..e7fea018781 100644 --- a/src/core/lib/support/atomic_with_atm.h +++ b/src/core/lib/support/atomic_with_atm.h @@ -63,4 +63,4 @@ class atomic { } // namespace grpc_core -#endif /* GRPC_CORE_LIB_SUPPORT_ATOMIC_H */ +#endif /* GRPC_CORE_LIB_SUPPORT_ATOMIC_WITH_ATM_H */ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index eb45ba7c0ad..e5cbfb7560d 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1246,6 +1246,9 @@ src/core/lib/support/alloc.c \ src/core/lib/support/arena.c \ src/core/lib/support/arena.h \ src/core/lib/support/atm.c \ +src/core/lib/support/atomic.h \ +src/core/lib/support/atomic_with_atm.h \ +src/core/lib/support/atomic_with_std.h \ src/core/lib/support/avl.c \ src/core/lib/support/backoff.c \ src/core/lib/support/backoff.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 427976c797c..2de4acb2ffe 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -7397,6 +7397,9 @@ "include/grpc/support/useful.h", "src/core/lib/profiling/timers.h", "src/core/lib/support/arena.h", + "src/core/lib/support/atomic.h", + "src/core/lib/support/atomic_with_atm.h", + "src/core/lib/support/atomic_with_std.h", "src/core/lib/support/backoff.h", "src/core/lib/support/block_annotate.h", "src/core/lib/support/env.h", @@ -7448,6 +7451,9 @@ "src/core/lib/support/arena.c", "src/core/lib/support/arena.h", "src/core/lib/support/atm.c", + "src/core/lib/support/atomic.h", + "src/core/lib/support/atomic_with_atm.h", + "src/core/lib/support/atomic_with_std.h", "src/core/lib/support/avl.c", "src/core/lib/support/backoff.c", "src/core/lib/support/backoff.h", diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index defccdc9318..9d3620a0fe3 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -763,7 +763,7 @@ class CSharpLanguage(object): self._make_options = ['EMBED_OPENSSL=true'] if self.args.compiler != 'coreclr': # On Mac, official distribution of mono is 32bit. - self._make_options += ['CFLAGS=-m32', 'CXXFLAGS=-m32', 'LDFLAGS=-m32'] + self._make_options += ['ARCH_FLAGS=-m32', 'LDFLAGS=-m32'] else: self._make_options = ['EMBED_OPENSSL=true', 'EMBED_ZLIB=true'] @@ -1352,7 +1352,8 @@ def make_jobspec(cfg, targets, makefile='Makefile'): '-f', makefile, '-j', '%d' % args.jobs, 'EXTRA_DEFINES=GRPC_TEST_SLOWDOWN_MACHINE_FACTOR=%f' % args.slowdown, - 'CONFIG=%s' % cfg] + + 'CONFIG=%s' % cfg, + 'Q='] + language_make_options + ([] if not args.travis else ['JENKINS_BUILD=1']) + targets, diff --git a/vsprojects/vcxproj/gpr/gpr.vcxproj b/vsprojects/vcxproj/gpr/gpr.vcxproj index 474f4d25c9f..7fb81a7fbca 100644 --- a/vsprojects/vcxproj/gpr/gpr.vcxproj +++ b/vsprojects/vcxproj/gpr/gpr.vcxproj @@ -188,6 +188,9 @@ + + + diff --git a/vsprojects/vcxproj/gpr/gpr.vcxproj.filters b/vsprojects/vcxproj/gpr/gpr.vcxproj.filters index 760de3070d7..27d9d2f38f4 100644 --- a/vsprojects/vcxproj/gpr/gpr.vcxproj.filters +++ b/vsprojects/vcxproj/gpr/gpr.vcxproj.filters @@ -260,6 +260,15 @@ src\core\lib\support + + src\core\lib\support + + + src\core\lib\support + + + src\core\lib\support + src\core\lib\support From 284195faab8a8b6c5232f722f298f3a51973d64d Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 12 Apr 2017 08:29:55 -0700 Subject: [PATCH 8/9] Write out atomic explicitly --- src/core/lib/support/atomic_with_atm.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/core/lib/support/atomic_with_atm.h b/src/core/lib/support/atomic_with_atm.h index e7fea018781..55727f1dee2 100644 --- a/src/core/lib/support/atomic_with_atm.h +++ b/src/core/lib/support/atomic_with_atm.h @@ -41,17 +41,21 @@ namespace grpc_core { enum MemoryOrderRelaxed { memory_order_relaxed }; template -class atomic { +class atomic; + +template <> +class atomic { public: - static_assert(sizeof(T) <= sizeof(gpr_atm), - "Atomics of size > sizeof(gpr_atm) are not supported"); - atomic() { gpr_atm_no_barrier_store(&x_, static_cast(T())); } + atomic() { gpr_atm_no_barrier_store(&x_, static_cast(false)); } + explicit atomic(bool x) { + gpr_atm_no_barrier_store(&x_, static_cast(x)); + } - bool compare_exchange_strong(T& expected, T update, MemoryOrderRelaxed, + bool compare_exchange_strong(bool& expected, bool update, MemoryOrderRelaxed, MemoryOrderRelaxed) { if (!gpr_atm_no_barrier_cas(&x_, static_cast(expected), static_cast(update))) { - expected = static_cast(gpr_atm_no_barrier_load(&x_)); + expected = gpr_atm_no_barrier_load(&x_) != 0; return false; } return true; From e85e95022099a88212c87dab48a304b23c2288f8 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 12 Apr 2017 08:35:49 -0700 Subject: [PATCH 9/9] bazelness --- BUILD | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/BUILD b/BUILD index 9f4614ec932..ca8d6051f63 100644 --- a/BUILD +++ b/BUILD @@ -366,10 +366,10 @@ grpc_cc_library( "src/core/lib/support/backoff.h", "src/core/lib/support/block_annotate.h", "src/core/lib/support/env.h", - "src/core/lib/support/memory.h" - "src/core/lib/support/atomic.h" - "src/core/lib/support/atomic_with_atm.h" - "src/core/lib/support/atomic_with_std.h" + "src/core/lib/support/memory.h", + "src/core/lib/support/atomic.h", + "src/core/lib/support/atomic_with_atm.h", + "src/core/lib/support/atomic_with_std.h", "src/core/lib/support/mpscq.h", "src/core/lib/support/murmur_hash.h", "src/core/lib/support/spinlock.h",