grpc 1.82.2 → 1.83.0.pre1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +8 -5
  3. data/etc/roots.pem +10400 -3855
  4. data/include/grpc/grpc_audit_logging.h +2 -2
  5. data/include/grpc/grpc_security_constants.h +2 -0
  6. data/include/grpc/impl/channel_arg_names.h +23 -0
  7. data/src/core/call/call_filters.h +19 -3
  8. data/src/core/call/call_spine.h +4 -4
  9. data/src/core/call/client_call.cc +1 -1
  10. data/src/core/call/metadata.cc +7 -2
  11. data/src/core/call/server_call.cc +13 -3
  12. data/src/core/call/server_call.h +5 -3
  13. data/src/core/client_channel/backup_poller.cc +2 -17
  14. data/src/core/client_channel/client_channel.cc +17 -14
  15. data/src/core/client_channel/client_channel.h +3 -1
  16. data/src/core/client_channel/client_channel_filter.cc +11 -13
  17. data/src/core/client_channel/client_channel_service_config.cc +5 -13
  18. data/src/core/client_channel/direct_channel.cc +5 -1
  19. data/src/core/client_channel/direct_channel.h +3 -1
  20. data/src/core/config/experiment_env_var.cc +30 -0
  21. data/src/core/config/experiment_env_var.h +26 -0
  22. data/src/core/credentials/call/regional_access_boundary_fetcher.cc +6 -6
  23. data/src/core/credentials/transport/ssl/ssl_security_connector.cc +14 -2
  24. data/src/core/credentials/transport/tls/grpc_tls_certificate_selector.cc +172 -0
  25. data/src/core/credentials/transport/tls/grpc_tls_certificate_selector.h +103 -0
  26. data/src/core/credentials/transport/tls/load_system_roots_fallback.cc +3 -2
  27. data/src/core/credentials/transport/tls/load_system_roots_supported.cc +10 -3
  28. data/src/core/credentials/transport/tls/tls_security_connector.cc +14 -2
  29. data/src/core/credentials/transport/xds/xds_credentials.cc +4 -12
  30. data/src/core/ext/filters/http/message_compress/compression_filter.cc +32 -25
  31. data/src/core/ext/filters/http/message_compress/compression_filter.h +1 -0
  32. data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +2 -1
  33. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +19 -13
  34. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +14 -57
  35. data/src/core/ext/transport/chttp2/transport/flow_control.cc +2 -2
  36. data/src/core/ext/transport/chttp2/transport/flow_control.h +3 -2
  37. data/src/core/ext/transport/chttp2/transport/frame.cc +58 -1
  38. data/src/core/ext/transport/chttp2/transport/frame.h +13 -1
  39. data/src/core/ext/transport/chttp2/transport/frame_data.cc +2 -34
  40. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +23 -55
  41. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +0 -1
  42. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +2 -4
  43. data/src/core/ext/transport/chttp2/transport/frame_security.cc +10 -1
  44. data/src/core/ext/transport/chttp2/transport/frame_security.h +2 -1
  45. data/src/core/ext/transport/chttp2/transport/goaway.cc +11 -1
  46. data/src/core/ext/transport/chttp2/transport/goaway.h +17 -1
  47. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +9 -0
  48. data/src/core/ext/transport/chttp2/transport/http2_client_transport.cc +117 -276
  49. data/src/core/ext/transport/chttp2/transport/http2_client_transport.h +44 -17
  50. data/src/core/ext/transport/chttp2/transport/http2_server_transport.cc +382 -496
  51. data/src/core/ext/transport/chttp2/transport/http2_server_transport.h +75 -77
  52. data/src/core/ext/transport/chttp2/transport/http2_settings.cc +1 -1
  53. data/src/core/ext/transport/chttp2/transport/http2_settings.h +30 -11
  54. data/src/core/ext/transport/chttp2/transport/http2_settings_promises.h +24 -9
  55. data/src/core/ext/transport/chttp2/transport/http2_transport.cc +26 -0
  56. data/src/core/ext/transport/chttp2/transport/http2_transport.h +2 -0
  57. data/src/core/ext/transport/chttp2/transport/internal.h +4 -6
  58. data/src/core/ext/transport/chttp2/transport/parsing.cc +3 -10
  59. data/src/core/ext/transport/chttp2/transport/ping_promise.cc +1 -1
  60. data/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc +4 -10
  61. data/src/core/ext/transport/chttp2/transport/read_context.h +62 -20
  62. data/src/core/ext/transport/chttp2/transport/security_frame.h +1 -0
  63. data/src/core/ext/transport/chttp2/transport/stream.h +271 -120
  64. data/src/core/ext/transport/chttp2/transport/stream_data_queue.h +77 -61
  65. data/src/core/handshaker/security/secure_endpoint.cc +0 -13
  66. data/src/core/lib/channel/promise_based_filter.cc +77 -3
  67. data/src/core/lib/channel/promise_based_filter.h +238 -184
  68. data/src/core/lib/compression/message_compress.cc +97 -132
  69. data/src/core/lib/compression/message_compress.h +0 -24
  70. data/src/core/lib/event_engine/extensions/receive_coalescing_extension.h +0 -4
  71. data/src/core/lib/event_engine/extensions/tcp_trace.h +1 -1
  72. data/src/core/lib/event_engine/posix_engine/posix_engine.cc +2 -12
  73. data/src/core/lib/event_engine/shim.cc +2 -16
  74. data/src/core/lib/event_engine/shim.h +0 -4
  75. data/src/core/lib/experiments/experiments.cc +57 -123
  76. data/src/core/lib/experiments/experiments.h +43 -82
  77. data/src/core/lib/iomgr/error.cc +3 -73
  78. data/src/core/lib/iomgr/error.h +8 -6
  79. data/src/core/lib/iomgr/error_cfstream.cc +1 -2
  80. data/src/core/lib/iomgr/ev_epoll1_linux.cc +2 -6
  81. data/src/core/lib/iomgr/ev_poll_posix.cc +2 -6
  82. data/src/core/lib/iomgr/tcp_posix.cc +2 -6
  83. data/src/core/lib/security/authorization/audit_logging.cc +2 -2
  84. data/src/core/lib/security/authorization/audit_logging.h +3 -3
  85. data/src/core/lib/security/authorization/grpc_authorization_engine.cc +11 -13
  86. data/src/core/lib/security/authorization/grpc_authorization_engine.h +1 -1
  87. data/src/core/lib/security/authorization/matchers.cc +20 -20
  88. data/src/core/lib/security/authorization/matchers.h +15 -16
  89. data/src/core/lib/security/authorization/rbac_policy.h +1 -1
  90. data/src/core/lib/security/authorization/stdout_logger.cc +3 -3
  91. data/src/core/lib/security/authorization/stdout_logger.h +6 -5
  92. data/src/core/lib/surface/call.cc +0 -8
  93. data/src/core/lib/surface/call.h +2 -0
  94. data/src/core/lib/surface/channel.cc +21 -2
  95. data/src/core/lib/surface/channel.h +14 -6
  96. data/src/core/lib/surface/filter_stack_call.cc +10 -29
  97. data/src/core/lib/surface/legacy_channel.cc +7 -7
  98. data/src/core/lib/surface/legacy_channel.h +3 -1
  99. data/src/core/lib/surface/version.cc +2 -2
  100. data/src/core/lib/transport/bdp_estimator.cc +13 -13
  101. data/src/core/lib/transport/bdp_estimator.h +9 -5
  102. data/src/core/lib/transport/error_utils.cc +26 -138
  103. data/src/core/lib/transport/promise_endpoint.h +2 -4
  104. data/src/core/load_balancing/grpclb/grpclb.cc +2 -1
  105. data/src/core/load_balancing/pick_first/pick_first.cc +33 -2
  106. data/src/core/load_balancing/pick_first/pick_first.h +6 -0
  107. data/src/core/load_balancing/ring_hash/ring_hash.cc +3 -10
  108. data/src/core/load_balancing/rls/rls.cc +2 -1
  109. data/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc +2 -7
  110. data/src/core/load_balancing/xds/cds.cc +80 -56
  111. data/src/core/load_balancing/xds/cds.h +21 -0
  112. data/src/core/mitigation_engine/mitigation.h +53 -0
  113. data/src/core/mitigation_engine/mitigation_provider.h +62 -0
  114. data/src/core/resolver/dns/dns_resolver_plugin.cc +1 -6
  115. data/src/core/resolver/xds/xds_resolver.cc +14 -11
  116. data/src/core/server/server.h +1 -4
  117. data/src/core/server/server_config_selector.h +5 -4
  118. data/src/core/server/server_config_selector_filter.cc +67 -80
  119. data/src/core/server/xds_server_config_fetcher.cc +681 -692
  120. data/src/core/server/xds_server_config_fetcher_legacy.cc +15 -12
  121. data/src/core/telemetry/call_tracer.cc +49 -2
  122. data/src/core/telemetry/call_tracer.h +1 -0
  123. data/src/core/telemetry/tcp_tracer.h +38 -0
  124. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +1 -1
  125. data/src/core/tsi/ssl_telemetry_utils.cc +343 -0
  126. data/src/core/tsi/ssl_telemetry_utils.h +74 -0
  127. data/src/core/tsi/ssl_transport_security.cc +577 -301
  128. data/src/core/tsi/ssl_transport_security.h +22 -6
  129. data/src/core/tsi/ssl_transport_security_utils.cc +2 -0
  130. data/src/core/tsi/transport_security.h +7 -0
  131. data/src/core/util/http_client/httpcli.cc +1 -4
  132. data/src/core/util/http_client/httpcli_security_connector.cc +2 -1
  133. data/src/core/util/status_helper.cc +71 -192
  134. data/src/core/util/status_helper.h +16 -21
  135. data/src/core/xds/grpc/file_watcher_certificate_provider_factory.cc +2 -11
  136. data/src/core/xds/grpc/xds_bootstrap_grpc.cc +2 -7
  137. data/src/core/xds/grpc/xds_cluster_parser.cc +5 -16
  138. data/src/core/xds/grpc/xds_common_types.cc +94 -38
  139. data/src/core/xds/grpc/xds_common_types.h +33 -18
  140. data/src/core/xds/grpc/xds_common_types_parser.cc +168 -100
  141. data/src/core/xds/grpc/xds_common_types_parser.h +18 -1
  142. data/src/core/xds/grpc/xds_endpoint_parser.cc +6 -17
  143. data/src/core/xds/grpc/xds_http_filter_registry.cc +2 -10
  144. data/src/core/xds/grpc/xds_http_rbac_filter.cc +3 -12
  145. data/src/core/xds/grpc/xds_metadata_parser.cc +0 -2
  146. data/src/core/xds/grpc/xds_route_config_parser.cc +7 -11
  147. data/src/core/xds/grpc/xds_routing.cc +113 -82
  148. data/src/core/xds/grpc/xds_routing.h +70 -20
  149. data/src/core/xds/grpc/xds_server_grpc.cc +22 -13
  150. data/src/core/xds/grpc/xds_server_grpc.h +16 -2
  151. data/src/core/xds/grpc/xds_server_grpc_interface.h +10 -0
  152. data/src/core/xds/grpc/xds_transport_grpc.cc +123 -18
  153. data/src/core/xds/grpc/xds_transport_grpc.h +28 -4
  154. data/src/core/xds/xds_client/lrs_client.cc +3 -7
  155. data/src/core/xds/xds_client/xds_bootstrap.cc +4 -16
  156. data/src/core/xds/xds_client/xds_client.cc +2 -15
  157. data/src/core/xds/xds_client/xds_transport.h +3 -0
  158. data/src/ruby/lib/grpc/version.rb +1 -1
  159. data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +1 -1
  160. metadata +10 -2
