Merge github.com:grpc/grpc into plucking-hell

Conflicts:
	Makefile
pull/2713/head
Craig Tiller 10 years ago
commit 42ce225d50
  1. 3
      .gitignore
  2. 12
      BUILD
  3. 243
      Makefile
  4. 4
      build.json
  5. 6
      gRPC.podspec
  6. 2
      include/grpc/grpc.h
  7. 2
      include/grpc/support/atm_gcc_atomic.h
  8. 5
      include/grpc/support/atm_gcc_sync.h
  9. 5
      include/grpc/support/atm_win32.h
  10. 44
      src/core/channel/http_client_filter.c
  11. 10
      src/core/channel/http_server_filter.c
  12. 16
      src/core/client_config/resolvers/dns_resolver.c
  13. 43
      src/core/client_config/subchannel_factory_decorators/add_channel_arg.c
  14. 45
      src/core/client_config/subchannel_factory_decorators/add_channel_arg.h
  15. 84
      src/core/client_config/subchannel_factory_decorators/merge_channel_args.c
  16. 45
      src/core/client_config/subchannel_factory_decorators/merge_channel_args.h
  17. 6
      src/core/iomgr/fd_posix.c
  18. 1
      src/core/iomgr/fd_posix.h
  19. 2
      src/core/iomgr/tcp_server_posix.c
  20. 12
      src/core/support/stack_lockfree.c
  21. 18
      src/core/surface/channel.c
  22. 11
      src/core/surface/server.c
  23. 6
      src/objective-c/generated_libraries/RemoteTestClient/RemoteTest.podspec
  24. 6
      src/objective-c/generated_libraries/RouteGuideClient/RouteGuide.podspec
  25. 3
      src/objective-c/tests/GRPCClientTests.m
  26. 4
      src/objective-c/tests/InteropTests.m
  27. 6
      src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/AllTests.xcscheme
  28. 34
      src/objective-c/tests/build_tests.sh
  29. 7
      src/objective-c/tests/run_tests.sh
  30. 2
      src/python/grpcio/.gitignore
  31. 1
      src/python/grpcio/MANIFEST.in
  32. 0
      src/python/grpcio/README.rst
  33. 1
      src/python/grpcio/commands.py
  34. 0
      src/python/grpcio/grpc/__init__.py
  35. 0
      src/python/grpcio/grpc/_adapter/.gitignore
  36. 0
      src/python/grpcio/grpc/_adapter/__init__.py
  37. 0
      src/python/grpcio/grpc/_adapter/_c/module.c
  38. 0
      src/python/grpcio/grpc/_adapter/_c/types.c
  39. 0
      src/python/grpcio/grpc/_adapter/_c/types.h
  40. 0
      src/python/grpcio/grpc/_adapter/_c/types/call.c
  41. 0
      src/python/grpcio/grpc/_adapter/_c/types/channel.c
  42. 0
      src/python/grpcio/grpc/_adapter/_c/types/client_credentials.c
  43. 0
      src/python/grpcio/grpc/_adapter/_c/types/completion_queue.c
  44. 0
      src/python/grpcio/grpc/_adapter/_c/types/server.c
  45. 0
      src/python/grpcio/grpc/_adapter/_c/types/server_credentials.c
  46. 0
      src/python/grpcio/grpc/_adapter/_c/utility.c
  47. 0
      src/python/grpcio/grpc/_adapter/_common.py
  48. 0
      src/python/grpcio/grpc/_adapter/_intermediary_low.py
  49. 0
      src/python/grpcio/grpc/_adapter/_low.py
  50. 0
      src/python/grpcio/grpc/_adapter/_types.py
  51. 0
      src/python/grpcio/grpc/_adapter/fore.py
  52. 0
      src/python/grpcio/grpc/_adapter/rear.py
  53. 0
      src/python/grpcio/grpc/_cython/.gitignore
  54. 0
      src/python/grpcio/grpc/_cython/README.rst
  55. 0
      src/python/grpcio/grpc/_cython/__init__.py
  56. 0
      src/python/grpcio/grpc/_cython/_cygrpc/__init__.py
  57. 0
      src/python/grpcio/grpc/_cython/_cygrpc/call.pxd
  58. 0
      src/python/grpcio/grpc/_cython/_cygrpc/call.pyx
  59. 0
      src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd
  60. 0
      src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx
  61. 0
      src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pxd
  62. 0
      src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx
  63. 0
      src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd
  64. 0
      src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx
  65. 0
      src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxd
  66. 0
      src/python/grpcio/grpc/_cython/_cygrpc/records.pxd
  67. 0
      src/python/grpcio/grpc/_cython/_cygrpc/records.pyx
  68. 0
      src/python/grpcio/grpc/_cython/_cygrpc/server.pxd
  69. 0
      src/python/grpcio/grpc/_cython/_cygrpc/server.pyx
  70. 0
      src/python/grpcio/grpc/_cython/adapter_low.py
  71. 0
      src/python/grpcio/grpc/_cython/cygrpc.pyx
  72. 0
      src/python/grpcio/grpc/_links/__init__.py
  73. 0
      src/python/grpcio/grpc/_links/invocation.py
  74. 0
      src/python/grpcio/grpc/_links/service.py
  75. 0
      src/python/grpcio/grpc/early_adopter/__init__.py
  76. 0
      src/python/grpcio/grpc/early_adopter/implementations.py
  77. 0
      src/python/grpcio/grpc/framework/__init__.py
  78. 0
      src/python/grpcio/grpc/framework/alpha/__init__.py
  79. 0
      src/python/grpcio/grpc/framework/alpha/_face_utilities.py
  80. 0
      src/python/grpcio/grpc/framework/alpha/_reexport.py
  81. 0
      src/python/grpcio/grpc/framework/alpha/exceptions.py
  82. 0
      src/python/grpcio/grpc/framework/alpha/interfaces.py
  83. 0
      src/python/grpcio/grpc/framework/alpha/utilities.py
  84. 0
      src/python/grpcio/grpc/framework/base/__init__.py
  85. 0
      src/python/grpcio/grpc/framework/base/_cancellation.py
  86. 0
      src/python/grpcio/grpc/framework/base/_constants.py
  87. 0
      src/python/grpcio/grpc/framework/base/_context.py
  88. 0
      src/python/grpcio/grpc/framework/base/_emission.py
  89. 0
      src/python/grpcio/grpc/framework/base/_ends.py
  90. 0
      src/python/grpcio/grpc/framework/base/_expiration.py
  91. 0
      src/python/grpcio/grpc/framework/base/_ingestion.py
  92. 0
      src/python/grpcio/grpc/framework/base/_interfaces.py
  93. 0
      src/python/grpcio/grpc/framework/base/_reception.py
  94. 0
      src/python/grpcio/grpc/framework/base/_termination.py
  95. 0
      src/python/grpcio/grpc/framework/base/_transmission.py
  96. 0
      src/python/grpcio/grpc/framework/base/exceptions.py
  97. 0
      src/python/grpcio/grpc/framework/base/implementations.py
  98. 0
      src/python/grpcio/grpc/framework/base/in_memory.py
  99. 0
      src/python/grpcio/grpc/framework/base/interfaces.py
  100. 0
      src/python/grpcio/grpc/framework/base/null.py
  101. Some files were not shown because too many files have changed in this diff Show More

