grpc 1.21.0 → 1.22.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 (141) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +422 -62
  3. data/include/grpc/grpc_security.h +61 -5
  4. data/include/grpc/grpc_security_constants.h +1 -1
  5. data/include/grpc/impl/codegen/gpr_types.h +1 -1
  6. data/include/grpc/slice.h +2 -2
  7. data/src/core/ext/filters/client_channel/backup_poller.cc +2 -3
  8. data/src/core/ext/filters/client_channel/backup_poller.h +5 -2
  9. data/src/core/ext/filters/client_channel/client_channel.cc +260 -122
  10. data/src/core/ext/filters/client_channel/client_channel.h +0 -8
  11. data/src/core/ext/filters/client_channel/client_channel_channelz.cc +3 -84
  12. data/src/core/ext/filters/client_channel/client_channel_channelz.h +2 -28
  13. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +2 -8
  14. data/src/core/ext/filters/client_channel/health/health_check_client.cc +5 -4
  15. data/src/core/ext/filters/client_channel/lb_policy.cc +16 -2
  16. data/src/core/ext/filters/client_channel/lb_policy.h +92 -98
  17. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +63 -87
  18. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +6 -2
  19. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +35 -87
  20. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +18 -74
  21. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +167 -217
  22. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +216 -190
  23. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc +6 -2
  24. data/src/core/ext/filters/client_channel/lb_policy_factory.h +1 -1
  25. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +1 -1
  26. data/src/core/ext/filters/client_channel/lb_policy_registry.h +1 -1
  27. data/src/core/ext/filters/client_channel/resolver.h +1 -1
  28. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +6 -3
  29. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +0 -1
  30. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +2 -0
  31. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +8 -8
  32. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +7 -7
  33. data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +28 -64
  34. data/src/core/ext/filters/client_channel/resolving_lb_policy.h +4 -12
  35. data/src/core/ext/filters/client_channel/server_address.cc +4 -6
  36. data/src/core/ext/filters/client_channel/server_address.h +1 -3
  37. data/src/core/ext/filters/client_channel/service_config.cc +20 -22
  38. data/src/core/ext/filters/client_channel/service_config.h +26 -28
  39. data/src/core/ext/filters/client_channel/subchannel.cc +261 -160
  40. data/src/core/ext/filters/client_channel/subchannel.h +97 -23
  41. data/src/core/ext/filters/client_channel/subchannel_interface.h +113 -0
  42. data/src/core/ext/filters/message_size/message_size_filter.cc +12 -12
  43. data/src/core/ext/filters/message_size/message_size_filter.h +2 -2
  44. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +50 -2
  45. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +2 -2
  46. data/src/core/ext/transport/chttp2/transport/frame_data.cc +31 -36
  47. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +3 -2
  48. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +71 -52
  49. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +18 -3
  50. data/src/core/ext/transport/chttp2/transport/hpack_table.cc +5 -12
  51. data/src/core/ext/transport/chttp2/transport/hpack_table.h +10 -1
  52. data/src/core/ext/transport/chttp2/transport/internal.h +3 -3
  53. data/src/core/ext/transport/chttp2/transport/parsing.cc +39 -57
  54. data/src/core/lib/channel/channelz.cc +136 -19
  55. data/src/core/lib/channel/channelz.h +36 -40
  56. data/src/core/lib/channel/channelz_registry.cc +74 -106
  57. data/src/core/lib/channel/channelz_registry.h +10 -28
  58. data/src/core/lib/channel/context.h +1 -1
  59. data/src/core/lib/channel/handshaker.cc +6 -0
  60. data/src/core/lib/compression/compression.cc +13 -8
  61. data/src/core/lib/compression/compression_internal.cc +14 -10
  62. data/src/core/lib/compression/compression_internal.h +1 -1
  63. data/src/core/lib/compression/stream_compression.cc +3 -2
  64. data/src/core/lib/compression/stream_compression.h +2 -2
  65. data/src/core/lib/compression/stream_compression_gzip.cc +9 -9
  66. data/src/core/lib/gpr/env.h +1 -1
  67. data/src/core/lib/gpr/string.cc +8 -1
  68. data/src/core/lib/gpr/string.h +6 -1
  69. data/src/core/lib/gprpp/fork.cc +1 -1
  70. data/src/core/lib/gprpp/fork.h +5 -1
  71. data/src/core/lib/gprpp/global_config.h +9 -0
  72. data/src/core/lib/gprpp/global_config_custom.h +1 -1
  73. data/src/core/lib/gprpp/inlined_vector.h +8 -0
  74. data/src/core/lib/gprpp/map.h +38 -21
  75. data/src/core/lib/gprpp/memory.h +2 -2
  76. data/src/core/lib/gprpp/orphanable.h +1 -1
  77. data/src/core/lib/gprpp/ref_counted.h +9 -4
  78. data/src/core/lib/http/httpcli.cc +3 -3
  79. data/src/core/lib/iomgr/buffer_list.h +1 -1
  80. data/src/core/lib/iomgr/call_combiner.cc +1 -1
  81. data/src/core/lib/iomgr/call_combiner.h +1 -1
  82. data/src/core/lib/iomgr/cfstream_handle.cc +3 -2
  83. data/src/core/lib/iomgr/cfstream_handle.h +4 -0
  84. data/src/core/lib/iomgr/error.cc +3 -3
  85. data/src/core/lib/iomgr/error.h +9 -3
  86. data/src/core/lib/iomgr/error_internal.h +1 -1
  87. data/src/core/lib/iomgr/ev_epoll1_linux.cc +1 -1
  88. data/src/core/lib/iomgr/ev_posix.cc +3 -3
  89. data/src/core/lib/iomgr/ev_posix.h +3 -2
  90. data/src/core/lib/iomgr/ev_windows.cc +2 -2
  91. data/src/core/lib/iomgr/iomgr.cc +4 -4
  92. data/src/core/lib/iomgr/lockfree_event.cc +1 -1
  93. data/src/core/lib/iomgr/port.h +5 -1
  94. data/src/core/lib/iomgr/tcp_posix.cc +1 -3
  95. data/src/core/lib/iomgr/tcp_server.cc +5 -0
  96. data/src/core/lib/iomgr/tcp_server.h +24 -0
  97. data/src/core/lib/iomgr/tcp_server_custom.cc +11 -9
  98. data/src/core/lib/iomgr/tcp_server_posix.cc +72 -11
  99. data/src/core/lib/iomgr/tcp_server_utils_posix.h +3 -0
  100. data/src/core/lib/iomgr/tcp_server_windows.cc +11 -9
  101. data/src/core/lib/iomgr/tcp_uv.cc +5 -6
  102. data/src/core/lib/iomgr/timer.h +2 -1
  103. data/src/core/lib/iomgr/udp_server.cc +2 -2
  104. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +1 -1
  105. data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +20 -2
  106. data/src/core/lib/security/credentials/ssl/ssl_credentials.h +2 -2
  107. data/src/core/lib/security/security_connector/security_connector.h +1 -1
  108. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +1 -1
  109. data/src/core/lib/security/transport/auth_filters.h +3 -0
  110. data/src/core/lib/security/transport/client_auth_filter.cc +13 -0
  111. data/src/core/lib/security/transport/security_handshaker.cc +7 -7
  112. data/src/core/lib/slice/b64.h +2 -2
  113. data/src/core/lib/slice/slice.cc +82 -10
  114. data/src/core/lib/slice/slice_buffer.cc +49 -21
  115. data/src/core/lib/slice/slice_hash_table.h +2 -2
  116. data/src/core/lib/slice/slice_intern.cc +15 -16
  117. data/src/core/lib/slice/slice_internal.h +52 -0
  118. data/src/core/lib/slice/slice_string_helpers.cc +10 -1
  119. data/src/core/lib/slice/slice_string_helpers.h +3 -1
  120. data/src/core/lib/slice/slice_utils.h +50 -0
  121. data/src/core/lib/slice/slice_weak_hash_table.h +2 -2
  122. data/src/core/lib/surface/call.cc +14 -8
  123. data/src/core/lib/surface/channel.cc +89 -97
  124. data/src/core/lib/surface/channel.h +60 -6
  125. data/src/core/lib/surface/completion_queue.cc +49 -36
  126. data/src/core/lib/surface/completion_queue.h +2 -1
  127. data/src/core/lib/surface/server.cc +8 -8
  128. data/src/core/lib/surface/validate_metadata.cc +14 -8
  129. data/src/core/lib/surface/validate_metadata.h +13 -2
  130. data/src/core/lib/surface/version.cc +1 -1
  131. data/src/core/lib/transport/metadata.cc +56 -26
  132. data/src/core/lib/transport/metadata.h +91 -75
  133. data/src/core/lib/transport/static_metadata.cc +262 -176
  134. data/src/core/lib/transport/static_metadata.h +272 -180
  135. data/src/core/lib/transport/transport.cc +1 -1
  136. data/src/core/lib/transport/transport.h +8 -2
  137. data/src/core/tsi/alts/handshaker/alts_shared_resource.h +1 -1
  138. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
  139. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +5 -2
  140. data/src/ruby/lib/grpc/version.rb +1 -1
  141. metadata +33 -31
