grpc 1.13.0 → 1.14.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (213) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +403 -153
  3. data/include/grpc/grpc.h +0 -8
  4. data/include/grpc/grpc_security.h +59 -2
  5. data/include/grpc/impl/codegen/grpc_types.h +8 -2
  6. data/include/grpc/impl/codegen/log.h +112 -0
  7. data/include/grpc/module.modulemap +2 -0
  8. data/include/grpc/support/log.h +2 -88
  9. data/include/grpc/support/string_util.h +2 -0
  10. data/src/boringssl/err_data.c +597 -593
  11. data/src/core/ext/filters/client_channel/client_channel.cc +715 -770
  12. data/src/core/ext/filters/client_channel/client_channel.h +5 -0
  13. data/src/core/ext/filters/client_channel/client_channel_channelz.cc +111 -0
  14. data/src/core/ext/filters/client_channel/client_channel_channelz.h +69 -0
  15. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +9 -0
  16. data/src/core/ext/filters/client_channel/http_proxy.cc +22 -5
  17. data/src/core/ext/filters/client_channel/lb_policy.h +15 -0
  18. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +3 -0
  19. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +3 -3
  20. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +3 -1
  21. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c +19 -0
  22. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h +54 -0
  23. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c +19 -0
  24. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h +54 -0
  25. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +4 -17
  26. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +37 -63
  27. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +79 -0
  28. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +5 -2
  29. data/src/core/ext/filters/client_channel/lb_policy_factory.cc +8 -0
  30. data/src/core/ext/filters/client_channel/lb_policy_factory.h +4 -0
  31. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +2 -2
  32. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +317 -0
  33. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +48 -9
  34. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +40 -293
  35. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +106 -84
  36. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +6 -2
  37. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +6 -5
  38. data/src/core/ext/filters/client_channel/subchannel.cc +36 -6
  39. data/src/core/ext/filters/client_channel/subchannel.h +4 -0
  40. data/src/core/ext/filters/deadline/deadline_filter.cc +18 -15
  41. data/src/core/ext/filters/deadline/deadline_filter.h +5 -5
  42. data/src/core/ext/filters/http/client/http_client_filter.cc +10 -9
  43. data/src/core/ext/filters/http/server/http_server_filter.h +1 -1
  44. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +1 -1
  45. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +3 -2
  46. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +33 -22
  47. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +1 -1
  48. data/src/core/ext/transport/chttp2/transport/internal.h +10 -3
  49. data/src/core/ext/transport/chttp2/transport/stream_lists.cc +17 -0
  50. data/src/core/ext/transport/chttp2/transport/writing.cc +21 -16
  51. data/src/core/ext/transport/inproc/inproc_transport.cc +46 -6
  52. data/src/core/lib/channel/channel_stack.cc +22 -24
  53. data/src/core/lib/channel/channel_trace.cc +28 -63
  54. data/src/core/lib/channel/channel_trace.h +13 -17
  55. data/src/core/lib/channel/channelz.cc +143 -0
  56. data/src/core/lib/channel/channelz.h +124 -0
  57. data/src/core/lib/channel/channelz_registry.cc +7 -24
  58. data/src/core/lib/channel/channelz_registry.h +12 -8
  59. data/src/core/lib/channel/connected_channel.cc +8 -1
  60. data/src/core/{ext/filters/load_reporting/server_load_reporting_filter.h → lib/gpr/alloc.h} +7 -9
  61. data/src/core/lib/gpr/arena.cc +8 -8
  62. data/src/core/lib/gpr/string.cc +28 -0
  63. data/src/core/lib/gpr/string.h +10 -0
  64. data/src/core/lib/gprpp/abstract.h +5 -2
  65. data/src/core/lib/gprpp/inlined_vector.h +57 -3
  66. data/src/core/lib/gprpp/memory.h +2 -2
  67. data/src/core/lib/gprpp/ref_counted_ptr.h +5 -0
  68. data/src/core/lib/gprpp/thd_posix.cc +1 -1
  69. data/src/core/lib/iomgr/call_combiner.h +80 -0
  70. data/src/core/lib/iomgr/closure.h +3 -2
  71. data/src/core/lib/iomgr/endpoint_pair_posix.cc +2 -2
  72. data/src/core/lib/iomgr/error.cc +12 -0
  73. data/src/core/lib/iomgr/error.h +5 -0
  74. data/src/core/lib/iomgr/ev_epoll1_linux.cc +36 -9
  75. data/src/core/lib/iomgr/ev_epollex_linux.cc +172 -46
  76. data/src/core/lib/iomgr/ev_epollsig_linux.cc +47 -21
  77. data/src/core/lib/iomgr/ev_poll_posix.cc +10 -4
  78. data/src/core/lib/iomgr/ev_posix.cc +17 -9
  79. data/src/core/lib/iomgr/ev_posix.h +20 -4
  80. data/src/core/lib/iomgr/executor.cc +196 -140
  81. data/src/core/lib/iomgr/executor.h +47 -14
  82. data/src/core/lib/iomgr/iomgr.cc +2 -0
  83. data/src/core/lib/iomgr/iomgr.h +5 -0
  84. data/src/core/lib/iomgr/is_epollexclusive_available.cc +1 -0
  85. data/src/core/lib/iomgr/socket_utils.h +9 -0
  86. data/src/core/lib/iomgr/socket_utils_common_posix.cc +4 -0
  87. data/src/core/lib/iomgr/socket_utils_uv.cc +4 -0
  88. data/src/core/lib/iomgr/socket_utils_windows.cc +4 -0
  89. data/src/core/lib/iomgr/tcp_client_posix.cc +3 -5
  90. data/src/core/lib/iomgr/tcp_posix.cc +6 -1
  91. data/src/core/lib/iomgr/tcp_server_posix.cc +3 -3
  92. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +1 -1
  93. data/src/core/lib/iomgr/timer_manager.cc +0 -1
  94. data/src/core/lib/iomgr/udp_server.cc +2 -3
  95. data/src/core/lib/json/json.cc +10 -0
  96. data/src/core/lib/json/json.h +5 -0
  97. data/src/core/lib/security/context/security_context.cc +8 -8
  98. data/src/core/lib/security/context/security_context.h +6 -2
  99. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +2 -1
  100. data/src/core/lib/security/credentials/local/local_credentials.cc +77 -0
  101. data/src/core/lib/security/credentials/local/local_credentials.h +40 -0
  102. data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +17 -3
  103. data/src/core/lib/security/security_connector/local_security_connector.cc +245 -0
  104. data/src/core/lib/security/security_connector/local_security_connector.h +58 -0
  105. data/src/core/lib/security/security_connector/security_connector.cc +30 -5
  106. data/src/core/lib/security/security_connector/security_connector.h +1 -0
  107. data/src/core/lib/security/transport/client_auth_filter.cc +5 -1
  108. data/src/core/lib/security/transport/server_auth_filter.cc +4 -5
  109. data/src/core/lib/surface/call.cc +75 -32
  110. data/src/core/lib/surface/call.h +2 -0
  111. data/src/core/lib/surface/channel.cc +32 -13
  112. data/src/core/lib/surface/channel.h +4 -0
  113. data/src/core/lib/surface/version.cc +1 -1
  114. data/src/core/lib/transport/transport.cc +20 -9
  115. data/src/core/lib/transport/transport.h +12 -10
  116. data/src/core/lib/transport/transport_op_string.cc +0 -7
  117. data/src/core/plugin_registry/grpc_plugin_registry.cc +0 -4
  118. data/src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h +2 -2
  119. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +2 -1
  120. data/src/core/tsi/alts/handshaker/altscontext.pb.c +0 -1
  121. data/src/core/tsi/alts/handshaker/altscontext.pb.h +1 -2
  122. data/src/core/tsi/alts/handshaker/handshaker.pb.c +0 -1
  123. data/src/core/tsi/alts/handshaker/handshaker.pb.h +1 -2
  124. data/src/core/tsi/alts/handshaker/transport_security_common.pb.c +0 -1
  125. data/src/core/tsi/alts/handshaker/transport_security_common.pb.h +1 -1
  126. data/src/core/tsi/alts/handshaker/transport_security_common_api.h +2 -2
  127. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc +47 -1
  128. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.h +3 -1
  129. data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +12 -11
  130. data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h +7 -2
  131. data/src/core/tsi/local_transport_security.cc +209 -0
  132. data/src/core/tsi/local_transport_security.h +51 -0
  133. data/src/core/tsi/ssl_transport_security.cc +2 -3
  134. data/src/{core/ext → cpp/ext/filters}/census/grpc_context.cc +0 -0
  135. data/src/ruby/ext/grpc/rb_channel_credentials.c +3 -3
  136. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +18 -18
  137. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +29 -29
  138. data/src/ruby/lib/grpc/generic/active_call.rb +19 -23
  139. data/src/ruby/lib/grpc/version.rb +1 -1
  140. data/src/ruby/spec/call_credentials_spec.rb +1 -1
  141. data/src/ruby/spec/call_spec.rb +1 -1
  142. data/src/ruby/spec/channel_credentials_spec.rb +1 -1
  143. data/src/ruby/spec/channel_spec.rb +1 -1
  144. data/src/ruby/spec/client_auth_spec.rb +1 -12
  145. data/src/ruby/spec/client_server_spec.rb +1 -1
  146. data/src/ruby/spec/compression_options_spec.rb +1 -1
  147. data/src/ruby/spec/error_sanity_spec.rb +1 -1
  148. data/src/ruby/spec/generic/client_stub_spec.rb +13 -1
  149. data/src/ruby/spec/generic/rpc_desc_spec.rb +1 -1
  150. data/src/ruby/spec/generic/rpc_server_pool_spec.rb +1 -1
  151. data/src/ruby/spec/generic/service_spec.rb +1 -1
  152. data/src/ruby/spec/google_rpc_status_utils_spec.rb +1 -12
  153. data/src/ruby/spec/pb/duplicate/codegen_spec.rb +1 -0
  154. data/src/ruby/spec/pb/health/checker_spec.rb +1 -1
  155. data/src/ruby/spec/server_credentials_spec.rb +1 -1
  156. data/src/ruby/spec/server_spec.rb +1 -1
  157. data/src/ruby/spec/spec_helper.rb +1 -0
  158. data/src/ruby/spec/support/services.rb +1 -1
  159. data/src/ruby/spec/time_consts_spec.rb +1 -1
  160. data/third_party/boringssl/crypto/asn1/tasn_dec.c +40 -19
  161. data/third_party/boringssl/crypto/bytestring/cbs.c +1 -0
  162. data/third_party/boringssl/crypto/cipher_extra/e_aesccm.c +47 -15
  163. data/third_party/boringssl/crypto/ec_extra/ec_asn1.c +9 -10
  164. data/third_party/boringssl/crypto/ecdh/ecdh.c +4 -3
  165. data/third_party/boringssl/crypto/fipsmodule/bn/add.c +30 -54
  166. data/third_party/boringssl/crypto/fipsmodule/bn/bn.c +7 -1
  167. data/third_party/boringssl/crypto/fipsmodule/bn/cmp.c +8 -8
  168. data/third_party/boringssl/crypto/fipsmodule/bn/div.c +97 -11
  169. data/third_party/boringssl/crypto/fipsmodule/bn/gcd.c +274 -218
  170. data/third_party/boringssl/crypto/fipsmodule/bn/internal.h +111 -34
  171. data/third_party/boringssl/crypto/fipsmodule/bn/montgomery.c +2 -2
  172. data/third_party/boringssl/crypto/fipsmodule/bn/montgomery_inv.c +1 -1
  173. data/third_party/boringssl/crypto/fipsmodule/bn/mul.c +24 -6
  174. data/third_party/boringssl/crypto/fipsmodule/bn/prime.c +324 -63
  175. data/third_party/boringssl/crypto/fipsmodule/bn/random.c +74 -21
  176. data/third_party/boringssl/crypto/fipsmodule/bn/shift.c +128 -86
  177. data/third_party/boringssl/crypto/fipsmodule/bn/sqrt.c +1 -1
  178. data/third_party/boringssl/crypto/fipsmodule/ec/ec_key.c +67 -112
  179. data/third_party/boringssl/crypto/fipsmodule/ec/internal.h +8 -1
  180. data/third_party/boringssl/crypto/fipsmodule/ec/oct.c +5 -5
  181. data/third_party/boringssl/crypto/fipsmodule/ec/p224-64.c +9 -17
  182. data/third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64-table.h +5378 -5418
  183. data/third_party/boringssl/crypto/fipsmodule/ec/simple.c +32 -32
  184. data/third_party/boringssl/crypto/fipsmodule/ecdsa/ecdsa.c +5 -11
  185. data/third_party/boringssl/crypto/fipsmodule/rsa/blinding.c +16 -40
  186. data/third_party/boringssl/crypto/fipsmodule/rsa/internal.h +1 -6
  187. data/third_party/boringssl/crypto/fipsmodule/rsa/rsa.c +41 -29
  188. data/third_party/boringssl/crypto/fipsmodule/rsa/rsa_impl.c +63 -49
  189. data/third_party/boringssl/crypto/x509/vpm_int.h +1 -0
  190. data/third_party/boringssl/crypto/x509/x509_vfy.c +4 -0
  191. data/third_party/boringssl/crypto/x509/x509_vpm.c +44 -22
  192. data/third_party/boringssl/include/openssl/aead.h +8 -2
  193. data/third_party/boringssl/include/openssl/asn1.h +1 -0
  194. data/third_party/boringssl/include/openssl/base.h +4 -0
  195. data/third_party/boringssl/include/openssl/bn.h +13 -3
  196. data/third_party/boringssl/include/openssl/bytestring.h +4 -4
  197. data/third_party/boringssl/include/openssl/ec.h +10 -4
  198. data/third_party/boringssl/include/openssl/ec_key.h +0 -3
  199. data/third_party/boringssl/include/openssl/rsa.h +1 -0
  200. data/third_party/boringssl/include/openssl/ssl.h +8 -3
  201. data/third_party/boringssl/include/openssl/ssl3.h +0 -1
  202. data/third_party/boringssl/include/openssl/x509.h +1 -0
  203. data/third_party/boringssl/include/openssl/x509v3.h +1 -0
  204. data/third_party/boringssl/ssl/handshake_client.cc +36 -64
  205. data/third_party/boringssl/ssl/ssl_cipher.cc +4 -0
  206. data/third_party/boringssl/ssl/ssl_lib.cc +1 -1
  207. metadata +45 -38
  208. data/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc +0 -222
  209. data/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc +0 -71
  210. data/src/core/ext/filters/load_reporting/server_load_reporting_plugin.h +0 -61
  211. data/src/ruby/spec/pb/package_with_underscore/checker_spec.rb +0 -51
  212. data/src/ruby/spec/pb/package_with_underscore/data.proto +0 -23
  213. data/src/ruby/spec/pb/package_with_underscore/service.proto +0 -23
@@ -21,30 +21,63 @@
21
21
 
22
22
  #include <grpc/support/port_platform.h>
23
23
 
24
+ #include "src/core/lib/gpr/spinlock.h"
25
+ #include "src/core/lib/gprpp/thd.h"
24
26
  #include "src/core/lib/iomgr/closure.h"
25
27
 
26
- typedef enum {
27
- GRPC_EXECUTOR_SHORT,
28
- GRPC_EXECUTOR_LONG
29
- } grpc_executor_job_length;
28
+ typedef struct {
29
+ gpr_mu mu;
30
+ size_t id; // For debugging purposes
31
+ gpr_cv cv;
32
+ grpc_closure_list elems;
33
+ size_t depth; // Number of closures in the closure list
34
+ bool shutdown;
35
+ bool queued_long_job;
36
+ grpc_core::Thread thd;
37
+ } ThreadState;
38
+
39
+ typedef enum { GRPC_EXECUTOR_SHORT, GRPC_EXECUTOR_LONG } GrpcExecutorJobType;
40
+
41
+ class GrpcExecutor {
42
+ public:
43
+ GrpcExecutor(const char* executor_name);
44
+
45
+ void Init();
46
+
47
+ /** Is the executor multi-threaded? */
48
+ bool IsThreaded() const;
49
+
50
+ /* Enable/disable threading - must be called after Init and Shutdown() */
51
+ void SetThreading(bool threading);
52
+
53
+ /** Shutdown the executor, running all pending work as part of the call */
54
+ void Shutdown();
55
+
56
+ /** Enqueue the closure onto the executor. is_short is true if the closure is
57
+ * a short job (i.e expected to not block and complete quickly) */
58
+ void Enqueue(grpc_closure* closure, grpc_error* error, bool is_short);
59
+
60
+ private:
61
+ static size_t RunClosures(grpc_closure_list list);
62
+ static void ThreadMain(void* arg);
63
+
64
+ const char* name_;
65
+ ThreadState* thd_state_;
66
+ size_t max_threads_;
67
+ gpr_atm num_threads_;
68
+ gpr_spinlock adding_thread_lock_;
69
+ };
70
+
71
+ // == Global executor functions ==
30
72
 
31
- /** Initialize the global executor.
32
- *
33
- * This mechanism is meant to outsource work (grpc_closure instances) to a
34
- * thread, for those cases where blocking isn't an option but there isn't a
35
- * non-blocking solution available. */
36
73
  void grpc_executor_init();
37
74
 
38
- grpc_closure_scheduler* grpc_executor_scheduler(grpc_executor_job_length);
75
+ grpc_closure_scheduler* grpc_executor_scheduler(GrpcExecutorJobType job_type);
39
76
 
40
- /** Shutdown the executor, running all pending work as part of the call */
41
77
  void grpc_executor_shutdown();
42
78
 
43
- /** Is the executor multi-threaded? */
44
79
  bool grpc_executor_is_threaded();
45
80
 
46
- /* enable/disable threading - must be called after grpc_executor_init and before
47
- grpc_executor_shutdown */
48
81
  void grpc_executor_set_threading(bool enable);
49
82
 
50
83
  #endif /* GRPC_CORE_LIB_IOMGR_EXECUTOR_H */
@@ -70,6 +70,8 @@ static size_t count_objects(void) {
70
70
  return n;
71
71
  }
72
72
 
73
+ size_t grpc_iomgr_count_objects_for_testing(void) { return count_objects(); }
74
+
73
75
  static void dump_objects(const char* kind) {
74
76
  grpc_iomgr_object* obj;
75
77
  for (obj = g_root_object.next; obj != &g_root_object; obj = obj->next) {
@@ -23,6 +23,8 @@
23
23
 
24
24
  #include "src/core/lib/iomgr/port.h"
25
25
 
26
+ #include <stdlib.h>
27
+
26
28
  /** Initializes the iomgr. */
27
29
  void grpc_iomgr_init();
28
30
 
@@ -33,4 +35,7 @@ void grpc_iomgr_start();
33
35
  * exec_ctx. */
34
36
  void grpc_iomgr_shutdown();
35
37
 
38
+ /* Exposed only for testing */
39
+ size_t grpc_iomgr_count_objects_for_testing();
40
+
36
41
  #endif /* GRPC_CORE_LIB_IOMGR_IOMGR_H */
@@ -27,6 +27,7 @@
27
27
  #include <grpc/support/log.h>
28
28
 
29
29
  #include <errno.h>
30
+ #include <sys/epoll.h>
30
31
  #include <sys/eventfd.h>
31
32
  #include <unistd.h>
32
33
 
@@ -23,12 +23,21 @@
23
23
 
24
24
  #include <stddef.h>
25
25
 
26
+ // TODO(juanlishen): The following functions might be simple enough to implement
27
+ // ourselves, so that they don't cause any portability hassle.
28
+
26
29
  /* A wrapper for htons on POSIX and Windows */
27
30
  uint16_t grpc_htons(uint16_t hostshort);
28
31
 
29
32
  /* A wrapper for ntohs on POSIX and WINDOWS */
30
33
  uint16_t grpc_ntohs(uint16_t netshort);
31
34
 
35
+ /* A wrapper for htonl on POSIX and Windows */
36
+ uint32_t grpc_htonl(uint32_t hostlong);
37
+
38
+ /* A wrapper for ntohl on POSIX and WINDOWS */
39
+ uint32_t grpc_ntohl(uint32_t netlong);
40
+
32
41
  /* A wrapper for inet_pton on POSIX and WINDOWS */
33
42
  int grpc_inet_pton(int af, const char* src, void* dst);
34
43
 
@@ -339,6 +339,10 @@ uint16_t grpc_htons(uint16_t hostshort) { return htons(hostshort); }
339
339
 
340
340
  uint16_t grpc_ntohs(uint16_t netshort) { return ntohs(netshort); }
341
341
 
342
+ uint32_t grpc_htonl(uint32_t hostlong) { return htonl(hostlong); }
343
+
344
+ uint32_t grpc_ntohl(uint32_t netlong) { return ntohl(netlong); }
345
+
342
346
  int grpc_inet_pton(int af, const char* src, void* dst) {
343
347
  return inet_pton(af, src, dst);
344
348
  }
@@ -33,6 +33,10 @@ uint16_t grpc_htons(uint16_t hostshort) { return htons(hostshort); }
33
33
 
34
34
  uint16_t grpc_ntohs(uint16_t netshort) { return ntohs(netshort); }
35
35
 
36
+ uint32_t grpc_htonl(uint32_t hostlong) { return htonl(hostlong); }
37
+
38
+ uint32_t grpc_ntohl(uint32_t netlong) { return ntohl(netlong); }
39
+
36
40
  int grpc_inet_pton(int af, const char* src, void* dst) {
37
41
  return inet_pton(af, src, dst);
38
42
  }
@@ -31,6 +31,10 @@ uint16_t grpc_htons(uint16_t hostshort) { return htons(hostshort); }
31
31
 
32
32
  uint16_t grpc_ntohs(uint16_t netshort) { return ntohs(netshort); }
33
33
 
34
+ uint32_t grpc_htonl(uint32_t hostlong) { return htonl(hostlong); }
35
+
36
+ uint32_t grpc_ntohl(uint32_t netlong) { return ntohl(netlong); }
37
+
34
38
  int grpc_inet_pton(int af, const char* src, void* dst) {
35
39
  return inet_pton(af, src, dst);
36
40
  }
@@ -211,8 +211,7 @@ static void on_writable(void* acp, grpc_error* error) {
211
211
  finish:
212
212
  if (fd != nullptr) {
213
213
  grpc_pollset_set_del_fd(ac->interested_parties, fd);
214
- grpc_fd_orphan(fd, nullptr, nullptr, false /* already_closed */,
215
- "tcp_client_orphan");
214
+ grpc_fd_orphan(fd, nullptr, nullptr, "tcp_client_orphan");
216
215
  fd = nullptr;
217
216
  }
218
217
  done = (--ac->refs == 0);
@@ -280,7 +279,7 @@ grpc_error* grpc_tcp_client_prepare_fd(const grpc_channel_args* channel_args,
280
279
  }
281
280
  addr_str = grpc_sockaddr_to_uri(mapped_addr);
282
281
  gpr_asprintf(&name, "tcp-client:%s", addr_str);
283
- *fdobj = grpc_fd_create(fd, name);
282
+ *fdobj = grpc_fd_create(fd, name, false);
284
283
  gpr_free(name);
285
284
  gpr_free(addr_str);
286
285
  return GRPC_ERROR_NONE;
@@ -305,8 +304,7 @@ void grpc_tcp_client_create_from_prepared_fd(
305
304
  return;
306
305
  }
307
306
  if (errno != EWOULDBLOCK && errno != EINPROGRESS) {
308
- grpc_fd_orphan(fdobj, nullptr, nullptr, false /* already_closed */,
309
- "tcp_client_connect_error");
307
+ grpc_fd_orphan(fdobj, nullptr, nullptr, "tcp_client_connect_error");
310
308
  GRPC_CLOSURE_SCHED(closure, GRPC_OS_ERROR(errno, "connect"));
311
309
  return;
312
310
  }
@@ -26,6 +26,7 @@
26
26
  #include "src/core/lib/iomgr/tcp_posix.h"
27
27
 
28
28
  #include <errno.h>
29
+ #include <limits.h>
29
30
  #include <stdbool.h>
30
31
  #include <stdlib.h>
31
32
  #include <string.h>
@@ -297,7 +298,7 @@ static void tcp_shutdown(grpc_endpoint* ep, grpc_error* why) {
297
298
 
298
299
  static void tcp_free(grpc_tcp* tcp) {
299
300
  grpc_fd_orphan(tcp->em_fd, tcp->release_fd_cb, tcp->release_fd,
300
- false /* already_closed */, "tcp_unref_orphan");
301
+ "tcp_unref_orphan");
301
302
  grpc_slice_buffer_destroy_internal(&tcp->last_read_buffer);
302
303
  grpc_resource_user_unref(tcp->resource_user);
303
304
  gpr_free(tcp->peer_string);
@@ -513,7 +514,11 @@ static void tcp_read(grpc_endpoint* ep, grpc_slice_buffer* incoming_buffer,
513
514
  }
514
515
 
515
516
  /* returns true if done, false if pending; if returning true, *error is set */
517
+ #if defined(IOV_MAX) && IOV_MAX < 1000
518
+ #define MAX_WRITE_IOVEC IOV_MAX
519
+ #else
516
520
  #define MAX_WRITE_IOVEC 1000
521
+ #endif
517
522
  static bool tcp_flush(grpc_tcp* tcp, grpc_error** error) {
518
523
  struct msghdr msg;
519
524
  struct iovec iov[MAX_WRITE_IOVEC];
@@ -150,7 +150,7 @@ static void deactivated_all_ports(grpc_tcp_server* s) {
150
150
  GRPC_CLOSURE_INIT(&sp->destroyed_closure, destroyed_port, s,
151
151
  grpc_schedule_on_exec_ctx);
152
152
  grpc_fd_orphan(sp->emfd, &sp->destroyed_closure, nullptr,
153
- false /* already_closed */, "tcp_listener_shutdown");
153
+ "tcp_listener_shutdown");
154
154
  }
155
155
  gpr_mu_unlock(&s->mu);
156
156
  } else {
@@ -226,7 +226,7 @@ static void on_read(void* arg, grpc_error* err) {
226
226
  gpr_log(GPR_INFO, "SERVER_CONNECT: incoming connection: %s", addr_str);
227
227
  }
228
228
 
229
- grpc_fd* fdobj = grpc_fd_create(fd, name);
229
+ grpc_fd* fdobj = grpc_fd_create(fd, name, false);
230
230
 
231
231
  read_notifier_pollset =
232
232
  sp->server->pollsets[static_cast<size_t>(gpr_atm_no_barrier_fetch_add(
@@ -362,7 +362,7 @@ static grpc_error* clone_port(grpc_tcp_listener* listener, unsigned count) {
362
362
  listener->sibling = sp;
363
363
  sp->server = listener->server;
364
364
  sp->fd = fd;
365
- sp->emfd = grpc_fd_create(fd, name);
365
+ sp->emfd = grpc_fd_create(fd, name, false);
366
366
  memcpy(&sp->addr, &listener->addr, sizeof(grpc_resolved_address));
367
367
  sp->port = port;
368
368
  sp->port_index = listener->port_index;
@@ -105,7 +105,7 @@ static grpc_error* add_socket_to_server(grpc_tcp_server* s, int fd,
105
105
  s->tail = sp;
106
106
  sp->server = s;
107
107
  sp->fd = fd;
108
- sp->emfd = grpc_fd_create(fd, name);
108
+ sp->emfd = grpc_fd_create(fd, name, false);
109
109
  memcpy(&sp->addr, addr, sizeof(grpc_resolved_address));
110
110
  sp->port = port;
111
111
  sp->port_index = port_index;
@@ -277,7 +277,6 @@ static void start_threads(void) {
277
277
  g_threaded = true;
278
278
  start_timer_thread_and_unlock();
279
279
  } else {
280
- g_threaded = false;
281
280
  gpr_mu_unlock(&g_mu);
282
281
  }
283
282
  }
@@ -152,7 +152,7 @@ GrpcUdpListener::GrpcUdpListener(grpc_udp_server* server, int fd,
152
152
  grpc_sockaddr_to_string(&addr_str, addr, 1);
153
153
  gpr_asprintf(&name, "udp-server-listener:%s", addr_str);
154
154
  gpr_free(addr_str);
155
- emfd_ = grpc_fd_create(fd, name);
155
+ emfd_ = grpc_fd_create(fd, name, false);
156
156
  memcpy(&addr_, addr, sizeof(grpc_resolved_address));
157
157
  GPR_ASSERT(emfd_);
158
158
  gpr_free(name);
@@ -300,8 +300,7 @@ void GrpcUdpListener::OrphanFd() {
300
300
  grpc_schedule_on_exec_ctx);
301
301
  /* Because at this point, all listening sockets have been shutdown already, no
302
302
  * need to call OnFdAboutToOrphan() to notify the handler again. */
303
- grpc_fd_orphan(emfd_, &destroyed_closure_, nullptr,
304
- false /* already_closed */, "udp_listener_shutdown");
303
+ grpc_fd_orphan(emfd_, &destroyed_closure_, nullptr, "udp_listener_shutdown");
305
304
  }
306
305
 
307
306
  void grpc_udp_server_destroy(grpc_udp_server* s, grpc_closure* on_done) {
@@ -18,10 +18,12 @@
18
18
 
19
19
  #include <grpc/support/port_platform.h>
20
20
 
21
+ #include <inttypes.h>
21
22
  #include <string.h>
22
23
 
23
24
  #include <grpc/support/alloc.h>
24
25
  #include <grpc/support/log.h>
26
+ #include <grpc/support/string_util.h>
25
27
 
26
28
  #include "src/core/lib/json/json.h"
27
29
 
@@ -84,3 +86,11 @@ grpc_json* grpc_json_create_child(grpc_json* sibling, grpc_json* parent,
84
86
  child->key = key;
85
87
  return child;
86
88
  }
89
+
90
+ grpc_json* grpc_json_add_number_string_child(grpc_json* parent, grpc_json* it,
91
+ const char* name, int64_t num) {
92
+ char* num_str;
93
+ gpr_asprintf(&num_str, "%" PRId64, num);
94
+ return grpc_json_create_child(it, parent, name, num_str, GRPC_JSON_STRING,
95
+ true);
96
+ }
@@ -91,4 +91,9 @@ grpc_json* grpc_json_create_child(grpc_json* sibling, grpc_json* parent,
91
91
  const char* key, const char* value,
92
92
  grpc_json_type type, bool owns_value);
93
93
 
94
+ /* Creates a child json string object from the integer num, then links the
95
+ json object into the parent's json tree */
96
+ grpc_json* grpc_json_add_number_string_child(grpc_json* parent, grpc_json* it,
97
+ const char* name, int64_t num);
98
+
94
99
  #endif /* GRPC_CORE_LIB_JSON_JSON_H */
@@ -21,6 +21,7 @@
21
21
  #include <string.h>
22
22
 
23
23
  #include "src/core/lib/channel/channel_args.h"
24
+ #include "src/core/lib/gpr/arena.h"
24
25
  #include "src/core/lib/gpr/string.h"
25
26
  #include "src/core/lib/security/context/security_context.h"
26
27
  #include "src/core/lib/surface/api_trace.h"
@@ -49,7 +50,7 @@ grpc_call_error grpc_call_set_credentials(grpc_call* call,
49
50
  ctx = static_cast<grpc_client_security_context*>(
50
51
  grpc_call_context_get(call, GRPC_CONTEXT_SECURITY));
51
52
  if (ctx == nullptr) {
52
- ctx = grpc_client_security_context_create();
53
+ ctx = grpc_client_security_context_create(grpc_call_get_arena(call));
53
54
  ctx->creds = grpc_call_credentials_ref(creds);
54
55
  grpc_call_context_set(call, GRPC_CONTEXT_SECURITY, ctx,
55
56
  grpc_client_security_context_destroy);
@@ -81,9 +82,10 @@ void grpc_auth_context_release(grpc_auth_context* context) {
81
82
 
82
83
  /* --- grpc_client_security_context --- */
83
84
 
84
- grpc_client_security_context* grpc_client_security_context_create(void) {
85
+ grpc_client_security_context* grpc_client_security_context_create(
86
+ gpr_arena* arena) {
85
87
  return static_cast<grpc_client_security_context*>(
86
- gpr_zalloc(sizeof(grpc_client_security_context)));
88
+ gpr_arena_alloc(arena, sizeof(grpc_client_security_context)));
87
89
  }
88
90
 
89
91
  void grpc_client_security_context_destroy(void* ctx) {
@@ -95,14 +97,13 @@ void grpc_client_security_context_destroy(void* ctx) {
95
97
  if (c->extension.instance != nullptr && c->extension.destroy != nullptr) {
96
98
  c->extension.destroy(c->extension.instance);
97
99
  }
98
- gpr_free(ctx);
99
100
  }
100
101
 
101
102
  /* --- grpc_server_security_context --- */
102
-
103
- grpc_server_security_context* grpc_server_security_context_create(void) {
103
+ grpc_server_security_context* grpc_server_security_context_create(
104
+ gpr_arena* arena) {
104
105
  return static_cast<grpc_server_security_context*>(
105
- gpr_zalloc(sizeof(grpc_server_security_context)));
106
+ gpr_arena_alloc(arena, sizeof(grpc_server_security_context)));
106
107
  }
107
108
 
108
109
  void grpc_server_security_context_destroy(void* ctx) {
@@ -112,7 +113,6 @@ void grpc_server_security_context_destroy(void* ctx) {
112
113
  if (c->extension.instance != nullptr && c->extension.destroy != nullptr) {
113
114
  c->extension.destroy(c->extension.instance);
114
115
  }
115
- gpr_free(ctx);
116
116
  }
117
117
 
118
118
  /* --- grpc_auth_context --- */
@@ -26,6 +26,8 @@
26
26
 
27
27
  extern grpc_core::DebugOnlyTraceFlag grpc_trace_auth_context_refcount;
28
28
 
29
+ struct gpr_arena;
30
+
29
31
  /* --- grpc_auth_context ---
30
32
 
31
33
  High level authentication context object. Can optionally be chained. */
@@ -89,7 +91,8 @@ typedef struct {
89
91
  grpc_security_context_extension extension;
90
92
  } grpc_client_security_context;
91
93
 
92
- grpc_client_security_context* grpc_client_security_context_create(void);
94
+ grpc_client_security_context* grpc_client_security_context_create(
95
+ gpr_arena* arena);
93
96
  void grpc_client_security_context_destroy(void* ctx);
94
97
 
95
98
  /* --- grpc_server_security_context ---
@@ -101,7 +104,8 @@ typedef struct {
101
104
  grpc_security_context_extension extension;
102
105
  } grpc_server_security_context;
103
106
 
104
- grpc_server_security_context* grpc_server_security_context_create(void);
107
+ grpc_server_security_context* grpc_server_security_context_create(
108
+ gpr_arena* arena);
105
109
  void grpc_server_security_context_destroy(void* ctx);
106
110
 
107
111
  /* --- Channel args for auth context --- */
@@ -231,7 +231,8 @@ end:
231
231
  creds->base.vtable = &google_default_credentials_vtable;
232
232
  creds->base.type = GRPC_CHANNEL_CREDENTIALS_TYPE_GOOGLE_DEFAULT;
233
233
  gpr_ref_init(&creds->base.refcount, 1);
234
- creds->ssl_creds = grpc_ssl_credentials_create(nullptr, nullptr, nullptr);
234
+ creds->ssl_creds =
235
+ grpc_ssl_credentials_create(nullptr, nullptr, nullptr, nullptr);
235
236
  GPR_ASSERT(creds->ssl_creds != nullptr);
236
237
  grpc_alts_credentials_options* options =
237
238
  grpc_alts_credentials_client_options_create();
@@ -0,0 +1,77 @@
1
+ /*
2
+ *
3
+ * Copyright 2018 gRPC authors.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ */
18
+
19
+ #include <grpc/support/port_platform.h>
20
+
21
+ #include "src/core/lib/security/credentials/local/local_credentials.h"
22
+
23
+ #include <grpc/grpc.h>
24
+ #include <grpc/support/alloc.h>
25
+ #include <grpc/support/log.h>
26
+
27
+ #include "src/core/lib/channel/channel_args.h"
28
+ #include "src/core/lib/security/security_connector/local_security_connector.h"
29
+
30
+ #define GRPC_CREDENTIALS_TYPE_LOCAL "Local"
31
+
32
+ static void local_credentials_destruct(grpc_channel_credentials* creds) {}
33
+
34
+ static void local_server_credentials_destruct(grpc_server_credentials* creds) {}
35
+
36
+ static grpc_security_status local_create_security_connector(
37
+ grpc_channel_credentials* creds,
38
+ grpc_call_credentials* request_metadata_creds, const char* target_name,
39
+ const grpc_channel_args* args, grpc_channel_security_connector** sc,
40
+ grpc_channel_args** new_args) {
41
+ return grpc_local_channel_security_connector_create(
42
+ creds, request_metadata_creds, args, target_name, sc);
43
+ }
44
+
45
+ static grpc_security_status local_server_create_security_connector(
46
+ grpc_server_credentials* creds, grpc_server_security_connector** sc) {
47
+ return grpc_local_server_security_connector_create(creds, sc);
48
+ }
49
+
50
+ static const grpc_channel_credentials_vtable local_credentials_vtable = {
51
+ local_credentials_destruct, local_create_security_connector,
52
+ /*duplicate_without_call_credentials=*/nullptr};
53
+
54
+ static const grpc_server_credentials_vtable local_server_credentials_vtable = {
55
+ local_server_credentials_destruct, local_server_create_security_connector};
56
+
57
+ grpc_channel_credentials* grpc_local_credentials_create(
58
+ grpc_local_connect_type connect_type) {
59
+ auto creds = static_cast<grpc_local_credentials*>(
60
+ gpr_zalloc(sizeof(grpc_local_credentials)));
61
+ creds->connect_type = connect_type;
62
+ creds->base.type = GRPC_CREDENTIALS_TYPE_LOCAL;
63
+ creds->base.vtable = &local_credentials_vtable;
64
+ gpr_ref_init(&creds->base.refcount, 1);
65
+ return &creds->base;
66
+ }
67
+
68
+ grpc_server_credentials* grpc_local_server_credentials_create(
69
+ grpc_local_connect_type connect_type) {
70
+ auto creds = static_cast<grpc_local_server_credentials*>(
71
+ gpr_zalloc(sizeof(grpc_local_server_credentials)));
72
+ creds->connect_type = connect_type;
73
+ creds->base.type = GRPC_CREDENTIALS_TYPE_LOCAL;
74
+ creds->base.vtable = &local_server_credentials_vtable;
75
+ gpr_ref_init(&creds->base.refcount, 1);
76
+ return &creds->base;
77
+ }