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
@@ -39,6 +39,14 @@ void grpc_iomgr_shutdown();
39
39
  * background poller. */
40
40
  void grpc_iomgr_shutdown_background_closure();
41
41
 
42
+ /* Returns true if polling engine runs in the background, false otherwise.
43
+ * Currently only 'epollbg' runs in the background.
44
+ */
45
+ bool grpc_iomgr_run_in_background();
46
+
47
+ /** Returns true if the caller is a worker thread for any background poller. */
48
+ bool grpc_iomgr_is_any_background_poller_thread();
49
+
42
50
  /* Exposed only for testing */
43
51
  size_t grpc_iomgr_count_objects_for_testing();
44
52
 
@@ -34,17 +34,21 @@ gpr_thd_id g_init_thread;
34
34
 
35
35
  static void iomgr_platform_init(void) {
36
36
  grpc_core::ExecCtx exec_ctx;
37
- grpc_executor_set_threading(false);
37
+ grpc_core::Executor::SetThreadingAll(false);
38
38
  g_init_thread = gpr_thd_currentid();
39
39
  grpc_pollset_global_init();
40
40
  }
41
41
  static void iomgr_platform_flush(void) {}
42
42
  static void iomgr_platform_shutdown(void) { grpc_pollset_global_shutdown(); }
43
43
  static void iomgr_platform_shutdown_background_closure(void) {}
44
+ static bool iomgr_platform_is_any_background_poller_thread(void) {
45
+ return false;
46
+ }
44
47
 
45
48
  static grpc_iomgr_platform_vtable vtable = {
46
49
  iomgr_platform_init, iomgr_platform_flush, iomgr_platform_shutdown,
47
- iomgr_platform_shutdown_background_closure};
50
+ iomgr_platform_shutdown_background_closure,
51
+ iomgr_platform_is_any_background_poller_thread};
48
52
 
49
53
  void grpc_custom_iomgr_init(grpc_socket_vtable* socket,
50
54
  grpc_custom_resolver_vtable* resolver,
@@ -45,3 +45,7 @@ void grpc_iomgr_platform_shutdown() { iomgr_platform_vtable->shutdown(); }
45
45
  void grpc_iomgr_platform_shutdown_background_closure() {
46
46
  iomgr_platform_vtable->shutdown_background_closure();
47
47
  }
48
+
49
+ bool grpc_iomgr_platform_is_any_background_poller_thread() {
50
+ return iomgr_platform_vtable->is_any_background_poller_thread();
51
+ }
@@ -36,6 +36,7 @@ typedef struct grpc_iomgr_platform_vtable {
36
36
  void (*flush)(void);
37
37
  void (*shutdown)(void);
38
38
  void (*shutdown_background_closure)(void);
39
+ bool (*is_any_background_poller_thread)(void);
39
40
  } grpc_iomgr_platform_vtable;
40
41
 
41
42
  void grpc_iomgr_register_object(grpc_iomgr_object* obj, const char* name);
@@ -56,6 +57,9 @@ void grpc_iomgr_platform_shutdown(void);
56
57
  /** shut down all the closures registered in the background poller */
57
58
  void grpc_iomgr_platform_shutdown_background_closure(void);
58
59
 
60
+ /** return true is the caller is a worker thread for any background poller */
61
+ bool grpc_iomgr_platform_is_any_background_poller_thread(void);
62
+
59
63
  bool grpc_iomgr_abort_on_leaks(void);
60
64
 
61
65
  #endif /* GRPC_CORE_LIB_IOMGR_IOMGR_INTERNAL_H */
@@ -55,9 +55,14 @@ static void iomgr_platform_shutdown_background_closure(void) {
55
55
  grpc_shutdown_background_closure();
56
56
  }
57
57
 
58
+ static bool iomgr_platform_is_any_background_poller_thread(void) {
59
+ return grpc_is_any_background_poller_thread();
60
+ }
61
+
58
62
  static grpc_iomgr_platform_vtable vtable = {
59
63
  iomgr_platform_init, iomgr_platform_flush, iomgr_platform_shutdown,
60
- iomgr_platform_shutdown_background_closure};
64
+ iomgr_platform_shutdown_background_closure,
65
+ iomgr_platform_is_any_background_poller_thread};
61
66
 