@@ -23,10 +23,12 @@
23
23
 
24
24
  #include "src/core/ext/filters/client_channel/client_channel_channelz.h"
25
25
  #include "src/core/ext/filters/client_channel/connector.h"
26
+ #include "src/core/ext/filters/client_channel/subchannel_interface.h"
26
27
  #include "src/core/ext/filters/client_channel/subchannel_pool_interface.h"
27
28
  #include "src/core/lib/backoff/backoff.h"
28
29
  #include "src/core/lib/channel/channel_stack.h"
29
30
  #include "src/core/lib/gprpp/arena.h"
31
+ #include "src/core/lib/gprpp/map.h"
30
32
  #include "src/core/lib/gprpp/ref_counted.h"
31
33
  #include "src/core/lib/gprpp/ref_counted_ptr.h"
32
34
  #include "src/core/lib/gprpp/sync.h"
@@ -68,7 +70,7 @@ namespace grpc_core {
68
70
 
69
71
  class SubchannelCall;
70
72
 
71
- class ConnectedSubchannel : public RefCounted<ConnectedSubchannel> {
73
+ class ConnectedSubchannel : public ConnectedSubchannelInterface {
72
74
  public:
73
75
  struct CallArgs {
74
76
  grpc_polling_entity* pollent;
@@ -77,7 +79,7 @@ class ConnectedSubchannel : public RefCounted<ConnectedSubchannel> {
77
79
  grpc_millis deadline;
78
80
  Arena* arena;
79
81
  grpc_call_context_element* context;
80
- grpc_core::CallCombiner* call_combiner;
82
+ CallCombiner* call_combiner;
81
83
  size_t parent_data_size;
82
84
  };
83
85
 
@@ -95,7 +97,7 @@ class ConnectedSubchannel : public RefCounted<ConnectedSubchannel> {
95
97
  grpc_error** error);
96
98
 
97
99
  grpc_channel_stack* channel_stack() const { return channel_stack_; }
98
- const grpc_channel_args* args() const { return args_; }
100
+ const grpc_channel_args* args() const override { return args_; }
99
101
  channelz::SubchannelNode* channelz_subchannel() const {
100
102
  return channelz_subchannel_.get();
101
103
  }
@@ -176,6 +178,9 @@ class SubchannelCall {
176
178
  // provides a target for load balancing.
177
179
  class Subchannel {
178
180
  public:
181
+ typedef SubchannelInterface::ConnectivityStateWatcher
182
+ ConnectivityStateWatcher;
183
+
179
184
  // The ctor and dtor are not intended to use directly.
180
185
  Subchannel(SubchannelKey* key, grpc_connector* connector,
181
186
  const grpc_channel_args* args);
@@ -201,20 +206,36 @@ class Subchannel {
201
206
  // Caller doesn't take ownership.
202
207
  const char* GetTargetAddress();
203
208
 
204
- // Gets the connected subchannel - or nullptr if not connected (which may
205
- // happen before it initially connects or during transient failures).
206
- RefCountedPtr<ConnectedSubchannel> connected_subchannel();
207
-
208
209
  channelz::SubchannelNode* channelz_node();
209
210
 
210
- // Polls the current connectivity state of the subchannel.
211
- grpc_connectivity_state CheckConnectivity(bool inhibit_health_checking);
212
-
213
- // When the connectivity state of the subchannel changes from \a *state,
214
- // invokes \a notify and updates \a *state with the new state.
215
- void NotifyOnStateChange(grpc_pollset_set* interested_parties,
216
- grpc_connectivity_state* state, grpc_closure* notify,
217
- bool inhibit_health_checking);
211
+ // Returns the current connectivity state of the subchannel.
212
+ // If health_check_service_name is non-null, the returned connectivity
213
+ // state will be based on the state reported by the backend for that
214
+ // service name.
215
+ // If the return value is GRPC_CHANNEL_READY, also sets *connected_subchannel.
216
+ grpc_connectivity_state CheckConnectivityState(
217
+ const char* health_check_service_name,
218
+ RefCountedPtr<ConnectedSubchannel>* connected_subchannel);
219
+
220
+ // Starts watching the subchannel's connectivity state.
221
+ // The first callback to the watcher will be delivered when the
222
+ // subchannel's connectivity state becomes a value other than
223
+ // initial_state, which may happen immediately.
224
+ // Subsequent callbacks will be delivered as the subchannel's state
225
+ // changes.
226
+ // The watcher will be destroyed either when the subchannel is
227
+ // destroyed or when CancelConnectivityStateWatch() is called.
228
+ void WatchConnectivityState(grpc_connectivity_state initial_state,
229
+ UniquePtr<char> health_check_service_name,
230
+ UniquePtr<ConnectivityStateWatcher> watcher);
231
+
232
+ // Cancels a connectivity state watch.
233
+ // If the watcher has already been destroyed, this is a no-op.
234
+ void CancelConnectivityStateWatch(const char* health_check_service_name,
235
+ ConnectivityStateWatcher* watcher);
236
+
237
+ // Attempt to connect to the backend. Has no effect if already connected.
238
+ void AttemptToConnect();
218
239
 
219
240
  // Resets the connection backoff of the subchannel.
220
241
  // TODO(roth): Move connection backoff out of subchannels and up into LB
@@ -236,12 +257,65 @@ class Subchannel {
236
257
  grpc_resolved_address* addr);
237
258
 
238
259
  private:
239
- struct ExternalStateWatcher;
260
+ // A linked list of ConnectivityStateWatchers that are monitoring the
261
+ // subchannel's state.
262
+ class ConnectivityStateWatcherList {
263
+ public:
264
+ ~ConnectivityStateWatcherList() { Clear(); }
265
+
266
+ void AddWatcherLocked(UniquePtr<ConnectivityStateWatcher> watcher);
267
+ void RemoveWatcherLocked(ConnectivityStateWatcher* watcher);
268
+
269
+ // Notifies all watchers in the list about a change to state.
270
+ void NotifyLocked(Subchannel* subchannel, grpc_connectivity_state state);
271
+
272
+ void Clear() { watchers_.clear(); }
273
+
274
+ bool empty() const { return watchers_.empty(); }
275
+
276
+ private:
277
+ // TODO(roth): This could be a set instead of a map if we had a set
278
+ // implementation.
279
+ Map<ConnectivityStateWatcher*, UniquePtr<ConnectivityStateWatcher>>
280
+ watchers_;
281
+ };
282
+
283
+ // A map that tracks ConnectivityStateWatchers using a particular health
284
+ // check service name.
285
+ //
286
+ // There is one entry in the map for each health check service name.
287
+ // Entries exist only as long as there are watchers using the
288
+ // corresponding service name.
289
+ //
290
+ // A health check client is maintained only while the subchannel is in
291
+ // state READY.
292
+ class HealthWatcherMap {
293
+ public:
294
+ void AddWatcherLocked(Subchannel* subchannel,
295
+ grpc_connectivity_state initial_state,
296
+ UniquePtr<char> health_check_service_name,
297
+ UniquePtr<ConnectivityStateWatcher> watcher);
298
+ void RemoveWatcherLocked(const char* health_check_service_name,
299
+ ConnectivityStateWatcher* watcher);
300
+
301
+ // Notifies the watcher when the subchannel's state changes.
302
+ void NotifyLocked(grpc_connectivity_state state);
303
+
304
+ grpc_connectivity_state CheckConnectivityStateLocked(
305
+ Subchannel* subchannel, const char* health_check_service_name);
306
+
307
+ void ShutdownLocked();
308
+
309
+ private:
310
+ class HealthWatcher;
311
+
312
+ Map<const char*, OrphanablePtr<HealthWatcher>, StringLess> map_;
313
+ };
314
+
240
315
  class ConnectedSubchannelStateWatcher;
241
316
 
242
317
  // Sets the subchannel's connectivity state to \a state.
243
- void SetConnectivityStateLocked(grpc_connectivity_state state,
244
- const char* reason);
318
+ void SetConnectivityStateLocked(grpc_connectivity_state state);
245
319
 
246
320
  // Methods for connection.
247
321
  void MaybeStartConnectingLocked();
@@ -279,15 +353,15 @@ class Subchannel {
279
353
  grpc_closure on_connecting_finished_;
280
354
  // Active connection, or null.
281
355
  RefCountedPtr<ConnectedSubchannel> connected_subchannel_;
282
- OrphanablePtr<ConnectedSubchannelStateWatcher> connected_subchannel_watcher_;
283
356
  bool connecting_ = false;
284
357
  bool disconnected_ = false;
285
358
 
286
359
  // Connectivity state tracking.
287
- grpc_connectivity_state_tracker state_tracker_;
288
- grpc_connectivity_state_tracker state_and_health_tracker_;
289
- UniquePtr<char> health_check_service_name_;
290
- ExternalStateWatcher* external_state_watcher_list_ = nullptr;
360
+ grpc_connectivity_state state_ = GRPC_CHANNEL_IDLE;
361
+ // The list of watchers without a health check service name.
362
+ ConnectivityStateWatcherList watcher_list_;
363
+ // The map of watchers with health check service names.
364
+ HealthWatcherMap health_watcher_map_;
291
365
 
292
366
  // Backoff state.
293
367
  BackOff backoff_;
@@ -0,0 +1,113 @@
1
+ /*
2
+ *
3
+ * Copyright 2019 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
+ #ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_SUBCHANNEL_INTERFACE_H
20
+ #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_SUBCHANNEL_INTERFACE_H
21
+
22
+ #include <grpc/support/port_platform.h>
23
+
24
+ #include "src/core/lib/debug/trace.h"
25
+ #include "src/core/lib/gprpp/ref_counted.h"
26
+ #include "src/core/lib/gprpp/ref_counted_ptr.h"
27
+
28
+ namespace grpc_core {
29
+
30
+ // TODO(roth): In a subsequent PR, remove this from this API.
31
+ class ConnectedSubchannelInterface
32
+ : public RefCounted<ConnectedSubchannelInterface> {
33
+ public:
34
+ virtual const grpc_channel_args* args() const GRPC_ABSTRACT;
35
+
36
+ protected:
37
+ template <typename TraceFlagT = TraceFlag>
38
+ explicit ConnectedSubchannelInterface(TraceFlagT* trace_flag = nullptr)
39
+ : RefCounted<ConnectedSubchannelInterface>(trace_flag) {}
40
+ };
41
+
42
+ class SubchannelInterface : public RefCounted<SubchannelInterface> {
43
+ public:
44
+ class ConnectivityStateWatcher {
45
+ public:
46
+ virtual ~ConnectivityStateWatcher() = default;
47
+
48
+ // Will be invoked whenever the subchannel's connectivity state
49
+ // changes. There will be only one invocation of this method on a
50
+ // given watcher instance at any given time.
51
+ //
52
+ // When the state changes to READY, connected_subchannel will
53
+ // contain a ref to the connected subchannel. When it changes from
54
+ // READY to some other state, the implementation must release its
55
+ // ref to the connected subchannel.
56
+ virtual void OnConnectivityStateChange(
57
+ grpc_connectivity_state new_state,
58
+ RefCountedPtr<ConnectedSubchannelInterface>
59
+ connected_subchannel) // NOLINT
60
+ GRPC_ABSTRACT;
61
+
62
+ // TODO(roth): Remove this as soon as we move to EventManager-based
63
+ // polling.
64
+ virtual grpc_pollset_set* interested_parties() GRPC_ABSTRACT;
65
+
66
+ GRPC_ABSTRACT_BASE_CLASS
67
+ };
68
+
69
+ virtual ~SubchannelInterface() = default;
70
+
71
+ // Returns the current connectivity state of the subchannel.
72
+ virtual grpc_connectivity_state CheckConnectivityState(
73
+ RefCountedPtr<ConnectedSubchannelInterface>* connected_subchannel)
74
+ GRPC_ABSTRACT;
75
+
76
+ // Starts watching the subchannel's connectivity state.
77
+ // The first callback to the watcher will be delivered when the
78
+ // subchannel's connectivity state becomes a value other than
79
+ // initial_state, which may happen immediately.
80
+ // Subsequent callbacks will be delivered as the subchannel's state
81
+ // changes.
82
+ // The watcher will be destroyed either when the subchannel is
83
+ // destroyed or when CancelConnectivityStateWatch() is called.
84
+ // There can be only one watcher of a given subchannel. It is not
85
+ // valid to call this method a second time without first cancelling
86
+ // the previous watcher using CancelConnectivityStateWatch().
87
+ virtual void WatchConnectivityState(
88
+ grpc_connectivity_state initial_state,
89
+ UniquePtr<ConnectivityStateWatcher> watcher) GRPC_ABSTRACT;
90
+
91
+ // Cancels a connectivity state watch.
92
+ // If the watcher has already been destroyed, this is a no-op.
93
+ virtual void CancelConnectivityStateWatch(ConnectivityStateWatcher* watcher)
94
+ GRPC_ABSTRACT;
95
+
96
+ // Attempt to connect to the backend. Has no effect if already connected.
97
+ // If the subchannel is currently in backoff delay due to a previously
98
+ // failed attempt, the new connection attempt will not start until the
99
+ // backoff delay has elapsed.
100
+ virtual void AttemptToConnect() GRPC_ABSTRACT;
101
+
102
+ // Resets the subchannel's connection backoff state. If AttemptToConnect()
103
+ // has been called since the subchannel entered TRANSIENT_FAILURE state,
104
+ // starts a new connection attempt immediately; otherwise, a new connection
105
+ // attempt will be started as soon as AttemptToConnect() is called.
106
+ virtual void ResetBackoff() GRPC_ABSTRACT;
107
+
108
+ GRPC_ABSTRACT_BASE_CLASS
109
+ };
110
+
111
+ } // namespace grpc_core
112
+
113
+ #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_SUBCHANNEL_INTERFACE_H */
@@ -88,7 +88,7 @@ UniquePtr<ServiceConfig::ParsedConfig> MessageSizeParser::ParsePerMethodParams(
88
88
  *error = GRPC_ERROR_CREATE_FROM_VECTOR("Message size parser", &error_list);
89
89
  return nullptr;
90
90
  }
91
- return UniquePtr<ServiceConfig::ParsedConfig>(New<MessageSizeParsedObject>(
91
+ return UniquePtr<ServiceConfig::ParsedConfig>(New<MessageSizeParsedConfig>(
92
92
  max_request_message_bytes, max_response_message_bytes));
93
93
  }
94
94
 
@@ -102,7 +102,7 @@ size_t MessageSizeParser::ParserIndex() { return g_message_size_parser_index; }
102
102
 
103
103
  namespace {
104
104
  struct channel_data {
105
- grpc_core::MessageSizeParsedObject::message_size_limits limits;
105
+ grpc_core::MessageSizeParsedConfig::message_size_limits limits;
106
106
  grpc_core::RefCountedPtr<grpc_core::ServiceConfig> svc_cfg;
107
107
  };
108
108
 
@@ -119,21 +119,21 @@ struct call_data {
119
119
  // Note: Per-method config is only available on the client, so we
120
120
  // apply the max request size to the send limit and the max response
121
121
  // size to the receive limit.
122
- const grpc_core::MessageSizeParsedObject* limits = nullptr;
122
+ const grpc_core::MessageSizeParsedConfig* limits = nullptr;
123
123
  grpc_core::ServiceConfig::CallData* svc_cfg_call_data = nullptr;
124
124
  if (args.context != nullptr) {
125
125
  svc_cfg_call_data = static_cast<grpc_core::ServiceConfig::CallData*>(
126
- args.context[GRPC_SERVICE_CONFIG_CALL_DATA].value);
126
+ args.context[GRPC_CONTEXT_SERVICE_CONFIG_CALL_DATA].value);
127
127
  }
128
128
  if (svc_cfg_call_data != nullptr) {
129
- limits = static_cast<const grpc_core::MessageSizeParsedObject*>(
130
- svc_cfg_call_data->GetMethodParsedObject(
129
+ limits = static_cast<const grpc_core::MessageSizeParsedConfig*>(
130
+ svc_cfg_call_data->GetMethodParsedConfig(
131
131
  grpc_core::MessageSizeParser::ParserIndex()));
132
132
  } else if (chand.svc_cfg != nullptr) {
133
133
  const auto* objs_vector =
134
- chand.svc_cfg->GetMethodServiceConfigObjectsVector(args.path);
134
+ chand.svc_cfg->GetMethodParsedConfigVector(args.path);
135
135
  if (objs_vector != nullptr) {
136
- limits = static_cast<const grpc_core::MessageSizeParsedObject*>(
136
+ limits = static_cast<const grpc_core::MessageSizeParsedConfig*>(
137
137
  (*objs_vector)[grpc_core::MessageSizeParser::ParserIndex()].get());
138
138
  }
139
139
  }
@@ -154,7 +154,7 @@ struct call_data {
154
154
  ~call_data() { GRPC_ERROR_UNREF(error); }
155
155
 
156
156
  grpc_core::CallCombiner* call_combiner;
157
- grpc_core::MessageSizeParsedObject::message_size_limits limits;
157
+ grpc_core::MessageSizeParsedConfig::message_size_limits limits;
158
158
  // Receive closures are chained: we inject this closure as the
159
159
  // recv_message_ready up-call on transport_stream_op, and remember to
160
160
  // call our next_recv_message_ready member after handling it.
@@ -300,9 +300,9 @@ static int default_size(const grpc_channel_args* args,
300
300
  return without_minimal_stack;
301
301
  }
302
302
 
303
- grpc_core::MessageSizeParsedObject::message_size_limits get_message_size_limits(
303
+ grpc_core::MessageSizeParsedConfig::message_size_limits get_message_size_limits(
304
304
  const grpc_channel_args* channel_args) {
305
- grpc_core::MessageSizeParsedObject::message_size_limits lim;
305
+ grpc_core::MessageSizeParsedConfig::message_size_limits lim;
306
306
  lim.max_send_size =
307
307
  default_size(channel_args, GRPC_DEFAULT_MAX_SEND_MESSAGE_LENGTH);
308
308
  lim.max_recv_size =
@@ -392,7 +392,7 @@ static bool maybe_add_message_size_filter(grpc_channel_stack_builder* builder,
392
392
  const grpc_channel_args* channel_args =
393
393
  grpc_channel_stack_builder_get_channel_arguments(builder);
394
394
  bool enable = false;
395
- grpc_core::MessageSizeParsedObject::message_size_limits lim =
395
+ grpc_core::MessageSizeParsedConfig::message_size_limits lim =
396
396
  get_message_size_limits(channel_args);
397
397
  if (lim.max_send_size != -1 || lim.max_recv_size != -1) {
398
398
  enable = true;
@@ -26,14 +26,14 @@ extern const grpc_channel_filter grpc_message_size_filter;
26
26
 
27
27
  namespace grpc_core {
28
28
 
29
- class MessageSizeParsedObject : public ServiceConfig::ParsedConfig {
29
+ class MessageSizeParsedConfig : public ServiceConfig::ParsedConfig {
30
30
  public:
31
31
  struct message_size_limits {
32
32
  int max_send_size;
33
33
  int max_recv_size;
34
34
  };
35
35
 
36
- MessageSizeParsedObject(int max_send_size, int max_recv_size) {
36
+ MessageSizeParsedConfig(int max_send_size, int max_recv_size) {
37
37
  limits_.max_send_size = max_send_size;
38
38
  limits_.max_recv_size = max_recv_size;
39
39
  }
@@ -20,12 +20,12 @@
20
20
 
21
21
  #include "src/core/ext/transport/chttp2/server/chttp2_server.h"
22
22
 
23
- #include <grpc/grpc.h>
24
-
25
23
  #include <inttypes.h>
26
24
  #include <limits.h>
27
25
  #include <string.h>
28
26
 
27
+ #include <grpc/grpc.h>
28
+ #include <grpc/impl/codegen/grpc_types.h>
29
29
  #include <grpc/support/alloc.h>
30
30
  #include <grpc/support/log.h>
31
31
  #include <grpc/support/string_util.h>
@@ -289,6 +289,50 @@ static void server_destroy_listener(grpc_server* server, void* arg,
289
289
  grpc_tcp_server_unref(tcp_server);
290
290
  }
291
291
 
292
+ static grpc_error* chttp2_server_add_acceptor(grpc_server* server,
293
+ const char* name,
294
+ grpc_channel_args* args) {
295
+ grpc_tcp_server* tcp_server = nullptr;
296
+ grpc_error* err = GRPC_ERROR_NONE;
297
+ server_state* state = nullptr;
298
+ const grpc_arg* arg = nullptr;
299
+ grpc_core::TcpServerFdHandler** arg_val = nullptr;
300
+ state = static_cast<server_state*>(gpr_zalloc(sizeof(*state)));
301
+ GRPC_CLOSURE_INIT(&state->tcp_server_shutdown_complete,
302
+ tcp_server_shutdown_complete, state,
303
+ grpc_schedule_on_exec_ctx);
304
+ err = grpc_tcp_server_create(&state->tcp_server_shutdown_complete, args,
305
+ &tcp_server);
306
+ if (err != GRPC_ERROR_NONE) {
307
+ goto error;
308
+ }
309
+ state->server = server;
310
+ state->tcp_server = tcp_server;
311
+ state->args = args;
312
+ state->shutdown = true;
313
+ gpr_mu_init(&state->mu);
314
+ // TODO(yangg) channelz
315
+ arg = grpc_channel_args_find(args, name);
316
+ GPR_ASSERT(arg->type == GRPC_ARG_POINTER);
317
+ arg_val = static_cast<grpc_core::TcpServerFdHandler**>(arg->value.pointer.p);
318
+ *arg_val = grpc_tcp_server_create_fd_handler(tcp_server);
319
+
320
+ grpc_server_add_listener(server, state, server_start_listener,
321
+ server_destroy_listener, /* socket_uuid */ 0);
322
+ return err;
323
+
324
+ /* Error path: cleanup and return */
325
+ error:
326
+ GPR_ASSERT(err != GRPC_ERROR_NONE);
327
+ if (tcp_server) {
328
+ grpc_tcp_server_unref(tcp_server);
329
+ } else {
330
+ grpc_channel_args_destroy(args);
331
+ gpr_free(state);
332
+ }
333
+ return err;
334
+ }
335
+
292
336
  grpc_error* grpc_chttp2_server_add_port(grpc_server* server, const char* addr,
293
337
  grpc_channel_args* args,
294
338
  int* port_num) {
@@ -306,6 +350,10 @@ grpc_error* grpc_chttp2_server_add_port(grpc_server* server, const char* addr,
306
350
 
307
351
  *port_num = -1;
308
352
 
353
+ if (strncmp(addr, "external:", 9) == 0) {
354
+ return chttp2_server_add_acceptor(server, addr, args);
355
+ }
356
+
309
357
  /* resolve address */
310
358
  err = grpc_blocking_resolve_address(addr, "https", &resolved);
311
359
  if (err != GRPC_ERROR_NONE) {