mirror of https://github.com/grpc/grpc.git
commit
e1613dcd31
160 changed files with 6749 additions and 4493 deletions
@ -1,11 +1,19 @@ |
||||
# C/C++ build outputs |
||||
bins |
||||
coverage |
||||
deps |
||||
*.gcno |
||||
gens |
||||
libs |
||||
objs |
||||
|
||||
# gcov coverage data |
||||
coverage |
||||
*.gcno |
||||
|
||||
# profiler output |
||||
*.prof |
||||
|
||||
# python compiled objects |
||||
*.pyc |
||||
|
||||
# cache for run_tests.py |
||||
.run_tests_cache |
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,68 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2015, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef __GRPC_INTERNAL_IOMGR_POLLSET_KICK_H_ |
||||
#define __GRPC_INTERNAL_IOMGR_POLLSET_KICK_H_ |
||||
|
||||
#include <grpc/support/port_platform.h> |
||||
|
||||
/* This is an abstraction around the typical pipe mechanism for waking up a
|
||||
thread sitting in a poll() style call. */ |
||||
|
||||
#ifdef GPR_POSIX_SOCKET |
||||
#include "src/core/iomgr/pollset_kick_posix.h" |
||||
#else |
||||
#error "No pollset kick support on platform" |
||||
#endif |
||||
|
||||
void grpc_pollset_kick_global_init(void); |
||||
void grpc_pollset_kick_global_destroy(void); |
||||
|
||||
void grpc_pollset_kick_init(grpc_pollset_kick_state *kick_state); |
||||
void grpc_pollset_kick_destroy(grpc_pollset_kick_state *kick_state); |
||||
|
||||
/* Must be called before entering poll(). If return value is -1, this consumed
|
||||
an existing kick. Otherwise the return value is an FD to add to the poll set. |
||||
*/ |
||||
int grpc_pollset_kick_pre_poll(grpc_pollset_kick_state *kick_state); |
||||
|
||||
/* Consume an existing kick. Must be called after poll returns that the fd was
|
||||
readable, and before calling kick_post_poll. */ |
||||
void grpc_pollset_kick_consume(grpc_pollset_kick_state *kick_state); |
||||
|
||||
/* Must be called after pre_poll, and after consume if applicable */ |
||||
void grpc_pollset_kick_post_poll(grpc_pollset_kick_state *kick_state); |
||||
|
||||
void grpc_pollset_kick_kick(grpc_pollset_kick_state *kick_state); |
||||
|
||||
#endif /* __GRPC_INTERNAL_IOMGR_POLLSET_KICK_H_ */ |
@ -0,0 +1,161 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2015, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
#include "src/core/iomgr/pollset_kick_posix.h" |
||||
|
||||
#include <errno.h> |
||||
#include <string.h> |
||||
#include <unistd.h> |
||||
|
||||
#include "src/core/iomgr/socket_utils_posix.h" |
||||
#include <grpc/support/alloc.h> |
||||
#include <grpc/support/log.h> |
||||
|
||||
/* This implementation is based on a freelist of pipes. */ |
||||
|
||||
typedef struct grpc_kick_pipe_info { |
||||
int pipe_read_fd; |
||||
int pipe_write_fd; |
||||
struct grpc_kick_pipe_info *next; |
||||
} grpc_kick_pipe_info; |
||||
|
||||
static grpc_kick_pipe_info *pipe_freelist = NULL; |
||||
static gpr_mu pipe_freelist_mu; |
||||
|
||||
static grpc_kick_pipe_info *allocate_pipe() { |
||||
grpc_kick_pipe_info *info; |
||||
gpr_mu_lock(&pipe_freelist_mu); |
||||
if (pipe_freelist != NULL) { |
||||
info = pipe_freelist; |
||||
pipe_freelist = pipe_freelist->next; |
||||
} else { |
||||
int pipefd[2]; |
||||
/* TODO(klempner): Make this nonfatal */ |
||||
GPR_ASSERT(0 == pipe(pipefd)); |
||||
GPR_ASSERT(grpc_set_socket_nonblocking(pipefd[0], 1)); |
||||
GPR_ASSERT(grpc_set_socket_nonblocking(pipefd[1], 1)); |
||||
info = gpr_malloc(sizeof(*info)); |
||||
info->pipe_read_fd = pipefd[0]; |
||||
info->pipe_write_fd = pipefd[1]; |
||||
info->next = NULL; |
||||
} |
||||
gpr_mu_unlock(&pipe_freelist_mu); |
||||
return info; |
||||
} |
||||
|
||||
static void free_pipe(grpc_kick_pipe_info *pipe_info) { |
||||
/* TODO(klempner): Start closing pipes if the free list gets too large */ |
||||
gpr_mu_lock(&pipe_freelist_mu); |
||||
pipe_info->next = pipe_freelist; |
||||
pipe_freelist = pipe_info; |
||||
gpr_mu_unlock(&pipe_freelist_mu); |
||||
} |
||||
|
||||
void grpc_pollset_kick_global_init() { |
||||
pipe_freelist = NULL; |
||||
gpr_mu_init(&pipe_freelist_mu); |
||||
} |
||||
|
||||
void grpc_pollset_kick_global_destroy() { |
||||
while (pipe_freelist != NULL) { |
||||
grpc_kick_pipe_info *current = pipe_freelist; |
||||
pipe_freelist = pipe_freelist->next; |
||||
close(current->pipe_read_fd); |
||||
close(current->pipe_write_fd); |
||||
gpr_free(current); |
||||
} |
||||
gpr_mu_destroy(&pipe_freelist_mu); |
||||
} |
||||
|
||||
void grpc_pollset_kick_init(grpc_pollset_kick_state *kick_state) { |
||||
gpr_mu_init(&kick_state->mu); |
||||
kick_state->kicked = 0; |
||||
kick_state->pipe_info = NULL; |
||||
} |
||||
|
||||
void grpc_pollset_kick_destroy(grpc_pollset_kick_state *kick_state) { |
||||
gpr_mu_destroy(&kick_state->mu); |
||||
GPR_ASSERT(kick_state->pipe_info == NULL); |
||||
} |
||||
|
||||
int grpc_pollset_kick_pre_poll(grpc_pollset_kick_state *kick_state) { |
||||
gpr_mu_lock(&kick_state->mu); |
||||
if (kick_state->kicked) { |
||||
kick_state->kicked = 0; |
||||
gpr_mu_unlock(&kick_state->mu); |
||||
return -1; |
||||
} |
||||
kick_state->pipe_info = allocate_pipe(); |
||||
gpr_mu_unlock(&kick_state->mu); |
||||
return kick_state->pipe_info->pipe_read_fd; |
||||
} |
||||
|
||||
void grpc_pollset_kick_consume(grpc_pollset_kick_state *kick_state) { |
||||
char buf[128]; |
||||
int r; |
||||
|
||||
for (;;) { |
||||
r = read(kick_state->pipe_info->pipe_read_fd, buf, sizeof(buf)); |
||||
if (r > 0) continue; |
||||
if (r == 0) return; |
||||
switch (errno) { |
||||
case EAGAIN: |
||||
return; |
||||
case EINTR: |
||||
continue; |
||||
default: |
||||
gpr_log(GPR_ERROR, "error reading pipe: %s", strerror(errno)); |
||||
return; |
||||
} |
||||
} |
||||
} |
||||
|
||||
void grpc_pollset_kick_post_poll(grpc_pollset_kick_state *kick_state) { |
||||
gpr_mu_lock(&kick_state->mu); |
||||
free_pipe(kick_state->pipe_info); |
||||
kick_state->pipe_info = NULL; |
||||
gpr_mu_unlock(&kick_state->mu); |
||||
} |
||||
|
||||
void grpc_pollset_kick_kick(grpc_pollset_kick_state *kick_state) { |
||||
gpr_mu_lock(&kick_state->mu); |
||||
if (kick_state->pipe_info != NULL) { |
||||
char c = 0; |
||||
while (write(kick_state->pipe_info->pipe_write_fd, &c, 1) != 1 && |
||||
errno == EINTR) |
||||
; |
||||
} else { |
||||
kick_state->kicked = 1; |
||||
} |
||||
gpr_mu_unlock(&kick_state->mu); |
||||
} |
@ -0,0 +1,47 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2015, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef __GRPC_INTERNAL_IOMGR_POLLSET_KICK_POSIX_H_ |
||||
#define __GRPC_INTERNAL_IOMGR_POLLSET_KICK_POSIX_H_ |
||||
|
||||
#include <grpc/support/sync.h> |
||||
|
||||
struct grpc_kick_pipe_info; |
||||
|
||||
typedef struct grpc_pollset_kick_state { |
||||
gpr_mu mu; |
||||
int kicked; |
||||
struct grpc_kick_pipe_info *pipe_info; |
||||
} grpc_pollset_kick_state; |
||||
|
||||
#endif /* __GRPC_INTERNAL_IOMGR_POLLSET_KICK_POSIX_H_ */ |
@ -1,5 +1,17 @@ |
||||
#!/bin/sh |
||||
# Loads the local shared library, and runs all of the test cases in tests/ |
||||
# against it |
||||
set -e |
||||
cd $(dirname $0) |
||||
php -d extension_dir=../ext/grpc/modules/ -d extension=grpc.so \ |
||||
/usr/local/bin/phpunit -v --debug --strict ../tests/unit_tests |
||||
default_extension_dir=`php -i | grep extension_dir | sed 's/.*=> //g'` |
||||
|
||||
# sym-link in system supplied extensions |
||||
for f in $default_extension_dir/*.so |
||||
do |
||||
ln -s $f ../ext/grpc/modules/$(basename $f) &> /dev/null || true |
||||
done |
||||
|
||||
php \ |
||||
-d extension_dir=../ext/grpc/modules/ \ |
||||
-d extension=grpc.so \ |
||||
`which phpunit` -v --debug --strict ../tests/unit_tests |
||||
|
@ -0,0 +1,10 @@ |
||||
# This is the configuration used to check the rubocop source code. |
||||
|
||||
inherit_from: .rubocop_todo.yml |
||||
|
||||
AllCops: |
||||
Exclude: |
||||
- 'bin/apis/**/*' |
||||
- 'bin/interop/test/**/*' |
||||
- 'bin/math.rb' |
||||
- 'bin/math_services.rb' |
@ -0,0 +1,52 @@ |
||||
# This configuration was generated by `rubocop --auto-gen-config` |
||||
# on 2015-01-16 02:30:04 -0800 using RuboCop version 0.28.0. |
||||
# The point is for the user to remove these configuration records |
||||
# one by one as the offenses are removed from the code base. |
||||
# Note that changes in the inspected code, or installation of new |
||||
# versions of RuboCop, may require this file to be generated again. |
||||
|
||||
# Offense count: 3 |
||||
# Lint/UselessAssignment: |
||||
# Enabled: false |
||||
|
||||
# Offense count: 33 |
||||
Metrics/AbcSize: |
||||
Max: 39 |
||||
|
||||
# Offense count: 3 |
||||
# Configuration parameters: CountComments. |
||||
Metrics/ClassLength: |
||||
Max: 231 |
||||
|
||||
# Offense count: 2 |
||||
Metrics/CyclomaticComplexity: |
||||
Max: 8 |
||||
|
||||
# Offense count: 36 |
||||
# Configuration parameters: CountComments. |
||||
Metrics/MethodLength: |
||||
Max: 37 |
||||
|
||||
# Offense count: 8 |
||||
# Configuration parameters: CountKeywordArgs. |
||||
Metrics/ParameterLists: |
||||
Max: 8 |
||||
|
||||
# Offense count: 2 |
||||
Metrics/PerceivedComplexity: |
||||
Max: 10 |
||||
|
||||
# Offense count: 7 |
||||
# Configuration parameters: AllowedVariables. |
||||
Style/GlobalVars: |
||||
Enabled: false |
||||
|
||||
# Offense count: 1 |
||||
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles. |
||||
Style/Next: |
||||
Enabled: false |
||||
|
||||
# Offense count: 2 |
||||
# Configuration parameters: Methods. |
||||
Style/SingleLineBlockParams: |
||||
Enabled: false |
@ -1,46 +1,44 @@ |
||||
# -*- ruby -*- |
||||
require 'rake/extensiontask' |
||||
require 'rspec/core/rake_task' |
||||
require 'rubocop/rake_task' |
||||
|
||||
desc 'Run Rubocop to check for style violations' |
||||
RuboCop::RakeTask.new |
||||
|
||||
Rake::ExtensionTask.new 'grpc' do |ext| |
||||
ext.lib_dir = File.join('lib', 'grpc') |
||||
end |
||||
|
||||
SPEC_SUITES = [ |
||||
{ :id => :wrapper, :title => 'wrapper layer', :files => %w(spec/*.rb) }, |
||||
{ :id => :idiomatic, :title => 'idiomatic layer', :dir => %w(spec/generic), |
||||
:tag => '~bidi' }, |
||||
{ :id => :bidi, :title => 'bidi tests', :dir => %w(spec/generic), |
||||
:tag => 'bidi' } |
||||
{ id: :wrapper, title: 'wrapper layer', files: %w(spec/*.rb) }, |
||||
{ id: :idiomatic, title: 'idiomatic layer', dir: %w(spec/generic), |
||||
tag: '~bidi' }, |
||||
{ id: :bidi, title: 'bidi tests', dir: %w(spec/generic), |
||||
tag: 'bidi' } |
||||
] |
||||
|
||||
desc "Run all RSpec tests" |
||||
desc 'Run all RSpec tests' |
||||
namespace :spec do |
||||
namespace :suite do |
||||
SPEC_SUITES.each do |suite| |
||||
desc "Run all specs in #{suite[:title]} spec suite" |
||||
RSpec::Core::RakeTask.new(suite[:id]) do |t| |
||||
spec_files = [] |
||||
if suite[:files] |
||||
suite[:files].each { |f| spec_files += Dir[f] } |
||||
end |
||||
suite[:files].each { |f| spec_files += Dir[f] } if suite[:files] |
||||
|
||||
if suite[:dirs] |
||||
suite[:dirs].each { |f| spec_files += Dir["#{f}/**/*_spec.rb"] } |
||||
end |
||||
|
||||
t.pattern = spec_files |
||||
|
||||
if suite[:tag] |
||||
t.rspec_opts = "--tag #{suite[:tag]}" |
||||
end |
||||
t.rspec_opts = "--tag #{suite[:tag]}" if suite[:tag] |
||||
end |
||||
end |
||||
end |
||||
end |
||||
|
||||
task :default => "spec:suite:idiomatic" # this should be spec:suite:bidi |
||||
task "spec:suite:wrapper" => :compile |
||||
task "spec:suite:idiomatic" => "spec:suite:wrapper" |
||||
task "spec:suite:bidi" => "spec:suite:idiomatic" |
||||
task default: 'spec:suite:idiomatic' # this should be spec:suite:bidi |
||||
task 'spec:suite:wrapper' => :compile |
||||
task 'spec:suite:idiomatic' => 'spec:suite:wrapper' |
||||
task 'spec:suite:bidi' => 'spec:suite:idiomatic' |
||||
|
@ -1,31 +1,34 @@ |
||||
# encoding: utf-8 |
||||
$:.push File.expand_path("../lib", __FILE__) |
||||
$LOAD_PATH.push File.expand_path('../lib', __FILE__) |
||||
require 'grpc/version' |
||||
|
||||
Gem::Specification.new do |s| |
||||
s.name = "grpc" |
||||
s.name = 'grpc' |
||||
s.version = Google::RPC::VERSION |
||||
s.authors = ["One Platform Team"] |
||||
s.email = "stubby-team@google.com" |
||||
s.homepage = "http://go/grpc" |
||||
s.authors = ['One Platform Team'] |
||||
s.email = 'stubby-team@google.com' |
||||
s.homepage = 'http://go/grpc' |
||||
s.summary = 'Google RPC system in Ruby' |
||||
s.description = 'Send RPCs from Ruby' |
||||
|
||||
s.files = `git ls-files`.split("\n") |
||||
s.test_files = `git ls-files -- spec/*`.split("\n") |
||||
s.executables = `git ls-files -- examples/*.rb`.split("\n").map{ |f| File.basename(f) } |
||||
s.require_paths = ['lib' ] |
||||
s.executables = `git ls-files -- bin/*.rb`.split("\n").map do |f| |
||||
File.basename(f) |
||||
end |
||||
s.require_paths = ['lib'] |
||||
s.platform = Gem::Platform::RUBY |
||||
|
||||
s.add_dependency 'xray' |
||||
s.add_dependency 'logging', '~> 1.8' |
||||
s.add_dependency 'google-protobuf', '~> 3.0.0alpha.1.1' |
||||
s.add_dependency 'minitest', '~> 5.4' # not a dev dependency, used by the interop tests |
||||
s.add_dependency 'minitest', '~> 5.4' # reqd for interop tests |
||||
|
||||
s.add_development_dependency "bundler", "~> 1.7" |
||||
s.add_development_dependency "rake", "~> 10.0" |
||||
s.add_development_dependency 'bundler', '~> 1.7' |
||||
s.add_development_dependency 'rake', '~> 10.0' |
||||
s.add_development_dependency 'rake-compiler', '~> 0' |
||||
s.add_development_dependency 'rspec', "~> 3.0" |
||||
s.add_development_dependency 'rubocop', '~> 0.28.0' |
||||
s.add_development_dependency 'rspec', '~> 3.0' |
||||
|
||||
s.extensions = %w[ext/grpc/extconf.rb] |
||||
s.extensions = %w(ext/grpc/extconf.rb) |
||||
end |
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue