Merge branch 'master' of github.com:grpc/grpc into cpp_docs

pull/3074/head
David Garcia Quintas 9 years ago
commit 9b29aa7bd4
  1. 5
      BUILD
  2. 7
      Makefile
  3. 6
      build.json
  4. 4
      gRPC.podspec
  5. 12
      include/grpc++/client_context.h
  6. 9
      include/grpc++/impl/call.h
  7. 5
      include/grpc++/server_context.h
  8. 31
      include/grpc++/support/string_ref.h
  9. 8
      include/grpc/grpc.h
  10. 9
      include/grpc/grpc_security.h
  11. 3
      include/grpc/support/time.h
  12. 33
      src/core/channel/http_client_filter.c
  13. 8
      src/core/client_config/resolver_factory.c
  14. 12
      src/core/client_config/resolver_factory.h
  15. 83
      src/core/client_config/resolver_registry.c
  16. 15
      src/core/client_config/resolver_registry.h
  17. 25
      src/core/client_config/resolvers/dns_resolver.c
  18. 23
      src/core/client_config/resolvers/sockaddr_resolver.c
  19. 11
      src/core/client_config/resolvers/zookeeper_resolver.c
  20. 10
      src/core/profiling/basic_timers.c
  21. 10
      src/core/support/time_posix.c
  22. 56
      src/core/support/time_precise.h
  23. 4
      src/core/support/time_win32.c
  24. 44
      src/core/surface/channel.c
  25. 8
      src/core/surface/init.c
  26. 11
      src/cpp/common/call.cc
  27. 9
      src/cpp/server/server.cc
  28. 7
      src/cpp/server/server_context.cc
  29. 6
      src/cpp/util/string_ref.cc
  30. 4
      templates/Makefile.template
  31. 2
      test/core/end2end/tests/default_host.c
  32. 31
      test/core/iomgr/tcp_client_posix_test.c
  33. 37
      test/cpp/end2end/async_end2end_test.cc
  34. 25
      test/cpp/end2end/end2end_test.cc
  35. 4
      test/cpp/end2end/generic_end2end_test.cc
  36. 10
      test/cpp/util/cli_call.cc
  37. 12
      test/cpp/util/cli_call.h
  38. 13
      test/cpp/util/cli_call_test.cc
  39. 22
      test/cpp/util/grpc_cli.cc
  40. 44
      test/cpp/util/string_ref_helper.cc
  41. 47
      test/cpp/util/string_ref_helper.h
  42. 2
      tools/doxygen/Doxyfile.core.internal
  43. 2
      tools/run_tests/run_csharp.bat
  44. 13
      tools/run_tests/run_tests.py
  45. 11
      tools/run_tests/sources_and_headers.json
  46. 4
      vsprojects/Grpc.mak
  47. 1
      vsprojects/gpr/gpr.vcxproj
  48. 3
      vsprojects/gpr/gpr.vcxproj.filters
  49. 1
      vsprojects/grpc/grpc.vcxproj
  50. 3
      vsprojects/grpc/grpc.vcxproj.filters
  51. 1
      vsprojects/grpc_unsecure/grpc_unsecure.vcxproj
  52. 3
      vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters

@ -51,6 +51,7 @@ cc_library(
"src/core/support/string.h", "src/core/support/string.h",
"src/core/support/string_win32.h", "src/core/support/string_win32.h",
"src/core/support/thd_internal.h", "src/core/support/thd_internal.h",
"src/core/support/time_precise.h",
"src/core/support/alloc.c", "src/core/support/alloc.c",
"src/core/support/cmdline.c", "src/core/support/cmdline.c",
"src/core/support/cpu_iphone.c", "src/core/support/cpu_iphone.c",
@ -208,7 +209,6 @@ cc_library(
"src/core/json/json_reader.h", "src/core/json/json_reader.h",
"src/core/json/json_writer.h", "src/core/json/json_writer.h",
"src/core/profiling/timers.h", "src/core/profiling/timers.h",
"src/core/profiling/timers_preciseclock.h",
"src/core/statistics/census_interface.h", "src/core/statistics/census_interface.h",
"src/core/statistics/census_rpc_stats.h", "src/core/statistics/census_rpc_stats.h",
"src/core/surface/byte_buffer_queue.h", "src/core/surface/byte_buffer_queue.h",
@ -477,7 +477,6 @@ cc_library(
"src/core/json/json_reader.h", "src/core/json/json_reader.h",
"src/core/json/json_writer.h", "src/core/json/json_writer.h",
"src/core/profiling/timers.h", "src/core/profiling/timers.h",
"src/core/profiling/timers_preciseclock.h",
"src/core/statistics/census_interface.h", "src/core/statistics/census_interface.h",
"src/core/statistics/census_rpc_stats.h", "src/core/statistics/census_rpc_stats.h",
"src/core/surface/byte_buffer_queue.h", "src/core/surface/byte_buffer_queue.h",
@ -992,6 +991,7 @@ objc_library(
"src/core/support/string.h", "src/core/support/string.h",
"src/core/support/string_win32.h", "src/core/support/string_win32.h",
"src/core/support/thd_internal.h", "src/core/support/thd_internal.h",
"src/core/support/time_precise.h",
], ],
includes = [ includes = [
"include", "include",
@ -1232,7 +1232,6 @@ objc_library(
"src/core/json/json_reader.h", "src/core/json/json_reader.h",
"src/core/json/json_writer.h", "src/core/json/json_writer.h",
"src/core/profiling/timers.h", "src/core/profiling/timers.h",
"src/core/profiling/timers_preciseclock.h",
"src/core/statistics/census_interface.h", "src/core/statistics/census_interface.h",
"src/core/statistics/census_rpc_stats.h", "src/core/statistics/census_rpc_stats.h",
"src/core/surface/byte_buffer_queue.h", "src/core/surface/byte_buffer_queue.h",

@ -1651,8 +1651,8 @@ else
$(Q)(cd third_party/openssl ; CC="$(CC) $(PIC_CPPFLAGS) -fvisibility=hidden $(CPPFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_EXTRA)" ./config no-asm $(OPENSSL_CONFIG_$(CONFIG))) $(Q)(cd third_party/openssl ; CC="$(CC) $(PIC_CPPFLAGS) -fvisibility=hidden $(CPPFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_EXTRA)" ./config no-asm $(OPENSSL_CONFIG_$(CONFIG)))
endif endif
endif endif
$(Q)$(MAKE) -C third_party/openssl clean $(Q)$(MAKE) -j 1 -C third_party/openssl clean
$(Q)(unset CPPFLAGS; $(MAKE) -C third_party/openssl build_crypto build_ssl) $(Q)(unset CPPFLAGS; $(MAKE) -j 1 -C third_party/openssl build_crypto build_ssl)
$(Q)mkdir -p $(LIBDIR)/$(CONFIG)/openssl $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/openssl
$(Q)cp third_party/openssl/libssl.a third_party/openssl/libcrypto.a $(LIBDIR)/$(CONFIG)/openssl $(Q)cp third_party/openssl/libssl.a third_party/openssl/libcrypto.a $(LIBDIR)/$(CONFIG)/openssl
@ -4794,6 +4794,7 @@ LIBGRPC++_TEST_UTIL_SRC = \
$(GENDIR)/test/cpp/util/echo_duplicate.pb.cc $(GENDIR)/test/cpp/util/echo_duplicate.grpc.pb.cc \ $(GENDIR)/test/cpp/util/echo_duplicate.pb.cc $(GENDIR)/test/cpp/util/echo_duplicate.grpc.pb.cc \
test/cpp/util/cli_call.cc \ test/cpp/util/cli_call.cc \
test/cpp/util/create_test_channel.cc \ test/cpp/util/create_test_channel.cc \
test/cpp/util/string_ref_helper.cc \
test/cpp/util/subprocess.cc \ test/cpp/util/subprocess.cc \
@ -4840,6 +4841,7 @@ endif
endif endif
$(OBJDIR)/$(CONFIG)/test/cpp/util/cli_call.o: $(GENDIR)/test/cpp/util/messages.pb.cc $(GENDIR)/test/cpp/util/messages.grpc.pb.cc $(GENDIR)/test/cpp/util/echo.pb.cc $(GENDIR)/test/cpp/util/echo.grpc.pb.cc $(GENDIR)/test/cpp/util/echo_duplicate.pb.cc $(GENDIR)/test/cpp/util/echo_duplicate.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/util/cli_call.o: $(GENDIR)/test/cpp/util/messages.pb.cc $(GENDIR)/test/cpp/util/messages.grpc.pb.cc $(GENDIR)/test/cpp/util/echo.pb.cc $(GENDIR)/test/cpp/util/echo.grpc.pb.cc $(GENDIR)/test/cpp/util/echo_duplicate.pb.cc $(GENDIR)/test/cpp/util/echo_duplicate.grpc.pb.cc
$(OBJDIR)/$(CONFIG)/test/cpp/util/create_test_channel.o: $(GENDIR)/test/cpp/util/messages.pb.cc $(GENDIR)/test/cpp/util/messages.grpc.pb.cc $(GENDIR)/test/cpp/util/echo.pb.cc $(GENDIR)/test/cpp/util/echo.grpc.pb.cc $(GENDIR)/test/cpp/util/echo_duplicate.pb.cc $(GENDIR)/test/cpp/util/echo_duplicate.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/util/create_test_channel.o: $(GENDIR)/test/cpp/util/messages.pb.cc $(GENDIR)/test/cpp/util/messages.grpc.pb.cc $(GENDIR)/test/cpp/util/echo.pb.cc $(GENDIR)/test/cpp/util/echo.grpc.pb.cc $(GENDIR)/test/cpp/util/echo_duplicate.pb.cc $(GENDIR)/test/cpp/util/echo_duplicate.grpc.pb.cc
$(OBJDIR)/$(CONFIG)/test/cpp/util/string_ref_helper.o: $(GENDIR)/test/cpp/util/messages.pb.cc $(GENDIR)/test/cpp/util/messages.grpc.pb.cc $(GENDIR)/test/cpp/util/echo.pb.cc $(GENDIR)/test/cpp/util/echo.grpc.pb.cc $(GENDIR)/test/cpp/util/echo_duplicate.pb.cc $(GENDIR)/test/cpp/util/echo_duplicate.grpc.pb.cc
$(OBJDIR)/$(CONFIG)/test/cpp/util/subprocess.o: $(GENDIR)/test/cpp/util/messages.pb.cc $(GENDIR)/test/cpp/util/messages.grpc.pb.cc $(GENDIR)/test/cpp/util/echo.pb.cc $(GENDIR)/test/cpp/util/echo.grpc.pb.cc $(GENDIR)/test/cpp/util/echo_duplicate.pb.cc $(GENDIR)/test/cpp/util/echo_duplicate.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/util/subprocess.o: $(GENDIR)/test/cpp/util/messages.pb.cc $(GENDIR)/test/cpp/util/messages.grpc.pb.cc $(GENDIR)/test/cpp/util/echo.pb.cc $(GENDIR)/test/cpp/util/echo.grpc.pb.cc $(GENDIR)/test/cpp/util/echo_duplicate.pb.cc $(GENDIR)/test/cpp/util/echo_duplicate.grpc.pb.cc
@ -20702,6 +20704,7 @@ test/cpp/qps/timer.cc: $(OPENSSL_DEP)
test/cpp/util/benchmark_config.cc: $(OPENSSL_DEP) test/cpp/util/benchmark_config.cc: $(OPENSSL_DEP)
test/cpp/util/cli_call.cc: $(OPENSSL_DEP) test/cpp/util/cli_call.cc: $(OPENSSL_DEP)
test/cpp/util/create_test_channel.cc: $(OPENSSL_DEP) test/cpp/util/create_test_channel.cc: $(OPENSSL_DEP)
test/cpp/util/string_ref_helper.cc: $(OPENSSL_DEP)
test/cpp/util/subprocess.cc: $(OPENSSL_DEP) test/cpp/util/subprocess.cc: $(OPENSSL_DEP)
test/cpp/util/test_config.cc: $(OPENSSL_DEP) test/cpp/util/test_config.cc: $(OPENSSL_DEP)
endif endif

@ -181,7 +181,6 @@
"src/core/json/json_reader.h", "src/core/json/json_reader.h",
"src/core/json/json_writer.h", "src/core/json/json_writer.h",
"src/core/profiling/timers.h", "src/core/profiling/timers.h",
"src/core/profiling/timers_preciseclock.h",
"src/core/statistics/census_interface.h", "src/core/statistics/census_interface.h",
"src/core/statistics/census_rpc_stats.h", "src/core/statistics/census_rpc_stats.h",
"src/core/surface/byte_buffer_queue.h", "src/core/surface/byte_buffer_queue.h",
@ -404,7 +403,8 @@
"src/core/support/stack_lockfree.h", "src/core/support/stack_lockfree.h",
"src/core/support/string.h", "src/core/support/string.h",
"src/core/support/string_win32.h", "src/core/support/string_win32.h",
"src/core/support/thd_internal.h" "src/core/support/thd_internal.h",
"src/core/support/time_precise.h"
], ],
"src": [ "src": [
"src/core/support/alloc.c", "src/core/support/alloc.c",
@ -663,6 +663,7 @@
"headers": [ "headers": [
"test/cpp/util/cli_call.h", "test/cpp/util/cli_call.h",
"test/cpp/util/create_test_channel.h", "test/cpp/util/create_test_channel.h",
"test/cpp/util/string_ref_helper.h",
"test/cpp/util/subprocess.h" "test/cpp/util/subprocess.h"
], ],
"src": [ "src": [
@ -671,6 +672,7 @@
"test/cpp/util/echo_duplicate.proto", "test/cpp/util/echo_duplicate.proto",
"test/cpp/util/cli_call.cc", "test/cpp/util/cli_call.cc",
"test/cpp/util/create_test_channel.cc", "test/cpp/util/create_test_channel.cc",
"test/cpp/util/string_ref_helper.cc",
"test/cpp/util/subprocess.cc" "test/cpp/util/subprocess.cc"
], ],
"deps": [ "deps": [

@ -68,6 +68,7 @@ Pod::Spec.new do |s|
'src/core/support/grpc_string.h', 'src/core/support/grpc_string.h',
'src/core/support/string_win32.h', 'src/core/support/string_win32.h',
'src/core/support/thd_internal.h', 'src/core/support/thd_internal.h',
'src/core/support/time_precise.h',
'grpc/support/alloc.h', 'grpc/support/alloc.h',
'grpc/support/atm.h', 'grpc/support/atm.h',
'grpc/support/atm_gcc_atomic.h', 'grpc/support/atm_gcc_atomic.h',
@ -210,7 +211,6 @@ Pod::Spec.new do |s|
'src/core/json/json_reader.h', 'src/core/json/json_reader.h',
'src/core/json/json_writer.h', 'src/core/json/json_writer.h',
'src/core/profiling/timers.h', 'src/core/profiling/timers.h',
'src/core/profiling/timers_preciseclock.h',
'src/core/statistics/census_interface.h', 'src/core/statistics/census_interface.h',
'src/core/statistics/census_rpc_stats.h', 'src/core/statistics/census_rpc_stats.h',
'src/core/surface/byte_buffer_queue.h', 'src/core/surface/byte_buffer_queue.h',
@ -404,6 +404,7 @@ Pod::Spec.new do |s|
'src/core/support/string.h', 'src/core/support/string.h',
'src/core/support/string_win32.h', 'src/core/support/string_win32.h',
'src/core/support/thd_internal.h', 'src/core/support/thd_internal.h',
'src/core/support/time_precise.h',
'src/core/security/auth_filters.h', 'src/core/security/auth_filters.h',
'src/core/security/base64.h', 'src/core/security/base64.h',
'src/core/security/credentials.h', 'src/core/security/credentials.h',
@ -482,7 +483,6 @@ Pod::Spec.new do |s|
'src/core/json/json_reader.h', 'src/core/json/json_reader.h',
'src/core/json/json_writer.h', 'src/core/json/json_writer.h',
'src/core/profiling/timers.h', 'src/core/profiling/timers.h',
'src/core/profiling/timers_preciseclock.h',
'src/core/statistics/census_interface.h', 'src/core/statistics/census_interface.h',
'src/core/statistics/census_rpc_stats.h', 'src/core/statistics/census_rpc_stats.h',
'src/core/surface/byte_buffer_queue.h', 'src/core/surface/byte_buffer_queue.h',

@ -58,6 +58,7 @@
#include <grpc++/support/auth_context.h> #include <grpc++/support/auth_context.h>
#include <grpc++/support/config.h> #include <grpc++/support/config.h>
#include <grpc++/support/status.h> #include <grpc++/support/status.h>
#include <grpc++/support/string_ref.h>
#include <grpc++/support/time.h> #include <grpc++/support/time.h>
struct census_context; struct census_context;
@ -184,8 +185,8 @@ class ClientContext {
/// ClientReaderInterface::WaitForInitialMetadata(). /// ClientReaderInterface::WaitForInitialMetadata().
/// ///
/// \return A multimap of initial metadata key-value pairs from the server. /// \return A multimap of initial metadata key-value pairs from the server.
const std::multimap<grpc::string, grpc::string>& GetServerInitialMetadata() { const std::multimap<grpc::string_ref, grpc::string_ref>&
// TODO(dgq): is this really an assert? Why not return an empty multimap? GetServerInitialMetadata() {
GPR_ASSERT(initial_metadata_received_); GPR_ASSERT(initial_metadata_received_);
return recv_initial_metadata_; return recv_initial_metadata_;
} }
@ -196,7 +197,8 @@ class ClientContext {
/// \warning This method is only callable once the stream has finished. /// \warning This method is only callable once the stream has finished.
/// ///
/// \return A multimap of metadata trailing key-value pairs from the server. /// \return A multimap of metadata trailing key-value pairs from the server.
const std::multimap<grpc::string, grpc::string>& GetServerTrailingMetadata() { const std::multimap<grpc::string_ref, grpc::string_ref>&
GetServerTrailingMetadata() {
// TODO(yangg) check finished // TODO(yangg) check finished
return trailing_metadata_; return trailing_metadata_;
} }
@ -318,8 +320,8 @@ class ClientContext {
mutable std::shared_ptr<const AuthContext> auth_context_; mutable std::shared_ptr<const AuthContext> auth_context_;
struct census_context* census_context_; struct census_context* census_context_;
std::multimap<grpc::string, grpc::string> send_initial_metadata_; std::multimap<grpc::string, grpc::string> send_initial_metadata_;
std::multimap<grpc::string, grpc::string> recv_initial_metadata_; std::multimap<grpc::string_ref, grpc::string_ref> recv_initial_metadata_;
std::multimap<grpc::string, grpc::string> trailing_metadata_; std::multimap<grpc::string_ref, grpc::string_ref> trailing_metadata_;
grpc_call* propagate_from_call_; grpc_call* propagate_from_call_;
PropagationOptions propagation_options_; PropagationOptions propagation_options_;

@ -54,8 +54,9 @@ namespace grpc {
class ByteBuffer; class ByteBuffer;
class Call; class Call;
void FillMetadataMap(grpc_metadata_array* arr, void FillMetadataMap(
std::multimap<grpc::string, grpc::string>* metadata); grpc_metadata_array* arr,
std::multimap<grpc::string_ref, grpc::string_ref>* metadata);
grpc_metadata* FillMetadataArray( grpc_metadata* FillMetadataArray(
const std::multimap<grpc::string, grpc::string>& metadata); const std::multimap<grpc::string, grpc::string>& metadata);
@ -418,7 +419,7 @@ class CallOpRecvInitialMetadata {
} }
private: private:
std::multimap<grpc::string, grpc::string>* recv_initial_metadata_; std::multimap<grpc::string_ref, grpc::string_ref>* recv_initial_metadata_;
grpc_metadata_array recv_initial_metadata_arr_; grpc_metadata_array recv_initial_metadata_arr_;
}; };
@ -461,7 +462,7 @@ class CallOpClientRecvStatus {
} }
private: private:
std::multimap<grpc::string, grpc::string>* recv_trailing_metadata_; std::multimap<grpc::string_ref, grpc::string_ref>* recv_trailing_metadata_;
Status* recv_status_; Status* recv_status_;
grpc_metadata_array recv_trailing_metadata_arr_; grpc_metadata_array recv_trailing_metadata_arr_;
grpc_status_code status_code_; grpc_status_code status_code_;

@ -41,6 +41,7 @@
#include <grpc/support/time.h> #include <grpc/support/time.h>
#include <grpc++/support/auth_context.h> #include <grpc++/support/auth_context.h>
#include <grpc++/support/config.h> #include <grpc++/support/config.h>
#include <grpc++/support/string_ref.h>
#include <grpc++/support/time.h> #include <grpc++/support/time.h>
struct gpr_timespec; struct gpr_timespec;
@ -103,7 +104,7 @@ class ServerContext {
bool IsCancelled() const; bool IsCancelled() const;
const std::multimap<grpc::string, grpc::string>& client_metadata() { const std::multimap<grpc::string_ref, grpc::string_ref>& client_metadata() {
return client_metadata_; return client_metadata_;
} }
@ -185,7 +186,7 @@ class ServerContext {
CompletionQueue* cq_; CompletionQueue* cq_;
bool sent_initial_metadata_; bool sent_initial_metadata_;
mutable std::shared_ptr<const AuthContext> auth_context_; mutable std::shared_ptr<const AuthContext> auth_context_;
std::multimap<grpc::string, grpc::string> client_metadata_; std::multimap<grpc::string_ref, grpc::string_ref> client_metadata_;
std::multimap<grpc::string, grpc::string> initial_metadata_; std::multimap<grpc::string, grpc::string> initial_metadata_;
std::multimap<grpc::string, grpc::string> trailing_metadata_; std::multimap<grpc::string, grpc::string> trailing_metadata_;

@ -35,6 +35,7 @@
#define GRPCXX_STRING_REF_H #define GRPCXX_STRING_REF_H
#include <iterator> #include <iterator>
#include <iosfwd>
#include <grpc++/support/config.h> #include <grpc++/support/config.h>
@ -50,22 +51,22 @@ class string_ref {
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
// constants // constants
static constexpr size_t npos = size_t(-1); const static size_t npos = size_t(-1);
// construct/copy. // construct/copy.
constexpr string_ref() : data_(nullptr), length_(0) {} string_ref() : data_(nullptr), length_(0) {}
constexpr string_ref(const string_ref& other) string_ref(const string_ref& other)
: data_(other.data_), length_(other.length_) {} : data_(other.data_), length_(other.length_) {}
string_ref& operator=(const string_ref& rhs); string_ref& operator=(const string_ref& rhs);
string_ref(const char* s); string_ref(const char* s);
constexpr string_ref(const char* s, size_t l) : data_(s), length_(l) {} string_ref(const char* s, size_t l) : data_(s), length_(l) {}
string_ref(const grpc::string& s) : data_(s.data()), length_(s.length()) {} string_ref(const grpc::string& s) : data_(s.data()), length_(s.length()) {}
// iterators // iterators
constexpr const_iterator begin() const { return data_; } const_iterator begin() const { return data_; }
constexpr const_iterator end() const { return data_ + length_; } const_iterator end() const { return data_ + length_; }
constexpr const_iterator cbegin() const { return data_; } const_iterator cbegin() const { return data_; }
constexpr const_iterator cend() const { return data_ + length_; } const_iterator cend() const { return data_ + length_; }
const_reverse_iterator rbegin() const { const_reverse_iterator rbegin() const {
return const_reverse_iterator(end()); return const_reverse_iterator(end());
} }
@ -80,10 +81,10 @@ class string_ref {
} }
// capacity // capacity
constexpr size_t size() const { return length_; } size_t size() const { return length_; }
constexpr size_t length() const { return length_; } size_t length() const { return length_; }
constexpr size_t max_size() const { return length_; } size_t max_size() const { return length_; }
constexpr bool empty() const { return length_ == 0; } bool empty() const { return length_ == 0; }
// element access // element access
const char* data() const { return data_; } const char* data() const { return data_; }
@ -95,9 +96,7 @@ class string_ref {
size_t find(string_ref s) const; size_t find(string_ref s) const;
size_t find(char c) const; size_t find(char c) const;
// Defined as constexpr in n3442 but C++11 constexpr semantics do not allow string_ref substr(size_t pos, size_t n = npos) const;
// the implementation of this function to comply.
/* constrexpr */ string_ref substr(size_t pos, size_t n = npos) const;
private: private:
const char* data_; const char* data_;
@ -112,6 +111,8 @@ bool operator>(string_ref x, string_ref y);
bool operator<=(string_ref x, string_ref y); bool operator<=(string_ref x, string_ref y);
bool operator>=(string_ref x, string_ref y); bool operator>=(string_ref x, string_ref y);
std::ostream& operator<<(std::ostream& stream, const string_ref& string);
} // namespace grpc } // namespace grpc
#endif // GRPCXX_STRING_REF_H #endif // GRPCXX_STRING_REF_H

@ -134,6 +134,14 @@ typedef struct {
/** Secondary user agent: goes at the end of the user-agent metadata /** Secondary user agent: goes at the end of the user-agent metadata
sent on each request */ sent on each request */
#define GRPC_ARG_SECONDARY_USER_AGENT_STRING "grpc.secondary_user_agent" #define GRPC_ARG_SECONDARY_USER_AGENT_STRING "grpc.secondary_user_agent"
/* The caller of the secure_channel_create functions may override the target
name used for SSL host name checking using this channel argument which is of
type GRPC_ARG_STRING. This *should* be used for testing only.
If this argument is not specified, the name used for SSL host name checking
will be the target parameter (assuming that the secure channel is an SSL
channel). If this parameter is specified and the underlying is not an SSL
channel, it will just be ignored. */
#define GRPC_SSL_TARGET_NAME_OVERRIDE_ARG "grpc.ssl_target_name_override"
/** Connectivity state of a channel. */ /** Connectivity state of a channel. */
typedef enum { typedef enum {

@ -142,15 +142,6 @@ grpc_credentials *grpc_iam_credentials_create(const char *authorization_token,
/* --- Secure channel creation. --- */ /* --- Secure channel creation. --- */
/* The caller of the secure_channel_create functions may override the target
name used for SSL host name checking using this channel argument which is of
type GRPC_ARG_STRING. This *should* be used for testing only.
If this argument is not specified, the name used for SSL host name checking
will be the target parameter (assuming that the secure channel is an SSL
channel). If this parameter is specified and the underlying is not an SSL
channel, it will just be ignored. */
#define GRPC_SSL_TARGET_NAME_OVERRIDE_ARG "grpc.ssl_target_name_override"
/* Creates a secure channel using the passed-in credentials. */ /* Creates a secure channel using the passed-in credentials. */
grpc_channel *grpc_secure_channel_create(grpc_credentials *creds, grpc_channel *grpc_secure_channel_create(grpc_credentials *creds,
const char *target, const char *target,

@ -52,6 +52,9 @@ typedef enum {
/* Realtime clock. May jump forwards or backwards. Settable by /* Realtime clock. May jump forwards or backwards. Settable by
the system administrator. Has its epoch at 0:00:00 UTC 1 Jan 1970. */ the system administrator. Has its epoch at 0:00:00 UTC 1 Jan 1970. */
GPR_CLOCK_REALTIME, GPR_CLOCK_REALTIME,
/* CPU cycle time obtained by rdtsc instruction on x86 platforms. Epoch
undefined. Degrades to GPR_CLOCK_REALTIME on other platforms. */
GPR_CLOCK_PRECISE,
/* Unmeasurable clock type: no base, created by taking the difference /* Unmeasurable clock type: no base, created by taking the difference
between two times */ between two times */
GPR_TIMESPAN GPR_TIMESPAN

@ -45,7 +45,6 @@ typedef struct call_data {
grpc_linked_mdelem content_type; grpc_linked_mdelem content_type;
grpc_linked_mdelem user_agent; grpc_linked_mdelem user_agent;
int sent_initial_metadata; int sent_initial_metadata;
int sent_authority;
int got_initial_metadata; int got_initial_metadata;
grpc_stream_op_buffer *recv_ops; grpc_stream_op_buffer *recv_ops;
@ -64,7 +63,6 @@ typedef struct channel_data {
grpc_mdelem *scheme; grpc_mdelem *scheme;
grpc_mdelem *content_type; grpc_mdelem *content_type;
grpc_mdelem *status; grpc_mdelem *status;
grpc_mdelem *default_authority;
/** complete user agent mdelem */ /** complete user agent mdelem */
grpc_mdelem *user_agent; grpc_mdelem *user_agent;
} channel_data; } channel_data;
@ -103,7 +101,6 @@ static void hc_on_recv(void *user_data, int success) {
static grpc_mdelem *client_strip_filter(void *user_data, grpc_mdelem *md) { static grpc_mdelem *client_strip_filter(void *user_data, grpc_mdelem *md) {
grpc_call_element *elem = user_data; grpc_call_element *elem = user_data;
call_data *calld = elem->call_data;
channel_data *channeld = elem->channel_data; channel_data *channeld = elem->channel_data;
/* eat the things we'd like to set ourselves */ /* eat the things we'd like to set ourselves */
if (md->key == channeld->method->key) return NULL; if (md->key == channeld->method->key) return NULL;
@ -111,10 +108,6 @@ static grpc_mdelem *client_strip_filter(void *user_data, grpc_mdelem *md) {
if (md->key == channeld->te_trailers->key) return NULL; if (md->key == channeld->te_trailers->key) return NULL;
if (md->key == channeld->content_type->key) return NULL; if (md->key == channeld->content_type->key) return NULL;
if (md->key == channeld->user_agent->key) return NULL; if (md->key == channeld->user_agent->key) return NULL;
if (channeld->default_authority &&
channeld->default_authority->key == md->key) {
calld->sent_authority = 1;
}
return md; return md;
} }
@ -138,11 +131,6 @@ static void hc_mutate_op(grpc_call_element *elem,
GRPC_MDELEM_REF(channeld->method)); GRPC_MDELEM_REF(channeld->method));
grpc_metadata_batch_add_head(&op->data.metadata, &calld->scheme, grpc_metadata_batch_add_head(&op->data.metadata, &calld->scheme,
GRPC_MDELEM_REF(channeld->scheme)); GRPC_MDELEM_REF(channeld->scheme));
if (channeld->default_authority && !calld->sent_authority) {
grpc_metadata_batch_add_head(
&op->data.metadata, &calld->authority,
GRPC_MDELEM_REF(channeld->default_authority));
}
grpc_metadata_batch_add_tail(&op->data.metadata, &calld->te_trailers, grpc_metadata_batch_add_tail(&op->data.metadata, &calld->te_trailers,
GRPC_MDELEM_REF(channeld->te_trailers)); GRPC_MDELEM_REF(channeld->te_trailers));
grpc_metadata_batch_add_tail(&op->data.metadata, &calld->content_type, grpc_metadata_batch_add_tail(&op->data.metadata, &calld->content_type,
@ -175,7 +163,6 @@ static void init_call_elem(grpc_call_element *elem,
call_data *calld = elem->call_data; call_data *calld = elem->call_data;
calld->sent_initial_metadata = 0; calld->sent_initial_metadata = 0;
calld->got_initial_metadata = 0; calld->got_initial_metadata = 0;
calld->sent_authority = 0;
calld->on_done_recv = NULL; calld->on_done_recv = NULL;
grpc_iomgr_closure_init(&calld->hc_on_recv, hc_on_recv, elem); grpc_iomgr_closure_init(&calld->hc_on_recv, hc_on_recv, elem);
if (initial_op) hc_mutate_op(elem, initial_op); if (initial_op) hc_mutate_op(elem, initial_op);
@ -257,8 +244,6 @@ static grpc_mdstr *user_agent_from_args(grpc_mdctx *mdctx,
static void init_channel_elem(grpc_channel_element *elem, grpc_channel *master, static void init_channel_elem(grpc_channel_element *elem, grpc_channel *master,
const grpc_channel_args *channel_args, const grpc_channel_args *channel_args,
grpc_mdctx *mdctx, int is_first, int is_last) { grpc_mdctx *mdctx, int is_first, int is_last) {
size_t i;
/* grab pointers to our data from the channel element */ /* grab pointers to our data from the channel element */
channel_data *channeld = elem->channel_data; channel_data *channeld = elem->channel_data;
@ -267,21 +252,6 @@ static void init_channel_elem(grpc_channel_element *elem, grpc_channel *master,
path */ path */
GPR_ASSERT(!is_last); GPR_ASSERT(!is_last);
channeld->default_authority = NULL;
if (channel_args) {
for (i = 0; i < channel_args->num_args; i++) {
if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_DEFAULT_AUTHORITY)) {
if (channel_args->args[i].type != GRPC_ARG_STRING) {
gpr_log(GPR_ERROR, "%s: must be an string",
GRPC_ARG_DEFAULT_AUTHORITY);
} else {
channeld->default_authority = grpc_mdelem_from_strings(
mdctx, ":authority", channel_args->args[i].value.string);
}
}
}
}
/* initialize members */ /* initialize members */
channeld->te_trailers = grpc_mdelem_from_strings(mdctx, "te", "trailers"); channeld->te_trailers = grpc_mdelem_from_strings(mdctx, "te", "trailers");
channeld->method = grpc_mdelem_from_strings(mdctx, ":method", "POST"); channeld->method = grpc_mdelem_from_strings(mdctx, ":method", "POST");
@ -306,9 +276,6 @@ static void destroy_channel_elem(grpc_channel_element *elem) {
GRPC_MDELEM_UNREF(channeld->content_type); GRPC_MDELEM_UNREF(channeld->content_type);
GRPC_MDELEM_UNREF(channeld->status); GRPC_MDELEM_UNREF(channeld->status);
GRPC_MDELEM_UNREF(channeld->user_agent); GRPC_MDELEM_UNREF(channeld->user_agent);
if (channeld->default_authority) {
GRPC_MDELEM_UNREF(channeld->default_authority);
}
} }
const grpc_channel_filter grpc_http_client_filter = { const grpc_channel_filter grpc_http_client_filter = {

@ -45,6 +45,12 @@ void grpc_resolver_factory_unref(grpc_resolver_factory *factory) {
grpc_resolver *grpc_resolver_factory_create_resolver( grpc_resolver *grpc_resolver_factory_create_resolver(
grpc_resolver_factory *factory, grpc_uri *uri, grpc_resolver_factory *factory, grpc_uri *uri,
grpc_subchannel_factory *subchannel_factory) { grpc_subchannel_factory *subchannel_factory) {
if (!factory) return NULL; if (factory == NULL) return NULL;
return factory->vtable->create_resolver(factory, uri, subchannel_factory); return factory->vtable->create_resolver(factory, uri, subchannel_factory);
} }
char *grpc_resolver_factory_get_default_authority(
grpc_resolver_factory *factory, grpc_uri *uri) {
if (factory == NULL) return NULL;
return factory->vtable->get_default_authority(factory, uri);
}

@ -51,9 +51,16 @@ struct grpc_resolver_factory_vtable {
void (*ref)(grpc_resolver_factory *factory); void (*ref)(grpc_resolver_factory *factory);
void (*unref)(grpc_resolver_factory *factory); void (*unref)(grpc_resolver_factory *factory);
/** Implementation of grpc_resolver_factory_create_resolver */
grpc_resolver *(*create_resolver)( grpc_resolver *(*create_resolver)(
grpc_resolver_factory *factory, grpc_uri *uri, grpc_resolver_factory *factory, grpc_uri *uri,
grpc_subchannel_factory *subchannel_factory); grpc_subchannel_factory *subchannel_factory);
/** Implementation of grpc_resolver_factory_get_default_authority */
char *(*get_default_authority)(grpc_resolver_factory *factory, grpc_uri *uri);
/** URI scheme that this factory implements */
const char *scheme;
}; };
void grpc_resolver_factory_ref(grpc_resolver_factory *resolver); void grpc_resolver_factory_ref(grpc_resolver_factory *resolver);
@ -64,4 +71,9 @@ grpc_resolver *grpc_resolver_factory_create_resolver(
grpc_resolver_factory *factory, grpc_uri *uri, grpc_resolver_factory *factory, grpc_uri *uri,
grpc_subchannel_factory *subchannel_factory); grpc_subchannel_factory *subchannel_factory);
/** Return a (freshly allocated with gpr_malloc) string representing
the default authority to use for this scheme. */
char *grpc_resolver_factory_get_default_authority(
grpc_resolver_factory *factory, grpc_uri *uri);
#endif /* GRPC_INTERNAL_CORE_CONFIG_RESOLVER_FACTORY_H */ #endif /* GRPC_INTERNAL_CORE_CONFIG_RESOLVER_FACTORY_H */

@ -41,41 +41,33 @@
#define MAX_RESOLVERS 10 #define MAX_RESOLVERS 10
typedef struct { static grpc_resolver_factory *g_all_of_the_resolvers[MAX_RESOLVERS];
char *scheme;
grpc_resolver_factory *factory;
} registered_resolver;
static registered_resolver g_all_of_the_resolvers[MAX_RESOLVERS];
static int g_number_of_resolvers = 0; static int g_number_of_resolvers = 0;
static char *g_default_resolver_scheme; static char *g_default_resolver_prefix;
void grpc_resolver_registry_init(const char *default_resolver_scheme) { void grpc_resolver_registry_init(const char *default_resolver_prefix) {
g_number_of_resolvers = 0; g_number_of_resolvers = 0;
g_default_resolver_scheme = gpr_strdup(default_resolver_scheme); g_default_resolver_prefix = gpr_strdup(default_resolver_prefix);
} }
void grpc_resolver_registry_shutdown(void) { void grpc_resolver_registry_shutdown(void) {
int i; int i;
for (i = 0; i < g_number_of_resolvers; i++) { for (i = 0; i < g_number_of_resolvers; i++) {
gpr_free(g_all_of_the_resolvers[i].scheme); grpc_resolver_factory_unref(g_all_of_the_resolvers[i]);
grpc_resolver_factory_unref(g_all_of_the_resolvers[i].factory);
} }
gpr_free(g_default_resolver_scheme); gpr_free(g_default_resolver_prefix);
} }
void grpc_register_resolver_type(const char *scheme, void grpc_register_resolver_type(grpc_resolver_factory *factory) {
grpc_resolver_factory *factory) {
int i; int i;
for (i = 0; i < g_number_of_resolvers; i++) { for (i = 0; i < g_number_of_resolvers; i++) {
GPR_ASSERT(0 != strcmp(scheme, g_all_of_the_resolvers[i].scheme)); GPR_ASSERT(0 != strcmp(factory->vtable->scheme,
g_all_of_the_resolvers[i]->vtable->scheme));
} }
GPR_ASSERT(g_number_of_resolvers != MAX_RESOLVERS); GPR_ASSERT(g_number_of_resolvers != MAX_RESOLVERS);
g_all_of_the_resolvers[g_number_of_resolvers].scheme = gpr_strdup(scheme);
grpc_resolver_factory_ref(factory); grpc_resolver_factory_ref(factory);
g_all_of_the_resolvers[g_number_of_resolvers].factory = factory; g_all_of_the_resolvers[g_number_of_resolvers++] = factory;
g_number_of_resolvers++;
} }
static grpc_resolver_factory *lookup_factory(grpc_uri *uri) { static grpc_resolver_factory *lookup_factory(grpc_uri *uri) {
@ -85,40 +77,57 @@ static grpc_resolver_factory *lookup_factory(grpc_uri *uri) {
if (!uri) return NULL; if (!uri) return NULL;
for (i = 0; i < g_number_of_resolvers; i++) { for (i = 0; i < g_number_of_resolvers; i++) {
if (0 == strcmp(uri->scheme, g_all_of_the_resolvers[i].scheme)) { if (0 == strcmp(uri->scheme, g_all_of_the_resolvers[i]->vtable->scheme)) {
return g_all_of_the_resolvers[i].factory; return g_all_of_the_resolvers[i];
} }
} }
return NULL; return NULL;
} }
grpc_resolver *grpc_resolver_create( static grpc_resolver_factory *resolve_factory(const char *target,
const char *name, grpc_subchannel_factory *subchannel_factory) { grpc_uri **uri) {
grpc_uri *uri;
char *tmp; char *tmp;
grpc_resolver_factory *factory = NULL; grpc_resolver_factory *factory = NULL;
grpc_resolver *resolver;
uri = grpc_uri_parse(name, 1); GPR_ASSERT(uri != NULL);
factory = lookup_factory(uri); *uri = grpc_uri_parse(target, 1);
if (factory == NULL && g_default_resolver_scheme != NULL) { factory = lookup_factory(*uri);
grpc_uri_destroy(uri);
gpr_asprintf(&tmp, "%s%s", g_default_resolver_scheme, name);
uri = grpc_uri_parse(tmp, 1);
factory = lookup_factory(uri);
if (factory == NULL) { if (factory == NULL) {
grpc_uri_destroy(grpc_uri_parse(name, 0)); if (g_default_resolver_prefix != NULL) {
grpc_uri_destroy(*uri);
gpr_asprintf(&tmp, "%s%s", g_default_resolver_prefix, target);
*uri = grpc_uri_parse(tmp, 1);
factory = lookup_factory(*uri);
if (factory == NULL) {
grpc_uri_destroy(grpc_uri_parse(target, 0));
grpc_uri_destroy(grpc_uri_parse(tmp, 0)); grpc_uri_destroy(grpc_uri_parse(tmp, 0));
gpr_log(GPR_ERROR, "don't know how to resolve '%s' or '%s'", name, tmp); gpr_log(GPR_ERROR, "don't know how to resolve '%s' or '%s'", target,
tmp);
} }
gpr_free(tmp); gpr_free(tmp);
} else if (factory == NULL) { } else {
grpc_uri_destroy(grpc_uri_parse(name, 0)); grpc_uri_destroy(grpc_uri_parse(target, 0));
gpr_log(GPR_ERROR, "don't know how to resolve '%s'", name); gpr_log(GPR_ERROR, "don't know how to resolve '%s'", target);
}
} }
resolver = return factory;
}
grpc_resolver *grpc_resolver_create(
const char *target, grpc_subchannel_factory *subchannel_factory) {
grpc_uri *uri = NULL;
grpc_resolver_factory *factory = resolve_factory(target, &uri);
grpc_resolver *resolver =
grpc_resolver_factory_create_resolver(factory, uri, subchannel_factory); grpc_resolver_factory_create_resolver(factory, uri, subchannel_factory);
grpc_uri_destroy(uri); grpc_uri_destroy(uri);
return resolver; return resolver;
} }
char *grpc_get_default_authority(const char *target) {
grpc_uri *uri = NULL;
grpc_resolver_factory *factory = resolve_factory(target, &uri);
char *authority = grpc_resolver_factory_get_default_authority(factory, uri);
grpc_uri_destroy(uri);
return authority;
}

@ -44,19 +44,22 @@ void grpc_resolver_registry_shutdown(void);
If \a priority is greater than zero, then the resolver will be eligible If \a priority is greater than zero, then the resolver will be eligible
to resolve names that are passed in with no scheme. Higher priority to resolve names that are passed in with no scheme. Higher priority
resolvers will be tried before lower priority schemes. */ resolvers will be tried before lower priority schemes. */
void grpc_register_resolver_type(const char *scheme, void grpc_register_resolver_type(grpc_resolver_factory *factory);
grpc_resolver_factory *factory);
/** Create a resolver given \a name. /** Create a resolver given \a target.
First tries to parse \a name as a URI. If this succeeds, tries First tries to parse \a target as a URI. If this succeeds, tries
to locate a registered resolver factory based on the URI scheme. to locate a registered resolver factory based on the URI scheme.
If parsing or location fails, prefixes default_prefix from If parsing or location fails, prefixes default_prefix from
grpc_resolver_registry_init to name, and tries again (if default_prefix grpc_resolver_registry_init to target, and tries again (if default_prefix
was not NULL). was not NULL).
If a resolver factory was found, use it to instantiate a resolver and If a resolver factory was found, use it to instantiate a resolver and
return it. return it.
If a resolver factory was not found, return NULL. */ If a resolver factory was not found, return NULL. */
grpc_resolver *grpc_resolver_create( grpc_resolver *grpc_resolver_create(
const char *name, grpc_subchannel_factory *subchannel_factory); const char *target, grpc_subchannel_factory *subchannel_factory);
/** Given a target, return a (freshly allocated with gpr_malloc) string
representing the default authority to pass from a client. */
char *grpc_get_default_authority(const char *target);
#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVER_REGISTRY_H */ #endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVER_REGISTRY_H */

@ -203,9 +203,6 @@ static grpc_resolver *dns_create(
grpc_subchannel_factory *subchannel_factory) { grpc_subchannel_factory *subchannel_factory) {
dns_resolver *r; dns_resolver *r;
const char *path = uri->path; const char *path = uri->path;
grpc_arg default_host_arg;
char *host;
char *port;
if (0 != strcmp(uri->authority, "")) { if (0 != strcmp(uri->authority, "")) {
gpr_log(GPR_ERROR, "authority based uri's not supported"); gpr_log(GPR_ERROR, "authority based uri's not supported");
@ -214,17 +211,6 @@ static grpc_resolver *dns_create(
if (path[0] == '/') ++path; if (path[0] == '/') ++path;
gpr_split_host_port(path, &host, &port);
default_host_arg.type = GRPC_ARG_STRING;
default_host_arg.key = GRPC_ARG_DEFAULT_AUTHORITY;
default_host_arg.value.string = host;
subchannel_factory = grpc_subchannel_factory_add_channel_arg(
subchannel_factory, &default_host_arg);
gpr_free(host);
gpr_free(port);
r = gpr_malloc(sizeof(dns_resolver)); r = gpr_malloc(sizeof(dns_resolver));
memset(r, 0, sizeof(*r)); memset(r, 0, sizeof(*r));
gpr_ref_init(&r->refs, 1); gpr_ref_init(&r->refs, 1);
@ -233,6 +219,7 @@ static grpc_resolver *dns_create(
r->name = gpr_strdup(path); r->name = gpr_strdup(path);
r->default_port = gpr_strdup(default_port); r->default_port = gpr_strdup(default_port);
r->subchannel_factory = subchannel_factory; r->subchannel_factory = subchannel_factory;
grpc_subchannel_factory_ref(subchannel_factory);
r->lb_policy_factory = lb_policy_factory; r->lb_policy_factory = lb_policy_factory;
return &r->base; return &r->base;
} }
@ -252,8 +239,16 @@ static grpc_resolver *dns_factory_create_resolver(
subchannel_factory); subchannel_factory);
} }
char *dns_factory_get_default_host_name(grpc_resolver_factory *factory,
grpc_uri *uri) {
const char *path = uri->path;
if (path[0] == '/') ++path;
return gpr_strdup(path);
}
static const grpc_resolver_factory_vtable dns_factory_vtable = { static const grpc_resolver_factory_vtable dns_factory_vtable = {
dns_factory_ref, dns_factory_unref, dns_factory_create_resolver}; dns_factory_ref, dns_factory_unref, dns_factory_create_resolver,
dns_factory_get_default_host_name, "dns"};
static grpc_resolver_factory dns_resolver_factory = {&dns_factory_vtable}; static grpc_resolver_factory dns_resolver_factory = {&dns_factory_vtable};
grpc_resolver_factory *grpc_dns_resolver_factory_create() { grpc_resolver_factory *grpc_dns_resolver_factory_create() {

@ -166,8 +166,29 @@ static int parse_unix(grpc_uri *uri, struct sockaddr_storage *addr, int *len) {
return 1; return 1;
} }
static char *unix_get_default_authority(grpc_resolver_factory *factory,
grpc_uri *uri) {
return gpr_strdup("localhost");
}
#endif #endif
static char *ip_get_default_authority(grpc_uri *uri) {
const char *path = uri->path;
if (path[0] == '/') ++path;
return gpr_strdup(path);
}
static char *ipv4_get_default_authority(grpc_resolver_factory *factory,
grpc_uri *uri) {
return ip_get_default_authority(uri);
}
static char *ipv6_get_default_authority(grpc_resolver_factory *factory,
grpc_uri *uri) {
return ip_get_default_authority(uri);
}
static int parse_ipv4(grpc_uri *uri, struct sockaddr_storage *addr, int *len) { static int parse_ipv4(grpc_uri *uri, struct sockaddr_storage *addr, int *len) {
const char *host_port = uri->path; const char *host_port = uri->path;
char *host; char *host;
@ -322,7 +343,7 @@ static void sockaddr_factory_unref(grpc_resolver_factory *factory) {}
} \ } \
static const grpc_resolver_factory_vtable name##_factory_vtable = { \ static const grpc_resolver_factory_vtable name##_factory_vtable = { \
sockaddr_factory_ref, sockaddr_factory_unref, \ sockaddr_factory_ref, sockaddr_factory_unref, \
name##_factory_create_resolver}; \ name##_factory_create_resolver, name##_get_default_authority, #name}; \
static grpc_resolver_factory name##_resolver_factory = { \ static grpc_resolver_factory name##_resolver_factory = { \
&name##_factory_vtable}; \ &name##_factory_vtable}; \
grpc_resolver_factory *grpc_##name##_resolver_factory_create() { \ grpc_resolver_factory *grpc_##name##_resolver_factory_create() { \

@ -467,8 +467,7 @@ static grpc_resolver *zookeeper_create(
} }
static void zookeeper_plugin_init() { static void zookeeper_plugin_init() {
grpc_register_resolver_type("zookeeper", grpc_register_resolver_type(grpc_zookeeper_resolver_factory_create());
grpc_zookeeper_resolver_factory_create());
} }
void grpc_zookeeper_register() { void grpc_zookeeper_register() {
@ -483,6 +482,11 @@ static void zookeeper_factory_ref(grpc_resolver_factory *factory) {}
static void zookeeper_factory_unref(grpc_resolver_factory *factory) {} static void zookeeper_factory_unref(grpc_resolver_factory *factory) {}
static char *zookeeper_factory_get_default_hostname(
grpc_resolver_factory *factory, grpc_uri *uri) {
return NULL;
}
static grpc_resolver *zookeeper_factory_create_resolver( static grpc_resolver *zookeeper_factory_create_resolver(
grpc_resolver_factory *factory, grpc_uri *uri, grpc_resolver_factory *factory, grpc_uri *uri,
grpc_subchannel_factory *subchannel_factory) { grpc_subchannel_factory *subchannel_factory) {
@ -492,7 +496,8 @@ static grpc_resolver *zookeeper_factory_create_resolver(
static const grpc_resolver_factory_vtable zookeeper_factory_vtable = { static const grpc_resolver_factory_vtable zookeeper_factory_vtable = {
zookeeper_factory_ref, zookeeper_factory_unref, zookeeper_factory_ref, zookeeper_factory_unref,
zookeeper_factory_create_resolver}; zookeeper_factory_create_resolver, zookeeper_factory_get_default_hostname,
"zookeeper"};
static grpc_resolver_factory zookeeper_resolver_factory = { static grpc_resolver_factory zookeeper_resolver_factory = {
&zookeeper_factory_vtable}; &zookeeper_factory_vtable};

@ -36,7 +36,6 @@
#ifdef GRPC_BASIC_PROFILER #ifdef GRPC_BASIC_PROFILER
#include "src/core/profiling/timers.h" #include "src/core/profiling/timers.h"
#include "src/core/profiling/timers_preciseclock.h"
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -53,7 +52,7 @@ typedef enum {
} marker_type; } marker_type;
typedef struct grpc_timer_entry { typedef struct grpc_timer_entry {
grpc_precise_clock tm; gpr_timespec tm;
int tag; int tag;
const char* tagstr; const char* tagstr;
marker_type type; marker_type type;
@ -71,9 +70,8 @@ static void log_report() {
int i; int i;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
grpc_timer_entry* entry = &(log[i]); grpc_timer_entry* entry = &(log[i]);
printf("GRPC_LAT_PROF " GRPC_PRECISE_CLOCK_FORMAT printf("GRPC_LAT_PROF %ld.%09d %p %c %d(%s) %p %s %d\n",
" %p %c %d(%s) %p %s %d\n", entry->tm.tv_sec, entry->tm.tv_nsec,
GRPC_PRECISE_CLOCK_PRINTF_ARGS(&entry->tm),
(void*)(gpr_intptr)gpr_thd_currentid(), entry->type, entry->tag, (void*)(gpr_intptr)gpr_thd_currentid(), entry->type, entry->tag,
entry->tagstr, entry->id, entry->file, entry->line); entry->tagstr, entry->id, entry->file, entry->line);
} }
@ -93,7 +91,7 @@ static void grpc_timers_log_add(int tag, const char* tagstr, marker_type type,
entry = &log[count++]; entry = &log[count++];
grpc_precise_clock_now(&entry->tm); entry->tm = gpr_now(GPR_CLOCK_PRECISE);
entry->tag = tag; entry->tag = tag;
entry->tagstr = tagstr; entry->tagstr = tagstr;
entry->type = type; entry->type = type;

@ -32,6 +32,7 @@
*/ */
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <src/core/support/time_precise.h>
#ifdef GPR_POSIX_TIME #ifdef GPR_POSIX_TIME
@ -66,8 +67,14 @@ void gpr_time_init(void) {}
gpr_timespec gpr_now(gpr_clock_type clock) { gpr_timespec gpr_now(gpr_clock_type clock) {
struct timespec now; struct timespec now;
GPR_ASSERT(clock != GPR_TIMESPAN); GPR_ASSERT(clock != GPR_TIMESPAN);
if (clock == GPR_CLOCK_PRECISE) {
gpr_timespec ret;
gpr_precise_clock_now(&ret);
return ret;
} else {
clock_gettime(clockid_for_gpr_clock[clock], &now); clock_gettime(clockid_for_gpr_clock[clock], &now);
return gpr_from_timespec(now, clock); return gpr_from_timespec(now, clock);
}
} }
#else #else
/* For some reason Apple's OSes haven't implemented clock_gettime. */ /* For some reason Apple's OSes haven't implemented clock_gettime. */
@ -104,6 +111,9 @@ gpr_timespec gpr_now(gpr_clock_type clock) {
now.tv_sec = now_dbl * 1e-9; now.tv_sec = now_dbl * 1e-9;
now.tv_nsec = now_dbl - now.tv_sec * 1e9; now.tv_nsec = now_dbl - now.tv_sec * 1e9;
break; break;
case GPR_CLOCK_PRECISE:
gpr_precise_clock_now(&now);
break;
case GPR_TIMESPAN: case GPR_TIMESPAN:
abort(); abort();
} }

@ -31,65 +31,63 @@
* *
*/ */
#ifndef GRPC_CORE_PROFILING_TIMERS_PRECISECLOCK_H #ifndef GRPC_CORE_SUPPORT_TIME_PRECISE_H_
#define GRPC_CORE_PROFILING_TIMERS_PRECISECLOCK_H #define GRPC_CORE_SUPPORT_TIME_PRECISE_H_
#include <grpc/support/sync.h> #include <grpc/support/sync.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
#include <stdio.h> #include <stdio.h>
#ifdef GRPC_TIMERS_RDTSC #ifdef GRPC_TIMERS_RDTSC
typedef long long int grpc_precise_clock;
#if defined(__i386__) #if defined(__i386__)
static void grpc_precise_clock_now(grpc_precise_clock *clk) { static void gpr_get_cycle_counter(long long int *clk) {
grpc_precise_clock ret; long long int ret;
__asm__ volatile("rdtsc" : "=A"(ret)); __asm__ volatile("rdtsc" : "=A"(ret));
*clk = ret; *clk = ret;
} }
// ---------------------------------------------------------------- // ----------------------------------------------------------------
#elif defined(__x86_64__) || defined(__amd64__) #elif defined(__x86_64__) || defined(__amd64__)
static void grpc_precise_clock_now(grpc_precise_clock *clk) { static void gpr_get_cycle_counter(long long int *clk) {
unsigned long long low, high; unsigned long long low, high;
__asm__ volatile("rdtsc" : "=a"(low), "=d"(high)); __asm__ volatile("rdtsc" : "=a"(low), "=d"(high));
*clk = (high << 32) | low; *clk = (high << 32) | low;
} }
#endif #endif
static gpr_once precise_clock_init = GPR_ONCE_INIT; static gpr_once precise_clock_init = GPR_ONCE_INIT;
static double cycles_per_second = 0.0; static long long cycles_per_second = 0;
static void grpc_precise_clock_init() { static void gpr_precise_clock_init() {
time_t start = time(NULL); time_t start = time(NULL);
grpc_precise_clock start_time; gpr_precise_clock start_cycle;
grpc_precise_clock end_time; gpr_precise_clock end_cycle;
while (time(NULL) == start) while (time(NULL) == start)
; ;
grpc_precise_clock_now(&start_time); gpr_get_cycle_counter(&start_cycle);
while (time(NULL) == start + 1) while (time(NULL) == start + 1)
; ;
grpc_precise_clock_now(&end_time); gpr_get_cycle_counter(&end_cycle);
cycles_per_second = end_time - start_time; cycles_per_second = end_cycle - start_cycle;
} }
static double grpc_precise_clock_scaling_factor() { static double grpc_precise_clock_scaling_factor() {
gpr_once_init(&precise_clock_init, grpc_precise_clock_init); gpr_once_init(&precise_clock_init, grpc_precise_clock_init);
return 1e6 / cycles_per_second; return 1e6 / cycles_per_second;
} }
#define GRPC_PRECISE_CLOCK_FORMAT "%f"
#define GRPC_PRECISE_CLOCK_PRINTF_ARGS(clk) \ static void gpr_precise_clock_now(gpr_timespec *clk) {
(*(clk)*grpc_precise_clock_scaling_factor()) long long int counter;
#else gpr_get_cycle_counter(&counter);
typedef struct grpc_precise_clock grpc_precise_clock; clk->clock = GPR_CLOCK_REALTIME;
struct grpc_precise_clock { clk->tv_sec = counter / cycles_per_second;
gpr_timespec clock; clk->tv_nsec = counter % cycles_per_second;
};
static void grpc_precise_clock_now(grpc_precise_clock* clk) {
clk->clock = gpr_now(GPR_CLOCK_REALTIME);
} }
#define GRPC_PRECISE_CLOCK_FORMAT "%ld.%09d"
#define GRPC_PRECISE_CLOCK_PRINTF_ARGS(clk) \ #else /* GRPC_TIMERS_RDTSC */
(clk)->clock.tv_sec, (clk)->clock.tv_nsec static void gpr_precise_clock_now(gpr_timespec *clk) {
static void grpc_precise_clock_print(const grpc_precise_clock* clk, FILE* fp) { *clk = gpr_now(GPR_CLOCK_REALTIME);
fprintf(fp, "%ld.%09d", clk->clock.tv_sec, clk->clock.tv_nsec); clk->clock_type = GPR_CLOCK_PRECISE;
} }
#endif /* GRPC_TIMERS_RDTSC */ #endif /* GRPC_TIMERS_RDTSC */
#endif /* GRPC_CORE_PROFILING_TIMERS_PRECISECLOCK_H */ #endif /* GRPC_CORE_SUPPORT_TIME_PRECISE_ */

@ -38,6 +38,7 @@
#ifdef GPR_WIN32 #ifdef GPR_WIN32
#include <grpc/support/time.h> #include <grpc/support/time.h>
#include <src/core/support/time_precise.h>
#include <sys/timeb.h> #include <sys/timeb.h>
static LARGE_INTEGER g_start_time; static LARGE_INTEGER g_start_time;
@ -68,6 +69,9 @@ gpr_timespec gpr_now(gpr_clock_type clock) {
now_tv.tv_sec = (time_t)now_dbl; now_tv.tv_sec = (time_t)now_dbl;
now_tv.tv_nsec = (int)((now_dbl - (double)now_tv.tv_sec) * 1e9); now_tv.tv_nsec = (int)((now_dbl - (double)now_tv.tv_sec) * 1e9);
break; break;
case GPR_CLOCK_PRECISE:
gpr_precise_clock_now(&now_tv);
break;
} }
return now_tv; return now_tv;
} }

@ -40,6 +40,7 @@
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
#include "src/core/client_config/resolver_registry.h"
#include "src/core/iomgr/iomgr.h" #include "src/core/iomgr/iomgr.h"
#include "src/core/support/string.h" #include "src/core/support/string.h"
#include "src/core/surface/call.h" #include "src/core/surface/call.h"
@ -70,6 +71,7 @@ struct grpc_channel {
grpc_mdstr *grpc_message_string; grpc_mdstr *grpc_message_string;
grpc_mdstr *path_string; grpc_mdstr *path_string;
grpc_mdstr *authority_string; grpc_mdstr *authority_string;
grpc_mdelem *default_authority;
/** mdelem for grpc-status: 0 thru grpc-status: 2 */ /** mdelem for grpc-status: 0 thru grpc-status: 2 */
grpc_mdelem *grpc_status_elem[NUM_CACHED_STATUS_ELEMS]; grpc_mdelem *grpc_status_elem[NUM_CACHED_STATUS_ELEMS];
@ -134,10 +136,47 @@ grpc_channel *grpc_channel_create_from_filters(
} else { } else {
channel->max_message_length = args->args[i].value.integer; channel->max_message_length = args->args[i].value.integer;
} }
} else if (0 == strcmp(args->args[i].key, GRPC_ARG_DEFAULT_AUTHORITY)) {
if (args->args[i].type != GRPC_ARG_STRING) {
gpr_log(GPR_ERROR, "%s: must be an string",
GRPC_ARG_DEFAULT_AUTHORITY);
} else {
if (channel->default_authority) {
/* setting this takes precedence over anything else */
GRPC_MDELEM_UNREF(channel->default_authority);
}
channel->default_authority = grpc_mdelem_from_strings(
mdctx, ":authority", args->args[i].value.string);
}
} else if (0 ==
strcmp(args->args[i].key, GRPC_SSL_TARGET_NAME_OVERRIDE_ARG)) {
if (args->args[i].type != GRPC_ARG_STRING) {
gpr_log(GPR_ERROR, "%s: must be an string",
GRPC_SSL_TARGET_NAME_OVERRIDE_ARG);
} else {
if (channel->default_authority) {
/* other ways of setting this (notably ssl) take precedence */
gpr_log(GPR_ERROR, "%s: default host already set some other way",
GRPC_ARG_DEFAULT_AUTHORITY);
} else {
channel->default_authority = grpc_mdelem_from_strings(
mdctx, ":authority", args->args[i].value.string);
}
}
} }
} }
} }
if (channel->is_client && channel->default_authority == NULL &&
target != NULL) {
char *default_authority = grpc_get_default_authority(target);
if (default_authority) {
channel->default_authority = grpc_mdelem_from_strings(
channel->metadata_context, ":authority", default_authority);
}
gpr_free(default_authority);
}
grpc_channel_stack_init(filters, num_filters, channel, args, grpc_channel_stack_init(filters, num_filters, channel, args,
channel->metadata_context, channel->metadata_context,
CHANNEL_STACK_FROM_CHANNEL(channel)); CHANNEL_STACK_FROM_CHANNEL(channel));
@ -161,6 +200,8 @@ static grpc_call *grpc_channel_create_call_internal(
send_metadata[num_metadata++] = path_mdelem; send_metadata[num_metadata++] = path_mdelem;
if (authority_mdelem != NULL) { if (authority_mdelem != NULL) {
send_metadata[num_metadata++] = authority_mdelem; send_metadata[num_metadata++] = authority_mdelem;
} else if (channel->default_authority != NULL) {
send_metadata[num_metadata++] = GRPC_MDELEM_REF(channel->default_authority);
} }
return grpc_call_create(channel, parent_call, propagation_mask, cq, NULL, return grpc_call_create(channel, parent_call, propagation_mask, cq, NULL,
@ -251,6 +292,9 @@ static void destroy_channel(void *p, int ok) {
} }
gpr_free(rc); gpr_free(rc);
} }
if (channel->default_authority != NULL) {
GRPC_MDELEM_UNREF(channel->default_authority);
}
grpc_mdctx_unref(channel->metadata_context); grpc_mdctx_unref(channel->metadata_context);
gpr_mu_destroy(&channel->registered_call_mu); gpr_mu_destroy(&channel->registered_call_mu);
gpr_free(channel->target); gpr_free(channel->target);

@ -86,11 +86,11 @@ void grpc_init(void) {
if (++g_initializations == 1) { if (++g_initializations == 1) {
gpr_time_init(); gpr_time_init();
grpc_resolver_registry_init("dns:///"); grpc_resolver_registry_init("dns:///");
grpc_register_resolver_type("dns", grpc_dns_resolver_factory_create()); grpc_register_resolver_type(grpc_dns_resolver_factory_create());
grpc_register_resolver_type("ipv4", grpc_ipv4_resolver_factory_create()); grpc_register_resolver_type(grpc_ipv4_resolver_factory_create());
grpc_register_resolver_type("ipv6", grpc_ipv6_resolver_factory_create()); grpc_register_resolver_type(grpc_ipv6_resolver_factory_create());
#ifdef GPR_POSIX_SOCKET #ifdef GPR_POSIX_SOCKET
grpc_register_resolver_type("unix", grpc_unix_resolver_factory_create()); grpc_register_resolver_type(grpc_unix_resolver_factory_create());
#endif #endif
grpc_register_tracer("channel", &grpc_trace_channel); grpc_register_tracer("channel", &grpc_trace_channel);
grpc_register_tracer("surface", &grpc_surface_trace); grpc_register_tracer("surface", &grpc_surface_trace);

@ -41,13 +41,14 @@
namespace grpc { namespace grpc {
void FillMetadataMap(grpc_metadata_array* arr, void FillMetadataMap(
std::multimap<grpc::string, grpc::string>* metadata) { grpc_metadata_array* arr,
std::multimap<grpc::string_ref, grpc::string_ref>* metadata) {
for (size_t i = 0; i < arr->count; i++) { for (size_t i = 0; i < arr->count; i++) {
// TODO(yangg) handle duplicates? // TODO(yangg) handle duplicates?
metadata->insert(std::pair<grpc::string, grpc::string>( metadata->insert(std::pair<grpc::string_ref, grpc::string_ref>(
arr->metadata[i].key, arr->metadata[i].key, grpc::string_ref(arr->metadata[i].value,
grpc::string(arr->metadata[i].value, arr->metadata[i].value_length))); arr->metadata[i].value_length)));
} }
grpc_metadata_array_destroy(arr); grpc_metadata_array_destroy(arr);
grpc_metadata_array_init(arr); grpc_metadata_array_init(arr);

@ -439,10 +439,11 @@ Server::BaseAsyncRequest::~BaseAsyncRequest() {}
bool Server::BaseAsyncRequest::FinalizeResult(void** tag, bool* status) { bool Server::BaseAsyncRequest::FinalizeResult(void** tag, bool* status) {
if (*status) { if (*status) {
for (size_t i = 0; i < initial_metadata_array_.count; i++) { for (size_t i = 0; i < initial_metadata_array_.count; i++) {
context_->client_metadata_.insert(std::make_pair( context_->client_metadata_.insert(
grpc::string(initial_metadata_array_.metadata[i].key), std::pair<grpc::string_ref, grpc::string_ref>(
grpc::string(initial_metadata_array_.metadata[i].value, initial_metadata_array_.metadata[i].key,
initial_metadata_array_.metadata[i].value + grpc::string_ref(
initial_metadata_array_.metadata[i].value,
initial_metadata_array_.metadata[i].value_length))); initial_metadata_array_.metadata[i].value_length)));
} }
} }

@ -136,10 +136,9 @@ ServerContext::ServerContext(gpr_timespec deadline, grpc_metadata* metadata,
cq_(nullptr), cq_(nullptr),
sent_initial_metadata_(false) { sent_initial_metadata_(false) {
for (size_t i = 0; i < metadata_count; i++) { for (size_t i = 0; i < metadata_count; i++) {
client_metadata_.insert(std::make_pair( client_metadata_.insert(std::pair<grpc::string_ref, grpc::string_ref>(
grpc::string(metadata[i].key), metadata[i].key,
grpc::string(metadata[i].value, grpc::string_ref(metadata[i].value, metadata[i].value_length)));
metadata[i].value + metadata[i].value_length)));
} }
} }

@ -39,7 +39,7 @@
namespace grpc { namespace grpc {
constexpr size_t string_ref::npos; const size_t string_ref::npos;
string_ref& string_ref::operator=(const string_ref& rhs) { string_ref& string_ref::operator=(const string_ref& rhs) {
data_ = rhs.data_; data_ = rhs.data_;
@ -108,4 +108,8 @@ bool operator>=(string_ref x, string_ref y) {
return x.compare(y) >= 0; return x.compare(y) >= 0;
} }
std::ostream& operator<<(std::ostream& out, const string_ref& string) {
return out << grpc::string(string.begin(), string.end());
}
} // namespace grpc } // namespace grpc

@ -859,8 +859,8 @@ else
$(Q)(cd third_party/openssl ; CC="$(CC) $(PIC_CPPFLAGS) -fvisibility=hidden $(CPPFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_EXTRA)" ./config no-asm $(OPENSSL_CONFIG_$(CONFIG))) $(Q)(cd third_party/openssl ; CC="$(CC) $(PIC_CPPFLAGS) -fvisibility=hidden $(CPPFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_EXTRA)" ./config no-asm $(OPENSSL_CONFIG_$(CONFIG)))
endif endif
endif endif
$(Q)$(MAKE) -C third_party/openssl clean $(Q)$(MAKE) -j 1 -C third_party/openssl clean
$(Q)(unset CPPFLAGS; $(MAKE) -C third_party/openssl build_crypto build_ssl) $(Q)(unset CPPFLAGS; $(MAKE) -j 1 -C third_party/openssl build_crypto build_ssl)
$(Q)mkdir -p $(LIBDIR)/$(CONFIG)/openssl $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/openssl
$(Q)cp third_party/openssl/libssl.a third_party/openssl/libcrypto.a $(LIBDIR)/$(CONFIG)/openssl $(Q)cp third_party/openssl/libssl.a third_party/openssl/libcrypto.a $(LIBDIR)/$(CONFIG)/openssl

@ -201,7 +201,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(details, "xyz"));
GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
GPR_ASSERT(0 == strcmp(call_details.host, "localhost")); GPR_ASSERT(0 == strncmp(call_details.host, "localhost", 9));
GPR_ASSERT(was_cancelled == 1); GPR_ASSERT(was_cancelled == 1);
gpr_free(details); gpr_free(details);

@ -39,10 +39,12 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <unistd.h> #include <unistd.h>
#include "src/core/iomgr/iomgr.h" #include <grpc/grpc.h>
#include "src/core/iomgr/socket_utils_posix.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
#include "src/core/iomgr/iomgr.h"
#include "src/core/iomgr/socket_utils_posix.h"
#include "test/core/util/test_config.h" #include "test/core/util/test_config.h"
static grpc_pollset_set g_pollset_set; static grpc_pollset_set g_pollset_set;
@ -198,16 +200,21 @@ void test_times_out(void) {
/* Make sure the event doesn't trigger early */ /* Make sure the event doesn't trigger early */
gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset)); gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
while (gpr_time_cmp(gpr_time_add(connect_deadline, for (;;) {
gpr_time_from_seconds(2, GPR_TIMESPAN)),
gpr_now(connect_deadline.clock_type)) > 0) {
int is_after_deadline =
gpr_time_cmp(connect_deadline, gpr_now(GPR_CLOCK_MONOTONIC)) <= 0;
grpc_pollset_worker worker; grpc_pollset_worker worker;
gpr_timespec now = gpr_now(connect_deadline.clock_type);
gpr_timespec continue_verifying_time = gpr_time_from_seconds(2, GPR_TIMESPAN);
gpr_timespec grace_time = gpr_time_from_seconds(1, GPR_TIMESPAN);
gpr_timespec finish_time = gpr_time_add(connect_deadline, continue_verifying_time);
gpr_timespec restart_verifying_time = gpr_time_add(connect_deadline, grace_time);
int is_after_deadline = gpr_time_cmp(now, connect_deadline) > 0;
if (gpr_time_cmp(now, finish_time) > 0) {
break;
}
gpr_log(GPR_DEBUG, "now=%d.%09d connect_deadline=%d.%09d",
now.tv_sec, now.tv_nsec, connect_deadline.tv_sec, connect_deadline.tv_nsec);
if (is_after_deadline && if (is_after_deadline &&
gpr_time_cmp(gpr_time_add(connect_deadline, gpr_time_cmp(now, restart_verifying_time) <= 0) {
gpr_time_from_seconds(1, GPR_TIMESPAN)),
gpr_now(GPR_CLOCK_MONOTONIC)) > 0) {
/* allow some slack before insisting that things be done */ /* allow some slack before insisting that things be done */
} else { } else {
GPR_ASSERT(g_connections_complete == GPR_ASSERT(g_connections_complete ==
@ -228,7 +235,7 @@ static void destroy_pollset(void *p) { grpc_pollset_destroy(p); }
int main(int argc, char **argv) { int main(int argc, char **argv) {
grpc_test_init(argc, argv); grpc_test_init(argc, argv);
grpc_iomgr_init(); grpc_init();
grpc_pollset_set_init(&g_pollset_set); grpc_pollset_set_init(&g_pollset_set);
grpc_pollset_init(&g_pollset); grpc_pollset_init(&g_pollset);
grpc_pollset_set_add_pollset(&g_pollset_set, &g_pollset); grpc_pollset_set_add_pollset(&g_pollset_set, &g_pollset);
@ -238,6 +245,6 @@ int main(int argc, char **argv) {
test_times_out(); test_times_out();
grpc_pollset_set_destroy(&g_pollset_set); grpc_pollset_set_destroy(&g_pollset_set);
grpc_pollset_shutdown(&g_pollset, destroy_pollset, &g_pollset); grpc_pollset_shutdown(&g_pollset, destroy_pollset, &g_pollset);
grpc_iomgr_shutdown(); grpc_shutdown();
return 0; return 0;
} }

@ -50,6 +50,7 @@
#include "test/core/util/test_config.h" #include "test/core/util/test_config.h"
#include "test/cpp/util/echo_duplicate.grpc.pb.h" #include "test/cpp/util/echo_duplicate.grpc.pb.h"
#include "test/cpp/util/echo.grpc.pb.h" #include "test/cpp/util/echo.grpc.pb.h"
#include "test/cpp/util/string_ref_helper.h"
#ifdef GPR_POSIX_SOCKET #ifdef GPR_POSIX_SOCKET
#include "src/core/iomgr/pollset_posix.h" #include "src/core/iomgr/pollset_posix.h"
@ -484,8 +485,10 @@ TEST_P(AsyncEnd2endTest, ClientInitialMetadataRpc) {
Verifier(GetParam()).Expect(2, true).Verify(cq_.get()); Verifier(GetParam()).Expect(2, true).Verify(cq_.get());
EXPECT_EQ(send_request.message(), recv_request.message()); EXPECT_EQ(send_request.message(), recv_request.message());
auto client_initial_metadata = srv_ctx.client_metadata(); auto client_initial_metadata = srv_ctx.client_metadata();
EXPECT_EQ(meta1.second, client_initial_metadata.find(meta1.first)->second); EXPECT_EQ(meta1.second,
EXPECT_EQ(meta2.second, client_initial_metadata.find(meta2.first)->second); ToString(client_initial_metadata.find(meta1.first)->second));
EXPECT_EQ(meta2.second,
ToString(client_initial_metadata.find(meta2.first)->second));
EXPECT_GE(client_initial_metadata.size(), static_cast<size_t>(2)); EXPECT_GE(client_initial_metadata.size(), static_cast<size_t>(2));
send_response.set_message(recv_request.message()); send_response.set_message(recv_request.message());
@ -532,8 +535,10 @@ TEST_P(AsyncEnd2endTest, ServerInitialMetadataRpc) {
response_reader->ReadInitialMetadata(tag(4)); response_reader->ReadInitialMetadata(tag(4));
Verifier(GetParam()).Expect(4, true).Verify(cq_.get()); Verifier(GetParam()).Expect(4, true).Verify(cq_.get());
auto server_initial_metadata = cli_ctx.GetServerInitialMetadata(); auto server_initial_metadata = cli_ctx.GetServerInitialMetadata();
EXPECT_EQ(meta1.second, server_initial_metadata.find(meta1.first)->second); EXPECT_EQ(meta1.second,
EXPECT_EQ(meta2.second, server_initial_metadata.find(meta2.first)->second); ToString(server_initial_metadata.find(meta1.first)->second));
EXPECT_EQ(meta2.second,
ToString(server_initial_metadata.find(meta2.first)->second));
EXPECT_EQ(static_cast<size_t>(2), server_initial_metadata.size()); EXPECT_EQ(static_cast<size_t>(2), server_initial_metadata.size());
send_response.set_message(recv_request.message()); send_response.set_message(recv_request.message());
@ -586,8 +591,10 @@ TEST_P(AsyncEnd2endTest, ServerTrailingMetadataRpc) {
EXPECT_EQ(send_response.message(), recv_response.message()); EXPECT_EQ(send_response.message(), recv_response.message());
EXPECT_TRUE(recv_status.ok()); EXPECT_TRUE(recv_status.ok());
auto server_trailing_metadata = cli_ctx.GetServerTrailingMetadata(); auto server_trailing_metadata = cli_ctx.GetServerTrailingMetadata();
EXPECT_EQ(meta1.second, server_trailing_metadata.find(meta1.first)->second); EXPECT_EQ(meta1.second,
EXPECT_EQ(meta2.second, server_trailing_metadata.find(meta2.first)->second); ToString(server_trailing_metadata.find(meta1.first)->second));
EXPECT_EQ(meta2.second,
ToString(server_trailing_metadata.find(meta2.first)->second));
EXPECT_EQ(static_cast<size_t>(2), server_trailing_metadata.size()); EXPECT_EQ(static_cast<size_t>(2), server_trailing_metadata.size());
} }
@ -631,8 +638,10 @@ TEST_P(AsyncEnd2endTest, MetadataRpc) {
Verifier(GetParam()).Expect(2, true).Verify(cq_.get()); Verifier(GetParam()).Expect(2, true).Verify(cq_.get());
EXPECT_EQ(send_request.message(), recv_request.message()); EXPECT_EQ(send_request.message(), recv_request.message());
auto client_initial_metadata = srv_ctx.client_metadata(); auto client_initial_metadata = srv_ctx.client_metadata();
EXPECT_EQ(meta1.second, client_initial_metadata.find(meta1.first)->second); EXPECT_EQ(meta1.second,
EXPECT_EQ(meta2.second, client_initial_metadata.find(meta2.first)->second); ToString(client_initial_metadata.find(meta1.first)->second));
EXPECT_EQ(meta2.second,
ToString(client_initial_metadata.find(meta2.first)->second));
EXPECT_GE(client_initial_metadata.size(), static_cast<size_t>(2)); EXPECT_GE(client_initial_metadata.size(), static_cast<size_t>(2));
srv_ctx.AddInitialMetadata(meta3.first, meta3.second); srv_ctx.AddInitialMetadata(meta3.first, meta3.second);
@ -642,8 +651,10 @@ TEST_P(AsyncEnd2endTest, MetadataRpc) {
response_reader->ReadInitialMetadata(tag(4)); response_reader->ReadInitialMetadata(tag(4));
Verifier(GetParam()).Expect(4, true).Verify(cq_.get()); Verifier(GetParam()).Expect(4, true).Verify(cq_.get());
auto server_initial_metadata = cli_ctx.GetServerInitialMetadata(); auto server_initial_metadata = cli_ctx.GetServerInitialMetadata();
EXPECT_EQ(meta3.second, server_initial_metadata.find(meta3.first)->second); EXPECT_EQ(meta3.second,
EXPECT_EQ(meta4.second, server_initial_metadata.find(meta4.first)->second); ToString(server_initial_metadata.find(meta3.first)->second));
EXPECT_EQ(meta4.second,
ToString(server_initial_metadata.find(meta4.first)->second));
EXPECT_GE(server_initial_metadata.size(), static_cast<size_t>(2)); EXPECT_GE(server_initial_metadata.size(), static_cast<size_t>(2));
send_response.set_message(recv_request.message()); send_response.set_message(recv_request.message());
@ -658,8 +669,10 @@ TEST_P(AsyncEnd2endTest, MetadataRpc) {
EXPECT_EQ(send_response.message(), recv_response.message()); EXPECT_EQ(send_response.message(), recv_response.message());
EXPECT_TRUE(recv_status.ok()); EXPECT_TRUE(recv_status.ok());
auto server_trailing_metadata = cli_ctx.GetServerTrailingMetadata(); auto server_trailing_metadata = cli_ctx.GetServerTrailingMetadata();
EXPECT_EQ(meta5.second, server_trailing_metadata.find(meta5.first)->second); EXPECT_EQ(meta5.second,
EXPECT_EQ(meta6.second, server_trailing_metadata.find(meta6.first)->second); ToString(server_trailing_metadata.find(meta5.first)->second));
EXPECT_EQ(meta6.second,
ToString(server_trailing_metadata.find(meta6.first)->second));
EXPECT_GE(server_trailing_metadata.size(), static_cast<size_t>(2)); EXPECT_GE(server_trailing_metadata.size(), static_cast<size_t>(2));
} }

@ -53,6 +53,7 @@
#include "test/core/util/test_config.h" #include "test/core/util/test_config.h"
#include "test/cpp/util/echo_duplicate.grpc.pb.h" #include "test/cpp/util/echo_duplicate.grpc.pb.h"
#include "test/cpp/util/echo.grpc.pb.h" #include "test/cpp/util/echo.grpc.pb.h"
#include "test/cpp/util/string_ref_helper.h"
using grpc::cpp::test::util::EchoRequest; using grpc::cpp::test::util::EchoRequest;
using grpc::cpp::test::util::EchoResponse; using grpc::cpp::test::util::EchoResponse;
@ -152,12 +153,13 @@ class TestServiceImpl : public ::grpc::cpp::test::util::TestService::Service {
} }
if (request->has_param() && request->param().echo_metadata()) { if (request->has_param() && request->param().echo_metadata()) {
const std::multimap<grpc::string, grpc::string>& client_metadata = const std::multimap<grpc::string_ref, grpc::string_ref>& client_metadata =
context->client_metadata(); context->client_metadata();
for (std::multimap<grpc::string, grpc::string>::const_iterator iter = for (std::multimap<grpc::string_ref, grpc::string_ref>::const_iterator
client_metadata.begin(); iter = client_metadata.begin();
iter != client_metadata.end(); ++iter) { iter != client_metadata.end(); ++iter) {
context->AddTrailingMetadata((*iter).first, (*iter).second); context->AddTrailingMetadata(ToString(iter->first),
ToString(iter->second));
} }
} }
if (request->has_param() && request->param().check_auth_context()) { if (request->has_param() && request->param().check_auth_context()) {
@ -182,12 +184,12 @@ class TestServiceImpl : public ::grpc::cpp::test::util::TestService::Service {
EchoRequest request; EchoRequest request;
response->set_message(""); response->set_message("");
int cancel_after_reads = 0; int cancel_after_reads = 0;
const std::multimap<grpc::string, grpc::string> client_initial_metadata = const std::multimap<grpc::string_ref, grpc::string_ref>&
context->client_metadata(); client_initial_metadata = context->client_metadata();
if (client_initial_metadata.find(kServerCancelAfterReads) != if (client_initial_metadata.find(kServerCancelAfterReads) !=
client_initial_metadata.end()) { client_initial_metadata.end()) {
std::istringstream iss( std::istringstream iss(ToString(
client_initial_metadata.find(kServerCancelAfterReads)->second); client_initial_metadata.find(kServerCancelAfterReads)->second));
iss >> cancel_after_reads; iss >> cancel_after_reads;
gpr_log(GPR_INFO, "cancel_after_reads %d", cancel_after_reads); gpr_log(GPR_INFO, "cancel_after_reads %d", cancel_after_reads);
} }
@ -721,14 +723,15 @@ TEST_F(End2endTest, RpcMaxMessageSize) {
EXPECT_FALSE(s.ok()); EXPECT_FALSE(s.ok());
} }
bool MetadataContains(const std::multimap<grpc::string, grpc::string>& metadata, bool MetadataContains(
const std::multimap<grpc::string_ref, grpc::string_ref>& metadata,
const grpc::string& key, const grpc::string& value) { const grpc::string& key, const grpc::string& value) {
int count = 0; int count = 0;
for (std::multimap<grpc::string, grpc::string>::const_iterator iter = for (std::multimap<grpc::string_ref, grpc::string_ref>::const_iterator iter =
metadata.begin(); metadata.begin();
iter != metadata.end(); ++iter) { iter != metadata.end(); ++iter) {
if ((*iter).first == key && (*iter).second == value) { if (ToString(iter->first) == key && ToString(iter->second) == value) {
count++; count++;
} }
} }

@ -160,7 +160,7 @@ class GenericEnd2endTest : public ::testing::Test {
srv_cq_.get(), tag(4)); srv_cq_.get(), tag(4));
verify_ok(srv_cq_.get(), 4, true); verify_ok(srv_cq_.get(), 4, true);
EXPECT_EQ(server_host_, srv_ctx.host()); EXPECT_EQ(server_host_, srv_ctx.host().substr(0, server_host_.length()));
EXPECT_EQ(kMethodName, srv_ctx.method()); EXPECT_EQ(kMethodName, srv_ctx.method());
ByteBuffer recv_buffer; ByteBuffer recv_buffer;
stream.Read(&recv_buffer, tag(5)); stream.Read(&recv_buffer, tag(5));
@ -233,7 +233,7 @@ TEST_F(GenericEnd2endTest, SimpleBidiStreaming) {
srv_cq_.get(), tag(2)); srv_cq_.get(), tag(2));
verify_ok(srv_cq_.get(), 2, true); verify_ok(srv_cq_.get(), 2, true);
EXPECT_EQ(server_host_, srv_ctx.host()); EXPECT_EQ(server_host_, srv_ctx.host().substr(0, server_host_.length()));
EXPECT_EQ(kMethodName, srv_ctx.method()); EXPECT_EQ(kMethodName, srv_ctx.method());
std::unique_ptr<ByteBuffer> send_buffer = std::unique_ptr<ByteBuffer> send_buffer =

@ -51,14 +51,14 @@ void* tag(int i) { return (void*)(gpr_intptr)i; }
Status CliCall::Call(std::shared_ptr<grpc::Channel> channel, Status CliCall::Call(std::shared_ptr<grpc::Channel> channel,
const grpc::string& method, const grpc::string& request, const grpc::string& method, const grpc::string& request,
grpc::string* response, const MetadataContainer& metadata, grpc::string* response,
MetadataContainer* server_initial_metadata, const OutgoingMetadataContainer& metadata,
MetadataContainer* server_trailing_metadata) { IncomingMetadataContainer* server_initial_metadata,
IncomingMetadataContainer* server_trailing_metadata) {
std::unique_ptr<grpc::GenericStub> stub(new grpc::GenericStub(channel)); std::unique_ptr<grpc::GenericStub> stub(new grpc::GenericStub(channel));
grpc::ClientContext ctx; grpc::ClientContext ctx;
if (!metadata.empty()) { if (!metadata.empty()) {
for (std::multimap<grpc::string, grpc::string>::const_iterator iter = for (OutgoingMetadataContainer::const_iterator iter = metadata.begin();
metadata.begin();
iter != metadata.end(); ++iter) { iter != metadata.end(); ++iter) {
ctx.AddMetadata(iter->first, iter->second); ctx.AddMetadata(iter->first, iter->second);
} }

@ -38,18 +38,22 @@
#include <grpc++/channel.h> #include <grpc++/channel.h>
#include <grpc++/support/status.h> #include <grpc++/support/status.h>
#include <grpc++/support/string_ref.h>
namespace grpc { namespace grpc {
namespace testing { namespace testing {
class CliCall GRPC_FINAL { class CliCall GRPC_FINAL {
public: public:
typedef std::multimap<grpc::string, grpc::string> MetadataContainer; typedef std::multimap<grpc::string, grpc::string> OutgoingMetadataContainer;
typedef std::multimap<grpc::string_ref, grpc::string_ref>
IncomingMetadataContainer;
static Status Call(std::shared_ptr<grpc::Channel> channel, static Status Call(std::shared_ptr<grpc::Channel> channel,
const grpc::string& method, const grpc::string& request, const grpc::string& method, const grpc::string& request,
grpc::string* response, const MetadataContainer& metadata, grpc::string* response,
MetadataContainer* server_initial_metadata, const OutgoingMetadataContainer& metadata,
MetadataContainer* server_trailing_metadata); IncomingMetadataContainer* server_initial_metadata,
IncomingMetadataContainer* server_trailing_metadata);
}; };
} // namespace testing } // namespace testing

@ -47,6 +47,7 @@
#include "test/core/util/port.h" #include "test/core/util/port.h"
#include "test/core/util/test_config.h" #include "test/core/util/test_config.h"
#include "test/cpp/util/echo.grpc.pb.h" #include "test/cpp/util/echo.grpc.pb.h"
#include "test/cpp/util/string_ref_helper.h"
using grpc::cpp::test::util::EchoRequest; using grpc::cpp::test::util::EchoRequest;
using grpc::cpp::test::util::EchoResponse; using grpc::cpp::test::util::EchoResponse;
@ -59,10 +60,11 @@ class TestServiceImpl : public ::grpc::cpp::test::util::TestService::Service {
Status Echo(ServerContext* context, const EchoRequest* request, Status Echo(ServerContext* context, const EchoRequest* request,
EchoResponse* response) GRPC_OVERRIDE { EchoResponse* response) GRPC_OVERRIDE {
if (!context->client_metadata().empty()) { if (!context->client_metadata().empty()) {
for (std::multimap<grpc::string, grpc::string>::const_iterator iter = for (std::multimap<grpc::string_ref, grpc::string_ref>::const_iterator
context->client_metadata().begin(); iter = context->client_metadata().begin();
iter != context->client_metadata().end(); ++iter) { iter != context->client_metadata().end(); ++iter) {
context->AddInitialMetadata(iter->first, iter->second); context->AddInitialMetadata(ToString(iter->first),
ToString(iter->second));
} }
} }
context->AddTrailingMetadata("trailing_key", "trailing_value"); context->AddTrailingMetadata("trailing_key", "trailing_value");
@ -119,8 +121,9 @@ TEST_F(CliCallTest, SimpleRpc) {
grpc::string request_bin, response_bin, expected_response_bin; grpc::string request_bin, response_bin, expected_response_bin;
EXPECT_TRUE(request.SerializeToString(&request_bin)); EXPECT_TRUE(request.SerializeToString(&request_bin));
EXPECT_TRUE(response.SerializeToString(&expected_response_bin)); EXPECT_TRUE(response.SerializeToString(&expected_response_bin));
std::multimap<grpc::string, grpc::string> client_metadata, std::multimap<grpc::string, grpc::string> client_metadata;
server_initial_metadata, server_trailing_metadata; std::multimap<grpc::string_ref, grpc::string_ref> server_initial_metadata,
server_trailing_metadata;
client_metadata.insert(std::pair<grpc::string, grpc::string>("key1", "val1")); client_metadata.insert(std::pair<grpc::string, grpc::string>("key1", "val1"));
Status s2 = CliCall::Call(channel_, kMethod, request_bin, &response_bin, Status s2 = CliCall::Call(channel_, kMethod, request_bin, &response_bin,
client_metadata, &server_initial_metadata, client_metadata, &server_initial_metadata,

@ -68,8 +68,10 @@
#include <grpc++/channel.h> #include <grpc++/channel.h>
#include <grpc++/create_channel.h> #include <grpc++/create_channel.h>
#include <grpc++/credentials.h> #include <grpc++/credentials.h>
#include <grpc++/support/string_ref.h>
#include "test/cpp/util/cli_call.h" #include "test/cpp/util/cli_call.h"
#include "test/cpp/util/string_ref_helper.h"
#include "test/cpp/util/test_config.h" #include "test/cpp/util/test_config.h"
DEFINE_bool(enable_ssl, true, "Whether to use ssl/tls."); DEFINE_bool(enable_ssl, true, "Whether to use ssl/tls.");
@ -104,16 +106,19 @@ void ParseMetadataFlag(
} }
} }
void PrintMetadata(const std::multimap<grpc::string, grpc::string>& m, template <typename T>
const grpc::string& message) { void PrintMetadata(const T& m, const grpc::string& message) {
if (m.empty()) { if (m.empty()) {
return; return;
} }
std::cout << message << std::endl; std::cout << message << std::endl;
for (std::multimap<grpc::string, grpc::string>::const_iterator iter = grpc::string pair;
m.begin(); for (typename T::const_iterator iter = m.begin(); iter != m.end(); ++iter) {
iter != m.end(); ++iter) { pair.clear();
std::cout << iter->first << " : " << iter->second << std::endl; pair.append(iter->first.data(), iter->first.size());
pair.append(" : ");
pair.append(iter->second.data(), iter->second.size());
std::cout << pair << std::endl;
} }
} }
@ -157,8 +162,9 @@ int main(int argc, char** argv) {
grpc::CreateChannel(server_address, creds, grpc::ChannelArguments()); grpc::CreateChannel(server_address, creds, grpc::ChannelArguments());
grpc::string response; grpc::string response;
std::multimap<grpc::string, grpc::string> client_metadata, std::multimap<grpc::string, grpc::string> client_metadata;
server_initial_metadata, server_trailing_metadata; std::multimap<grpc::string_ref, grpc::string_ref> server_initial_metadata,
server_trailing_metadata;
ParseMetadataFlag(&client_metadata); ParseMetadataFlag(&client_metadata);
PrintMetadata(client_metadata, "Sending client initial metadata:"); PrintMetadata(client_metadata, "Sending client initial metadata:");
grpc::Status s = grpc::testing::CliCall::Call( grpc::Status s = grpc::testing::CliCall::Call(

@ -0,0 +1,44 @@
/*
*
* 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 "test/cpp/util/string_ref_helper.h"
namespace grpc {
namespace testing {
grpc::string ToString(const grpc::string_ref& r) {
return grpc::string(r.data(), r.size());
}
} // namespace testing
} // namespace grpc

@ -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_TEST_CPP_UTIL_STRING_REF_HELPER_H
#define GRPC_TEST_CPP_UTIL_STRING_REF_HELPER_H
#include <grpc++/support/string_ref.h>
namespace grpc {
namespace testing {
grpc::string ToString(const grpc::string_ref& r);
} // namespace testing
} // namespace grpc
#endif // GRPC_TEST_CPP_UTIL_STRING_REF_HELPER_H

@ -845,7 +845,6 @@ src/core/json/json_common.h \
src/core/json/json_reader.h \ src/core/json/json_reader.h \
src/core/json/json_writer.h \ src/core/json/json_writer.h \
src/core/profiling/timers.h \ src/core/profiling/timers.h \
src/core/profiling/timers_preciseclock.h \
src/core/statistics/census_interface.h \ src/core/statistics/census_interface.h \
src/core/statistics/census_rpc_stats.h \ src/core/statistics/census_rpc_stats.h \
src/core/surface/byte_buffer_queue.h \ src/core/surface/byte_buffer_queue.h \
@ -1058,6 +1057,7 @@ src/core/support/stack_lockfree.h \
src/core/support/string.h \ src/core/support/string.h \
src/core/support/string_win32.h \ src/core/support/string_win32.h \
src/core/support/thd_internal.h \ src/core/support/thd_internal.h \
src/core/support/time_precise.h \
src/core/support/alloc.c \ src/core/support/alloc.c \
src/core/support/cmdline.c \ src/core/support/cmdline.c \
src/core/support/cpu_iphone.c \ src/core/support/cpu_iphone.c \

@ -8,7 +8,7 @@ cd /d %~dp0\..\..\src\csharp
@rem set UUID variable to a random GUID, we will use it to put TestResults.xml to a dedicated directory, so that parallel test runs don't collide @rem set UUID variable to a random GUID, we will use it to put TestResults.xml to a dedicated directory, so that parallel test runs don't collide
for /F %%i in ('powershell -Command "[guid]::NewGuid().ToString()"') do (set UUID=%%i) for /F %%i in ('powershell -Command "[guid]::NewGuid().ToString()"') do (set UUID=%%i)
packages\NUnit.Runners.2.6.4\tools\nunit-console-x86.exe -labels "%1/bin/Debug/%1.dll" -work test-results/%UUID% || goto :error packages\NUnit.Runners.2.6.4\tools\nunit-console-x86.exe /domain:None -labels "%1/bin/Debug/%1.dll" -work test-results/%UUID% || goto :error
endlocal endlocal

@ -536,7 +536,8 @@ def _start_port_server(port_server_port):
# if not running ==> start a new one # if not running ==> start a new one
# otherwise, leave it up # otherwise, leave it up
try: try:
version = urllib2.urlopen('http://localhost:%d/version' % port_server_port).read() version = urllib2.urlopen('http://localhost:%d/version' % port_server_port,
timeout=1).read()
running = True running = True
except Exception: except Exception:
running = False running = False
@ -554,12 +555,20 @@ def _start_port_server(port_server_port):
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
stdout=port_log) stdout=port_log)
# ensure port server is up # ensure port server is up
waits = 0
while True: while True:
if waits > 10:
port_server.kill()
print "port_server failed to start"
sys.exit(1)
try: try:
urllib2.urlopen('http://localhost:%d/get' % port_server_port).read() urllib2.urlopen('http://localhost:%d/get' % port_server_port,
timeout=1).read()
break break
except urllib2.URLError: except urllib2.URLError:
print "waiting for port_server"
time.sleep(0.5) time.sleep(0.5)
waits += 1
except: except:
port_server.kill() port_server.kill()
raise raise

@ -12168,7 +12168,8 @@
"src/core/support/stack_lockfree.h", "src/core/support/stack_lockfree.h",
"src/core/support/string.h", "src/core/support/string.h",
"src/core/support/string_win32.h", "src/core/support/string_win32.h",
"src/core/support/thd_internal.h" "src/core/support/thd_internal.h",
"src/core/support/time_precise.h"
], ],
"language": "c", "language": "c",
"name": "gpr", "name": "gpr",
@ -12242,6 +12243,7 @@
"src/core/support/thd_win32.c", "src/core/support/thd_win32.c",
"src/core/support/time.c", "src/core/support/time.c",
"src/core/support/time_posix.c", "src/core/support/time_posix.c",
"src/core/support/time_precise.h",
"src/core/support/time_win32.c", "src/core/support/time_win32.c",
"src/core/support/tls_pthread.c" "src/core/support/tls_pthread.c"
] ]
@ -12339,7 +12341,6 @@
"src/core/json/json_reader.h", "src/core/json/json_reader.h",
"src/core/json/json_writer.h", "src/core/json/json_writer.h",
"src/core/profiling/timers.h", "src/core/profiling/timers.h",
"src/core/profiling/timers_preciseclock.h",
"src/core/security/auth_filters.h", "src/core/security/auth_filters.h",
"src/core/security/base64.h", "src/core/security/base64.h",
"src/core/security/credentials.h", "src/core/security/credentials.h",
@ -12542,7 +12543,6 @@
"src/core/profiling/basic_timers.c", "src/core/profiling/basic_timers.c",
"src/core/profiling/stap_timers.c", "src/core/profiling/stap_timers.c",
"src/core/profiling/timers.h", "src/core/profiling/timers.h",
"src/core/profiling/timers_preciseclock.h",
"src/core/security/auth_filters.h", "src/core/security/auth_filters.h",
"src/core/security/base64.c", "src/core/security/base64.c",
"src/core/security/base64.h", "src/core/security/base64.h",
@ -12818,7 +12818,6 @@
"src/core/json/json_reader.h", "src/core/json/json_reader.h",
"src/core/json/json_writer.h", "src/core/json/json_writer.h",
"src/core/profiling/timers.h", "src/core/profiling/timers.h",
"src/core/profiling/timers_preciseclock.h",
"src/core/statistics/census_interface.h", "src/core/statistics/census_interface.h",
"src/core/statistics/census_rpc_stats.h", "src/core/statistics/census_rpc_stats.h",
"src/core/surface/byte_buffer_queue.h", "src/core/surface/byte_buffer_queue.h",
@ -13006,7 +13005,6 @@
"src/core/profiling/basic_timers.c", "src/core/profiling/basic_timers.c",
"src/core/profiling/stap_timers.c", "src/core/profiling/stap_timers.c",
"src/core/profiling/timers.h", "src/core/profiling/timers.h",
"src/core/profiling/timers_preciseclock.h",
"src/core/statistics/census_interface.h", "src/core/statistics/census_interface.h",
"src/core/statistics/census_rpc_stats.h", "src/core/statistics/census_rpc_stats.h",
"src/core/surface/byte_buffer.c", "src/core/surface/byte_buffer.c",
@ -13289,6 +13287,7 @@
"test/cpp/util/echo_duplicate.pb.h", "test/cpp/util/echo_duplicate.pb.h",
"test/cpp/util/messages.grpc.pb.h", "test/cpp/util/messages.grpc.pb.h",
"test/cpp/util/messages.pb.h", "test/cpp/util/messages.pb.h",
"test/cpp/util/string_ref_helper.h",
"test/cpp/util/subprocess.h" "test/cpp/util/subprocess.h"
], ],
"language": "c++", "language": "c++",
@ -13298,6 +13297,8 @@
"test/cpp/util/cli_call.h", "test/cpp/util/cli_call.h",
"test/cpp/util/create_test_channel.cc", "test/cpp/util/create_test_channel.cc",
"test/cpp/util/create_test_channel.h", "test/cpp/util/create_test_channel.h",
"test/cpp/util/string_ref_helper.cc",
"test/cpp/util/string_ref_helper.h",
"test/cpp/util/subprocess.cc", "test/cpp/util/subprocess.cc",
"test/cpp/util/subprocess.h" "test/cpp/util/subprocess.h"
] ]

@ -4752,8 +4752,8 @@ Debug\grpc++_test_config.lib: $(OUT_DIR)
Debug\grpc++_test_util.lib: $(OUT_DIR) Debug\grpc++_test_util.lib: $(OUT_DIR)
echo Building grpc++_test_util echo Building grpc++_test_util
$(CC) $(CXXFLAGS) /Fo:$(OUT_DIR)\ $(REPO_ROOT)\test\cpp\util\cli_call.cc $(REPO_ROOT)\test\cpp\util\create_test_channel.cc $(REPO_ROOT)\test\cpp\util\subprocess.cc $(REPO_ROOT)\test\cpp\util\messages.pb.cc $(REPO_ROOT)\test\cpp\util\messages.grpc.pb.cc $(REPO_ROOT)\test\cpp\util\echo.pb.cc $(REPO_ROOT)\test\cpp\util\echo.grpc.pb.cc $(REPO_ROOT)\test\cpp\util\echo_duplicate.pb.cc $(REPO_ROOT)\test\cpp\util\echo_duplicate.grpc.pb.cc $(CC) $(CXXFLAGS) /Fo:$(OUT_DIR)\ $(REPO_ROOT)\test\cpp\util\cli_call.cc $(REPO_ROOT)\test\cpp\util\create_test_channel.cc $(REPO_ROOT)\test\cpp\util\string_ref_helper.cc $(REPO_ROOT)\test\cpp\util\subprocess.cc $(REPO_ROOT)\test\cpp\util\messages.pb.cc $(REPO_ROOT)\test\cpp\util\messages.grpc.pb.cc $(REPO_ROOT)\test\cpp\util\echo.pb.cc $(REPO_ROOT)\test\cpp\util\echo.grpc.pb.cc $(REPO_ROOT)\test\cpp\util\echo_duplicate.pb.cc $(REPO_ROOT)\test\cpp\util\echo_duplicate.grpc.pb.cc
$(LIBTOOL) /OUT:"Debug\grpc++_test_util.lib" $(OUT_DIR)\cli_call.obj $(OUT_DIR)\create_test_channel.obj $(OUT_DIR)\subprocess.obj $(OUT_DIR)\messages.pb.obj $(OUT_DIR)\messages.grpc.pb.obj $(OUT_DIR)\echo.pb.obj $(OUT_DIR)\echo.grpc.pb.obj $(OUT_DIR)\echo_duplicate.pb.obj $(OUT_DIR)\echo_duplicate.grpc.pb.obj $(LIBTOOL) /OUT:"Debug\grpc++_test_util.lib" $(OUT_DIR)\cli_call.obj $(OUT_DIR)\create_test_channel.obj $(OUT_DIR)\string_ref_helper.obj $(OUT_DIR)\subprocess.obj $(OUT_DIR)\messages.pb.obj $(OUT_DIR)\messages.grpc.pb.obj $(OUT_DIR)\echo.pb.obj $(OUT_DIR)\echo.grpc.pb.obj $(OUT_DIR)\echo_duplicate.pb.obj $(OUT_DIR)\echo_duplicate.grpc.pb.obj
build_grpc++_unsecure: build_grpc++_unsecure:
msbuild grpc.sln /t:grpc++_unsecure /p:Configuration=Debug /p:Linkage-grpc_dependencies_zlib=static msbuild grpc.sln /t:grpc++_unsecure /p:Configuration=Debug /p:Linkage-grpc_dependencies_zlib=static

@ -158,6 +158,7 @@
<ClInclude Include="..\..\src\core\support\string.h" /> <ClInclude Include="..\..\src\core\support\string.h" />
<ClInclude Include="..\..\src\core\support\string_win32.h" /> <ClInclude Include="..\..\src\core\support\string_win32.h" />
<ClInclude Include="..\..\src\core\support\thd_internal.h" /> <ClInclude Include="..\..\src\core\support\thd_internal.h" />
<ClInclude Include="..\..\src\core\support\time_precise.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\src\core\support\alloc.c"> <ClCompile Include="..\..\src\core\support\alloc.c">

@ -218,6 +218,9 @@
<ClInclude Include="..\..\src\core\support\thd_internal.h"> <ClInclude Include="..\..\src\core\support\thd_internal.h">
<Filter>src\core\support</Filter> <Filter>src\core\support</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\src\core\support\time_precise.h">
<Filter>src\core\support</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

@ -307,7 +307,6 @@
<ClInclude Include="..\..\src\core\json\json_reader.h" /> <ClInclude Include="..\..\src\core\json\json_reader.h" />
<ClInclude Include="..\..\src\core\json\json_writer.h" /> <ClInclude Include="..\..\src\core\json\json_writer.h" />
<ClInclude Include="..\..\src\core\profiling\timers.h" /> <ClInclude Include="..\..\src\core\profiling\timers.h" />
<ClInclude Include="..\..\src\core\profiling\timers_preciseclock.h" />
<ClInclude Include="..\..\src\core\statistics\census_interface.h" /> <ClInclude Include="..\..\src\core\statistics\census_interface.h" />
<ClInclude Include="..\..\src\core\statistics\census_rpc_stats.h" /> <ClInclude Include="..\..\src\core\statistics\census_rpc_stats.h" />
<ClInclude Include="..\..\src\core\surface\byte_buffer_queue.h" /> <ClInclude Include="..\..\src\core\surface\byte_buffer_queue.h" />

@ -680,9 +680,6 @@
<ClInclude Include="..\..\src\core\profiling\timers.h"> <ClInclude Include="..\..\src\core\profiling\timers.h">
<Filter>src\core\profiling</Filter> <Filter>src\core\profiling</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\src\core\profiling\timers_preciseclock.h">
<Filter>src\core\profiling</Filter>
</ClInclude>
<ClInclude Include="..\..\src\core\statistics\census_interface.h"> <ClInclude Include="..\..\src\core\statistics\census_interface.h">
<Filter>src\core\statistics</Filter> <Filter>src\core\statistics</Filter>
</ClInclude> </ClInclude>

@ -290,7 +290,6 @@
<ClInclude Include="..\..\src\core\json\json_reader.h" /> <ClInclude Include="..\..\src\core\json\json_reader.h" />
<ClInclude Include="..\..\src\core\json\json_writer.h" /> <ClInclude Include="..\..\src\core\json\json_writer.h" />
<ClInclude Include="..\..\src\core\profiling\timers.h" /> <ClInclude Include="..\..\src\core\profiling\timers.h" />
<ClInclude Include="..\..\src\core\profiling\timers_preciseclock.h" />
<ClInclude Include="..\..\src\core\statistics\census_interface.h" /> <ClInclude Include="..\..\src\core\statistics\census_interface.h" />
<ClInclude Include="..\..\src\core\statistics\census_rpc_stats.h" /> <ClInclude Include="..\..\src\core\statistics\census_rpc_stats.h" />
<ClInclude Include="..\..\src\core\surface\byte_buffer_queue.h" /> <ClInclude Include="..\..\src\core\surface\byte_buffer_queue.h" />

@ -578,9 +578,6 @@
<ClInclude Include="..\..\src\core\profiling\timers.h"> <ClInclude Include="..\..\src\core\profiling\timers.h">
<Filter>src\core\profiling</Filter> <Filter>src\core\profiling</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\src\core\profiling\timers_preciseclock.h">
<Filter>src\core\profiling</Filter>
</ClInclude>
<ClInclude Include="..\..\src\core\statistics\census_interface.h"> <ClInclude Include="..\..\src\core\statistics\census_interface.h">
<Filter>src\core\statistics</Filter> <Filter>src\core\statistics</Filter>
</ClInclude> </ClInclude>

Loading…
Cancel
Save