Merge branch 'c++lame' of github.com:ctiller/grpc into c++lame

pull/10676/head
Craig Tiller 8 years ago
commit 8d686a36e6
  1. 8
      BUILD
  2. 4
      include/grpc/impl/codegen/port_platform.h
  3. 18
      src/core/lib/support/atomic_with_atm.h
  4. 1
      src/core/lib/surface/lame_client.cc
  5. 44
      src/ruby/spec/generic/rpc_server_pool_spec.rb
  6. 2
      test/core/security/credentials_test.c
  7. 7
      tools/dockerfile/test/bazel/Dockerfile
  8. 5
      tools/run_tests/run_tests.py

@ -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",

@ -293,8 +293,8 @@
#if defined(__has_include)
#if __has_include(<atomic>)
#define GRPC_HAS_CXX11_ATOMIC
#endif // __has_include(<atomic>)
#endif // defined(__has_include)
#endif /* __has_include(<atomic>) */
#endif /* defined(__has_include) */
#ifndef GPR_PLATFORM_STRING
#warning "GPR_PLATFORM_STRING not auto-detected"

@ -41,17 +41,21 @@ namespace grpc_core {
enum MemoryOrderRelaxed { memory_order_relaxed };
template <class T>
class atomic {
class atomic;
template <>
class atomic<bool> {
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<gpr_atm>(T())); }
atomic() { gpr_atm_no_barrier_store(&x_, static_cast<gpr_atm>(false)); }
explicit atomic(bool x) {
gpr_atm_no_barrier_store(&x_, static_cast<gpr_atm>(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<gpr_atm>(expected),
static_cast<gpr_atm>(update))) {
expected = static_cast<T>(gpr_atm_no_barrier_load(&x_));
expected = gpr_atm_no_barrier_load(&x_) != 0;
return false;
}
return true;
@ -63,4 +67,4 @@ class atomic {
} // namespace grpc_core
#endif /* GRPC_CORE_LIB_SUPPORT_ATOMIC_H */
#endif /* GRPC_CORE_LIB_SUPPORT_ATOMIC_WITH_ATM_H */

@ -34,7 +34,6 @@
#include <grpc/grpc.h>
#include <string.h>
#include <atomic>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>

@ -52,28 +52,31 @@ 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' 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
expect(p.ready_for_work?).to be(true)
wait_mu.synchronize do
wait = false
wait_cv.broadcast
end
end
end
@ -105,13 +108,20 @@ 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
wait_forever_mu = Mutex.new
wait_forever_cv = ConditionVariable.new
wait_forever = true
job_running = Queue.new
job = proc do
sleep(5) # long running
q.push(o)
job_running.push(Object.new)
wait_forever_mu.synchronize do
wait_forever_cv.wait while wait_forever
end
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

@ -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") ==

@ -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.

@ -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,

Loading…
Cancel
Save