grpc 1.18.0 → 1.19.0.pre1

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 (146) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +301 -33
  3. data/include/grpc/grpc_security.h +195 -0
  4. data/include/grpc/impl/codegen/grpc_types.h +17 -1
  5. data/include/grpc/impl/codegen/port_platform.h +36 -0
  6. data/include/grpc/impl/codegen/slice.h +1 -1
  7. data/src/core/ext/filters/client_channel/channel_connectivity.cc +2 -0
  8. data/src/core/ext/filters/client_channel/client_channel.cc +74 -69
  9. data/src/core/ext/filters/client_channel/client_channel.h +2 -2
  10. data/src/core/ext/filters/client_channel/client_channel_channelz.cc +5 -6
  11. data/src/core/ext/filters/client_channel/client_channel_channelz.h +5 -4
  12. data/src/core/ext/filters/client_channel/client_channel_factory.cc +2 -2
  13. data/src/core/ext/filters/client_channel/client_channel_factory.h +4 -4
  14. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +3 -3
  15. data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +176 -0
  16. data/src/core/ext/filters/client_channel/global_subchannel_pool.h +68 -0
  17. data/src/core/ext/filters/client_channel/health/health_check_client.cc +10 -8
  18. data/src/core/ext/filters/client_channel/health/health_check_client.h +1 -1
  19. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +146 -156
  20. data/src/core/ext/filters/client_channel/lb_policy.cc +30 -1
  21. data/src/core/ext/filters/client_channel/lb_policy.h +29 -1
  22. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +28 -30
  23. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +5 -8
  24. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +5 -8
  25. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +23 -24
  26. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +80 -15
  27. data/src/core/ext/filters/client_channel/lb_policy_factory.h +6 -1
  28. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +2 -2
  29. data/src/core/ext/filters/client_channel/lb_policy_registry.h +1 -1
  30. data/src/core/ext/filters/client_channel/local_subchannel_pool.cc +96 -0
  31. data/src/core/ext/filters/client_channel/local_subchannel_pool.h +56 -0
  32. data/src/core/ext/filters/client_channel/parse_address.cc +24 -5
  33. data/src/core/ext/filters/client_channel/request_routing.cc +13 -3
  34. data/src/core/ext/filters/client_channel/request_routing.h +5 -1
  35. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +11 -6
  36. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +2 -2
  37. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +7 -35
  38. data/src/core/ext/filters/client_channel/subchannel.cc +698 -791
  39. data/src/core/ext/filters/client_channel/subchannel.h +213 -123
  40. data/src/core/ext/filters/client_channel/subchannel_pool_interface.cc +97 -0
  41. data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +94 -0
  42. data/src/core/ext/filters/http/client_authority_filter.cc +5 -2
  43. data/src/core/ext/filters/max_age/max_age_filter.cc +1 -1
  44. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +13 -12
  45. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +5 -7
  46. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +19 -27
  47. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +18 -19
  48. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +27 -6
  49. data/src/core/ext/transport/chttp2/transport/flow_control.cc +1 -1
  50. data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +3 -2
  51. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +1 -1
  52. data/src/core/ext/transport/chttp2/transport/writing.cc +8 -5
  53. data/src/core/lib/channel/handshaker.cc +141 -214
  54. data/src/core/lib/channel/handshaker.h +110 -101
  55. data/src/core/lib/channel/handshaker_factory.h +11 -19
  56. data/src/core/lib/channel/handshaker_registry.cc +64 -52
  57. data/src/core/lib/channel/handshaker_registry.h +21 -16
  58. data/src/core/lib/gpr/log_posix.cc +2 -1
  59. data/src/core/lib/gpr/time.cc +8 -0
  60. data/src/core/lib/gpr/time_posix.cc +8 -2
  61. data/src/core/lib/gprpp/optional.h +47 -0
  62. data/src/core/lib/http/httpcli_security_connector.cc +13 -14
  63. data/src/core/lib/iomgr/buffer_list.cc +182 -24
  64. data/src/core/lib/iomgr/buffer_list.h +70 -8
  65. data/src/core/lib/iomgr/combiner.cc +11 -3
  66. data/src/core/lib/iomgr/error.cc +9 -5
  67. data/src/core/lib/iomgr/ev_epoll1_linux.cc +3 -0
  68. data/src/core/lib/iomgr/ev_epollex_linux.cc +136 -162
  69. data/src/core/lib/iomgr/ev_poll_posix.cc +3 -0
  70. data/src/core/lib/iomgr/ev_posix.cc +4 -0
  71. data/src/core/lib/iomgr/ev_posix.h +4 -0
  72. data/src/core/lib/iomgr/exec_ctx.cc +1 -0
  73. data/src/core/lib/iomgr/exec_ctx.h +137 -8
  74. data/src/core/lib/iomgr/executor.cc +122 -87
  75. data/src/core/lib/iomgr/executor.h +53 -48
  76. data/src/core/lib/iomgr/fork_posix.cc +6 -4
  77. data/src/core/lib/iomgr/{network_status_tracker.cc → grpc_if_nametoindex.h} +8 -14
  78. data/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc +42 -0
  79. data/src/core/lib/iomgr/{network_status_tracker.h → grpc_if_nametoindex_unsupported.cc} +15 -9
  80. data/src/core/lib/iomgr/internal_errqueue.h +105 -3
  81. data/src/core/lib/iomgr/iomgr.cc +6 -5
  82. data/src/core/lib/iomgr/iomgr.h +8 -0
  83. data/src/core/lib/iomgr/iomgr_custom.cc +6 -2
  84. data/src/core/lib/iomgr/iomgr_internal.cc +4 -0
  85. data/src/core/lib/iomgr/iomgr_internal.h +4 -0
  86. data/src/core/lib/iomgr/iomgr_posix.cc +10 -1
  87. data/src/core/lib/iomgr/iomgr_windows.cc +8 -1
  88. data/src/core/lib/iomgr/port.h +1 -0
  89. data/src/core/lib/iomgr/resolve_address_posix.cc +4 -3
  90. data/src/core/lib/iomgr/resolve_address_windows.cc +2 -1
  91. data/src/core/lib/iomgr/tcp_custom.cc +0 -4
  92. data/src/core/lib/iomgr/tcp_posix.cc +58 -44
  93. data/src/core/lib/iomgr/tcp_uv.cc +0 -1
  94. data/src/core/lib/iomgr/tcp_windows.cc +0 -4
  95. data/src/core/lib/iomgr/timer_manager.cc +8 -0
  96. data/src/core/lib/iomgr/udp_server.cc +6 -4
  97. data/src/core/lib/json/json.cc +1 -4
  98. data/src/core/lib/security/credentials/alts/alts_credentials.cc +1 -1
  99. data/src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc +2 -2
  100. data/src/core/lib/security/credentials/composite/composite_credentials.h +4 -0
  101. data/src/core/lib/security/credentials/credentials.h +9 -1
  102. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +15 -2
  103. data/src/core/lib/security/credentials/google_default/google_default_credentials.h +2 -0
  104. data/src/core/lib/security/credentials/jwt/json_token.cc +1 -1
  105. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +1 -0
  106. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +3 -2
  107. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +2 -2
  108. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +1 -0
  109. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +192 -0
  110. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +213 -0
  111. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +10 -8
  112. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +6 -10
  113. data/src/core/lib/security/security_connector/local/local_security_connector.cc +10 -8
  114. data/src/core/lib/security/security_connector/security_connector.h +2 -2
  115. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +4 -6
  116. data/src/core/lib/security/security_connector/ssl_utils.h +33 -0
  117. data/src/core/lib/security/transport/security_handshaker.cc +267 -300
  118. data/src/core/lib/security/transport/security_handshaker.h +11 -2
  119. data/src/core/lib/security/transport/server_auth_filter.cc +1 -0
  120. data/src/core/lib/surface/call.cc +5 -1
  121. data/src/core/lib/surface/channel_init.h +5 -0
  122. data/src/core/lib/surface/completion_queue.cc +4 -7
  123. data/src/core/lib/surface/init.cc +5 -3
  124. data/src/core/lib/surface/init_secure.cc +1 -1
  125. data/src/core/lib/surface/server.cc +19 -17
  126. data/src/core/lib/surface/version.cc +1 -1
  127. data/src/core/lib/transport/service_config.h +1 -0
  128. data/src/core/lib/transport/static_metadata.cc +279 -279
  129. data/src/core/lib/transport/transport.cc +5 -3
  130. data/src/core/tsi/ssl_transport_security.cc +10 -4
  131. data/src/ruby/ext/grpc/extconf.rb +12 -4
  132. data/src/ruby/ext/grpc/rb_call_credentials.c +8 -5
  133. data/src/ruby/ext/grpc/rb_channel.c +14 -10
  134. data/src/ruby/ext/grpc/rb_channel_credentials.c +8 -4
  135. data/src/ruby/ext/grpc/rb_compression_options.c +9 -7
  136. data/src/ruby/ext/grpc/rb_event_thread.c +2 -0
  137. data/src/ruby/ext/grpc/rb_grpc.c +22 -23
  138. data/src/ruby/ext/grpc/rb_grpc.h +4 -2
  139. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +18 -0
  140. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +27 -0
  141. data/src/ruby/ext/grpc/rb_server.c +8 -4
  142. data/src/ruby/lib/grpc/version.rb +1 -1
  143. metadata +46 -39
  144. data/src/core/ext/filters/client_channel/subchannel_index.cc +0 -248
  145. data/src/core/ext/filters/client_channel/subchannel_index.h +0 -76
  146. data/src/core/lib/channel/handshaker_factory.cc +0 -42