@@ -25,203 +25,168 @@
25
25
  #include <zconf.h>
26
26
  #include <zlib.h>
27
27
 
28
- #include <algorithm>
29
- #include <cstdint>
30
- #include <optional>
31
-
32
28
  #include "src/core/lib/slice/slice.h"
33
29
  #include "src/core/util/grpc_check.h"
34
- #include "src/core/util/status_helper.h"
35
30
  #include "absl/log/log.h"
36
- #include "absl/status/status.h"
37
- #include "absl/status/statusor.h"
38
31
 
39
32
  #define OUTPUT_BLOCK_SIZE 1024
40
33
 
41
- namespace grpc_core {
42
- namespace {
43
-
44
- absl::StatusOr<SliceBuffer> ZlibBody(z_stream* zs, const SliceBuffer& input,
45
- int (*flate)(z_stream* zs, int flush),
46
- std::optional<uint32_t> max_output_size) {
34
+ static int zlib_body(z_stream* zs, grpc_slice_buffer* input,
35
+ grpc_slice_buffer* output,
36
+ int (*flate)(z_stream* zs, int flush)) {
47
37
  int r = Z_STREAM_END; // Do not fail on an empty input.
48
38
  int flush;
49
39
  size_t i;
50
- uint32_t remaining_output_size = max_output_size.value_or(UINT32_MAX);
51
- SliceBuffer output_sb;
40
+ grpc_slice outbuf = GRPC_SLICE_MALLOC(OUTPUT_BLOCK_SIZE);
52
41
  const uInt uint_max = ~uInt{0};
53
- auto outbuf = MutableSlice::CreateUninitialized(
54
- std::min<uint32_t>(remaining_output_size, OUTPUT_BLOCK_SIZE));
55
42
 
56
- GRPC_CHECK(outbuf.length() <= uint_max);
57
- zs->avail_out = static_cast<uInt>(outbuf.length());
58
- zs->next_out = const_cast<uint8_t*>(outbuf.begin());
43
+ GRPC_CHECK(GRPC_SLICE_LENGTH(outbuf) <= uint_max);
44
+ zs->avail_out = static_cast<uInt> GRPC_SLICE_LENGTH(outbuf);
45
+ zs->next_out = GRPC_SLICE_START_PTR(outbuf);
59
46
  flush = Z_NO_FLUSH;
60
- for (i = 0; i < input.Count(); i++) {
61
- if (i == input.Count() - 1) {
62
- flush = Z_FINISH;
63
- }
64
- GRPC_CHECK(input[i].length() <= uint_max);
65
- zs->avail_in = static_cast<uInt>(input[i].length());
66
- zs->next_in = const_cast<uint8_t*>(input[i].begin());
47
+ for (i = 0; i < input->count; i++) {
48
+ if (i == input->count - 1) flush = Z_FINISH;
49
+ GRPC_CHECK(GRPC_SLICE_LENGTH(input->slices[i]) <= uint_max);
50
+ zs->avail_in = static_cast<uInt> GRPC_SLICE_LENGTH(input->slices[i]);
51
+ zs->next_in = GRPC_SLICE_START_PTR(input->slices[i]);
67
52
  do {
68
53
  if (zs->avail_out == 0) {
69
- if (max_output_size.has_value() && remaining_output_size == 0) {
70
- VLOG(2) << "zlib: max provided output size exceeded";
71
- return absl::ResourceExhaustedError(
72
- "Decompressed message larger than max");
73
- }
74
- output_sb.AppendIndexed(Slice(std::move(outbuf)));
75
- outbuf = MutableSlice::CreateUninitialized(
76
- std::min<uint32_t>(remaining_output_size, OUTPUT_BLOCK_SIZE));
77
- // Update remaining output size to reflect the size of the slice we just
78
- // filled with compressed / decompressed data.
79
- if (max_output_size.has_value()) {
80
- remaining_output_size -= outbuf.length();
81
- }
82
- GRPC_CHECK(outbuf.length() <= uint_max);
83
- zs->avail_out = static_cast<uInt>(outbuf.length());
84
- zs->next_out = const_cast<uint8_t*>(outbuf.begin());
54
+ grpc_slice_buffer_add_indexed(output, outbuf);
55
+ outbuf = GRPC_SLICE_MALLOC(OUTPUT_BLOCK_SIZE);
56
+ GRPC_CHECK(GRPC_SLICE_LENGTH(outbuf) <= uint_max);
57
+ zs->avail_out = static_cast<uInt> GRPC_SLICE_LENGTH(outbuf);
58
+ zs->next_out = GRPC_SLICE_START_PTR(outbuf);
85
59
  }
86
60
  r = flate(zs, flush);
87
61
  if (r < 0 && r != Z_BUF_ERROR /* not fatal */) {
88
62
  VLOG(2) << "zlib error (" << r << ")";
89
- return absl::InternalError("Decompression failed due to zlib error");
63
+ goto error;
90
64
  }
91
65
  } while (zs->avail_out == 0);
92
66
  if (zs->avail_in) {
93
67
  VLOG(2) << "zlib: not all input consumed";
94
- return absl::InternalError(
95
- "Decompression failed due to not all input "
96
- "consumed");
68
+ goto error;
97
69
  }
98
70
  }
99
71
  if (r != Z_STREAM_END) {
100
72
  VLOG(2) << "zlib: Data error";
101
- return absl::InternalError("Decompression failed due to data error");
73
+ goto error;
102
74
  }
103
75
 
104
- // TODO(vigneshbabu): Add a Truncate() method to the Slice type to avoid using
105
- // the underlying C type here.
106
- grpc_slice slice = outbuf.TakeCSlice();
107
- if (slice.refcount) {
108
- slice.data.refcounted.length -= zs->avail_out;
109
- } else {
110
- slice.data.inlined.length -= zs->avail_out;
111
- }
112
- output_sb.AppendIndexed(Slice(slice));
113
- return output_sb;
76
+ GRPC_CHECK(outbuf.refcount);
77
+ outbuf.data.refcounted.length -= zs->avail_out;
78
+ grpc_slice_buffer_add_indexed(output, outbuf);
79
+
80
+ return 1;
81
+
82
+ error:
83
+ grpc_core::CSliceUnref(outbuf);
84
+ return 0;
114
85
  }
115
86
 
116
- void* ZallocGpr(void* /*opaque*/, unsigned int items, unsigned int size) {
87
+ static void* zalloc_gpr(void* /*opaque*/, unsigned int items,
88
+ unsigned int size) {
117
89
  return gpr_malloc(items * size);
118
90
  }
119
91
 
120
- void ZFreeGpr(void* /*opaque*/, void* address) { gpr_free(address); }
92
+ static void zfree_gpr(void* /*opaque*/, void* address) { gpr_free(address); }
121
93
 
122
- std::optional<SliceBuffer> ZlibCompress(const SliceBuffer& input, int gzip) {
94
+ static int zlib_compress(grpc_slice_buffer* input, grpc_slice_buffer* output,
95
+ int gzip) {
123
96
  z_stream zs;
124
- absl::StatusOr<SliceBuffer> compression_result;
97
+ int r;
98
+ size_t i;
99
+ size_t count_before = output->count;
100
+ size_t length_before = output->length;
125
101
  memset(&zs, 0, sizeof(zs));
126
- zs.zalloc = ZallocGpr;
127
- zs.zfree = ZFreeGpr;
128
- bool r = deflateInit2(&zs, Z_DEFAULT_COMPRESSION, Z_DEFLATED,
129
- 15 | (gzip ? 16 : 0), 8, Z_DEFAULT_STRATEGY);
102
+ zs.zalloc = zalloc_gpr;
103
+ zs.zfree = zfree_gpr;
104
+ r = deflateInit2(&zs, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 15 | (gzip ? 16 : 0),
105
+ 8, Z_DEFAULT_STRATEGY);
130
106
  GRPC_CHECK(r == Z_OK);
131
- compression_result = ZlibBody(&zs, input, deflate, input.Length());
132
- deflateEnd(&zs);
133
- if (compression_result.ok() &&
134
- compression_result->Length() < input.Length()) {
135
- return std::move(*compression_result);
107
+ r = zlib_body(&zs, input, output, deflate) && output->length < input->length;
108
+ if (!r) {
109
+ for (i = count_before; i < output->count; i++) {
110
+ grpc_core::CSliceUnref(output->slices[i]);
111
+ }
112
+ output->count = count_before;
113
+ output->length = length_before;
136
114
  }
137
- return std::nullopt;
115
+ deflateEnd(&zs);
116
+ return r;
138
117
  }
139
118
 
140
- absl::StatusOr<SliceBuffer> ZlibDecompress(
141
- const SliceBuffer& input, int gzip,
142
- std::optional<uint32_t> max_output_size) {
119
+ static int zlib_decompress(grpc_slice_buffer* input, grpc_slice_buffer* output,
120
+ int gzip) {
143
121
  z_stream zs;
144
- absl::StatusOr<SliceBuffer> decompression_result;
122
+ int r;
123
+ size_t i;
124
+ size_t count_before = output->count;
125
+ size_t length_before = output->length;
145
126
  memset(&zs, 0, sizeof(zs));
146
- zs.zalloc = ZallocGpr;
147
- zs.zfree = ZFreeGpr;
148
- bool r = inflateInit2(&zs, 15 | (gzip ? 16 : 0));
127
+ zs.zalloc = zalloc_gpr;
128
+ zs.zfree = zfree_gpr;
129
+ r = inflateInit2(&zs, 15 | (gzip ? 16 : 0));
149
130
  GRPC_CHECK(r == Z_OK);
150
- decompression_result = ZlibBody(&zs, input, inflate, max_output_size);
131
+ r = zlib_body(&zs, input, output, inflate);
132
+ if (!r) {
133
+ for (i = count_before; i < output->count; i++) {
134
+ grpc_core::CSliceUnref(output->slices[i]);
135
+ }
136
+ output->count = count_before;
137
+ output->length = length_before;
138
+ }
151
139
  inflateEnd(&zs);
152
- return decompression_result;
140
+ return r;
153
141
  }
154
142
 
155
- } // namespace
143
+ static int copy(grpc_slice_buffer* input, grpc_slice_buffer* output) {
144
+ size_t i;
145
+ for (i = 0; i < input->count; i++) {
146
+ grpc_slice_buffer_add(output, grpc_core::CSliceRef(input->slices[i]));
147
+ }
148
+ return 1;
149
+ }
156
150
 
157
- std::optional<SliceBuffer> MessageCompress(grpc_compression_algorithm algorithm,
158
- const SliceBuffer& input) {
151
+ static int compress_inner(grpc_compression_algorithm algorithm,
152
+ grpc_slice_buffer* input, grpc_slice_buffer* output) {
159
153
  switch (algorithm) {
160
154
  case GRPC_COMPRESS_NONE:
161
155
  // the fallback path always needs to be send uncompressed: we simply
162
156
  // rely on that here
163
- return std::nullopt;
157
+ return 0;
164
158
  case GRPC_COMPRESS_DEFLATE:
165
- return ZlibCompress(input, 0);
159
+ return zlib_compress(input, output, 0);
166
160
  case GRPC_COMPRESS_GZIP:
167
- return ZlibCompress(input, 1);
161
+ return zlib_compress(input, output, 1);
168
162
  case GRPC_COMPRESS_ALGORITHMS_COUNT:
169
163
  break;
170
164
  }
171
165
  LOG(ERROR) << "invalid compression algorithm " << algorithm;
172
- return std::nullopt;
166
+ return 0;
173
167
  }
174
168
 
175
- absl::StatusOr<SliceBuffer> MessageDecompress(
176
- grpc_compression_algorithm algorithm, const SliceBuffer& input,
177
- std::optional<uint32_t> max_output_size) {
178
- switch (algorithm) {
179
- case GRPC_COMPRESS_NONE: {
180
- SliceBuffer output;
181
- output.Append(input);
182
- return output;
183
- }
184
- case GRPC_COMPRESS_DEFLATE:
185
- return ZlibDecompress(input, 0, max_output_size);
186
- case GRPC_COMPRESS_GZIP:
187
- return ZlibDecompress(input, 1, max_output_size);
188
- case GRPC_COMPRESS_ALGORITHMS_COUNT:
189
- break;
190
- }
191
- LOG(ERROR) << "invalid compression algorithm " << algorithm;
192
- return absl::InternalError("Invalid compression algorithm");
193
- }
194
-
195
- } // namespace grpc_core
196
-
197
169
  int grpc_msg_compress(grpc_compression_algorithm algorithm,
198
170
  grpc_slice_buffer* input, grpc_slice_buffer* output) {
199
- int retval = 1;
200
- grpc_core::SliceBuffer input_sb;
201
- grpc_slice_buffer_swap(input, input_sb.c_slice_buffer());
202
- std::optional<grpc_core::SliceBuffer> output_sb =
203
- grpc_core::MessageCompress(algorithm, input_sb);
204
- if (!output_sb.has_value()) {
205
- output_sb.emplace();
206
- output_sb->Append(input_sb);
207
- retval = 0;
171
+ if (!compress_inner(algorithm, input, output)) {
172
+ copy(input, output);
173
+ return 0;
208
174
  }
209
- grpc_slice_buffer_swap(input, input_sb.c_slice_buffer());
210
- grpc_slice_buffer_swap(output, output_sb->c_slice_buffer());
211
- return retval;
175
+ return 1;
212
176
  }
213
177
 
214
178
  int grpc_msg_decompress(grpc_compression_algorithm algorithm,
215
179
  grpc_slice_buffer* input, grpc_slice_buffer* output) {
216
- grpc_core::SliceBuffer input_sb;
217
- grpc_slice_buffer_swap(input, input_sb.c_slice_buffer());
218
-
219
- absl::StatusOr<grpc_core::SliceBuffer> output_sb =
220
- grpc_core::MessageDecompress(algorithm, input_sb, std::nullopt);
221
- if (!output_sb.ok()) {
222
- return 0;
180
+ switch (algorithm) {
181
+ case GRPC_COMPRESS_NONE:
182
+ return copy(input, output);
183
+ case GRPC_COMPRESS_DEFLATE:
184
+ return zlib_decompress(input, output, 0);
185
+ case GRPC_COMPRESS_GZIP:
186
+ return zlib_decompress(input, output, 1);
187
+ case GRPC_COMPRESS_ALGORITHMS_COUNT:
188
+ break;
223
189
  }
224
- grpc_slice_buffer_swap(input, input_sb.c_slice_buffer());
225
- grpc_slice_buffer_swap(output, output_sb->c_slice_buffer());
226
- return 1;
190
+ LOG(ERROR) << "invalid compression algorithm " << algorithm;
191
+ return 0;
227
192
  }
@@ -23,13 +23,6 @@
23
23
  #include <grpc/slice.h>
24
24
  #include <grpc/support/port_platform.h>
25
25
 
26
- #include <cstdint>
27
- #include <optional>
28
-
29
- #include "src/core/lib/slice/slice_buffer.h"
30
- #include "absl/status/status.h"
31
- #include "absl/status/statusor.h"
32
-
33
26
  // compress 'input' to 'output' using 'algorithm'.
34
27
  // On success, appends compressed slices to output and returns 1.
35
28
  // On failure, appends uncompressed slices to output and returns 0.
@@ -42,21 +35,4 @@ int grpc_msg_compress(grpc_compression_algorithm algorithm,
42
35
  int grpc_msg_decompress(grpc_compression_algorithm algorithm,
43
36
  grpc_slice_buffer* input, grpc_slice_buffer* output);
44
37
 
45
- namespace grpc_core {
46
-
47
- // Compresses 'input' using 'algorithm'.
48
- // On success, returns a SliceBuffer containing the compressed data.
49
- // On failure, returns nullopt.
50
- std::optional<SliceBuffer> MessageCompress(grpc_compression_algorithm algorithm,
51
- const SliceBuffer& input);
52
- // Decompresses 'input'.
53
- // On success, returns a SliceBuffer containing the decompressed data.
54
- // On failure, returns a non-OK status.
55
- // Fails if the decompressed data would be larger than max_output_size.
56
- absl::StatusOr<SliceBuffer> MessageDecompress(
57
- grpc_compression_algorithm algorithm, const SliceBuffer& input,
58
- std::optional<uint32_t> max_output_size);
59
-
60
- } // namespace grpc_core
61
-
62
38
  #endif // GRPC_SRC_CORE_LIB_COMPRESSION_MESSAGE_COMPRESS_H
@@ -37,10 +37,6 @@ class ReceiveCoalescingExtension {
37
37
  /// It is safe to call this only when there are no outstanding Reads on
38
38
  /// the Endpoint.
39
39
  virtual void DisableRpcReceiveCoalescing() = 0;
40
-
41
- /// If invoked, the endpoint tries to preserve proper order and alignment of
42
- /// any memory that maybe shared across reads.
43
- virtual void EnforceRxMemoryAlignment() = 0;
44
40
  };
45
41
 
46
42
  } // namespace grpc_event_engine::experimental
@@ -36,7 +36,7 @@ class TcpTraceExtension {
36
36
  // Enable TCP telemetry collection using the Instrumentation API.
37
37
  virtual void EnableTcpTelemetry(
38
38
  grpc_core::RefCountedPtr<grpc_core::CollectionScope> collection_scope,
39
- bool is_control_endpoint) = 0;
39
+ bool is_control_endpoint, bool trace_full_buffer) = 0;
40
40
  };
41
41
 
42
42
  } // namespace grpc_event_engine::experimental
@@ -76,14 +76,6 @@ namespace grpc_event_engine::experimental {
76
76
 
77
77
  namespace {
78
78
 
79
- bool ShouldUsePosixPoller() {
80
- #if defined(GRPC_PYTHON_BUILD)
81
- return grpc_core::IsEventEnginePollerForPythonEnabled();
82
- #else
83
- return true;
84
- #endif
85
- }
86
-
87
79
  #if GRPC_ENABLE_FORK_SUPPORT && GRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK
88
80
 
89
81
  // Thread pool can outlive EE but we need to ensure the ordering if both
@@ -434,10 +426,8 @@ PosixEventEngine::PosixEventEngine(const Options& options)
434
426
  : connection_shards_(options.connection_shards),
435
427
  executor_(MakeThreadPool(options.reserve_threads)),
436
428
  timer_manager_(std::make_shared<TimerManager>(executor_)) {
437
- if (ShouldUsePosixPoller()) {
438
- poller_ = grpc_event_engine::experimental::MakeDefaultPoller(executor_);
439
- SchedulePoller();
440
- }
429
+ poller_ = grpc_event_engine::experimental::MakeDefaultPoller(executor_);
430
+ SchedulePoller();
441
431
  }
442
432
 
443
433
  #endif // GRPC_POSIX_SOCKET_TCP
@@ -21,14 +21,10 @@
21
21
 
22
22
  namespace grpc_event_engine::experimental {
23
23
 
24
- bool UseEventEngineClient() {
25
- return !EventEngineExperimentDisabledForPython() &&
26
- grpc_core::IsEventEngineClientEnabled();
27
- }
24
+ bool UseEventEngineClient() { return grpc_core::IsEventEngineClientEnabled(); }
28
25
 
29
26
  bool UseEventEngineListener() {
30
- return !EventEngineExperimentDisabledForPython() &&
31
- grpc_core::IsEventEngineListenerEnabled();
27
+ return grpc_core::IsEventEngineListenerEnabled();
32
28
  }
33
29
 
34
30
  bool UsePollsetAlternative() {
@@ -36,14 +32,4 @@ bool UsePollsetAlternative() {
36
32
  grpc_core::IsPollsetAlternativeEnabled();
37
33
  }
38
34
 
39
- // Returns true if the poller is disabled by build configuration or experiment
40
- // flags.
41
- bool EventEngineExperimentDisabledForPython() {
42
- #ifdef GRPC_PYTHON_BUILD
43
- return !grpc_core::IsEventEnginePollerForPythonEnabled();
44
- #else
45
- return false;
46
- #endif
47
- }
48
-
49
35
  } // namespace grpc_event_engine::experimental
@@ -35,10 +35,6 @@ bool UseEventEngineListener();
35
35
  // may disable the poller in some builds.
36
36
  bool UsePollsetAlternative();
37
37
 
38
- // Returns true if the poller is disabled by build configuration or experiment
39
- // flags.
40
- bool EventEngineExperimentDisabledForPython();
41
-
42
38
  } // namespace grpc_event_engine::experimental
43
39
 
44
40
  #endif // GRPC_SRC_CORE_LIB_EVENT_ENGINE_SHIM_H