3
.gitignore vendored

@ -33,3 +33,6 @@ coverage
# Makefile's cache # Makefile's cache
cache.mk cache.mk
# Temporary test reports
report.xml

12
BUILD

@ -170,6 +170,8 @@ cc_library(
"src/core/client_config/resolvers/sockaddr_resolver.h", "src/core/client_config/resolvers/sockaddr_resolver.h",
"src/core/client_config/subchannel.h", "src/core/client_config/subchannel.h",
"src/core/client_config/subchannel_factory.h", "src/core/client_config/subchannel_factory.h",
"src/core/client_config/subchannel_factory_decorators/add_channel_arg.h",
"src/core/client_config/subchannel_factory_decorators/merge_channel_args.h",
"src/core/client_config/uri_parser.h", "src/core/client_config/uri_parser.h",
"src/core/compression/message_compress.h", "src/core/compression/message_compress.h",
"src/core/debug/trace.h", "src/core/debug/trace.h",
@ -289,6 +291,8 @@ cc_library(
"src/core/client_config/resolvers/sockaddr_resolver.c", "src/core/client_config/resolvers/sockaddr_resolver.c",
"src/core/client_config/subchannel.c", "src/core/client_config/subchannel.c",
"src/core/client_config/subchannel_factory.c", "src/core/client_config/subchannel_factory.c",
"src/core/client_config/subchannel_factory_decorators/add_channel_arg.c",
"src/core/client_config/subchannel_factory_decorators/merge_channel_args.c",
"src/core/client_config/uri_parser.c", "src/core/client_config/uri_parser.c",
"src/core/compression/algorithm.c", "src/core/compression/algorithm.c",
"src/core/compression/message_compress.c", "src/core/compression/message_compress.c",
@ -426,6 +430,8 @@ cc_library(
"src/core/client_config/resolvers/sockaddr_resolver.h", "src/core/client_config/resolvers/sockaddr_resolver.h",
"src/core/client_config/subchannel.h", "src/core/client_config/subchannel.h",
"src/core/client_config/subchannel_factory.h", "src/core/client_config/subchannel_factory.h",
"src/core/client_config/subchannel_factory_decorators/add_channel_arg.h",
"src/core/client_config/subchannel_factory_decorators/merge_channel_args.h",
"src/core/client_config/uri_parser.h", "src/core/client_config/uri_parser.h",
"src/core/compression/message_compress.h", "src/core/compression/message_compress.h",
"src/core/debug/trace.h", "src/core/debug/trace.h",
@ -522,6 +528,8 @@ cc_library(
"src/core/client_config/resolvers/sockaddr_resolver.c", "src/core/client_config/resolvers/sockaddr_resolver.c",
"src/core/client_config/subchannel.c", "src/core/client_config/subchannel.c",
"src/core/client_config/subchannel_factory.c", "src/core/client_config/subchannel_factory.c",
"src/core/client_config/subchannel_factory_decorators/add_channel_arg.c",
"src/core/client_config/subchannel_factory_decorators/merge_channel_args.c",
"src/core/client_config/uri_parser.c", "src/core/client_config/uri_parser.c",
"src/core/compression/algorithm.c", "src/core/compression/algorithm.c",
"src/core/compression/message_compress.c", "src/core/compression/message_compress.c",
@ -1005,6 +1013,8 @@ objc_library(
"src/core/client_config/resolvers/sockaddr_resolver.c", "src/core/client_config/resolvers/sockaddr_resolver.c",
"src/core/client_config/subchannel.c", "src/core/client_config/subchannel.c",
"src/core/client_config/subchannel_factory.c", "src/core/client_config/subchannel_factory.c",
"src/core/client_config/subchannel_factory_decorators/add_channel_arg.c",
"src/core/client_config/subchannel_factory_decorators/merge_channel_args.c",
"src/core/client_config/uri_parser.c", "src/core/client_config/uri_parser.c",
"src/core/compression/algorithm.c", "src/core/compression/algorithm.c",
"src/core/compression/message_compress.c", "src/core/compression/message_compress.c",
@ -1144,6 +1154,8 @@ objc_library(
"src/core/client_config/resolvers/sockaddr_resolver.h", "src/core/client_config/resolvers/sockaddr_resolver.h",
"src/core/client_config/subchannel.h", "src/core/client_config/subchannel.h",
"src/core/client_config/subchannel_factory.h", "src/core/client_config/subchannel_factory.h",
"src/core/client_config/subchannel_factory_decorators/add_channel_arg.h",
"src/core/client_config/subchannel_factory_decorators/merge_channel_args.h",
"src/core/client_config/uri_parser.h", "src/core/client_config/uri_parser.h",
"src/core/compression/message_compress.h", "src/core/compression/message_compress.h",
"src/core/debug/trace.h", "src/core/debug/trace.h",

File diff suppressed because one or more lines are too long

@ -135,6 +135,8 @@
"src/core/client_config/resolvers/sockaddr_resolver.h", "src/core/client_config/resolvers/sockaddr_resolver.h",
"src/core/client_config/subchannel.h", "src/core/client_config/subchannel.h",
"src/core/client_config/subchannel_factory.h", "src/core/client_config/subchannel_factory.h",
"src/core/client_config/subchannel_factory_decorators/add_channel_arg.h",
"src/core/client_config/subchannel_factory_decorators/merge_channel_args.h",
"src/core/client_config/uri_parser.h", "src/core/client_config/uri_parser.h",
"src/core/compression/message_compress.h", "src/core/compression/message_compress.h",
"src/core/debug/trace.h", "src/core/debug/trace.h",
@ -230,6 +232,8 @@
"src/core/client_config/resolvers/sockaddr_resolver.c", "src/core/client_config/resolvers/sockaddr_resolver.c",
"src/core/client_config/subchannel.c", "src/core/client_config/subchannel.c",
"src/core/client_config/subchannel_factory.c", "src/core/client_config/subchannel_factory.c",
"src/core/client_config/subchannel_factory_decorators/add_channel_arg.c",
"src/core/client_config/subchannel_factory_decorators/merge_channel_args.c",
"src/core/client_config/uri_parser.c", "src/core/client_config/uri_parser.c",
"src/core/compression/algorithm.c", "src/core/compression/algorithm.c",
"src/core/compression/message_compress.c", "src/core/compression/message_compress.c",

@ -172,6 +172,8 @@ Pod::Spec.new do |s|
'src/core/client_config/resolvers/sockaddr_resolver.h', 'src/core/client_config/resolvers/sockaddr_resolver.h',
'src/core/client_config/subchannel.h', 'src/core/client_config/subchannel.h',
'src/core/client_config/subchannel_factory.h', 'src/core/client_config/subchannel_factory.h',
'src/core/client_config/subchannel_factory_decorators/add_channel_arg.h',
'src/core/client_config/subchannel_factory_decorators/merge_channel_args.h',
'src/core/client_config/uri_parser.h', 'src/core/client_config/uri_parser.h',
'src/core/compression/message_compress.h', 'src/core/compression/message_compress.h',
'src/core/debug/trace.h', 'src/core/debug/trace.h',
@ -298,6 +300,8 @@ Pod::Spec.new do |s|
'src/core/client_config/resolvers/sockaddr_resolver.c', 'src/core/client_config/resolvers/sockaddr_resolver.c',
'src/core/client_config/subchannel.c', 'src/core/client_config/subchannel.c',
'src/core/client_config/subchannel_factory.c', 'src/core/client_config/subchannel_factory.c',
'src/core/client_config/subchannel_factory_decorators/add_channel_arg.c',
'src/core/client_config/subchannel_factory_decorators/merge_channel_args.c',
'src/core/client_config/uri_parser.c', 'src/core/client_config/uri_parser.c',
'src/core/compression/algorithm.c', 'src/core/compression/algorithm.c',
'src/core/compression/message_compress.c', 'src/core/compression/message_compress.c',
@ -436,6 +440,8 @@ Pod::Spec.new do |s|
'src/core/client_config/resolvers/sockaddr_resolver.h', 'src/core/client_config/resolvers/sockaddr_resolver.h',
'src/core/client_config/subchannel.h', 'src/core/client_config/subchannel.h',
'src/core/client_config/subchannel_factory.h', 'src/core/client_config/subchannel_factory.h',
'src/core/client_config/subchannel_factory_decorators/add_channel_arg.h',
'src/core/client_config/subchannel_factory_decorators/merge_channel_args.h',
'src/core/client_config/uri_parser.h', 'src/core/client_config/uri_parser.h',
'src/core/compression/message_compress.h', 'src/core/compression/message_compress.h',
'src/core/debug/trace.h', 'src/core/debug/trace.h',

@ -126,6 +126,8 @@ typedef struct {
/** Initial sequence number for http2 transports */ /** Initial sequence number for http2 transports */
#define GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER \ #define GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER \
"grpc.http2.initial_sequence_number" "grpc.http2.initial_sequence_number"
/** Default authority to pass if none specified on call construction */
#define GRPC_ARG_DEFAULT_AUTHORITY "grpc.default_authority"
/** Primary user agent: goes at the start of the user-agent metadata /** Primary user agent: goes at the start of the user-agent metadata
sent on each request */ sent on each request */
#define GRPC_ARG_PRIMARY_USER_AGENT_STRING "grpc.primary_user_agent" #define GRPC_ARG_PRIMARY_USER_AGENT_STRING "grpc.primary_user_agent"

@ -46,6 +46,8 @@ typedef gpr_intptr gpr_atm;
#define gpr_atm_no_barrier_load(p) (__atomic_load_n((p), __ATOMIC_RELAXED)) #define gpr_atm_no_barrier_load(p) (__atomic_load_n((p), __ATOMIC_RELAXED))
#define gpr_atm_rel_store(p, value) \ #define gpr_atm_rel_store(p, value) \
(__atomic_store_n((p), (gpr_intptr)(value), __ATOMIC_RELEASE)) (__atomic_store_n((p), (gpr_intptr)(value), __ATOMIC_RELEASE))
#define gpr_atm_no_barrier_store(p, value) \
(__atomic_store_n((p), (gpr_intptr)(value), __ATOMIC_RELAXED))
#define gpr_atm_no_barrier_fetch_add(p, delta) \ #define gpr_atm_no_barrier_fetch_add(p, delta) \
(__atomic_fetch_add((p), (gpr_intptr)(delta), __ATOMIC_RELAXED)) (__atomic_fetch_add((p), (gpr_intptr)(delta), __ATOMIC_RELAXED))

@ -68,6 +68,11 @@ static __inline void gpr_atm_rel_store(gpr_atm *p, gpr_atm value) {
*p = value; *p = value;
} }
static __inline void gpr_atm_no_barrier_store(gpr_atm *p, gpr_atm value) {
GPR_ATM_COMPILE_BARRIER_();
*p = value;
}
#undef GPR_ATM_LS_BARRIER_ #undef GPR_ATM_LS_BARRIER_
#undef GPR_ATM_COMPILE_BARRIER_ #undef GPR_ATM_COMPILE_BARRIER_

@ -57,6 +57,11 @@ static __inline void gpr_atm_rel_store(gpr_atm *p, gpr_atm value) {
*p = value; *p = value;
} }
static __inline void gpr_atm_no_barrier_store(gpr_atm *p, gpr_atm value) {
/* TODO(ctiller): Can we implement something better here? */
gpr_atm_rel_store(p, value);
}
static __inline int gpr_atm_no_barrier_cas(gpr_atm *p, gpr_atm o, gpr_atm n) { static __inline int gpr_atm_no_barrier_cas(gpr_atm *p, gpr_atm o, gpr_atm n) {
/* InterlockedCompareExchangePointerNoFence() not available on vista or /* InterlockedCompareExchangePointerNoFence() not available on vista or
windows7 */ windows7 */

@ -40,10 +40,12 @@
typedef struct call_data { typedef struct call_data {
grpc_linked_mdelem method; grpc_linked_mdelem method;
grpc_linked_mdelem scheme; grpc_linked_mdelem scheme;
grpc_linked_mdelem authority;
grpc_linked_mdelem te_trailers; grpc_linked_mdelem te_trailers;
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;
@ -62,6 +64,7 @@ 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;
@ -100,6 +103,7 @@ 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;
@ -107,6 +111,10 @@ 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;
} }
@ -130,6 +138,11 @@ 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,
@ -162,6 +175,7 @@ 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);
@ -241,8 +255,10 @@ static grpc_mdstr *user_agent_from_args(grpc_mdctx *mdctx,
/* Constructor for channel_data */ /* Constructor for channel_data */
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 *args, grpc_mdctx *mdctx, const grpc_channel_args *channel_args,
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;
@ -251,17 +267,32 @@ 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");
channeld->scheme = channeld->scheme = grpc_mdelem_from_strings(mdctx, ":scheme",
grpc_mdelem_from_strings(mdctx, ":scheme", scheme_from_args(args)); scheme_from_args(channel_args));
channeld->content_type = channeld->content_type =
grpc_mdelem_from_strings(mdctx, "content-type", "application/grpc"); grpc_mdelem_from_strings(mdctx, "content-type", "application/grpc");
channeld->status = grpc_mdelem_from_strings(mdctx, ":status", "200"); channeld->status = grpc_mdelem_from_strings(mdctx, ":status", "200");
channeld->user_agent = grpc_mdelem_from_metadata_strings( channeld->user_agent = grpc_mdelem_from_metadata_strings(
mdctx, grpc_mdstr_from_string(mdctx, "user-agent", 0), mdctx, grpc_mdstr_from_string(mdctx, "user-agent", 0),
user_agent_from_args(mdctx, args)); user_agent_from_args(mdctx, channel_args));
} }
/* Destructor for channel data */ /* Destructor for channel data */
@ -275,6 +306,9 @@ 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 = {

@ -44,6 +44,7 @@ typedef struct call_data {
gpr_uint8 sent_status; gpr_uint8 sent_status;
gpr_uint8 seen_scheme; gpr_uint8 seen_scheme;
gpr_uint8 seen_te_trailers; gpr_uint8 seen_te_trailers;
gpr_uint8 seen_authority;
grpc_linked_mdelem status; grpc_linked_mdelem status;
grpc_stream_op_buffer *recv_ops; grpc_stream_op_buffer *recv_ops;
@ -125,6 +126,9 @@ static grpc_mdelem *server_filter(void *user_data, grpc_mdelem *md) {
} }
calld->seen_path = 1; calld->seen_path = 1;
return md; return md;
} else if (md->key == channeld->authority_key) {
calld->seen_authority = 1;
return md;
} else if (md->key == channeld->host_key) { } else if (md->key == channeld->host_key) {
/* translate host to :authority since :authority may be /* translate host to :authority since :authority may be
omitted */ omitted */
@ -132,6 +136,7 @@ static grpc_mdelem *server_filter(void *user_data, grpc_mdelem *md) {
channeld->mdctx, GRPC_MDSTR_REF(channeld->authority_key), channeld->mdctx, GRPC_MDSTR_REF(channeld->authority_key),
GRPC_MDSTR_REF(md->value)); GRPC_MDSTR_REF(md->value));
GRPC_MDELEM_UNREF(md); GRPC_MDELEM_UNREF(md);
calld->seen_authority = 1;
return authority; return authority;
} else { } else {
return md; return md;
@ -154,12 +159,15 @@ static void hs_on_recv(void *user_data, int success) {
(:method, :scheme, content-type, with :path and :authority covered (:method, :scheme, content-type, with :path and :authority covered
at the channel level right now) */ at the channel level right now) */
if (calld->seen_post && calld->seen_scheme && calld->seen_te_trailers && if (calld->seen_post && calld->seen_scheme && calld->seen_te_trailers &&
calld->seen_path) { calld->seen_path && calld->seen_authority) {
/* do nothing */ /* do nothing */
} else { } else {
if (!calld->seen_path) { if (!calld->seen_path) {
gpr_log(GPR_ERROR, "Missing :path header"); gpr_log(GPR_ERROR, "Missing :path header");
} }
if (!calld->seen_authority) {
gpr_log(GPR_ERROR, "Missing :authority header");
}
if (!calld->seen_post) { if (!calld->seen_post) {
gpr_log(GPR_ERROR, "Missing :method header"); gpr_log(GPR_ERROR, "Missing :method header");
} }

@ -36,9 +36,11 @@
#include <string.h> #include <string.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/host_port.h>
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
#include "src/core/client_config/lb_policies/pick_first.h" #include "src/core/client_config/lb_policies/pick_first.h"
#include "src/core/client_config/subchannel_factory_decorators/add_channel_arg.h"
#include "src/core/iomgr/resolve_address.h" #include "src/core/iomgr/resolve_address.h"
#include "src/core/support/string.h" #include "src/core/support/string.h"
@ -201,6 +203,9 @@ 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");
@ -209,6 +214,16 @@ 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);
@ -218,7 +233,6 @@ static grpc_resolver *dns_create(
r->default_port = gpr_strdup(default_port); r->default_port = gpr_strdup(default_port);
r->subchannel_factory = subchannel_factory; r->subchannel_factory = subchannel_factory;
r->lb_policy_factory = lb_policy_factory; r->lb_policy_factory = lb_policy_factory;
grpc_subchannel_factory_ref(subchannel_factory);
return &r->base; return &r->base;
} }

@ -0,0 +1,43 @@
/*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "src/core/client_config/subchannel_factory_decorators/add_channel_arg.h"
#include "src/core/client_config/subchannel_factory_decorators/merge_channel_args.h"
grpc_subchannel_factory *grpc_subchannel_factory_add_channel_arg(
grpc_subchannel_factory *input, const grpc_arg *arg) {
grpc_channel_args args;
args.num_args = 1;
args.args = (grpc_arg *)arg;
return grpc_subchannel_factory_merge_channel_args(input, &args);
}

@ -0,0 +1,45 @@
/*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_FACTORY_DECORATORS_ADD_CHANNEL_ARG_H
#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_FACTORY_DECORATORS_ADD_CHANNEL_ARG_H
#include "src/core/client_config/subchannel_factory.h"
/** Takes a subchannel factory, returns a new one that mutates incoming
channel_args by adding a new argument; ownership of input, arg is retained
by the caller. */
grpc_subchannel_factory *grpc_subchannel_factory_add_channel_arg(
grpc_subchannel_factory *input, const grpc_arg *arg);
#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_FACTORY_DECORATORS_ADD_CHANNEL_ARG_H */

@ -0,0 +1,84 @@
/*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "src/core/client_config/subchannel_factory_decorators/merge_channel_args.h"
#include <grpc/support/alloc.h>
#include "src/core/channel/channel_args.h"
typedef struct {
grpc_subchannel_factory base;
gpr_refcount refs;
grpc_subchannel_factory *wrapped;
grpc_channel_args *merge_args;
} merge_args_factory;
static void merge_args_factory_ref(grpc_subchannel_factory *scf) {
merge_args_factory *f = (merge_args_factory *)scf;
gpr_ref(&f->refs);
}
static void merge_args_factory_unref(grpc_subchannel_factory *scf) {
merge_args_factory *f = (merge_args_factory *)scf;
if (gpr_unref(&f->refs)) {
grpc_subchannel_factory_unref(f->wrapped);
grpc_channel_args_destroy(f->merge_args);
gpr_free(f);
}
}
static grpc_subchannel *merge_args_factory_create_subchannel(
grpc_subchannel_factory *scf, grpc_subchannel_args *args) {
merge_args_factory *f = (merge_args_factory *)scf;
grpc_channel_args *final_args =
grpc_channel_args_merge(args->args, f->merge_args);
grpc_subchannel *s;
args->args = final_args;
s = grpc_subchannel_factory_create_subchannel(f->wrapped, args);
grpc_channel_args_destroy(final_args);
return s;
}
static const grpc_subchannel_factory_vtable merge_args_factory_vtable = {
merge_args_factory_ref, merge_args_factory_unref,
merge_args_factory_create_subchannel};
grpc_subchannel_factory *grpc_subchannel_factory_merge_channel_args(
grpc_subchannel_factory *input, const grpc_channel_args *args) {
merge_args_factory *f = gpr_malloc(sizeof(*f));
f->base.vtable = &merge_args_factory_vtable;
gpr_ref_init(&f->refs, 1);
grpc_subchannel_factory_ref(input);
f->wrapped = input;
f->merge_args = grpc_channel_args_copy(args);
return &f->base;
}

@ -0,0 +1,45 @@
/*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_FACTORY_DECORATORS_MERGE_CHANNEL_ARGS_H
#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_FACTORY_DECORATORS_MERGE_CHANNEL_ARGS_H
#include "src/core/client_config/subchannel_factory.h"
/** Takes a subchannel factory, returns a new one that mutates incoming
channel_args by adding a new argument; ownership of input, args is retained
by the caller. */
grpc_subchannel_factory *grpc_subchannel_factory_merge_channel_args(
grpc_subchannel_factory *input, const grpc_channel_args *args);
#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_FACTORY_DECORATORS_MERGE_CHANNEL_ARGS_H */

@ -102,6 +102,7 @@ static grpc_fd *alloc_fd(int fd) {
r->freelist_next = NULL; r->freelist_next = NULL;
r->read_watcher = r->write_watcher = NULL; r->read_watcher = r->write_watcher = NULL;
r->on_done_closure = NULL; r->on_done_closure = NULL;
r->closed = 0;
return r; return r;
} }
@ -215,6 +216,8 @@ void grpc_fd_orphan(grpc_fd *fd, grpc_iomgr_closure *on_done,
REF_BY(fd, 1, reason); /* remove active status, but keep referenced */ REF_BY(fd, 1, reason); /* remove active status, but keep referenced */
gpr_mu_lock(&fd->watcher_mu); gpr_mu_lock(&fd->watcher_mu);
if (!has_watchers(fd)) { if (!has_watchers(fd)) {
GPR_ASSERT(!fd->closed);
fd->closed = 1;
close(fd->fd); close(fd->fd);
if (fd->on_done_closure) { if (fd->on_done_closure) {
grpc_iomgr_add_callback(fd->on_done_closure); grpc_iomgr_add_callback(fd->on_done_closure);
@ -432,7 +435,8 @@ void grpc_fd_end_poll(grpc_fd_watcher *watcher, int got_read, int got_write) {
if (kick) { if (kick) {
maybe_wake_one_watcher_locked(fd); maybe_wake_one_watcher_locked(fd);
} }
if (grpc_fd_is_orphaned(fd) && !has_watchers(fd)) { if (grpc_fd_is_orphaned(fd) && !has_watchers(fd) && !fd->closed) {
fd->closed = 1;
close(fd->fd); close(fd->fd);
if (fd->on_done_closure != NULL) { if (fd->on_done_closure != NULL) {
grpc_iomgr_add_callback(fd->on_done_closure); grpc_iomgr_add_callback(fd->on_done_closure);

@ -60,6 +60,7 @@ struct grpc_fd {
gpr_mu set_state_mu; gpr_mu set_state_mu;
gpr_atm shutdown; gpr_atm shutdown;
int closed;
/* The watcher list. /* The watcher list.

@ -142,6 +142,7 @@ grpc_tcp_server *grpc_tcp_server_create(void) {
static void finish_shutdown(grpc_tcp_server *s) { static void finish_shutdown(grpc_tcp_server *s) {
s->shutdown_complete(s->shutdown_complete_arg); s->shutdown_complete(s->shutdown_complete_arg);
s->shutdown_complete = NULL;
gpr_mu_destroy(&s->mu); gpr_mu_destroy(&s->mu);
@ -157,6 +158,7 @@ static void destroyed_port(void *server, int success) {
gpr_mu_unlock(&s->mu); gpr_mu_unlock(&s->mu);
finish_shutdown(s); finish_shutdown(s);
} else { } else {
GPR_ASSERT(s->destroyed_ports < s->nports);
gpr_mu_unlock(&s->mu); gpr_mu_unlock(&s->mu);
} }
} }

@ -95,6 +95,8 @@ gpr_stack_lockfree *gpr_stack_lockfree_create(int entries) {
memset(&stack->pushed, 0, sizeof(stack->pushed)); memset(&stack->pushed, 0, sizeof(stack->pushed));
#endif #endif
GPR_ASSERT(sizeof(stack->entries->atm) == sizeof(stack->entries->contents));
/* Point the head at reserved dummy entry */ /* Point the head at reserved dummy entry */
stack->head.contents.index = INVALID_ENTRY_INDEX; stack->head.contents.index = INVALID_ENTRY_INDEX;
return stack; return stack;
@ -108,11 +110,15 @@ void gpr_stack_lockfree_destroy(gpr_stack_lockfree *stack) {
int gpr_stack_lockfree_push(gpr_stack_lockfree *stack, int entry) { int gpr_stack_lockfree_push(gpr_stack_lockfree *stack, int entry) {
lockfree_node head; lockfree_node head;
lockfree_node newhead; lockfree_node newhead;
lockfree_node curent;
lockfree_node newent;
/* First fill in the entry's index and aba ctr for new head */ /* First fill in the entry's index and aba ctr for new head */
newhead.contents.index = (gpr_uint16)entry; newhead.contents.index = (gpr_uint16)entry;
/* Also post-increment the aba_ctr */ /* Also post-increment the aba_ctr */
newhead.contents.aba_ctr = stack->entries[entry].contents.aba_ctr++; curent.atm = gpr_atm_no_barrier_load(&stack->entries[entry].atm);
newhead.contents.aba_ctr = ++curent.contents.aba_ctr;
gpr_atm_no_barrier_store(&stack->entries[entry].atm, curent.atm);
#ifndef NDEBUG #ifndef NDEBUG
/* Check for double push */ /* Check for double push */
@ -131,7 +137,9 @@ int gpr_stack_lockfree_push(gpr_stack_lockfree *stack, int entry) {
/* Atomically get the existing head value for use */ /* Atomically get the existing head value for use */
head.atm = gpr_atm_no_barrier_load(&(stack->head.atm)); head.atm = gpr_atm_no_barrier_load(&(stack->head.atm));
/* Point to it */ /* Point to it */
stack->entries[entry].contents.index = head.contents.index; newent.atm = gpr_atm_no_barrier_load(&stack->entries[entry].atm);
newent.contents.index = head.contents.index;
gpr_atm_no_barrier_store(&stack->entries[entry].atm, newent.atm);
} while (!gpr_atm_rel_cas(&(stack->head.atm), head.atm, newhead.atm)); } while (!gpr_atm_rel_cas(&(stack->head.atm), head.atm, newhead.atm));
/* Use rel_cas above to make sure that entry index is set properly */ /* Use rel_cas above to make sure that entry index is set properly */
return head.contents.index == INVALID_ENTRY_INDEX; return head.contents.index == INVALID_ENTRY_INDEX;

@ -149,14 +149,17 @@ static grpc_call *grpc_channel_create_call_internal(
grpc_channel *channel, grpc_completion_queue *cq, grpc_mdelem *path_mdelem, grpc_channel *channel, grpc_completion_queue *cq, grpc_mdelem *path_mdelem,
grpc_mdelem *authority_mdelem, gpr_timespec deadline) { grpc_mdelem *authority_mdelem, gpr_timespec deadline) {
grpc_mdelem *send_metadata[2]; grpc_mdelem *send_metadata[2];
int num_metadata = 0;
GPR_ASSERT(channel->is_client); GPR_ASSERT(channel->is_client);
send_metadata[0] = path_mdelem; send_metadata[num_metadata++] = path_mdelem;
send_metadata[1] = authority_mdelem; if (authority_mdelem != NULL) {
send_metadata[num_metadata++] = authority_mdelem;
}
return grpc_call_create(channel, cq, NULL, send_metadata, return grpc_call_create(channel, cq, NULL, send_metadata,
GPR_ARRAY_SIZE(send_metadata), deadline); num_metadata, deadline);
} }
grpc_call *grpc_channel_create_call(grpc_channel *channel, grpc_call *grpc_channel_create_call(grpc_channel *channel,
@ -168,9 +171,10 @@ grpc_call *grpc_channel_create_call(grpc_channel *channel,
grpc_mdelem_from_metadata_strings( grpc_mdelem_from_metadata_strings(
channel->metadata_context, GRPC_MDSTR_REF(channel->path_string), channel->metadata_context, GRPC_MDSTR_REF(channel->path_string),
grpc_mdstr_from_string(channel->metadata_context, method, 0)), grpc_mdstr_from_string(channel->metadata_context, method, 0)),
host ?
grpc_mdelem_from_metadata_strings( grpc_mdelem_from_metadata_strings(
channel->metadata_context, GRPC_MDSTR_REF(channel->authority_string), channel->metadata_context, GRPC_MDSTR_REF(channel->authority_string),
grpc_mdstr_from_string(channel->metadata_context, host, 0)), grpc_mdstr_from_string(channel->metadata_context, host, 0)) : NULL,
deadline); deadline);
} }
@ -180,9 +184,9 @@ void *grpc_channel_register_call(grpc_channel *channel, const char *method,
rc->path = grpc_mdelem_from_metadata_strings( rc->path = grpc_mdelem_from_metadata_strings(
channel->metadata_context, GRPC_MDSTR_REF(channel->path_string), channel->metadata_context, GRPC_MDSTR_REF(channel->path_string),
grpc_mdstr_from_string(channel->metadata_context, method, 0)); grpc_mdstr_from_string(channel->metadata_context, method, 0));
rc->authority = grpc_mdelem_from_metadata_strings( rc->authority = host ? grpc_mdelem_from_metadata_strings(
channel->metadata_context, GRPC_MDSTR_REF(channel->authority_string), channel->metadata_context, GRPC_MDSTR_REF(channel->authority_string),
grpc_mdstr_from_string(channel->metadata_context, host, 0)); grpc_mdstr_from_string(channel->metadata_context, host, 0)) : NULL;
gpr_mu_lock(&channel->registered_call_mu); gpr_mu_lock(&channel->registered_call_mu);
rc->next = channel->registered_calls; rc->next = channel->registered_calls;
channel->registered_calls = rc; channel->registered_calls = rc;
@ -196,7 +200,7 @@ grpc_call *grpc_channel_create_registered_call(
registered_call *rc = registered_call_handle; registered_call *rc = registered_call_handle;
return grpc_channel_create_call_internal( return grpc_channel_create_call_internal(
channel, completion_queue, GRPC_MDELEM_REF(rc->path), channel, completion_queue, GRPC_MDELEM_REF(rc->path),
GRPC_MDELEM_REF(rc->authority), deadline); rc->authority ? GRPC_MDELEM_REF(rc->authority) : NULL, deadline);
} }
#ifdef GRPC_CHANNEL_REF_COUNT_DEBUG #ifdef GRPC_CHANNEL_REF_COUNT_DEBUG

@ -554,8 +554,10 @@ static void server_on_recv(void *ptr, int success) {
gpr_time_cmp(op_deadline, gpr_inf_future(op_deadline.clock_type))) { gpr_time_cmp(op_deadline, gpr_inf_future(op_deadline.clock_type))) {
calld->deadline = op->data.metadata.deadline; calld->deadline = op->data.metadata.deadline;
} }
calld->got_initial_metadata = 1; if (calld->host && calld->path) {
start_new_rpc(elem); calld->got_initial_metadata = 1;
start_new_rpc(elem);
}
break; break;
} }
} }
@ -1271,6 +1273,8 @@ static void done_request_event(void *req, grpc_cq_completion *c) {
} else { } else {
gpr_free(req); gpr_free(req);
} }
server_unref(server);
} }
static void fail_call(grpc_server *server, requested_call *rc) { static void fail_call(grpc_server *server, requested_call *rc) {
@ -1283,6 +1287,7 @@ static void fail_call(grpc_server *server, requested_call *rc) {
rc->data.registered.initial_metadata->count = 0; rc->data.registered.initial_metadata->count = 0;
break; break;
} }
server_ref(server);
grpc_cq_end_op(rc->cq_for_notification, rc->tag, 0, done_request_event, rc, grpc_cq_end_op(rc->cq_for_notification, rc->tag, 0, done_request_event, rc,
&rc->completion); &rc->completion);
} }
@ -1293,6 +1298,8 @@ static void publish_registered_or_batch(grpc_call *call, int success,
grpc_call_stack_element(grpc_call_get_call_stack(call), 0); grpc_call_stack_element(grpc_call_get_call_stack(call), 0);
requested_call *rc = prc; requested_call *rc = prc;
call_data *calld = elem->call_data; call_data *calld = elem->call_data;
channel_data *chand = elem->channel_data;
server_ref(chand->server);
grpc_cq_end_op(calld->cq_new, rc->tag, success, done_request_event, rc, grpc_cq_end_op(calld->cq_new, rc->tag, success, done_request_event, rc,
&rc->completion); &rc->completion);
GRPC_CALL_INTERNAL_UNREF(call, "server", 0); GRPC_CALL_INTERNAL_UNREF(call, "server", 0);

@ -8,11 +8,7 @@ Pod::Spec.new do |s|
# Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients. # Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients.
s.prepare_command = <<-CMD s.prepare_command = <<-CMD
cd ../../../.. protoc --plugin=protoc-gen-grpc=../../../../bins/$CONFIG/grpc_objective_c_plugin --objc_out=. --grpc_out=. *.proto
# TODO(jcanizales): Make only Objective-C plugin.
make plugins
cd -
protoc --plugin=protoc-gen-grpc=../../../../bins/opt/grpc_objective_c_plugin --objc_out=. --grpc_out=. *.proto
CMD CMD
s.subspec "Messages" do |ms| s.subspec "Messages" do |ms|

@ -8,11 +8,7 @@ Pod::Spec.new do |s|
# Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients. # Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients.
s.prepare_command = <<-CMD s.prepare_command = <<-CMD
cd ../../../.. protoc --plugin=protoc-gen-grpc=../../../../bins/$CONFIG/grpc_objective_c_plugin --objc_out=. --grpc_out=. *.proto
# TODO(jcanizales): Make only Objective-C plugin.
make plugins
cd -
protoc --plugin=protoc-gen-grpc=../../../../bins/opt/grpc_objective_c_plugin --objc_out=. --grpc_out=. *.proto
CMD CMD
s.subspec "Messages" do |ms| s.subspec "Messages" do |ms|

@ -43,7 +43,8 @@
// These are a few tests similar to InteropTests, but which use the generic gRPC client (GRPCCall) // These are a few tests similar to InteropTests, but which use the generic gRPC client (GRPCCall)
// rather than a generated proto library on top of it. // rather than a generated proto library on top of it.
static NSString * const kHostAddress = @"grpc-test.sandbox.google.com"; // grpc-test.sandbox.google.com
static NSString * const kHostAddress = @"http://localhost:5050";
static NSString * const kPackage = @"grpc.testing"; static NSString * const kPackage = @"grpc.testing";
static NSString * const kService = @"TestService"; static NSString * const kService = @"TestService";

@ -83,8 +83,10 @@
RMTTestService *_service; RMTTestService *_service;
} }
// grpc-test.sandbox.google.com
- (void)setUp { - (void)setUp {
_service = [[RMTTestService alloc] initWithHost:@"grpc-test.sandbox.google.com"]; _service = [[RMTTestService alloc] initWithHost:@"http://localhost:5050"];
} }
// Tests as described here: https://github.com/grpc/grpc/blob/master/doc/interop-test-descriptions.md // Tests as described here: https://github.com/grpc/grpc/blob/master/doc/interop-test-descriptions.md

@ -38,6 +38,12 @@
ReferencedContainer = "container:Tests.xcodeproj"> ReferencedContainer = "container:Tests.xcodeproj">
</BuildableReference> </BuildableReference>
<SkippedTests> <SkippedTests>
<Test
Identifier = "GRPCClientTests/testConnectionToRemoteServer">
</Test>
<Test
Identifier = "GRPCClientTests/testMetadata">
</Test>
<Test <Test
Identifier = "LocalClearTextTests"> Identifier = "LocalClearTextTests">
</Test> </Test>

@ -1,3 +1,4 @@
#!/bin/bash
# Copyright 2015, Google Inc. # Copyright 2015, Google Inc.
# All rights reserved. # All rights reserved.
# #
@ -27,31 +28,12 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""A setup module for the GRPC Python interop testing package.""" set -e
import setuptools cd $(dirname $0)
_PACKAGES = ( # The local test server needs to be compiled before this because pod install of
'interop', # gRPC renames some C gRPC files and not the server's code references to them.
) #
# Suppress error output because Cocoapods issue #3823 causes a flooding warning.
_PACKAGE_DIRECTORIES = { pod install 2>/dev/null
'interop': 'interop',
}
_PACKAGE_DATA = {
'interop': [
'credentials/ca.pem', 'credentials/server1.key',
'credentials/server1.pem',]
}
_INSTALL_REQUIRES = ['oauth2client>=1.4.7', 'grpcio>=0.10.0a0']
setuptools.setup(
name='interop',
version='0.0.1',
packages=_PACKAGES,
package_dir=_PACKAGE_DIRECTORIES,
package_data=_PACKAGE_DATA,
install_requires=_INSTALL_REQUIRES
)

@ -32,9 +32,10 @@ set -e
cd $(dirname $0) cd $(dirname $0)
# TODO(jcanizales): Remove when Cocoapods issue #3823 is resolved. # Run the tests server.
export COCOAPODS_DISABLE_DETERMINISTIC_UUIDS=YES ../../../bins/$CONFIG/interop_server --port=5050 &
pod install # Kill it when this script exits.
trap 'kill -9 `jobs -p`' EXIT
# xcodebuild is very verbose. We filter its output and tell Bash to fail if any # xcodebuild is very verbose. We filter its output and tell Bash to fail if any
# element of the pipe fails. # element of the pipe fails.

@ -1,5 +1,5 @@
MANIFEST MANIFEST
grpcio.egg-info/ *.egg-info/
build/ build/
dist/ dist/
*.egg *.egg

@ -1,2 +1,3 @@
graft grpc graft grpc
include commands.py include commands.py
include requirements.txt

@ -43,6 +43,7 @@ napoleon_numpy_docstring = True
html_theme = 'sphinx_rtd_theme' html_theme = 'sphinx_rtd_theme'
""" """
class SphinxDocumentation(setuptools.Command): class SphinxDocumentation(setuptools.Command):
"""Command to generate documentation via sphinx.""" """Command to generate documentation via sphinx."""

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save