@@ -25,7 +25,9 @@
25
25
  #include "src/core/lib/gprpp/thd.h"
26
26
  #include "src/core/lib/iomgr/closure.h"
27
27
 
28
- typedef struct {
28
+ namespace grpc_core {
29
+
30
+ struct ThreadState {
29
31
  gpr_mu mu;
30
32
  size_t id; // For debugging purposes
31
33
  const char* name; // Thread state name
@@ -35,17 +37,24 @@ typedef struct {
35
37
  bool shutdown;
36
38
  bool queued_long_job;
37
39
  grpc_core::Thread thd;
38
- } ThreadState;
40
+ };
39
41
 
40
- typedef enum {
41
- GRPC_EXECUTOR_SHORT = 0,
42
- GRPC_EXECUTOR_LONG,
43
- GRPC_NUM_EXECUTOR_JOB_TYPES // Add new values above this
44
- } GrpcExecutorJobType;
42
+ enum class ExecutorType {
43
+ DEFAULT = 0,
44
+ RESOLVER,
45
+
46
+ NUM_EXECUTORS // Add new values above this
47
+ };
45
48
 
46
- class GrpcExecutor {
49
+ enum class ExecutorJobType {
50
+ SHORT = 0,
51
+ LONG,
52
+ NUM_JOB_TYPES // Add new values above this
53
+ };
54
+
55
+ class Executor {
47
56
  public:
48
- GrpcExecutor(const char* executor_name);
57
+ Executor(const char* executor_name);
49
58
 
50
59
  void Init();
51
60
 
@@ -62,55 +71,51 @@ class GrpcExecutor {
62
71
  * a short job (i.e expected to not block and complete quickly) */
63
72
  void Enqueue(grpc_closure* closure, grpc_error* error, bool is_short);
64
73
 
65
- private:
66
- static size_t RunClosures(const char* executor_name, grpc_closure_list list);
67
- static void ThreadMain(void* arg);
74
+ // TODO(sreek): Currently we have two executors (available globally): The
75
+ // default executor and the resolver executor.
76
+ //
77
+ // Some of the functions below operate on the DEFAULT executor only while some
78
+ // operate of ALL the executors. This is a bit confusing and should be cleaned
79
+ // up in future (where we make all the following functions take ExecutorType
80
+ // and/or JobType)
68
81
 
69
- const char* name_;
70
- ThreadState* thd_state_;
71
- size_t max_threads_;
72
- gpr_atm num_threads_;
73
- gpr_spinlock adding_thread_lock_;
74
- };
75
-
76
- // == Global executor functions ==
82
+ // Initialize ALL the executors
83
+ static void InitAll();
77
84
 
78
- typedef enum {
79
- GRPC_DEFAULT_EXECUTOR = 0,
80
- GRPC_RESOLVER_EXECUTOR,
85
+ // Shutdown ALL the executors
86
+ static void ShutdownAll();
81
87
 
82
- GRPC_NUM_EXECUTORS // Add new values above this
83
- } GrpcExecutorType;
88
+ // Set the threading mode for ALL the executors
89
+ static void SetThreadingAll(bool enable);
84
90
 
85
- // TODO(sreek): Currently we have two executors (available globally): The
86
- // default executor and the resolver executor.
87
- //
88
- // Some of the functions below operate on the DEFAULT executor only while some
89
- // operate of ALL the executors. This is a bit confusing and should be cleaned
90
- // up in future (where we make all the following functions take executor_type
91
- // and/or job_type)
91
+ // Set the threading mode for ALL the executors
92
+ static void SetThreadingDefault(bool enable);
92
93
 
93
- // Initialize ALL the executors
94
- void grpc_executor_init();
94
+ // Get the DEFAULT executor scheduler for the given job_type
95
+ static grpc_closure_scheduler* Scheduler(ExecutorJobType job_type);
95
96
 
96
- // Shutdown ALL the executors
97
- void grpc_executor_shutdown();
97
+ // Get the executor scheduler for a given executor_type and a job_type
98
+ static grpc_closure_scheduler* Scheduler(ExecutorType executor_type,
99
+ ExecutorJobType job_type);
98
100
 
99
- // Set the threading mode for ALL the executors
100
- void grpc_executor_set_threading(bool enable);
101
+ // Return if a given executor is running in threaded mode (i.e if
102
+ // SetThreading(true) was called previously on that executor)
103
+ static bool IsThreaded(ExecutorType executor_type);
101
104
 
102
- // Get the DEFAULT executor scheduler for the given job_type
103
- grpc_closure_scheduler* grpc_executor_scheduler(GrpcExecutorJobType job_type);
105
+ // Return if the DEFAULT executor is threaded
106
+ static bool IsThreadedDefault();
104
107
 
105
- // Get the executor scheduler for a given executor_type and a job_type
106
- grpc_closure_scheduler* grpc_executor_scheduler(GrpcExecutorType executor_type,
107
- GrpcExecutorJobType job_type);
108
+ private:
109
+ static size_t RunClosures(const char* executor_name, grpc_closure_list list);
110
+ static void ThreadMain(void* arg);
108
111
 
109
- // Return if a given executor is running in threaded mode (i.e if
110
- // grpc_executor_set_threading(true) was called previously on that executor)
111
- bool grpc_executor_is_threaded(GrpcExecutorType executor_type);
112
+ const char* name_;
113
+ ThreadState* thd_state_;
114
+ size_t max_threads_;
115
+ gpr_atm num_threads_;
116
+ gpr_spinlock adding_thread_lock_;
117
+ };
112
118
 
113
- // Return if the DEFAULT executor is threaded
114
- bool grpc_executor_is_threaded();
119
+ } // namespace grpc_core
115
120
 
116
121
  #endif /* GRPC_CORE_LIB_IOMGR_EXECUTOR_H */
@@ -47,11 +47,13 @@ bool registered_handlers = false;
47
47
  } // namespace
48
48
 
49
49
  void grpc_prefork() {
50
- grpc_core::ExecCtx exec_ctx;
51
50
  skipped_handler = true;
51
+ // This may be called after core shuts down, so verify initialized before
52
+ // instantiating an ExecCtx.
52
53
  if (!grpc_is_initialized()) {
53
54
  return;
54
55
  }
56
+ grpc_core::ExecCtx exec_ctx;
55
57
  if (!grpc_core::Fork::Enabled()) {
56
58
  gpr_log(GPR_ERROR,
57
59
  "Fork support not enabled; try running with the "
@@ -71,7 +73,7 @@ void grpc_prefork() {
71
73
  return;
72
74
  }
73
75
  grpc_timer_manager_set_threading(false);
74
- grpc_executor_set_threading(false);
76
+ grpc_core::Executor::SetThreadingAll(false);
75
77
  grpc_core::ExecCtx::Get()->Flush();
76
78
  grpc_core::Fork::AwaitThreads();
77
79
  skipped_handler = false;
@@ -82,7 +84,7 @@ void grpc_postfork_parent() {
82
84
  grpc_core::Fork::AllowExecCtx();
83
85
  grpc_core::ExecCtx exec_ctx;
84
86
  grpc_timer_manager_set_threading(true);
85
- grpc_executor_set_threading(true);
87
+ grpc_core::Executor::SetThreadingAll(true);
86
88
  }
87
89
  }
88
90
 
@@ -96,7 +98,7 @@ void grpc_postfork_child() {
96
98
  reset_polling_engine();
97
99
  }
98
100
  grpc_timer_manager_set_threading(true);
99
- grpc_executor_set_threading(true);
101
+ grpc_core::Executor::SetThreadingAll(true);
100
102
  }
101
103
  }
102
104
 
@@ -16,21 +16,15 @@
16
16
  *
17
17
  */
18
18
 
19
- #include <grpc/support/port_platform.h>
20
-
21
- #include "src/core/lib/iomgr/endpoint.h"
22
- #include "src/core/lib/iomgr/network_status_tracker.h"
23
-
24
- void grpc_network_status_shutdown(void) {}
19
+ #ifndef GRPC_CORE_LIB_IOMGR_GRPC_IF_NAMETOINDEX_H
20
+ #define GRPC_CORE_LIB_IOMGR_GRPC_IF_NAMETOINDEX_H
25
21
 
26
- void grpc_network_status_init(void) {
27
- // TODO(makarandd): Install callback with OS to monitor network status.
28
- }
29
-
30
- void grpc_destroy_network_status_monitor() {}
22
+ #include <grpc/support/port_platform.h>
31
23
 
32
- void grpc_network_status_register_endpoint(grpc_endpoint* ep) { (void)ep; }
24
+ #include <stddef.h>
33
25
 
34
- void grpc_network_status_unregister_endpoint(grpc_endpoint* ep) { (void)ep; }
26
+ /* Returns the interface index corresponding to the interface "name" provided.
27
+ * Returns non-zero upon success, and zero upon failure. */
28
+ uint32_t grpc_if_nametoindex(char* name);
35
29
 
36
- void grpc_network_status_shutdown_all_endpoints() {}
30
+ #endif /* GRPC_CORE_LIB_IOMGR_GRPC_IF_NAMETOINDEX_H */
@@ -0,0 +1,42 @@
1
+ /*
2
+ *
3
+ * Copyright 2016 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/iomgr/port.h"
22
+
23
+ #if GRPC_IF_NAMETOINDEX == 1 && defined(GRPC_POSIX_SOCKET_IF_NAMETOINDEX)
24
+
25
+ #include "src/core/lib/iomgr/grpc_if_nametoindex.h"
26
+
27
+ #include <errno.h>
28
+ #include <net/if.h>
29
+
30
+ #include <grpc/support/log.h>
31
+
32
+ uint32_t grpc_if_nametoindex(char* name) {
33
+ uint32_t out = if_nametoindex(name);
34
+ if (out == 0) {
35
+ gpr_log(GPR_DEBUG, "if_nametoindex failed for name %s. errno %d", name,
36
+ errno);
37
+ }
38
+ return out;
39
+ }
40
+
41
+ #endif /* GRPC_IF_NAMETOINDEX == 1 && \
42
+ defined(GRPC_POSIX_SOCKET_IF_NAMETOINDEX) */
@@ -16,17 +16,23 @@
16
16
  *
17
17
  */
18
18
 
19
- #ifndef GRPC_CORE_LIB_IOMGR_NETWORK_STATUS_TRACKER_H
20
- #define GRPC_CORE_LIB_IOMGR_NETWORK_STATUS_TRACKER_H
21
19
  #include <grpc/support/port_platform.h>
22
20
 
23
- #include "src/core/lib/iomgr/endpoint.h"
21
+ #include "src/core/lib/iomgr/port.h"
24
22
 
25
- void grpc_network_status_init(void);
26
- void grpc_network_status_shutdown(void);
23
+ #if GRPC_IF_NAMETOINDEX == 0 || !defined(GRPC_POSIX_SOCKET_IF_NAMETOINDEX)
27
24
 
28
- void grpc_network_status_register_endpoint(grpc_endpoint* ep);
29
- void grpc_network_status_unregister_endpoint(grpc_endpoint* ep);
30
- void grpc_network_status_shutdown_all_endpoints();
25
+ #include "src/core/lib/iomgr/grpc_if_nametoindex.h"
31
26
 
32
- #endif /* GRPC_CORE_LIB_IOMGR_NETWORK_STATUS_TRACKER_H */
27
+ #include <grpc/support/log.h>
28
+
29
+ uint32_t grpc_if_nametoindex(char* name) {
30
+ gpr_log(GPR_DEBUG,
31
+ "Not attempting to convert interface name %s to index for current "
32
+ "platform.",
33
+ name);
34
+ return 0;
35
+ }
36
+
37
+ #endif /* GRPC_IF_NAMETOINDEX == 0 || \
38
+ !defined(GRPC_POSIX_SOCKET_IF_NAMETOINDEX) */
@@ -37,6 +37,7 @@
37
37
  #ifdef GRPC_LINUX_ERRQUEUE
38
38
  #include <linux/errqueue.h>
39
39
  #include <linux/net_tstamp.h>
40
+ #include <linux/netlink.h>
40
41
  #include <sys/socket.h>
41
42
  #endif /* GRPC_LINUX_ERRQUEUE */
42
43
 
@@ -56,6 +57,12 @@ constexpr int SCM_TSTAMP_SND = 0;
56
57
  constexpr int SCM_TSTAMP_SCHED = 1;
57
58
  /* The timestamp type for when data acknowledged by peer. */
58
59
  constexpr int SCM_TSTAMP_ACK = 2;
60
+
61
+ /* Control message type containing OPT_STATS */
62
+ #ifndef SCM_TIMESTAMPING_OPT_STATS
63
+ #define SCM_TIMESTAMPING_OPT_STATS 54
64
+ #endif
65
+
59
66
  /* Redefine required constants from <linux/net_tstamp.h> */
60
67
  constexpr uint32_t SOF_TIMESTAMPING_TX_SOFTWARE = 1u << 1;
61
68
  constexpr uint32_t SOF_TIMESTAMPING_SOFTWARE = 1u << 4;
@@ -63,13 +70,108 @@ constexpr uint32_t SOF_TIMESTAMPING_OPT_ID = 1u << 7;
63
70
  constexpr uint32_t SOF_TIMESTAMPING_TX_SCHED = 1u << 8;
64
71
  constexpr uint32_t SOF_TIMESTAMPING_TX_ACK = 1u << 9;
65
72
  constexpr uint32_t SOF_TIMESTAMPING_OPT_TSONLY = 1u << 11;
73
+ constexpr uint32_t SOF_TIMESTAMPING_OPT_STATS = 1u << 12;
66
74
 
67
- constexpr uint32_t kTimestampingSocketOptions = SOF_TIMESTAMPING_SOFTWARE |
68
- SOF_TIMESTAMPING_OPT_ID |
69
- SOF_TIMESTAMPING_OPT_TSONLY;
75
+ constexpr uint32_t kTimestampingSocketOptions =
76
+ SOF_TIMESTAMPING_SOFTWARE | SOF_TIMESTAMPING_OPT_ID |
77
+ SOF_TIMESTAMPING_OPT_TSONLY | SOF_TIMESTAMPING_OPT_STATS;
70
78
  constexpr uint32_t kTimestampingRecordingOptions =
71
79
  SOF_TIMESTAMPING_TX_SCHED | SOF_TIMESTAMPING_TX_SOFTWARE |
72
80
  SOF_TIMESTAMPING_TX_ACK;
81
+
82
+ /* Netlink attribute types used for TCP opt stats. */
83
+ enum TCPOptStats {
84
+ TCP_NLA_PAD,
85
+ TCP_NLA_BUSY, /* Time (usec) busy sending data. */
86
+ TCP_NLA_RWND_LIMITED, /* Time (usec) limited by receive window. */
87
+ TCP_NLA_SNDBUF_LIMITED, /* Time (usec) limited by send buffer. */
88
+ TCP_NLA_DATA_SEGS_OUT, /* Data pkts sent including retransmission. */
89
+ TCP_NLA_TOTAL_RETRANS, /* Data pkts retransmitted. */
90
+ TCP_NLA_PACING_RATE, /* Pacing rate in Bps. */
91
+ TCP_NLA_DELIVERY_RATE, /* Delivery rate in Bps. */
92
+ TCP_NLA_SND_CWND, /* Sending congestion window. */
93
+ TCP_NLA_REORDERING, /* Reordering metric. */
94
+ TCP_NLA_MIN_RTT, /* minimum RTT. */
95
+ TCP_NLA_RECUR_RETRANS, /* Recurring retransmits for the current pkt. */
96
+ TCP_NLA_DELIVERY_RATE_APP_LMT, /* Delivery rate application limited? */
97
+ TCP_NLA_SNDQ_SIZE, /* Data (bytes) pending in send queue */
98
+ TCP_NLA_CA_STATE, /* ca_state of socket */
99
+ TCP_NLA_SND_SSTHRESH, /* Slow start size threshold */
100
+ TCP_NLA_DELIVERED, /* Data pkts delivered incl. out-of-order */
101
+ TCP_NLA_DELIVERED_CE, /* Like above but only ones w/ CE marks */
102
+ TCP_NLA_BYTES_SENT, /* Data bytes sent including retransmission */
103
+ TCP_NLA_BYTES_RETRANS, /* Data bytes retransmitted */
104
+ TCP_NLA_DSACK_DUPS, /* DSACK blocks received */
105
+ TCP_NLA_REORD_SEEN, /* reordering events seen */
106
+ TCP_NLA_SRTT, /* smoothed RTT in usecs */
107
+ };
108
+
109
+ /* tcp_info from from linux/tcp.h */
110
+ struct tcp_info {
111
+ uint8_t tcpi_state;
112
+ uint8_t tcpi_ca_state;
113
+ uint8_t tcpi_retransmits;
114
+ uint8_t tcpi_probes;
115
+ uint8_t tcpi_backoff;
116
+ uint8_t tcpi_options;
117
+ uint8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
118
+ uint8_t tcpi_delivery_rate_app_limited : 1;
119
+ uint32_t tcpi_rto;
120
+ uint32_t tcpi_ato;
121
+ uint32_t tcpi_snd_mss;
122
+ uint32_t tcpi_rcv_mss;
123
+ uint32_t tcpi_unacked;
124
+ uint32_t tcpi_sacked;
125
+ uint32_t tcpi_lost;
126
+ uint32_t tcpi_retrans;
127
+ uint32_t tcpi_fackets;
128
+ /* Times. */
129
+ uint32_t tcpi_last_data_sent;
130
+ uint32_t tcpi_last_ack_sent; /* Not remembered, sorry. */
131
+ uint32_t tcpi_last_data_recv;
132
+ uint32_t tcpi_last_ack_recv;
133
+ /* Metrics. */
134
+ uint32_t tcpi_pmtu;
135
+ uint32_t tcpi_rcv_ssthresh;
136
+ uint32_t tcpi_rtt;
137
+ uint32_t tcpi_rttvar;
138
+ uint32_t tcpi_snd_ssthresh;
139
+ uint32_t tcpi_snd_cwnd;
140
+ uint32_t tcpi_advmss;
141
+ uint32_t tcpi_reordering;
142
+ uint32_t tcpi_rcv_rtt;
143
+ uint32_t tcpi_rcv_space;
144
+ uint32_t tcpi_total_retrans;
145
+ uint64_t tcpi_pacing_rate;
146
+ uint64_t tcpi_max_pacing_rate;
147
+ uint64_t tcpi_bytes_acked; /* RFC4898 tcpEStatsAppHCThruOctetsAcked */
148
+ uint64_t tcpi_bytes_received; /* RFC4898 tcpEStatsAppHCThruOctetsReceived */
149
+
150
+ uint32_t tcpi_segs_out; /* RFC4898 tcpEStatsPerfSegsOut */
151
+ uint32_t tcpi_segs_in; /* RFC4898 tcpEStatsPerfSegsIn */
152
+ uint32_t tcpi_notsent_bytes;
153
+ uint32_t tcpi_min_rtt;
154
+
155
+ uint32_t tcpi_data_segs_in; /* RFC4898 tcpEStatsDataSegsIn */
156
+ uint32_t tcpi_data_segs_out; /* RFC4898 tcpEStatsDataSegsOut */
157
+
158
+ uint64_t tcpi_delivery_rate;
159
+ uint64_t tcpi_busy_time; /* Time (usec) busy sending data */
160
+ uint64_t tcpi_rwnd_limited; /* Time (usec) limited by receive window */
161
+ uint64_t tcpi_sndbuf_limited; /* Time (usec) limited by send buffer */
162
+
163
+ uint32_t tcpi_delivered;
164
+ uint32_t tcpi_delivered_ce;
165
+ uint64_t tcpi_bytes_sent; /* RFC4898 tcpEStatsPerfHCDataOctetsOut */
166
+ uint64_t tcpi_bytes_retrans; /* RFC4898 tcpEStatsPerfOctetsRetrans */
167
+ uint32_t tcpi_dsack_dups; /* RFC4898 tcpEStatsStackDSACKDups */
168
+ uint32_t tcpi_reord_seen; /* reordering events seen */
169
+ socklen_t length; /* Length of struct returned by kernel */
170
+ };
171
+
172
+ #ifndef TCP_INFO
173
+ #define TCP_INFO 11
174
+ #endif
73
175
  #endif /* GRPC_LINUX_ERRQUEUE */
74
176
 
75
177
  /* Returns true if kernel is capable of supporting errqueue and timestamping.
@@ -38,7 +38,6 @@
38
38
  #include "src/core/lib/iomgr/executor.h"
39
39
  #include "src/core/lib/iomgr/internal_errqueue.h"
40
40
  #include "src/core/lib/iomgr/iomgr_internal.h"
41
- #include "src/core/lib/iomgr/network_status_tracker.h"
42
41
  #include "src/core/lib/iomgr/timer.h"
43
42
  #include "src/core/lib/iomgr/timer_manager.h"
44
43
 
@@ -53,11 +52,10 @@ void grpc_iomgr_init() {
53
52
  g_shutdown = 0;
54
53
  gpr_mu_init(&g_mu);
55
54
  gpr_cv_init(&g_rcv);
56
- grpc_executor_init();
55
+ grpc_core::Executor::InitAll();
57
56
  grpc_timer_list_init();
58
57
  g_root_object.next = g_root_object.prev = &g_root_object;
59
58
  g_root_object.name = (char*)"root";
60
- grpc_network_status_init();
61
59
  grpc_iomgr_platform_init();
62
60
  grpc_core::grpc_errqueue_init();
63
61
  }
@@ -90,7 +88,7 @@ void grpc_iomgr_shutdown() {
90
88
  {
91
89
  grpc_timer_manager_shutdown();
92
90
  grpc_iomgr_platform_flush();
93
- grpc_executor_shutdown();
91
+ grpc_core::Executor::ShutdownAll();
94
92
 
95
93
  gpr_mu_lock(&g_mu);
96
94
  g_shutdown = 1;
@@ -152,7 +150,6 @@ void grpc_iomgr_shutdown() {
152
150
  gpr_mu_unlock(&g_mu);
153
151
 
154
152
  grpc_iomgr_platform_shutdown();
155
- grpc_network_status_shutdown();
156
153
  gpr_mu_destroy(&g_mu);
157
154
  gpr_cv_destroy(&g_rcv);
158
155
  }
@@ -161,6 +158,10 @@ void grpc_iomgr_shutdown_background_closure() {
161
158
  grpc_iomgr_platform_shutdown_background_closure();
162
159
  }
163
160
 
161
+ bool grpc_iomgr_is_any_background_poller_thread() {
162
+ return grpc_iomgr_platform_is_any_background_poller_thread();
163
+ }
164
+
164
165
  void grpc_iomgr_register_object(grpc_iomgr_object* obj, const char* name) {
165
166
  obj->name = gpr_strdup(name);
166
167
  gpr_mu_lock(&g_mu);