62
67
  void grpc_set_default_iomgr_platform() {
63
68
  grpc_set_tcp_client_impl(&grpc_posix_tcp_client_vtable);
@@ -69,4 +74,8 @@ void grpc_set_default_iomgr_platform() {
69
74
  grpc_set_iomgr_platform_vtable(&vtable);
70
75
  }
71
76
 
77
+ bool grpc_iomgr_run_in_background() {
78
+ return grpc_event_engine_run_in_background();
79
+ }
80
+
72
81
  #endif /* GRPC_POSIX_SOCKET_IOMGR */
@@ -73,9 +73,14 @@ static void iomgr_platform_shutdown(void) {
73
73
 
74
74
  static void iomgr_platform_shutdown_background_closure(void) {}
75
75
 
76
+ static bool iomgr_platform_is_any_background_poller_thread(void) {
77
+ return false;
78
+ }
79
+
76
80
  static grpc_iomgr_platform_vtable vtable = {
77
81
  iomgr_platform_init, iomgr_platform_flush, iomgr_platform_shutdown,
78
- iomgr_platform_shutdown_background_closure};
82
+ iomgr_platform_shutdown_background_closure,
83
+ iomgr_platform_is_any_background_poller_thread};
79
84
 
80
85
  void grpc_set_default_iomgr_platform() {
81
86
  grpc_set_tcp_client_impl(&grpc_windows_tcp_client_vtable);
@@ -87,4 +92,6 @@ void grpc_set_default_iomgr_platform() {
87
92
  grpc_set_iomgr_platform_vtable(&vtable);
88
93
  }
89
94
 
95
+ bool grpc_iomgr_run_in_background() { return false; }
96
+
90
97
  #endif /* GRPC_WINSOCK_SOCKET */
@@ -184,6 +184,7 @@
184
184
  #define GRPC_POSIX_SOCKET_EV_EPOLLEX 1
185
185
  #define GRPC_POSIX_SOCKET_EV_POLL 1
186
186
  #define GRPC_POSIX_SOCKET_EV_EPOLL1 1
187
+ #define GRPC_POSIX_SOCKET_IF_NAMETOINDEX 1
187
188
  #define GRPC_POSIX_SOCKET_IOMGR 1
188
189
  #define GRPC_POSIX_SOCKET_RESOLVE_ADDRESS 1
189
190
  #define GRPC_POSIX_SOCKET_SOCKADDR 1
@@ -105,7 +105,7 @@ static grpc_error* posix_blocking_resolve_address(
105
105
  grpc_error_set_str(
106
106
  grpc_error_set_str(
107
107
  grpc_error_set_int(
108
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("OS Error"),
108
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING(gai_strerror(s)),
109
109
  GRPC_ERROR_INT_ERRNO, s),
110
110
  GRPC_ERROR_STR_OS_ERROR,
111
111
  grpc_slice_from_static_string(gai_strerror(s))),
@@ -150,7 +150,7 @@ typedef struct {
150
150
  void* arg;
151
151
  } request;
152
152
 
153
- /* Callback to be passed to grpc_executor to asynch-ify
153
+ /* Callback to be passed to grpc Executor to asynch-ify
154
154
  * grpc_blocking_resolve_address */
155
155
  static void do_request_thread(void* rp, grpc_error* error) {
156
156
  request* r = static_cast<request*>(rp);
@@ -168,7 +168,8 @@ static void posix_resolve_address(const char* name, const char* default_port,
168
168
  request* r = static_cast<request*>(gpr_malloc(sizeof(request)));
169
169
  GRPC_CLOSURE_INIT(
170
170
  &r->request_closure, do_request_thread, r,
171
- grpc_executor_scheduler(GRPC_RESOLVER_EXECUTOR, GRPC_EXECUTOR_SHORT));
171
+ grpc_core::Executor::Scheduler(grpc_core::ExecutorType::RESOLVER,
172
+ grpc_core::ExecutorJobType::SHORT));
172
173
  r->name = gpr_strdup(name);
173
174
  r->default_port = gpr_strdup(default_port);
174
175
  r->on_done = on_done;
@@ -153,7 +153,8 @@ static void windows_resolve_address(const char* name, const char* default_port,
153
153
  request* r = (request*)gpr_malloc(sizeof(request));
154
154
  GRPC_CLOSURE_INIT(
155
155
  &r->request_closure, do_request_thread, r,
156
- grpc_executor_scheduler(GRPC_RESOLVER_EXECUTOR, GRPC_EXECUTOR_SHORT));
156
+ grpc_core::Executor::Scheduler(grpc_core::ExecutorType::RESOLVER,
157
+ grpc_core::ExecutorJobType::SHORT));
157
158
  r->name = gpr_strdup(name);
158
159
  r->default_port = gpr_strdup(default_port);
159
160
  r->on_done = on_done;
@@ -31,7 +31,6 @@
31
31
 
32
32
  #include "src/core/lib/iomgr/error.h"
33
33
  #include "src/core/lib/iomgr/iomgr_custom.h"
34
- #include "src/core/lib/iomgr/network_status_tracker.h"
35
34
  #include "src/core/lib/iomgr/resource_quota.h"
36
35
  #include "src/core/lib/iomgr/tcp_client.h"
37
36
  #include "src/core/lib/iomgr/tcp_custom.h"
@@ -309,7 +308,6 @@ static void custom_close_callback(grpc_custom_socket* socket) {
309
308
  }
310
309
 
311
310
  static void endpoint_destroy(grpc_endpoint* ep) {
312
- grpc_network_status_unregister_endpoint(ep);
313
311
  custom_tcp_endpoint* tcp = (custom_tcp_endpoint*)ep;
314
312
  grpc_custom_socket_vtable->close(tcp->socket, custom_close_callback);
315
313
  }
@@ -361,8 +359,6 @@ grpc_endpoint* custom_tcp_endpoint_create(grpc_custom_socket* socket,
361
359
  tcp->resource_user = grpc_resource_user_create(resource_quota, peer_string);
362
360
  grpc_resource_user_slice_allocator_init(
363
361
  &tcp->slice_allocator, tcp->resource_user, tcp_read_allocation_done, tcp);
364
- /* Tell network status tracking code about the new endpoint */
365
- grpc_network_status_register_endpoint(&tcp->base);
366
362
 
367
363
  return &tcp->base;
368
364
  }
@@ -22,7 +22,6 @@
22
22
 
23
23
  #ifdef GRPC_POSIX_SOCKET_TCP
24
24
 
25
- #include "src/core/lib/iomgr/network_status_tracker.h"
26
25
  #include "src/core/lib/iomgr/tcp_posix.h"
27
26
 
28
27
  #include <errno.h>
@@ -127,9 +126,8 @@ struct grpc_tcp {
127
126
  bool socket_ts_enabled; /* True if timestamping options are set on the socket
128
127
  */
129
128
  bool ts_capable; /* Cache whether we can set timestamping options */
130
- gpr_atm
131
- stop_error_notification; /* Set to 1 if we do not want to be notified on
132
- errors anymore */
129
+ gpr_atm stop_error_notification; /* Set to 1 if we do not want to be notified
130
+ on errors anymore */
133
131
  };
134
132
 
135
133
  struct backup_poller {
@@ -197,7 +195,7 @@ static void run_poller(void* bp, grpc_error* error_ignored) {
197
195
  static void drop_uncovered(grpc_tcp* tcp) {
198
196
  backup_poller* p = (backup_poller*)gpr_atm_acq_load(&g_backup_poller);
199
197
  gpr_atm old_count =
200
- gpr_atm_no_barrier_fetch_add(&g_uncovered_notifications_pending, -1);
198
+ gpr_atm_full_fetch_add(&g_uncovered_notifications_pending, -1);
201
199
  if (grpc_tcp_trace.enabled()) {
202
200
  gpr_log(GPR_INFO, "BACKUP_POLLER:%p uncover cnt %d->%d", p,
203
201
  static_cast<int>(old_count), static_cast<int>(old_count) - 1);
@@ -229,10 +227,10 @@ static void cover_self(grpc_tcp* tcp) {
229
227
  }
230
228
  grpc_pollset_init(BACKUP_POLLER_POLLSET(p), &p->pollset_mu);
231
229
  gpr_atm_rel_store(&g_backup_poller, (gpr_atm)p);
232
- GRPC_CLOSURE_SCHED(
233
- GRPC_CLOSURE_INIT(&p->run_poller, run_poller, p,
234
- grpc_executor_scheduler(GRPC_EXECUTOR_LONG)),
235
- GRPC_ERROR_NONE);
230
+ GRPC_CLOSURE_SCHED(GRPC_CLOSURE_INIT(&p->run_poller, run_poller, p,
231
+ grpc_core::Executor::Scheduler(
232
+ grpc_core::ExecutorJobType::LONG)),
233
+ GRPC_ERROR_NONE);
236
234
  } else {
237
235
  while ((p = (backup_poller*)gpr_atm_acq_load(&g_backup_poller)) ==
238
236
  nullptr) {
@@ -345,6 +343,13 @@ static void tcp_free(grpc_tcp* tcp) {
345
343
  grpc_slice_buffer_destroy_internal(&tcp->last_read_buffer);
346
344
  grpc_resource_user_unref(tcp->resource_user);
347
345
  gpr_free(tcp->peer_string);
346
+ /* The lock is not really necessary here, since all refs have been released */
347
+ gpr_mu_lock(&tcp->tb_mu);
348
+ grpc_core::TracedBuffer::Shutdown(
349
+ &tcp->tb_head, tcp->outgoing_buffer_arg,
350
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("endpoint destroyed"));
351
+ gpr_mu_unlock(&tcp->tb_mu);
352
+ tcp->outgoing_buffer_arg = nullptr;
348
353
  gpr_mu_destroy(&tcp->tb_mu);
349
354
  gpr_free(tcp);
350
355
  }
@@ -388,16 +393,9 @@ static void tcp_ref(grpc_tcp* tcp) { gpr_ref(&tcp->refcount); }
388
393
  #endif
389
394
 
390
395
  static void tcp_destroy(grpc_endpoint* ep) {
391
- grpc_network_status_unregister_endpoint(ep);
392
396
  grpc_tcp* tcp = reinterpret_cast<grpc_tcp*>(ep);
393
397
  grpc_slice_buffer_reset_and_unref_internal(&tcp->last_read_buffer);
394
398
  if (grpc_event_engine_can_track_errors()) {
395
- gpr_mu_lock(&tcp->tb_mu);
396
- grpc_core::TracedBuffer::Shutdown(
397
- &tcp->tb_head, tcp->outgoing_buffer_arg,
398
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("endpoint destroyed"));
399
- gpr_mu_unlock(&tcp->tb_mu);
400
- tcp->outgoing_buffer_arg = nullptr;
401
399
  gpr_atm_no_barrier_store(&tcp->stop_error_notification, true);
402
400
  grpc_fd_set_error(tcp->em_fd);
403
401
  }
@@ -411,13 +409,15 @@ static void call_read_cb(grpc_tcp* tcp, grpc_error* error) {
411
409
  gpr_log(GPR_INFO, "TCP:%p call_cb %p %p:%p", tcp, cb, cb->cb, cb->cb_arg);
412
410
  size_t i;
413
411
  const char* str = grpc_error_string(error);
414
- gpr_log(GPR_INFO, "read: error=%s", str);
415
-
416
- for (i = 0; i < tcp->incoming_buffer->count; i++) {
417
- char* dump = grpc_dump_slice(tcp->incoming_buffer->slices[i],
418
- GPR_DUMP_HEX | GPR_DUMP_ASCII);
419
- gpr_log(GPR_INFO, "READ %p (peer=%s): %s", tcp, tcp->peer_string, dump);
420
- gpr_free(dump);
412
+ gpr_log(GPR_INFO, "READ %p (peer=%s) error=%s", tcp, tcp->peer_string, str);
413
+
414
+ if (gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
415
+ for (i = 0; i < tcp->incoming_buffer->count; i++) {
416
+ char* dump = grpc_dump_slice(tcp->incoming_buffer->slices[i],
417
+ GPR_DUMP_HEX | GPR_DUMP_ASCII);
418
+ gpr_log(GPR_DEBUG, "DATA: %s", dump);
419
+ gpr_free(dump);
420
+ }
421
421
  }
422
422
  }
423
423
 
@@ -596,6 +596,7 @@ static bool tcp_write_with_timestamps(grpc_tcp* tcp, struct msghdr* msg,
596
596
  static void tcp_handle_error(void* arg /* grpc_tcp */, grpc_error* error);
597
597
 
598
598
  #ifdef GRPC_LINUX_ERRQUEUE
599
+
599
600
  static bool tcp_write_with_timestamps(grpc_tcp* tcp, struct msghdr* msg,
600
601
  size_t sending_length,
601
602
  ssize_t* sent_length) {
@@ -634,7 +635,7 @@ static bool tcp_write_with_timestamps(grpc_tcp* tcp, struct msghdr* msg,
634
635
  gpr_mu_lock(&tcp->tb_mu);
635
636
  grpc_core::TracedBuffer::AddNewEntry(
636
637
  &tcp->tb_head, static_cast<uint32_t>(tcp->bytes_counter + length),
637
- tcp->outgoing_buffer_arg);
638
+ tcp->fd, tcp->outgoing_buffer_arg);
638
639
  gpr_mu_unlock(&tcp->tb_mu);
639
640
  tcp->outgoing_buffer_arg = nullptr;
640
641
  }
@@ -651,6 +652,7 @@ static bool tcp_write_with_timestamps(grpc_tcp* tcp, struct msghdr* msg,
651
652
  struct cmsghdr* process_timestamp(grpc_tcp* tcp, msghdr* msg,
652
653
  struct cmsghdr* cmsg) {
653
654
  auto next_cmsg = CMSG_NXTHDR(msg, cmsg);
655
+ cmsghdr* opt_stats = nullptr;
654
656
  if (next_cmsg == nullptr) {
655
657
  if (grpc_tcp_trace.enabled()) {
656
658
  gpr_log(GPR_ERROR, "Received timestamp without extended error");
@@ -658,6 +660,19 @@ struct cmsghdr* process_timestamp(grpc_tcp* tcp, msghdr* msg,
658
660
  return cmsg;
659
661
  }
660
662
 
663
+ /* Check if next_cmsg is an OPT_STATS msg */
664
+ if (next_cmsg->cmsg_level == SOL_SOCKET &&
665
+ next_cmsg->cmsg_type == SCM_TIMESTAMPING_OPT_STATS) {
666
+ opt_stats = next_cmsg;
667
+ next_cmsg = CMSG_NXTHDR(msg, opt_stats);
668
+ if (next_cmsg == nullptr) {
669
+ if (grpc_tcp_trace.enabled()) {
670
+ gpr_log(GPR_ERROR, "Received timestamp without extended error");
671
+ }
672
+ return opt_stats;
673
+ }
674
+ }
675
+
661
676
  if (!(next_cmsg->cmsg_level == SOL_IP || next_cmsg->cmsg_level == SOL_IPV6) ||
662
677
  !(next_cmsg->cmsg_type == IP_RECVERR ||
663
678
  next_cmsg->cmsg_type == IPV6_RECVERR)) {
@@ -679,7 +694,8 @@ struct cmsghdr* process_timestamp(grpc_tcp* tcp, msghdr* msg,
679
694
  * to protect the traced buffer list. A lock free list might be better. Using
680
695
  * a simple mutex for now. */
681
696
  gpr_mu_lock(&tcp->tb_mu);
682
- grpc_core::TracedBuffer::ProcessTimestamp(&tcp->tb_head, serr, tss);
697
+ grpc_core::TracedBuffer::ProcessTimestamp(&tcp->tb_head, serr, opt_stats,
698
+ tss);
683
699
  gpr_mu_unlock(&tcp->tb_mu);
684
700
  return next_cmsg;
685
701
  }
@@ -699,9 +715,15 @@ static void process_errors(grpc_tcp* tcp) {
699
715
  msg.msg_iovlen = 0;
700
716
  msg.msg_flags = 0;
701
717
 
718
+ /* Allocate enough space so we don't need to keep increasing this as size
719
+ * of OPT_STATS increase */
720
+ constexpr size_t cmsg_alloc_space =
721
+ CMSG_SPACE(sizeof(grpc_core::scm_timestamping)) +
722
+ CMSG_SPACE(sizeof(sock_extended_err) + sizeof(sockaddr_in)) +
723
+ CMSG_SPACE(32 * NLA_ALIGN(NLA_HDRLEN + sizeof(uint64_t)));
724
+ /* Allocate aligned space for cmsgs received along with timestamps */
702
725
  union {
703
- char rbuf[1024 /*CMSG_SPACE(sizeof(scm_timestamping)) +
704
- CMSG_SPACE(sizeof(sock_extended_err) + sizeof(sockaddr_in))*/];
726
+ char rbuf[cmsg_alloc_space];
705
727
  struct cmsghdr align;
706
728
  } aligned_buf;
707
729
  memset(&aligned_buf, 0, sizeof(aligned_buf));
@@ -721,10 +743,8 @@ static void process_errors(grpc_tcp* tcp) {
721
743
  if (r == -1) {
722
744
  return;
723
745
  }
724
- if (grpc_tcp_trace.enabled()) {
725
- if ((msg.msg_flags & MSG_CTRUNC) == 1) {
726
- gpr_log(GPR_INFO, "Error message was truncated.");
727
- }
746
+ if ((msg.msg_flags & MSG_CTRUNC) == 1) {
747
+ gpr_log(GPR_ERROR, "Error message was truncated.");
728
748
  }
729
749
 
730
750
  if (msg.msg_controllen == 0) {
@@ -961,10 +981,13 @@ static void tcp_write(grpc_endpoint* ep, grpc_slice_buffer* buf,
961
981
  size_t i;
962
982
 
963
983
  for (i = 0; i < buf->count; i++) {
964
- char* data =
965
- grpc_dump_slice(buf->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII);
966
- gpr_log(GPR_INFO, "WRITE %p (peer=%s): %s", tcp, tcp->peer_string, data);
967
- gpr_free(data);
984
+ gpr_log(GPR_INFO, "WRITE %p (peer=%s)", tcp, tcp->peer_string);
985
+ if (gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
986
+ char* data =
987
+ grpc_dump_slice(buf->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII);
988
+ gpr_log(GPR_DEBUG, "DATA: %s", data);
989
+ gpr_free(data);
990
+ }
968
991
  }
969
992
  }
970
993
 
@@ -1131,8 +1154,6 @@ grpc_endpoint* grpc_tcp_create(grpc_fd* em_fd,
1131
1154
  tcp->resource_user = grpc_resource_user_create(resource_quota, peer_string);
1132
1155
  grpc_resource_user_slice_allocator_init(
1133
1156
  &tcp->slice_allocator, tcp->resource_user, tcp_read_allocation_done, tcp);
1134
- /* Tell network status tracker about new endpoint */
1135
- grpc_network_status_register_endpoint(&tcp->base);
1136
1157
  grpc_resource_quota_unref_internal(resource_quota);
1137
1158
  gpr_mu_init(&tcp->tb_mu);
1138
1159
  tcp->tb_head = nullptr;
@@ -1159,7 +1180,6 @@ int grpc_tcp_fd(grpc_endpoint* ep) {
1159
1180
 
1160
1181
  void grpc_tcp_destroy_and_release_fd(grpc_endpoint* ep, int* fd,
1161
1182
  grpc_closure* done) {
1162
- grpc_network_status_unregister_endpoint(ep);
1163
1183
  grpc_tcp* tcp = reinterpret_cast<grpc_tcp*>(ep);
1164
1184
  GPR_ASSERT(ep->vtable == &vtable);
1165
1185
  tcp->release_fd = fd;
@@ -1167,12 +1187,6 @@ void grpc_tcp_destroy_and_release_fd(grpc_endpoint* ep, int* fd,
1167
1187
  grpc_slice_buffer_reset_and_unref_internal(&tcp->last_read_buffer);
1168
1188
  if (grpc_event_engine_can_track_errors()) {
1169
1189
  /* Stop errors notification. */
1170
- gpr_mu_lock(&tcp->tb_mu);
1171
- grpc_core::TracedBuffer::Shutdown(
1172
- &tcp->tb_head, tcp->outgoing_buffer_arg,
1173
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("endpoint destroyed"));
1174
- gpr_mu_unlock(&tcp->tb_mu);
1175
- tcp->outgoing_buffer_arg = nullptr;
1176
1190
  gpr_atm_no_barrier_store(&tcp->stop_error_notification, true);
1177
1191
  grpc_fd_set_error(tcp->em_fd);
1178
1192
  }
@@ -33,7 +33,6 @@
33
33
  #include "src/core/lib/gpr/string.h"
34
34
  #include "src/core/lib/iomgr/error.h"
35
35
  #include "src/core/lib/iomgr/iomgr_custom.h"
36
- #include "src/core/lib/iomgr/network_status_tracker.h"
37
36
  #include "src/core/lib/iomgr/resolve_address_custom.h"
38
37
  #include "src/core/lib/iomgr/resource_quota.h"
39
38
  #include "src/core/lib/iomgr/tcp_custom.h"
@@ -24,7 +24,6 @@
24
24
 
25
25
  #include <limits.h>
26
26
 
27
- #include "src/core/lib/iomgr/network_status_tracker.h"
28
27
  #include "src/core/lib/iomgr/sockaddr_windows.h"
29
28
 
30
29
  #include <grpc/slice_buffer.h>
@@ -470,7 +469,6 @@ static void win_shutdown(grpc_endpoint* ep, grpc_error* why) {
470
469
  }
471
470
 
472
471
  static void win_destroy(grpc_endpoint* ep) {
473
- grpc_network_status_unregister_endpoint(ep);
474
472
  grpc_tcp* tcp = (grpc_tcp*)ep;
475
473
  grpc_slice_buffer_reset_and_unref_internal(&tcp->last_read_buffer);
476
474
  TCP_UNREF(tcp, "destroy");
@@ -526,8 +524,6 @@ grpc_endpoint* grpc_tcp_create(grpc_winsocket* socket,
526
524
  tcp->peer_string = gpr_strdup(peer_string);
527
525
  grpc_slice_buffer_init(&tcp->last_read_buffer);
528
526
  tcp->resource_user = grpc_resource_user_create(resource_quota, peer_string);
529
- /* Tell network status tracking code about the new endpoint */
530
- grpc_network_status_register_endpoint(&tcp->base);
531
527
  grpc_resource_quota_unref_internal(resource_quota);
532
528
 
533
529
  return &tcp->base;
@@ -105,6 +105,14 @@ void grpc_timer_manager_tick() {
105
105
  }
106
106
 
107
107
  static void run_some_timers() {
108
+ // In the case of timers, the ExecCtx for the thread is declared
109
+ // in the timer thread itself, but this is the point where we
110
+ // could start seeing application-level callbacks. No need to
111
+ // create a new ExecCtx, though, since there already is one and it is
112
+ // flushed (but not destructed) in this function itself
113
+ grpc_core::ApplicationCallbackExecCtx callback_exec_ctx(
114
+ GRPC_APP_CALLBACK_EXEC_CTX_FLAG_IS_INTERNAL_THREAD);
115
+
108
116
  // if there's something to execute...
109
117
  gpr_mu_lock(&g_mu);
110
118
  // remove a waiter from the pool, and start another thread if necessary