aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/grpc/src/core/lib
diff options
context:
space:
mode:
authorheretic <heretic@yandex-team.ru>2022-02-10 16:45:46 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:46 +0300
commit81eddc8c0b55990194e112b02d127b87d54164a9 (patch)
tree9142afc54d335ea52910662635b898e79e192e49 /contrib/libs/grpc/src/core/lib
parent397cbe258b9e064f49c4ca575279f02f39fef76e (diff)
downloadydb-81eddc8c0b55990194e112b02d127b87d54164a9.tar.gz
Restoring authorship annotation for <heretic@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/grpc/src/core/lib')
-rw-r--r--contrib/libs/grpc/src/core/lib/.yandex_meta/licenses.list.txt108
-rw-r--r--contrib/libs/grpc/src/core/lib/channel/channel_args.cc30
-rw-r--r--contrib/libs/grpc/src/core/lib/channel/channel_args.h6
-rw-r--r--contrib/libs/grpc/src/core/lib/channel/channel_stack.h24
-rw-r--r--contrib/libs/grpc/src/core/lib/channel/channel_trace.cc56
-rw-r--r--contrib/libs/grpc/src/core/lib/channel/channel_trace.h6
-rw-r--r--contrib/libs/grpc/src/core/lib/channel/channelz.cc334
-rw-r--r--contrib/libs/grpc/src/core/lib/channel/channelz.h88
-rw-r--r--contrib/libs/grpc/src/core/lib/channel/channelz_registry.cc134
-rw-r--r--contrib/libs/grpc/src/core/lib/channel/channelz_registry.h14
-rw-r--r--contrib/libs/grpc/src/core/lib/channel/connected_channel.cc10
-rw-r--r--contrib/libs/grpc/src/core/lib/channel/context.h2
-rw-r--r--contrib/libs/grpc/src/core/lib/channel/handshaker.cc22
-rw-r--r--contrib/libs/grpc/src/core/lib/channel/handshaker.h8
-rw-r--r--contrib/libs/grpc/src/core/lib/channel/handshaker_registry.cc10
-rw-r--r--contrib/libs/grpc/src/core/lib/compression/message_compress.cc10
-rw-r--r--contrib/libs/grpc/src/core/lib/debug/stats.cc42
-rw-r--r--contrib/libs/grpc/src/core/lib/debug/stats.h6
-rw-r--r--contrib/libs/grpc/src/core/lib/gpr/log_linux.cc12
-rw-r--r--contrib/libs/grpc/src/core/lib/gpr/log_posix.cc12
-rw-r--r--contrib/libs/grpc/src/core/lib/gpr/string.cc20
-rw-r--r--contrib/libs/grpc/src/core/lib/gpr/string.h8
-rw-r--r--contrib/libs/grpc/src/core/lib/gpr/sync_abseil.cc232
-rw-r--r--contrib/libs/grpc/src/core/lib/gpr/sync_posix.cc20
-rw-r--r--contrib/libs/grpc/src/core/lib/gpr/sync_windows.cc8
-rw-r--r--contrib/libs/grpc/src/core/lib/gpr/time.cc8
-rw-r--r--contrib/libs/grpc/src/core/lib/gpr/time_posix.cc2
-rw-r--r--contrib/libs/grpc/src/core/lib/gpr/time_precise.cc6
-rw-r--r--contrib/libs/grpc/src/core/lib/gpr/time_precise.h12
-rw-r--r--contrib/libs/grpc/src/core/lib/gprpp/debug_location.h2
-rw-r--r--contrib/libs/grpc/src/core/lib/gprpp/dual_ref_counted.h672
-rw-r--r--contrib/libs/grpc/src/core/lib/gprpp/fork.cc2
-rw-r--r--contrib/libs/grpc/src/core/lib/gprpp/global_config_env.cc16
-rw-r--r--contrib/libs/grpc/src/core/lib/gprpp/host_port.cc60
-rw-r--r--contrib/libs/grpc/src/core/lib/gprpp/host_port.h28
-rw-r--r--contrib/libs/grpc/src/core/lib/gprpp/map.h10
-rw-r--r--contrib/libs/grpc/src/core/lib/gprpp/memory.h6
-rw-r--r--contrib/libs/grpc/src/core/lib/gprpp/ref_counted.h102
-rw-r--r--contrib/libs/grpc/src/core/lib/gprpp/ref_counted_ptr.h316
-rw-r--r--contrib/libs/grpc/src/core/lib/gprpp/sync.h18
-rw-r--r--contrib/libs/grpc/src/core/lib/http/format_request.cc92
-rw-r--r--contrib/libs/grpc/src/core/lib/http/httpcli.cc26
-rw-r--r--contrib/libs/grpc/src/core/lib/http/httpcli_security_connector.cc16
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/buffer_list.cc72
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/buffer_list.h44
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/call_combiner.h6
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/cfstream_handle.cc8
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/dualstack_socket_posix.cc94
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/endpoint.cc10
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/endpoint.h14
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/endpoint_cfstream.cc72
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/endpoint_pair_posix.cc20
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/error.h8
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/error_cfstream.cc18
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/ev_apple.cc712
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/ev_apple.h86
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/ev_epoll1_linux.cc50
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/ev_epollex_linux.cc52
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/ev_poll_posix.cc18
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/exec_ctx.h40
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/executor.cc2
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/fork_posix.cc8
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/iomgr_posix_cfstream.cc168
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/is_epollexclusive_available.cc28
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/load_file.cc2
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/parse_address.cc476
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/parse_address.h106
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/poller/eventmanager_libuv.cc174
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/poller/eventmanager_libuv.h176
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/pollset_set_custom.cc20
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/port.h4
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/resolve_address_custom.cc86
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/resolve_address_custom.h8
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/resolve_address_posix.cc16
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/resolve_address_windows.cc28
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/resource_quota.cc68
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/sockaddr_utils.cc62
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/sockaddr_utils.h24
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/socket_utils_common_posix.cc230
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/socket_utils_posix.h30
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/socket_windows.cc8
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/tcp_client_cfstream.cc28
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/tcp_client_custom.cc12
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/tcp_client_posix.cc78
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/tcp_client_posix.h12
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/tcp_client_windows.cc18
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/tcp_custom.cc66
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/tcp_custom.h8
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/tcp_posix.cc1274
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/tcp_server.cc6
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/tcp_server.h14
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/tcp_server_custom.cc52
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/tcp_server_posix.cc76
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/tcp_server_utils_posix.h6
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/tcp_server_utils_posix_common.cc30
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc20
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/tcp_server_windows.cc32
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/tcp_uv.cc6
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/tcp_windows.cc52
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/timer_generic.cc26
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/udp_server.cc64
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/udp_server.h10
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/unix_sockets_posix.cc18
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/unix_sockets_posix.h6
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/unix_sockets_posix_noop.cc10
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/work_serializer.cc310
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/work_serializer.h130
-rw-r--r--contrib/libs/grpc/src/core/lib/json/json.h430
-rw-r--r--contrib/libs/grpc/src/core/lib/json/json_reader.cc1024
-rw-r--r--contrib/libs/grpc/src/core/lib/json/json_util.cc116
-rw-r--r--contrib/libs/grpc/src/core/lib/json/json_util.h74
-rw-r--r--contrib/libs/grpc/src/core/lib/json/json_writer.cc406
-rw-r--r--contrib/libs/grpc/src/core/lib/security/authorization/authorization_engine.cc354
-rw-r--r--contrib/libs/grpc/src/core/lib/security/authorization/authorization_engine.h168
-rw-r--r--contrib/libs/grpc/src/core/lib/security/authorization/evaluate_args.cc306
-rw-r--r--contrib/libs/grpc/src/core/lib/security/authorization/evaluate_args.h118
-rw-r--r--contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/activation.h114
-rw-r--r--contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h84
-rw-r--r--contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/cel_expression.h136
-rw-r--r--contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/cel_value.h186
-rw-r--r--contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/evaluator_core.h134
-rw-r--r--contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h112
-rw-r--r--contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/statusor.h100
-rw-r--r--contrib/libs/grpc/src/core/lib/security/certificate_provider.h120
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/alts/check_gcp_environment.cc2
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/composite/composite_credentials.cc38
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/composite/composite_credentials.h22
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/credentials.h42
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/fake/fake_credentials.h12
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/google_default/credentials_generic.cc16
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/google_default/google_default_credentials.cc144
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/iam/iam_credentials.cc16
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/iam/iam_credentials.h8
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/jwt/json_token.cc52
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/jwt/json_token.h4
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_credentials.cc30
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_credentials.h24
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_verifier.cc298
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_verifier.h4
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc218
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/oauth2/oauth2_credentials.h16
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/plugin/plugin_credentials.cc50
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/plugin/plugin_credentials.h8
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/ssl/ssl_credentials.cc40
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/ssl/ssl_credentials.h20
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc642
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h428
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc90
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h114
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/tls/tls_credentials.cc256
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/tls/tls_credentials.h124
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/xds/xds_credentials.cc90
-rw-r--r--contrib/libs/grpc/src/core/lib/security/credentials/xds/xds_credentials.h102
-rw-r--r--contrib/libs/grpc/src/core/lib/security/security_connector/alts/alts_security_connector.cc68
-rw-r--r--contrib/libs/grpc/src/core/lib/security/security_connector/fake/fake_security_connector.cc82
-rw-r--r--contrib/libs/grpc/src/core/lib/security/security_connector/load_system_roots_fallback.cc4
-rw-r--r--contrib/libs/grpc/src/core/lib/security/security_connector/load_system_roots_linux.cc10
-rw-r--r--contrib/libs/grpc/src/core/lib/security/security_connector/local/local_security_connector.cc64
-rw-r--r--contrib/libs/grpc/src/core/lib/security/security_connector/security_connector.cc4
-rw-r--r--contrib/libs/grpc/src/core/lib/security/security_connector/security_connector.h4
-rw-r--r--contrib/libs/grpc/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc76
-rw-r--r--contrib/libs/grpc/src/core/lib/security/security_connector/ssl/ssl_security_connector.h10
-rw-r--r--contrib/libs/grpc/src/core/lib/security/security_connector/ssl_utils.cc276
-rw-r--r--contrib/libs/grpc/src/core/lib/security/security_connector/ssl_utils.h68
-rw-r--r--contrib/libs/grpc/src/core/lib/security/security_connector/tls/tls_security_connector.cc1212
-rw-r--r--contrib/libs/grpc/src/core/lib/security/security_connector/tls/tls_security_connector.h366
-rw-r--r--contrib/libs/grpc/src/core/lib/security/transport/client_auth_filter.cc88
-rw-r--r--contrib/libs/grpc/src/core/lib/security/transport/secure_endpoint.cc14
-rw-r--r--contrib/libs/grpc/src/core/lib/security/transport/security_handshaker.cc4
-rw-r--r--contrib/libs/grpc/src/core/lib/security/util/json_util.cc54
-rw-r--r--contrib/libs/grpc/src/core/lib/security/util/json_util.h4
-rw-r--r--contrib/libs/grpc/src/core/lib/slice/slice.cc76
-rw-r--r--contrib/libs/grpc/src/core/lib/slice/slice_internal.h30
-rw-r--r--contrib/libs/grpc/src/core/lib/slice/slice_utils.h18
-rw-r--r--contrib/libs/grpc/src/core/lib/surface/byte_buffer_reader.cc4
-rw-r--r--contrib/libs/grpc/src/core/lib/surface/call.cc104
-rw-r--r--contrib/libs/grpc/src/core/lib/surface/call.h4
-rw-r--r--contrib/libs/grpc/src/core/lib/surface/call_log_batch.cc100
-rw-r--r--contrib/libs/grpc/src/core/lib/surface/channel.cc140
-rw-r--r--contrib/libs/grpc/src/core/lib/surface/channel.h102
-rw-r--r--contrib/libs/grpc/src/core/lib/surface/completion_queue.cc94
-rw-r--r--contrib/libs/grpc/src/core/lib/surface/event_string.cc36
-rw-r--r--contrib/libs/grpc/src/core/lib/surface/event_string.h6
-rw-r--r--contrib/libs/grpc/src/core/lib/surface/init.cc54
-rw-r--r--contrib/libs/grpc/src/core/lib/surface/init_secure.cc2
-rw-r--r--contrib/libs/grpc/src/core/lib/surface/server.cc2700
-rw-r--r--contrib/libs/grpc/src/core/lib/surface/server.h768
-rw-r--r--contrib/libs/grpc/src/core/lib/surface/version.cc4
-rw-r--r--contrib/libs/grpc/src/core/lib/transport/authority_override.cc76
-rw-r--r--contrib/libs/grpc/src/core/lib/transport/authority_override.h64
-rw-r--r--contrib/libs/grpc/src/core/lib/transport/bdp_estimator.h4
-rw-r--r--contrib/libs/grpc/src/core/lib/transport/byte_stream.h14
-rw-r--r--contrib/libs/grpc/src/core/lib/transport/connectivity_state.cc46
-rw-r--r--contrib/libs/grpc/src/core/lib/transport/connectivity_state.h50
-rw-r--r--contrib/libs/grpc/src/core/lib/transport/error_utils.cc26
-rw-r--r--contrib/libs/grpc/src/core/lib/transport/error_utils.h12
-rw-r--r--contrib/libs/grpc/src/core/lib/transport/metadata.cc28
-rw-r--r--contrib/libs/grpc/src/core/lib/transport/static_metadata.cc590
-rw-r--r--contrib/libs/grpc/src/core/lib/transport/static_metadata.h162
-rw-r--r--contrib/libs/grpc/src/core/lib/transport/transport.h32
-rw-r--r--contrib/libs/grpc/src/core/lib/transport/transport_op_string.cc122
-rw-r--r--contrib/libs/grpc/src/core/lib/uri/uri_parser.cc60
-rw-r--r--contrib/libs/grpc/src/core/lib/uri/uri_parser.h6
-rw-r--r--contrib/libs/grpc/src/core/lib/ya.make28
204 files changed, 11445 insertions, 11445 deletions
diff --git a/contrib/libs/grpc/src/core/lib/.yandex_meta/licenses.list.txt b/contrib/libs/grpc/src/core/lib/.yandex_meta/licenses.list.txt
index 0aab52b438..e5eda93675 100644
--- a/contrib/libs/grpc/src/core/lib/.yandex_meta/licenses.list.txt
+++ b/contrib/libs/grpc/src/core/lib/.yandex_meta/licenses.list.txt
@@ -1,54 +1,54 @@
-====================Apache-2.0====================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-
-
-====================Apache-2.0====================
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-
-====================COPYRIGHT====================
- * Copyright 2015 gRPC authors.
-
-
-====================COPYRIGHT====================
- * Copyright 2015-2016 gRPC authors.
-
-
-====================COPYRIGHT====================
- * Copyright 2016 gRPC authors.
-
-
-====================COPYRIGHT====================
- * Copyright 2017 gRPC authors.
-
-
-====================COPYRIGHT====================
- * Copyright 2018 gRPC authors.
-
-
-====================COPYRIGHT====================
- * Copyright 2020 gRPC authors.
-
-
-====================COPYRIGHT====================
-# Copyright 2019 gRPC authors.
+====================Apache-2.0====================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+
+====================Apache-2.0====================
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+
+====================COPYRIGHT====================
+ * Copyright 2015 gRPC authors.
+
+
+====================COPYRIGHT====================
+ * Copyright 2015-2016 gRPC authors.
+
+
+====================COPYRIGHT====================
+ * Copyright 2016 gRPC authors.
+
+
+====================COPYRIGHT====================
+ * Copyright 2017 gRPC authors.
+
+
+====================COPYRIGHT====================
+ * Copyright 2018 gRPC authors.
+
+
+====================COPYRIGHT====================
+ * Copyright 2020 gRPC authors.
+
+
+====================COPYRIGHT====================
+# Copyright 2019 gRPC authors.
diff --git a/contrib/libs/grpc/src/core/lib/channel/channel_args.cc b/contrib/libs/grpc/src/core/lib/channel/channel_args.cc
index 720345a745..cb3d61fc4d 100644
--- a/contrib/libs/grpc/src/core/lib/channel/channel_args.cc
+++ b/contrib/libs/grpc/src/core/lib/channel/channel_args.cc
@@ -21,11 +21,11 @@
#include <limits.h>
#include <string.h>
-#include <vector>
-
-#include "y_absl/strings/str_format.h"
-#include "y_absl/strings/str_join.h"
-
+#include <vector>
+
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/str_join.h"
+
#include <grpc/grpc.h>
#include <grpc/impl/codegen/grpc_types.h>
#include <grpc/impl/codegen/log.h>
@@ -341,28 +341,28 @@ grpc_arg grpc_channel_arg_pointer_create(
return arg;
}
-TString grpc_channel_args_string(const grpc_channel_args* args) {
- if (args == nullptr) return "";
- std::vector<TString> arg_strings;
+TString grpc_channel_args_string(const grpc_channel_args* args) {
+ if (args == nullptr) return "";
+ std::vector<TString> arg_strings;
for (size_t i = 0; i < args->num_args; ++i) {
const grpc_arg& arg = args->args[i];
- TString arg_string;
+ TString arg_string;
switch (arg.type) {
case GRPC_ARG_INTEGER:
- arg_string = y_absl::StrFormat("%s=%d", arg.key, arg.value.integer);
+ arg_string = y_absl::StrFormat("%s=%d", arg.key, arg.value.integer);
break;
case GRPC_ARG_STRING:
- arg_string = y_absl::StrFormat("%s=%s", arg.key, arg.value.string);
+ arg_string = y_absl::StrFormat("%s=%s", arg.key, arg.value.string);
break;
case GRPC_ARG_POINTER:
- arg_string = y_absl::StrFormat("%s=%p", arg.key, arg.value.pointer.p);
+ arg_string = y_absl::StrFormat("%s=%p", arg.key, arg.value.pointer.p);
break;
default:
- arg_string = "arg with unknown type";
+ arg_string = "arg with unknown type";
}
- arg_strings.push_back(arg_string);
+ arg_strings.push_back(arg_string);
}
- return y_absl::StrJoin(arg_strings, ", ");
+ return y_absl::StrJoin(arg_strings, ", ");
}
namespace {
diff --git a/contrib/libs/grpc/src/core/lib/channel/channel_args.h b/contrib/libs/grpc/src/core/lib/channel/channel_args.h
index 19a14415a5..6b973aa94d 100644
--- a/contrib/libs/grpc/src/core/lib/channel/channel_args.h
+++ b/contrib/libs/grpc/src/core/lib/channel/channel_args.h
@@ -21,8 +21,8 @@
#include <grpc/support/port_platform.h>
-#include <util/generic/string.h>
-
+#include <util/generic/string.h>
+
#include <grpc/grpc.h>
#include "src/core/lib/surface/channel_stack_type.h"
@@ -117,7 +117,7 @@ grpc_arg grpc_channel_arg_pointer_create(char* name, void* value,
const grpc_arg_pointer_vtable* vtable);
// Returns a string representing channel args in human-readable form.
-TString grpc_channel_args_string(const grpc_channel_args* args);
+TString grpc_channel_args_string(const grpc_channel_args* args);
// Takes ownership of the old_args
typedef grpc_channel_args* (*grpc_channel_args_client_channel_creation_mutator)(
diff --git a/contrib/libs/grpc/src/core/lib/channel/channel_stack.h b/contrib/libs/grpc/src/core/lib/channel/channel_stack.h
index 0cd0a3b98b..e297df9488 100644
--- a/contrib/libs/grpc/src/core/lib/channel/channel_stack.h
+++ b/contrib/libs/grpc/src/core/lib/channel/channel_stack.h
@@ -31,19 +31,19 @@
chains are linear, then channel stacks provide a mechanism to minimize
allocations for that chain.
Call stacks are created by channel stacks and represent the per-call data
- for that stack.
+ for that stack.
+
+ Implementations should take care of the following details for a batch -
+ 1. Synchronization is achieved with a CallCombiner. View
+ src/core/lib/iomgr/call_combiner.h for more details.
+ 2. If the filter wants to inject an error on the way down, it needs to call
+ grpc_transport_stream_op_batch_finish_with_failure from within the call
+ combiner. This will cause any batch callbacks to be called with that error.
+ 3. If the filter wants to inject an error on the way up (from a callback), it
+ should also inject that error in the recv_trailing_metadata callback so that
+ it can have an effect on the call status.
+*/
- Implementations should take care of the following details for a batch -
- 1. Synchronization is achieved with a CallCombiner. View
- src/core/lib/iomgr/call_combiner.h for more details.
- 2. If the filter wants to inject an error on the way down, it needs to call
- grpc_transport_stream_op_batch_finish_with_failure from within the call
- combiner. This will cause any batch callbacks to be called with that error.
- 3. If the filter wants to inject an error on the way up (from a callback), it
- should also inject that error in the recv_trailing_metadata callback so that
- it can have an effect on the call status.
-*/
-
#include <grpc/support/port_platform.h>
#include <stddef.h>
diff --git a/contrib/libs/grpc/src/core/lib/channel/channel_trace.cc b/contrib/libs/grpc/src/core/lib/channel/channel_trace.cc
index c0b833e410..dbc33af2d4 100644
--- a/contrib/libs/grpc/src/core/lib/channel/channel_trace.cc
+++ b/contrib/libs/grpc/src/core/lib/channel/channel_trace.cc
@@ -144,46 +144,46 @@ const char* severity_string(ChannelTrace::Severity severity) {
} // anonymous namespace
-Json ChannelTrace::TraceEvent::RenderTraceEvent() const {
- char* description = grpc_slice_to_c_string(data_);
- Json::Object object = {
- {"description", description},
- {"severity", severity_string(severity_)},
- {"timestamp", gpr_format_timespec(timestamp_)},
- };
- gpr_free(description);
+Json ChannelTrace::TraceEvent::RenderTraceEvent() const {
+ char* description = grpc_slice_to_c_string(data_);
+ Json::Object object = {
+ {"description", description},
+ {"severity", severity_string(severity_)},
+ {"timestamp", gpr_format_timespec(timestamp_)},
+ };
+ gpr_free(description);
if (referenced_entity_ != nullptr) {
const bool is_channel =
(referenced_entity_->type() == BaseNode::EntityType::kTopLevelChannel ||
referenced_entity_->type() == BaseNode::EntityType::kInternalChannel);
- object[is_channel ? "channelRef" : "subchannelRef"] = Json::Object{
- {(is_channel ? "channelId" : "subchannelId"),
- ToString(referenced_entity_->uuid())},
- };
+ object[is_channel ? "channelRef" : "subchannelRef"] = Json::Object{
+ {(is_channel ? "channelId" : "subchannelId"),
+ ToString(referenced_entity_->uuid())},
+ };
}
- return object;
+ return object;
}
-Json ChannelTrace::RenderJson() const {
- // Tracing is disabled if max_event_memory_ == 0.
- if (max_event_memory_ == 0) {
- return Json(); // JSON null
- }
- Json::Object object = {
- {"creationTimestamp", gpr_format_timespec(time_created_)},
- };
+Json ChannelTrace::RenderJson() const {
+ // Tracing is disabled if max_event_memory_ == 0.
+ if (max_event_memory_ == 0) {
+ return Json(); // JSON null
+ }
+ Json::Object object = {
+ {"creationTimestamp", gpr_format_timespec(time_created_)},
+ };
if (num_events_logged_ > 0) {
- object["numEventsLogged"] = ToString(num_events_logged_);
+ object["numEventsLogged"] = ToString(num_events_logged_);
}
- // Only add in the event list if it is non-empty.
+ // Only add in the event list if it is non-empty.
if (head_trace_ != nullptr) {
- Json::Array array;
- for (TraceEvent* it = head_trace_; it != nullptr; it = it->next()) {
- array.emplace_back(it->RenderTraceEvent());
+ Json::Array array;
+ for (TraceEvent* it = head_trace_; it != nullptr; it = it->next()) {
+ array.emplace_back(it->RenderTraceEvent());
}
- object["events"] = std::move(array);
+ object["events"] = std::move(array);
}
- return object;
+ return object;
}
} // namespace channelz
diff --git a/contrib/libs/grpc/src/core/lib/channel/channel_trace.h b/contrib/libs/grpc/src/core/lib/channel/channel_trace.h
index 429aec254a..c26e3016da 100644
--- a/contrib/libs/grpc/src/core/lib/channel/channel_trace.h
+++ b/contrib/libs/grpc/src/core/lib/channel/channel_trace.h
@@ -75,9 +75,9 @@ class ChannelTrace {
void AddTraceEventWithReference(Severity severity, const grpc_slice& data,
RefCountedPtr<BaseNode> referenced_entity);
- // Creates and returns the raw Json object, so a parent channelz
+ // Creates and returns the raw Json object, so a parent channelz
// object may incorporate the json before rendering.
- Json RenderJson() const;
+ Json RenderJson() const;
private:
friend size_t testing::GetSizeofTraceEvent(void);
@@ -98,7 +98,7 @@ class ChannelTrace {
// Renders the data inside of this TraceEvent into a json object. This is
// used by the ChannelTrace, when it is rendering itself.
- Json RenderTraceEvent() const;
+ Json RenderTraceEvent() const;
// set and get for the next_ pointer.
TraceEvent* next() const { return next_; }
diff --git a/contrib/libs/grpc/src/core/lib/channel/channelz.cc b/contrib/libs/grpc/src/core/lib/channel/channelz.cc
index 1c2850f0d9..16f505c053 100644
--- a/contrib/libs/grpc/src/core/lib/channel/channelz.cc
+++ b/contrib/libs/grpc/src/core/lib/channel/channelz.cc
@@ -45,8 +45,8 @@
#include "src/core/lib/transport/error_utils.h"
#include "src/core/lib/uri/uri_parser.h"
-#include <util/string/cast.h>
-
+#include <util/string/cast.h>
+
namespace grpc_core {
namespace channelz {
@@ -54,7 +54,7 @@ namespace channelz {
// BaseNode
//
-BaseNode::BaseNode(EntityType type, TString name)
+BaseNode::BaseNode(EntityType type, TString name)
: type_(type), uuid_(-1), name_(std::move(name)) {
// The registry will set uuid_ under its lock.
ChannelzRegistry::Register(this);
@@ -62,9 +62,9 @@ BaseNode::BaseNode(EntityType type, TString name)
BaseNode::~BaseNode() { ChannelzRegistry::Unregister(uuid_); }
-TString BaseNode::RenderJsonString() {
- Json json = RenderJson();
- return json.Dump();
+TString BaseNode::RenderJsonString() {
+ Json json = RenderJson();
+ return json.Dump();
}
//
@@ -116,21 +116,21 @@ void CallCountingHelper::CollectData(CounterData* out) {
}
}
-void CallCountingHelper::PopulateCallCounts(Json::Object* object) {
+void CallCountingHelper::PopulateCallCounts(Json::Object* object) {
CounterData data;
CollectData(&data);
if (data.calls_started != 0) {
- (*object)["callsStarted"] = ToString(data.calls_started);
- gpr_timespec ts = gpr_convert_clock_type(
- gpr_cycle_counter_to_time(data.last_call_started_cycle),
- GPR_CLOCK_REALTIME);
- (*object)["lastCallStartedTimestamp"] = gpr_format_timespec(ts);
+ (*object)["callsStarted"] = ToString(data.calls_started);
+ gpr_timespec ts = gpr_convert_clock_type(
+ gpr_cycle_counter_to_time(data.last_call_started_cycle),
+ GPR_CLOCK_REALTIME);
+ (*object)["lastCallStartedTimestamp"] = gpr_format_timespec(ts);
}
if (data.calls_succeeded != 0) {
- (*object)["callsSucceeded"] = ToString(data.calls_succeeded);
+ (*object)["callsSucceeded"] = ToString(data.calls_succeeded);
}
if (data.calls_failed) {
- (*object)["callsFailed"] = ToString(data.calls_failed);
+ (*object)["callsFailed"] = ToString(data.calls_failed);
}
}
@@ -138,13 +138,13 @@ void CallCountingHelper::PopulateCallCounts(Json::Object* object) {
// ChannelNode
//
-ChannelNode::ChannelNode(TString target, size_t channel_tracer_max_nodes,
- bool is_internal_channel)
- : BaseNode(is_internal_channel ? EntityType::kInternalChannel
- : EntityType::kTopLevelChannel,
+ChannelNode::ChannelNode(TString target, size_t channel_tracer_max_nodes,
+ bool is_internal_channel)
+ : BaseNode(is_internal_channel ? EntityType::kInternalChannel
+ : EntityType::kTopLevelChannel,
target),
target_(std::move(target)),
- trace_(channel_tracer_max_nodes) {}
+ trace_(channel_tracer_max_nodes) {}
const char* ChannelNode::GetChannelConnectivityStateChangeString(
grpc_connectivity_state state) {
@@ -163,60 +163,60 @@ const char* ChannelNode::GetChannelConnectivityStateChangeString(
GPR_UNREACHABLE_CODE(return "UNKNOWN");
}
-Json ChannelNode::RenderJson() {
- Json::Object data = {
- {"target", target_},
- };
- // Connectivity state.
+Json ChannelNode::RenderJson() {
+ Json::Object data = {
+ {"target", target_},
+ };
+ // Connectivity state.
// If low-order bit is on, then the field is set.
int state_field = connectivity_state_.Load(MemoryOrder::RELAXED);
if ((state_field & 1) != 0) {
grpc_connectivity_state state =
static_cast<grpc_connectivity_state>(state_field >> 1);
- data["state"] = Json::Object{
- {"state", ConnectivityStateName(state)},
- };
+ data["state"] = Json::Object{
+ {"state", ConnectivityStateName(state)},
+ };
}
- // Fill in the channel trace if applicable.
- Json trace_json = trace_.RenderJson();
- if (trace_json.type() != Json::Type::JSON_NULL) {
- data["trace"] = std::move(trace_json);
+ // Fill in the channel trace if applicable.
+ Json trace_json = trace_.RenderJson();
+ if (trace_json.type() != Json::Type::JSON_NULL) {
+ data["trace"] = std::move(trace_json);
}
- // Ask CallCountingHelper to populate call count data.
- call_counter_.PopulateCallCounts(&data);
- // Construct outer object.
- Json::Object json = {
- {"ref",
- Json::Object{
- {"channelId", ToString(uuid())},
- }},
- {"data", std::move(data)},
- };
- // Template method. Child classes may override this to add their specific
+ // Ask CallCountingHelper to populate call count data.
+ call_counter_.PopulateCallCounts(&data);
+ // Construct outer object.
+ Json::Object json = {
+ {"ref",
+ Json::Object{
+ {"channelId", ToString(uuid())},
+ }},
+ {"data", std::move(data)},
+ };
+ // Template method. Child classes may override this to add their specific
// functionality.
- PopulateChildRefs(&json);
- return json;
+ PopulateChildRefs(&json);
+ return json;
}
-void ChannelNode::PopulateChildRefs(Json::Object* json) {
+void ChannelNode::PopulateChildRefs(Json::Object* json) {
MutexLock lock(&child_mu_);
if (!child_subchannels_.empty()) {
- Json::Array array;
- for (intptr_t subchannel_uuid : child_subchannels_) {
- array.emplace_back(Json::Object{
- {"subchannelId", ToString(subchannel_uuid)},
- });
+ Json::Array array;
+ for (intptr_t subchannel_uuid : child_subchannels_) {
+ array.emplace_back(Json::Object{
+ {"subchannelId", ToString(subchannel_uuid)},
+ });
}
- (*json)["subchannelRef"] = std::move(array);
+ (*json)["subchannelRef"] = std::move(array);
}
if (!child_channels_.empty()) {
- Json::Array array;
- for (intptr_t channel_uuid : child_channels_) {
- array.emplace_back(Json::Object{
- {"channelId", ToString(channel_uuid)},
- });
+ Json::Array array;
+ for (intptr_t channel_uuid : child_channels_) {
+ array.emplace_back(Json::Object{
+ {"channelId", ToString(channel_uuid)},
+ });
}
- (*json)["channelRef"] = std::move(array);
+ (*json)["channelRef"] = std::move(array);
}
}
@@ -228,7 +228,7 @@ void ChannelNode::SetConnectivityState(grpc_connectivity_state state) {
void ChannelNode::AddChildChannel(intptr_t child_uuid) {
MutexLock lock(&child_mu_);
- child_channels_.insert(child_uuid);
+ child_channels_.insert(child_uuid);
}
void ChannelNode::RemoveChildChannel(intptr_t child_uuid) {
@@ -238,7 +238,7 @@ void ChannelNode::RemoveChildChannel(intptr_t child_uuid) {
void ChannelNode::AddChildSubchannel(intptr_t child_uuid) {
MutexLock lock(&child_mu_);
- child_subchannels_.insert(child_uuid);
+ child_subchannels_.insert(child_uuid);
}
void ChannelNode::RemoveChildSubchannel(intptr_t child_uuid) {
@@ -250,7 +250,7 @@ void ChannelNode::RemoveChildSubchannel(intptr_t child_uuid) {
// ServerNode
//
-ServerNode::ServerNode(size_t channel_tracer_max_nodes)
+ServerNode::ServerNode(size_t channel_tracer_max_nodes)
: BaseNode(EntityType::kServer, ""), trace_(channel_tracer_max_nodes) {}
ServerNode::~ServerNode() {}
@@ -275,65 +275,65 @@ void ServerNode::RemoveChildListenSocket(intptr_t child_uuid) {
child_listen_sockets_.erase(child_uuid);
}
-TString ServerNode::RenderServerSockets(intptr_t start_socket_id,
- intptr_t max_results) {
- GPR_ASSERT(start_socket_id >= 0);
- GPR_ASSERT(max_results >= 0);
+TString ServerNode::RenderServerSockets(intptr_t start_socket_id,
+ intptr_t max_results) {
+ GPR_ASSERT(start_socket_id >= 0);
+ GPR_ASSERT(max_results >= 0);
// If user does not set max_results, we choose 500.
size_t pagination_limit = max_results == 0 ? 500 : max_results;
- Json::Object object;
- {
- MutexLock lock(&child_mu_);
- size_t sockets_rendered = 0;
- // Create list of socket refs.
- Json::Array array;
- auto it = child_sockets_.lower_bound(start_socket_id);
- for (; it != child_sockets_.end() && sockets_rendered < pagination_limit;
- ++it, ++sockets_rendered) {
- array.emplace_back(Json::Object{
- {"socketId", ToString(it->first)},
- {"name", it->second->name()},
- });
+ Json::Object object;
+ {
+ MutexLock lock(&child_mu_);
+ size_t sockets_rendered = 0;
+ // Create list of socket refs.
+ Json::Array array;
+ auto it = child_sockets_.lower_bound(start_socket_id);
+ for (; it != child_sockets_.end() && sockets_rendered < pagination_limit;
+ ++it, ++sockets_rendered) {
+ array.emplace_back(Json::Object{
+ {"socketId", ToString(it->first)},
+ {"name", it->second->name()},
+ });
}
- object["socketRef"] = std::move(array);
- if (it == child_sockets_.end()) object["end"] = true;
+ object["socketRef"] = std::move(array);
+ if (it == child_sockets_.end()) object["end"] = true;
}
- Json json = std::move(object);
- return json.Dump();
+ Json json = std::move(object);
+ return json.Dump();
}
-Json ServerNode::RenderJson() {
- Json::Object data;
- // Fill in the channel trace if applicable.
- Json trace_json = trace_.RenderJson();
- if (trace_json.type() != Json::Type::JSON_NULL) {
- data["trace"] = std::move(trace_json);
+Json ServerNode::RenderJson() {
+ Json::Object data;
+ // Fill in the channel trace if applicable.
+ Json trace_json = trace_.RenderJson();
+ if (trace_json.type() != Json::Type::JSON_NULL) {
+ data["trace"] = std::move(trace_json);
}
- // Ask CallCountingHelper to populate call count data.
- call_counter_.PopulateCallCounts(&data);
- // Construct top-level object.
- Json::Object object = {
- {"ref",
- Json::Object{
- {"serverId", ToString(uuid())},
- }},
- {"data", std::move(data)},
- };
- // Render listen sockets.
- {
- MutexLock lock(&child_mu_);
- if (!child_listen_sockets_.empty()) {
- Json::Array array;
- for (const auto& it : child_listen_sockets_) {
- array.emplace_back(Json::Object{
- {"socketId", ToString(it.first)},
- {"name", it.second->name()},
- });
- }
- object["listenSocket"] = std::move(array);
+ // Ask CallCountingHelper to populate call count data.
+ call_counter_.PopulateCallCounts(&data);
+ // Construct top-level object.
+ Json::Object object = {
+ {"ref",
+ Json::Object{
+ {"serverId", ToString(uuid())},
+ }},
+ {"data", std::move(data)},
+ };
+ // Render listen sockets.
+ {
+ MutexLock lock(&child_mu_);
+ if (!child_listen_sockets_.empty()) {
+ Json::Array array;
+ for (const auto& it : child_listen_sockets_) {
+ array.emplace_back(Json::Object{
+ {"socketId", ToString(it.first)},
+ {"name", it.second->name()},
+ });
+ }
+ object["listenSocket"] = std::move(array);
}
}
- return object;
+ return object;
}
//
@@ -342,44 +342,44 @@ Json ServerNode::RenderJson() {
namespace {
-void PopulateSocketAddressJson(Json::Object* json, const char* name,
+void PopulateSocketAddressJson(Json::Object* json, const char* name,
const char* addr_str) {
if (addr_str == nullptr) return;
- Json::Object data;
+ Json::Object data;
grpc_uri* uri = grpc_uri_parse(addr_str, true);
if ((uri != nullptr) && ((strcmp(uri->scheme, "ipv4") == 0) ||
(strcmp(uri->scheme, "ipv6") == 0))) {
const char* host_port = uri->path;
if (*host_port == '/') ++host_port;
- TString host;
- TString port;
+ TString host;
+ TString port;
GPR_ASSERT(SplitHostPort(host_port, &host, &port));
int port_num = -1;
- if (!port.empty()) {
- port_num = atoi(port.data());
+ if (!port.empty()) {
+ port_num = atoi(port.data());
}
- char* b64_host = grpc_base64_encode(host.data(), host.size(), false, false);
- data["tcpip_address"] = Json::Object{
- {"port", port_num},
- {"ip_address", b64_host},
- };
- gpr_free(b64_host);
+ char* b64_host = grpc_base64_encode(host.data(), host.size(), false, false);
+ data["tcpip_address"] = Json::Object{
+ {"port", port_num},
+ {"ip_address", b64_host},
+ };
+ gpr_free(b64_host);
} else if (uri != nullptr && strcmp(uri->scheme, "unix") == 0) {
- data["uds_address"] = Json::Object{
- {"filename", uri->path},
- };
+ data["uds_address"] = Json::Object{
+ {"filename", uri->path},
+ };
} else {
- data["other_address"] = Json::Object{
- {"name", addr_str},
- };
+ data["other_address"] = Json::Object{
+ {"name", addr_str},
+ };
}
grpc_uri_destroy(uri);
- (*json)[name] = std::move(data);
+ (*json)[name] = std::move(data);
}
} // namespace
-SocketNode::SocketNode(TString local, TString remote, TString name)
+SocketNode::SocketNode(TString local, TString remote, TString name)
: BaseNode(EntityType::kSocket, std::move(name)),
local_(std::move(local)),
remote_(std::move(remote)) {}
@@ -407,20 +407,20 @@ void SocketNode::RecordMessageReceived() {
MemoryOrder::RELAXED);
}
-Json SocketNode::RenderJson() {
- // Create and fill the data child.
- Json::Object data;
+Json SocketNode::RenderJson() {
+ // Create and fill the data child.
+ Json::Object data;
gpr_timespec ts;
int64_t streams_started = streams_started_.Load(MemoryOrder::RELAXED);
if (streams_started != 0) {
- data["streamsStarted"] = ToString(streams_started);
+ data["streamsStarted"] = ToString(streams_started);
gpr_cycle_counter last_local_stream_created_cycle =
last_local_stream_created_cycle_.Load(MemoryOrder::RELAXED);
if (last_local_stream_created_cycle != 0) {
ts = gpr_convert_clock_type(
gpr_cycle_counter_to_time(last_local_stream_created_cycle),
GPR_CLOCK_REALTIME);
- data["lastLocalStreamCreatedTimestamp"] = gpr_format_timespec(ts);
+ data["lastLocalStreamCreatedTimestamp"] = gpr_format_timespec(ts);
}
gpr_cycle_counter last_remote_stream_created_cycle =
last_remote_stream_created_cycle_.Load(MemoryOrder::RELAXED);
@@ -428,71 +428,71 @@ Json SocketNode::RenderJson() {
ts = gpr_convert_clock_type(
gpr_cycle_counter_to_time(last_remote_stream_created_cycle),
GPR_CLOCK_REALTIME);
- data["lastRemoteStreamCreatedTimestamp"] = gpr_format_timespec(ts);
+ data["lastRemoteStreamCreatedTimestamp"] = gpr_format_timespec(ts);
}
}
int64_t streams_succeeded = streams_succeeded_.Load(MemoryOrder::RELAXED);
if (streams_succeeded != 0) {
- data["streamsSucceeded"] = ToString(streams_succeeded);
+ data["streamsSucceeded"] = ToString(streams_succeeded);
}
int64_t streams_failed = streams_failed_.Load(MemoryOrder::RELAXED);
- if (streams_failed != 0) {
- data["streamsFailed"] = ToString(streams_failed);
+ if (streams_failed != 0) {
+ data["streamsFailed"] = ToString(streams_failed);
}
int64_t messages_sent = messages_sent_.Load(MemoryOrder::RELAXED);
if (messages_sent != 0) {
- data["messagesSent"] = ToString(messages_sent);
+ data["messagesSent"] = ToString(messages_sent);
ts = gpr_convert_clock_type(
gpr_cycle_counter_to_time(
last_message_sent_cycle_.Load(MemoryOrder::RELAXED)),
GPR_CLOCK_REALTIME);
- data["lastMessageSentTimestamp"] = gpr_format_timespec(ts);
+ data["lastMessageSentTimestamp"] = gpr_format_timespec(ts);
}
int64_t messages_received = messages_received_.Load(MemoryOrder::RELAXED);
if (messages_received != 0) {
- data["messagesReceived"] = ToString(messages_received);
+ data["messagesReceived"] = ToString(messages_received);
ts = gpr_convert_clock_type(
gpr_cycle_counter_to_time(
last_message_received_cycle_.Load(MemoryOrder::RELAXED)),
GPR_CLOCK_REALTIME);
- data["lastMessageReceivedTimestamp"] = gpr_format_timespec(ts);
+ data["lastMessageReceivedTimestamp"] = gpr_format_timespec(ts);
}
int64_t keepalives_sent = keepalives_sent_.Load(MemoryOrder::RELAXED);
if (keepalives_sent != 0) {
- data["keepAlivesSent"] = ToString(keepalives_sent);
+ data["keepAlivesSent"] = ToString(keepalives_sent);
}
- // Create and fill the parent object.
- Json::Object object = {
- {"ref",
- Json::Object{
- {"socketId", ToString(uuid())},
- {"name", name()},
- }},
- {"data", std::move(data)},
- };
- PopulateSocketAddressJson(&object, "remote", remote_.c_str());
- PopulateSocketAddressJson(&object, "local", local_.c_str());
- return object;
+ // Create and fill the parent object.
+ Json::Object object = {
+ {"ref",
+ Json::Object{
+ {"socketId", ToString(uuid())},
+ {"name", name()},
+ }},
+ {"data", std::move(data)},
+ };
+ PopulateSocketAddressJson(&object, "remote", remote_.c_str());
+ PopulateSocketAddressJson(&object, "local", local_.c_str());
+ return object;
}
//
// ListenSocketNode
//
-ListenSocketNode::ListenSocketNode(TString local_addr, TString name)
+ListenSocketNode::ListenSocketNode(TString local_addr, TString name)
: BaseNode(EntityType::kSocket, std::move(name)),
local_addr_(std::move(local_addr)) {}
-Json ListenSocketNode::RenderJson() {
- Json::Object object = {
- {"ref",
- Json::Object{
- {"socketId", ToString(uuid())},
- {"name", name()},
- }},
- };
- PopulateSocketAddressJson(&object, "local", local_addr_.c_str());
- return object;
+Json ListenSocketNode::RenderJson() {
+ Json::Object object = {
+ {"ref",
+ Json::Object{
+ {"socketId", ToString(uuid())},
+ {"name", name()},
+ }},
+ };
+ PopulateSocketAddressJson(&object, "local", local_addr_.c_str());
+ return object;
}
} // namespace channelz
diff --git a/contrib/libs/grpc/src/core/lib/channel/channelz.h b/contrib/libs/grpc/src/core/lib/channel/channelz.h
index 0356a6cdb1..596770ccdc 100644
--- a/contrib/libs/grpc/src/core/lib/channel/channelz.h
+++ b/contrib/libs/grpc/src/core/lib/channel/channelz.h
@@ -23,11 +23,11 @@
#include <grpc/grpc.h>
-#include <set>
-#include <util/generic/string.h>
+#include <set>
+#include <util/generic/string.h>
+
+#include "y_absl/container/inlined_vector.h"
-#include "y_absl/container/inlined_vector.h"
-
#include "src/core/lib/channel/channel_trace.h"
#include "src/core/lib/gpr/time_precise.h"
#include "src/core/lib/gprpp/atomic.h"
@@ -43,9 +43,9 @@
// Channel arg key for channelz node.
#define GRPC_ARG_CHANNELZ_CHANNEL_NODE "grpc.channelz_channel_node"
-// Channel arg key for indicating an internal channel.
-#define GRPC_ARG_CHANNELZ_IS_INTERNAL_CHANNEL \
- "grpc.channelz_is_internal_channel"
+// Channel arg key for indicating an internal channel.
+#define GRPC_ARG_CHANNELZ_IS_INTERNAL_CHANNEL \
+ "grpc.channelz_is_internal_channel"
/** This is the default value for whether or not to enable channelz. If
* GRPC_ARG_ENABLE_CHANNELZ is set, it will override this default value. */
@@ -84,28 +84,28 @@ class BaseNode : public RefCounted<BaseNode> {
};
protected:
- BaseNode(EntityType type, TString name);
+ BaseNode(EntityType type, TString name);
public:
virtual ~BaseNode();
// All children must implement this function.
- virtual Json RenderJson() = 0;
+ virtual Json RenderJson() = 0;
// Renders the json and returns allocated string that must be freed by the
// caller.
- TString RenderJsonString();
+ TString RenderJsonString();
EntityType type() const { return type_; }
intptr_t uuid() const { return uuid_; }
- const TString& name() const { return name_; }
+ const TString& name() const { return name_; }
private:
// to allow the ChannelzRegistry to set uuid_ under its lock.
friend class ChannelzRegistry;
const EntityType type_;
intptr_t uuid_;
- TString name_;
+ TString name_;
};
// This class is a helper class for channelz entities that deal with Channels,
@@ -123,7 +123,7 @@ class CallCountingHelper {
void RecordCallSucceeded();
// Common rendering of the call count data and last_call_started_timestamp.
- void PopulateCallCounts(Json::Object* json);
+ void PopulateCallCounts(Json::Object* json);
private:
// testing peer friend.
@@ -147,13 +147,13 @@ class CallCountingHelper {
// Make sure the size is exactly one cache line.
uint8_t padding[GPR_CACHELINE_SIZE - 3 * sizeof(Atomic<intptr_t>) -
sizeof(Atomic<gpr_cycle_counter>)];
- };
- // TODO(soheilhy,veblush): Revist this after abseil integration.
- // This has a problem when using abseil inlined_vector because it
- // carries an alignment attribute properly but our allocator doesn't
- // respect this. To avoid UBSAN errors, this should be removed with
- // abseil inlined_vector.
- // GPR_ALIGN_STRUCT(GPR_CACHELINE_SIZE);
+ };
+ // TODO(soheilhy,veblush): Revist this after abseil integration.
+ // This has a problem when using abseil inlined_vector because it
+ // carries an alignment attribute properly but our allocator doesn't
+ // respect this. To avoid UBSAN errors, this should be removed with
+ // abseil inlined_vector.
+ // GPR_ALIGN_STRUCT(GPR_CACHELINE_SIZE);
struct CounterData {
int64_t calls_started = 0;
@@ -166,21 +166,21 @@ class CallCountingHelper {
void CollectData(CounterData* out);
// Really zero-sized, but 0-sized arrays are illegal on MSVC.
- y_absl::InlinedVector<AtomicCounterData, 1> per_cpu_counter_data_storage_;
+ y_absl::InlinedVector<AtomicCounterData, 1> per_cpu_counter_data_storage_;
size_t num_cores_ = 0;
};
// Handles channelz bookkeeping for channels
class ChannelNode : public BaseNode {
public:
- ChannelNode(TString target, size_t channel_tracer_max_nodes,
- bool is_internal_channel);
+ ChannelNode(TString target, size_t channel_tracer_max_nodes,
+ bool is_internal_channel);
// Returns the string description of the given connectivity state.
static const char* GetChannelConnectivityStateChangeString(
grpc_connectivity_state state);
- Json RenderJson() override;
+ Json RenderJson() override;
// proxy methods to composed classes.
void AddTraceEvent(ChannelTrace::Severity severity, const grpc_slice& data) {
@@ -209,12 +209,12 @@ class ChannelNode : public BaseNode {
void RemoveChildSubchannel(intptr_t child_uuid);
private:
- // Allows the channel trace test to access trace_.
- friend class testing::ChannelNodePeer;
-
- void PopulateChildRefs(Json::Object* json);
+ // Allows the channel trace test to access trace_.
+ friend class testing::ChannelNodePeer;
+
+ void PopulateChildRefs(Json::Object* json);
- TString target_;
+ TString target_;
CallCountingHelper call_counter_;
ChannelTrace trace_;
@@ -222,22 +222,22 @@ class ChannelNode : public BaseNode {
// bits are a grpc_connectivity_state value.
Atomic<int> connectivity_state_{0};
- Mutex child_mu_; // Guards sets below.
- std::set<intptr_t> child_channels_;
- std::set<intptr_t> child_subchannels_;
+ Mutex child_mu_; // Guards sets below.
+ std::set<intptr_t> child_channels_;
+ std::set<intptr_t> child_subchannels_;
};
// Handles channelz bookkeeping for servers
class ServerNode : public BaseNode {
public:
- explicit ServerNode(size_t channel_tracer_max_nodes);
+ explicit ServerNode(size_t channel_tracer_max_nodes);
~ServerNode() override;
- Json RenderJson() override;
+ Json RenderJson() override;
- TString RenderServerSockets(intptr_t start_socket_id,
- intptr_t max_results);
+ TString RenderServerSockets(intptr_t start_socket_id,
+ intptr_t max_results);
void AddChildSocket(RefCountedPtr<SocketNode> node);
@@ -272,10 +272,10 @@ class ServerNode : public BaseNode {
// Handles channelz bookkeeping for sockets
class SocketNode : public BaseNode {
public:
- SocketNode(TString local, TString remote, TString name);
+ SocketNode(TString local, TString remote, TString name);
~SocketNode() override {}
- Json RenderJson() override;
+ Json RenderJson() override;
void RecordStreamStartedFromLocal();
void RecordStreamStartedFromRemote();
@@ -291,7 +291,7 @@ class SocketNode : public BaseNode {
keepalives_sent_.FetchAdd(1, MemoryOrder::RELAXED);
}
- const TString& remote() { return remote_; }
+ const TString& remote() { return remote_; }
private:
Atomic<int64_t> streams_started_{0};
@@ -304,20 +304,20 @@ class SocketNode : public BaseNode {
Atomic<gpr_cycle_counter> last_remote_stream_created_cycle_{0};
Atomic<gpr_cycle_counter> last_message_sent_cycle_{0};
Atomic<gpr_cycle_counter> last_message_received_cycle_{0};
- TString local_;
- TString remote_;
+ TString local_;
+ TString remote_;
};
// Handles channelz bookkeeping for listen sockets
class ListenSocketNode : public BaseNode {
public:
- ListenSocketNode(TString local_addr, TString name);
+ ListenSocketNode(TString local_addr, TString name);
~ListenSocketNode() override {}
- Json RenderJson() override;
+ Json RenderJson() override;
private:
- TString local_addr_;
+ TString local_addr_;
};
} // namespace channelz
diff --git a/contrib/libs/grpc/src/core/lib/channel/channelz_registry.cc b/contrib/libs/grpc/src/core/lib/channel/channelz_registry.cc
index 89a7d5ad14..5a6e28ad78 100644
--- a/contrib/libs/grpc/src/core/lib/channel/channelz_registry.cc
+++ b/contrib/libs/grpc/src/core/lib/channel/channelz_registry.cc
@@ -21,8 +21,8 @@
#include <algorithm>
#include <cstring>
-#include "y_absl/container/inlined_vector.h"
-
+#include "y_absl/container/inlined_vector.h"
+
#include "src/core/lib/channel/channel_trace.h"
#include "src/core/lib/channel/channelz.h"
#include "src/core/lib/channel/channelz_registry.h"
@@ -32,7 +32,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-#include <grpc/support/string_util.h>
+#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
namespace grpc_core {
@@ -78,21 +78,21 @@ RefCountedPtr<BaseNode> ChannelzRegistry::InternalGet(intptr_t uuid) {
// Found node. Return only if its refcount is not zero (i.e., when we
// know that there is no other thread about to destroy it).
BaseNode* node = it->second;
- return node->RefIfNonZero();
+ return node->RefIfNonZero();
}
-TString ChannelzRegistry::InternalGetTopChannels(
- intptr_t start_channel_id) {
- y_absl::InlinedVector<RefCountedPtr<BaseNode>, 10> top_level_channels;
+TString ChannelzRegistry::InternalGetTopChannels(
+ intptr_t start_channel_id) {
+ y_absl::InlinedVector<RefCountedPtr<BaseNode>, 10> top_level_channels;
RefCountedPtr<BaseNode> node_after_pagination_limit;
{
MutexLock lock(&mu_);
for (auto it = node_map_.lower_bound(start_channel_id);
it != node_map_.end(); ++it) {
BaseNode* node = it->second;
- RefCountedPtr<BaseNode> node_ref;
+ RefCountedPtr<BaseNode> node_ref;
if (node->type() == BaseNode::EntityType::kTopLevelChannel &&
- (node_ref = node->RefIfNonZero()) != nullptr) {
+ (node_ref = node->RefIfNonZero()) != nullptr) {
// Check if we are over pagination limit to determine if we need to set
// the "end" element. If we don't go through this block, we know that
// when the loop terminates, we have <= to kPaginationLimit.
@@ -100,38 +100,38 @@ TString ChannelzRegistry::InternalGetTopChannels(
// refcount, we need to decrease it, but we can't unref while
// holding the lock, because this may lead to a deadlock.
if (top_level_channels.size() == kPaginationLimit) {
- node_after_pagination_limit = std::move(node_ref);
+ node_after_pagination_limit = std::move(node_ref);
break;
}
- top_level_channels.emplace_back(std::move(node_ref));
+ top_level_channels.emplace_back(std::move(node_ref));
}
}
}
- Json::Object object;
+ Json::Object object;
if (!top_level_channels.empty()) {
- // Create list of channels.
- Json::Array array;
+ // Create list of channels.
+ Json::Array array;
for (size_t i = 0; i < top_level_channels.size(); ++i) {
- array.emplace_back(top_level_channels[i]->RenderJson());
+ array.emplace_back(top_level_channels[i]->RenderJson());
}
- object["channel"] = std::move(array);
+ object["channel"] = std::move(array);
}
- if (node_after_pagination_limit == nullptr) object["end"] = true;
- Json json(std::move(object));
- return json.Dump();
+ if (node_after_pagination_limit == nullptr) object["end"] = true;
+ Json json(std::move(object));
+ return json.Dump();
}
-TString ChannelzRegistry::InternalGetServers(intptr_t start_server_id) {
- y_absl::InlinedVector<RefCountedPtr<BaseNode>, 10> servers;
+TString ChannelzRegistry::InternalGetServers(intptr_t start_server_id) {
+ y_absl::InlinedVector<RefCountedPtr<BaseNode>, 10> servers;
RefCountedPtr<BaseNode> node_after_pagination_limit;
{
MutexLock lock(&mu_);
for (auto it = node_map_.lower_bound(start_server_id);
it != node_map_.end(); ++it) {
BaseNode* node = it->second;
- RefCountedPtr<BaseNode> node_ref;
+ RefCountedPtr<BaseNode> node_ref;
if (node->type() == BaseNode::EntityType::kServer &&
- (node_ref = node->RefIfNonZero()) != nullptr) {
+ (node_ref = node->RefIfNonZero()) != nullptr) {
// Check if we are over pagination limit to determine if we need to set
// the "end" element. If we don't go through this block, we know that
// when the loop terminates, we have <= to kPaginationLimit.
@@ -139,41 +139,41 @@ TString ChannelzRegistry::InternalGetServers(intptr_t start_server_id) {
// refcount, we need to decrease it, but we can't unref while
// holding the lock, because this may lead to a deadlock.
if (servers.size() == kPaginationLimit) {
- node_after_pagination_limit = std::move(node_ref);
+ node_after_pagination_limit = std::move(node_ref);
break;
}
- servers.emplace_back(std::move(node_ref));
+ servers.emplace_back(std::move(node_ref));
}
}
}
- Json::Object object;
+ Json::Object object;
if (!servers.empty()) {
- // Create list of servers.
- Json::Array array;
+ // Create list of servers.
+ Json::Array array;
for (size_t i = 0; i < servers.size(); ++i) {
- array.emplace_back(servers[i]->RenderJson());
+ array.emplace_back(servers[i]->RenderJson());
}
- object["server"] = std::move(array);
+ object["server"] = std::move(array);
}
- if (node_after_pagination_limit == nullptr) object["end"] = true;
- Json json(std::move(object));
- return json.Dump();
+ if (node_after_pagination_limit == nullptr) object["end"] = true;
+ Json json(std::move(object));
+ return json.Dump();
}
void ChannelzRegistry::InternalLogAllEntities() {
- y_absl::InlinedVector<RefCountedPtr<BaseNode>, 10> nodes;
+ y_absl::InlinedVector<RefCountedPtr<BaseNode>, 10> nodes;
{
MutexLock lock(&mu_);
for (auto& p : node_map_) {
- RefCountedPtr<BaseNode> node = p.second->RefIfNonZero();
- if (node != nullptr) {
- nodes.emplace_back(std::move(node));
+ RefCountedPtr<BaseNode> node = p.second->RefIfNonZero();
+ if (node != nullptr) {
+ nodes.emplace_back(std::move(node));
}
}
}
for (size_t i = 0; i < nodes.size(); ++i) {
- TString json = nodes[i]->RenderJsonString();
- gpr_log(GPR_INFO, "%s", json.c_str());
+ TString json = nodes[i]->RenderJsonString();
+ gpr_log(GPR_INFO, "%s", json.c_str());
}
}
@@ -181,15 +181,15 @@ void ChannelzRegistry::InternalLogAllEntities() {
} // namespace grpc_core
char* grpc_channelz_get_top_channels(intptr_t start_channel_id) {
- return gpr_strdup(
- grpc_core::channelz::ChannelzRegistry::GetTopChannels(start_channel_id)
- .c_str());
+ return gpr_strdup(
+ grpc_core::channelz::ChannelzRegistry::GetTopChannels(start_channel_id)
+ .c_str());
}
char* grpc_channelz_get_servers(intptr_t start_server_id) {
- return gpr_strdup(
- grpc_core::channelz::ChannelzRegistry::GetServers(start_server_id)
- .c_str());
+ return gpr_strdup(
+ grpc_core::channelz::ChannelzRegistry::GetServers(start_server_id)
+ .c_str());
}
char* grpc_channelz_get_server(intptr_t server_id) {
@@ -200,29 +200,29 @@ char* grpc_channelz_get_server(intptr_t server_id) {
grpc_core::channelz::BaseNode::EntityType::kServer) {
return nullptr;
}
- grpc_core::Json json = grpc_core::Json::Object{
- {"server", server_node->RenderJson()},
- };
- return gpr_strdup(json.Dump().c_str());
+ grpc_core::Json json = grpc_core::Json::Object{
+ {"server", server_node->RenderJson()},
+ };
+ return gpr_strdup(json.Dump().c_str());
}
char* grpc_channelz_get_server_sockets(intptr_t server_id,
intptr_t start_socket_id,
intptr_t max_results) {
- // Validate inputs before handing them of to the renderer.
+ // Validate inputs before handing them of to the renderer.
grpc_core::RefCountedPtr<grpc_core::channelz::BaseNode> base_node =
grpc_core::channelz::ChannelzRegistry::Get(server_id);
if (base_node == nullptr ||
- base_node->type() != grpc_core::channelz::BaseNode::EntityType::kServer ||
- start_socket_id < 0 || max_results < 0) {
+ base_node->type() != grpc_core::channelz::BaseNode::EntityType::kServer ||
+ start_socket_id < 0 || max_results < 0) {
return nullptr;
}
// This cast is ok since we have just checked to make sure base_node is
- // actually a server node.
+ // actually a server node.
grpc_core::channelz::ServerNode* server_node =
static_cast<grpc_core::channelz::ServerNode*>(base_node.get());
- return gpr_strdup(
- server_node->RenderServerSockets(start_socket_id, max_results).c_str());
+ return gpr_strdup(
+ server_node->RenderServerSockets(start_socket_id, max_results).c_str());
}
char* grpc_channelz_get_channel(intptr_t channel_id) {
@@ -235,10 +235,10 @@ char* grpc_channelz_get_channel(intptr_t channel_id) {
grpc_core::channelz::BaseNode::EntityType::kInternalChannel)) {
return nullptr;
}
- grpc_core::Json json = grpc_core::Json::Object{
- {"channel", channel_node->RenderJson()},
- };
- return gpr_strdup(json.Dump().c_str());
+ grpc_core::Json json = grpc_core::Json::Object{
+ {"channel", channel_node->RenderJson()},
+ };
+ return gpr_strdup(json.Dump().c_str());
}
char* grpc_channelz_get_subchannel(intptr_t subchannel_id) {
@@ -249,10 +249,10 @@ char* grpc_channelz_get_subchannel(intptr_t subchannel_id) {
grpc_core::channelz::BaseNode::EntityType::kSubchannel) {
return nullptr;
}
- grpc_core::Json json = grpc_core::Json::Object{
- {"subchannel", subchannel_node->RenderJson()},
- };
- return gpr_strdup(json.Dump().c_str());
+ grpc_core::Json json = grpc_core::Json::Object{
+ {"subchannel", subchannel_node->RenderJson()},
+ };
+ return gpr_strdup(json.Dump().c_str());
}
char* grpc_channelz_get_socket(intptr_t socket_id) {
@@ -263,8 +263,8 @@ char* grpc_channelz_get_socket(intptr_t socket_id) {
grpc_core::channelz::BaseNode::EntityType::kSocket) {
return nullptr;
}
- grpc_core::Json json = grpc_core::Json::Object{
- {"socket", socket_node->RenderJson()},
- };
- return gpr_strdup(json.Dump().c_str());
+ grpc_core::Json json = grpc_core::Json::Object{
+ {"socket", socket_node->RenderJson()},
+ };
+ return gpr_strdup(json.Dump().c_str());
}
diff --git a/contrib/libs/grpc/src/core/lib/channel/channelz_registry.h b/contrib/libs/grpc/src/core/lib/channel/channelz_registry.h
index 54526e83bf..73a5e20fbd 100644
--- a/contrib/libs/grpc/src/core/lib/channel/channelz_registry.h
+++ b/contrib/libs/grpc/src/core/lib/channel/channelz_registry.h
@@ -23,9 +23,9 @@
#include <stdint.h>
-#include <map>
-#include <util/generic/string.h>
-
+#include <map>
+#include <util/generic/string.h>
+
#include "src/core/lib/channel/channel_trace.h"
#include "src/core/lib/channel/channelz.h"
#include "src/core/lib/gprpp/map.h"
@@ -54,13 +54,13 @@ class ChannelzRegistry {
// Returns the allocated JSON string that represents the proto
// GetTopChannelsResponse as per channelz.proto.
- static TString GetTopChannels(intptr_t start_channel_id) {
+ static TString GetTopChannels(intptr_t start_channel_id) {
return Default()->InternalGetTopChannels(start_channel_id);
}
// Returns the allocated JSON string that represents the proto
// GetServersResponse as per channelz.proto.
- static TString GetServers(intptr_t start_server_id) {
+ static TString GetServers(intptr_t start_server_id) {
return Default()->InternalGetServers(start_server_id);
}
@@ -83,8 +83,8 @@ class ChannelzRegistry {
// returns the void* associated with that uuid. Else returns nullptr.
RefCountedPtr<BaseNode> InternalGet(intptr_t uuid);
- TString InternalGetTopChannels(intptr_t start_channel_id);
- TString InternalGetServers(intptr_t start_server_id);
+ TString InternalGetTopChannels(intptr_t start_channel_id);
+ TString InternalGetServers(intptr_t start_server_id);
void InternalLogAllEntities();
diff --git a/contrib/libs/grpc/src/core/lib/channel/connected_channel.cc b/contrib/libs/grpc/src/core/lib/channel/connected_channel.cc
index 22a1e9501e..be74d9e88b 100644
--- a/contrib/libs/grpc/src/core/lib/channel/connected_channel.cc
+++ b/contrib/libs/grpc/src/core/lib/channel/connected_channel.cc
@@ -90,12 +90,12 @@ static callback_state* get_state_for_batch(
/* We perform a small hack to locate transport data alongside the connected
channel data in call allocations, to allow everything to be pulled in minimal
cache line requests */
-#define TRANSPORT_STREAM_FROM_CALL_DATA(calld) \
- ((grpc_stream*)(((char*)(calld)) + \
- GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(call_data))))
+#define TRANSPORT_STREAM_FROM_CALL_DATA(calld) \
+ ((grpc_stream*)(((char*)(calld)) + \
+ GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(call_data))))
#define CALL_DATA_FROM_TRANSPORT_STREAM(transport_stream) \
- ((call_data*)(((char*)(transport_stream)) - \
- GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(call_data))))
+ ((call_data*)(((char*)(transport_stream)) - \
+ GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(call_data))))
/* Intercept a call operation and either push it directly up or translate it
into transport stream operations */
diff --git a/contrib/libs/grpc/src/core/lib/channel/context.h b/contrib/libs/grpc/src/core/lib/channel/context.h
index 7699609ef6..bd7fd495e4 100644
--- a/contrib/libs/grpc/src/core/lib/channel/context.h
+++ b/contrib/libs/grpc/src/core/lib/channel/context.h
@@ -35,7 +35,7 @@ typedef enum {
/// Reserved for traffic_class_context.
GRPC_CONTEXT_TRAFFIC,
- /// Holds a pointer to ServiceConfigCallData associated with this call.
+ /// Holds a pointer to ServiceConfigCallData associated with this call.
GRPC_CONTEXT_SERVICE_CONFIG_CALL_DATA,
GRPC_CONTEXT_COUNT
diff --git a/contrib/libs/grpc/src/core/lib/channel/handshaker.cc b/contrib/libs/grpc/src/core/lib/channel/handshaker.cc
index cc36c26660..826be41cbb 100644
--- a/contrib/libs/grpc/src/core/lib/channel/handshaker.cc
+++ b/contrib/libs/grpc/src/core/lib/channel/handshaker.cc
@@ -20,8 +20,8 @@
#include <string.h>
-#include "y_absl/strings/str_format.h"
-
+#include "y_absl/strings/str_format.h"
+
#include <grpc/impl/codegen/slice.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@@ -39,16 +39,16 @@ TraceFlag grpc_handshaker_trace(false, "handshaker");
namespace {
-TString HandshakerArgsString(HandshakerArgs* args) {
+TString HandshakerArgsString(HandshakerArgs* args) {
size_t num_args = args->args != nullptr ? args->args->num_args : 0;
size_t read_buffer_length =
args->read_buffer != nullptr ? args->read_buffer->length : 0;
- return y_absl::StrFormat(
- "{endpoint=%p, args=%p {size=%" PRIuPTR
- ": %s}, read_buffer=%p (length=%" PRIuPTR "), exit_early=%d}",
- args->endpoint, args->args, num_args,
- grpc_channel_args_string(args->args), args->read_buffer,
- read_buffer_length, args->exit_early);
+ return y_absl::StrFormat(
+ "{endpoint=%p, args=%p {size=%" PRIuPTR
+ ": %s}, read_buffer=%p (length=%" PRIuPTR "), exit_early=%d}",
+ args->endpoint, args->args, num_args,
+ grpc_channel_args_string(args->args), args->read_buffer,
+ read_buffer_length, args->exit_early);
}
} // namespace
@@ -129,8 +129,8 @@ bool HandshakeManager::CallNextHandshakerLocked(grpc_error* error) {
gpr_log(GPR_INFO,
"handshake_manager %p: error=%s shutdown=%d index=%" PRIuPTR
", args=%s",
- this, grpc_error_string(error), is_shutdown_, index_,
- HandshakerArgsString(&args_).c_str());
+ this, grpc_error_string(error), is_shutdown_, index_,
+ HandshakerArgsString(&args_).c_str());
}
GPR_ASSERT(index_ <= handshakers_.size());
// If we got an error or we've been shut down or we're exiting early or
diff --git a/contrib/libs/grpc/src/core/lib/channel/handshaker.h b/contrib/libs/grpc/src/core/lib/channel/handshaker.h
index 91e9d393fa..cc8e9b2578 100644
--- a/contrib/libs/grpc/src/core/lib/channel/handshaker.h
+++ b/contrib/libs/grpc/src/core/lib/channel/handshaker.h
@@ -21,8 +21,8 @@
#include <grpc/support/port_platform.h>
-#include "y_absl/container/inlined_vector.h"
-
+#include "y_absl/container/inlined_vector.h"
+
#include <grpc/support/string_util.h>
#include <grpc/impl/codegen/grpc_types.h>
@@ -147,8 +147,8 @@ class HandshakeManager : public RefCounted<HandshakeManager> {
gpr_mu mu_;
bool is_shutdown_ = false;
// An array of handshakers added via grpc_handshake_manager_add().
- y_absl::InlinedVector<RefCountedPtr<Handshaker>, HANDSHAKERS_INIT_SIZE>
- handshakers_;
+ y_absl::InlinedVector<RefCountedPtr<Handshaker>, HANDSHAKERS_INIT_SIZE>
+ handshakers_;
// The index of the handshaker to invoke next and closure to invoke it.
size_t index_ = 0;
grpc_closure call_next_handshaker_;
diff --git a/contrib/libs/grpc/src/core/lib/channel/handshaker_registry.cc b/contrib/libs/grpc/src/core/lib/channel/handshaker_registry.cc
index be0a5edfb2..614531832d 100644
--- a/contrib/libs/grpc/src/core/lib/channel/handshaker_registry.cc
+++ b/contrib/libs/grpc/src/core/lib/channel/handshaker_registry.cc
@@ -18,8 +18,8 @@
#include <grpc/support/port_platform.h>
-#include "y_absl/container/inlined_vector.h"
-
+#include "y_absl/container/inlined_vector.h"
+
#include "src/core/lib/channel/handshaker_registry.h"
#include "src/core/lib/gpr/alloc.h"
#include "src/core/lib/gprpp/memory.h"
@@ -45,7 +45,7 @@ class HandshakerFactoryList {
HandshakeManager* handshake_mgr);
private:
- y_absl::InlinedVector<std::unique_ptr<HandshakerFactory>, 2> factories_;
+ y_absl::InlinedVector<std::unique_ptr<HandshakerFactory>, 2> factories_;
};
HandshakerFactoryList* g_handshaker_factory_lists = nullptr;
@@ -76,12 +76,12 @@ void HandshakerFactoryList::AddHandshakers(const grpc_channel_args* args,
void HandshakerRegistry::Init() {
GPR_ASSERT(g_handshaker_factory_lists == nullptr);
- g_handshaker_factory_lists = new HandshakerFactoryList[NUM_HANDSHAKER_TYPES];
+ g_handshaker_factory_lists = new HandshakerFactoryList[NUM_HANDSHAKER_TYPES];
}
void HandshakerRegistry::Shutdown() {
GPR_ASSERT(g_handshaker_factory_lists != nullptr);
- delete[] g_handshaker_factory_lists;
+ delete[] g_handshaker_factory_lists;
g_handshaker_factory_lists = nullptr;
}
diff --git a/contrib/libs/grpc/src/core/lib/compression/message_compress.cc b/contrib/libs/grpc/src/core/lib/compression/message_compress.cc
index 26136828d6..7c2a70bad4 100644
--- a/contrib/libs/grpc/src/core/lib/compression/message_compress.cc
+++ b/contrib/libs/grpc/src/core/lib/compression/message_compress.cc
@@ -34,7 +34,7 @@
static int zlib_body(z_stream* zs, grpc_slice_buffer* input,
grpc_slice_buffer* output,
int (*flate)(z_stream* zs, int flush)) {
- int r = Z_STREAM_END; /* Do not fail on an empty input. */
+ int r = Z_STREAM_END; /* Do not fail on an empty input. */
int flush;
size_t i;
grpc_slice outbuf = GRPC_SLICE_MALLOC(OUTPUT_BLOCK_SIZE);
@@ -68,10 +68,10 @@ static int zlib_body(z_stream* zs, grpc_slice_buffer* input,
goto error;
}
}
- if (r != Z_STREAM_END) {
- gpr_log(GPR_INFO, "zlib: Data error");
- goto error;
- }
+ if (r != Z_STREAM_END) {
+ gpr_log(GPR_INFO, "zlib: Data error");
+ goto error;
+ }
GPR_ASSERT(outbuf.refcount);
outbuf.data.refcounted.length -= zs->avail_out;
diff --git a/contrib/libs/grpc/src/core/lib/debug/stats.cc b/contrib/libs/grpc/src/core/lib/debug/stats.cc
index a0e70e21e0..1bcd1af25a 100644
--- a/contrib/libs/grpc/src/core/lib/debug/stats.cc
+++ b/contrib/libs/grpc/src/core/lib/debug/stats.cc
@@ -23,11 +23,11 @@
#include <inttypes.h>
#include <string.h>
-#include <vector>
-
-#include "y_absl/strings/str_format.h"
-#include "y_absl/strings/str_join.h"
-
+#include <vector>
+
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/str_join.h"
+
#include <grpc/support/alloc.h>
#include <grpc/support/string_util.h>
@@ -145,28 +145,28 @@ double grpc_stats_histo_percentile(const grpc_stats_data* stats,
static_cast<double>(count) * percentile / 100.0);
}
-TString grpc_stats_data_as_json(const grpc_stats_data* data) {
- std::vector<TString> parts;
- parts.push_back("{");
+TString grpc_stats_data_as_json(const grpc_stats_data* data) {
+ std::vector<TString> parts;
+ parts.push_back("{");
for (size_t i = 0; i < GRPC_STATS_COUNTER_COUNT; i++) {
- parts.push_back(y_absl::StrFormat(
- "\"%s\": %" PRIdPTR, grpc_stats_counter_name[i], data->counters[i]));
+ parts.push_back(y_absl::StrFormat(
+ "\"%s\": %" PRIdPTR, grpc_stats_counter_name[i], data->counters[i]));
}
for (size_t i = 0; i < GRPC_STATS_HISTOGRAM_COUNT; i++) {
- parts.push_back(y_absl::StrFormat("\"%s\": [", grpc_stats_histogram_name[i]));
+ parts.push_back(y_absl::StrFormat("\"%s\": [", grpc_stats_histogram_name[i]));
for (int j = 0; j < grpc_stats_histo_buckets[i]; j++) {
- parts.push_back(
- y_absl::StrFormat("%s%" PRIdPTR, j == 0 ? "" : ",",
- data->histograms[grpc_stats_histo_start[i] + j]));
+ parts.push_back(
+ y_absl::StrFormat("%s%" PRIdPTR, j == 0 ? "" : ",",
+ data->histograms[grpc_stats_histo_start[i] + j]));
}
- parts.push_back(
- y_absl::StrFormat("], \"%s_bkt\": [", grpc_stats_histogram_name[i]));
+ parts.push_back(
+ y_absl::StrFormat("], \"%s_bkt\": [", grpc_stats_histogram_name[i]));
for (int j = 0; j < grpc_stats_histo_buckets[i]; j++) {
- parts.push_back(y_absl::StrFormat(
- "%s%d", j == 0 ? "" : ",", grpc_stats_histo_bucket_boundaries[i][j]));
+ parts.push_back(y_absl::StrFormat(
+ "%s%d", j == 0 ? "" : ",", grpc_stats_histo_bucket_boundaries[i][j]));
}
- parts.push_back("]");
+ parts.push_back("]");
}
- parts.push_back("}");
- return y_absl::StrJoin(parts, "");
+ parts.push_back("}");
+ return y_absl::StrJoin(parts, "");
}
diff --git a/contrib/libs/grpc/src/core/lib/debug/stats.h b/contrib/libs/grpc/src/core/lib/debug/stats.h
index 9498bf1fbf..c184fa7fc7 100644
--- a/contrib/libs/grpc/src/core/lib/debug/stats.h
+++ b/contrib/libs/grpc/src/core/lib/debug/stats.h
@@ -21,8 +21,8 @@
#include <grpc/support/port_platform.h>
-#include <util/generic/string.h>
-
+#include <util/generic/string.h>
+
#include <grpc/support/atm.h>
#include "src/core/lib/debug/stats_data.h"
#include "src/core/lib/iomgr/exec_ctx.h"
@@ -58,7 +58,7 @@ void grpc_stats_collect(grpc_stats_data* output);
// c = b-a
void grpc_stats_diff(const grpc_stats_data* b, const grpc_stats_data* a,
grpc_stats_data* c);
-TString grpc_stats_data_as_json(const grpc_stats_data* data);
+TString grpc_stats_data_as_json(const grpc_stats_data* data);
int grpc_stats_histo_find_bucket_slow(int value, const int* table,
int table_size);
double grpc_stats_histo_percentile(const grpc_stats_data* data,
diff --git a/contrib/libs/grpc/src/core/lib/gpr/log_linux.cc b/contrib/libs/grpc/src/core/lib/gpr/log_linux.cc
index 2e9891d95a..7b098d4711 100644
--- a/contrib/libs/grpc/src/core/lib/gpr/log_linux.cc
+++ b/contrib/libs/grpc/src/core/lib/gpr/log_linux.cc
@@ -38,8 +38,8 @@
#include <sys/syscall.h>
#include <time.h>
#include <unistd.h>
-#include <util/generic/string.h>
-#include "y_absl/strings/str_format.h"
+#include <util/generic/string.h>
+#include "y_absl/strings/str_format.h"
static long sys_gettid(void) { return syscall(__NR_gettid); }
@@ -86,10 +86,10 @@ void gpr_default_log(gpr_log_func_args* args) {
strcpy(time_buffer, "error:strftime");
}
- TString prefix = y_absl::StrFormat(
- "%s%s.%09" PRId32 " %7ld %s:%d]", gpr_log_severity_string(args->severity),
- time_buffer, now.tv_nsec, tid, display_file, args->line);
- fprintf(stderr, "%-60s %s\n", prefix.c_str(), args->message);
+ TString prefix = y_absl::StrFormat(
+ "%s%s.%09" PRId32 " %7ld %s:%d]", gpr_log_severity_string(args->severity),
+ time_buffer, now.tv_nsec, tid, display_file, args->line);
+ fprintf(stderr, "%-60s %s\n", prefix.c_str(), args->message);
}
#endif /* GPR_LINUX_LOG */
diff --git a/contrib/libs/grpc/src/core/lib/gpr/log_posix.cc b/contrib/libs/grpc/src/core/lib/gpr/log_posix.cc
index 5dd441f4e1..bc02118d94 100644
--- a/contrib/libs/grpc/src/core/lib/gpr/log_posix.cc
+++ b/contrib/libs/grpc/src/core/lib/gpr/log_posix.cc
@@ -29,8 +29,8 @@
#include <stdio.h>
#include <string.h>
#include <time.h>
-#include <util/generic/string.h>
-#include "y_absl/strings/str_format.h"
+#include <util/generic/string.h>
+#include "y_absl/strings/str_format.h"
static intptr_t sys_gettid(void) { return (intptr_t)pthread_self(); }
@@ -84,10 +84,10 @@ void gpr_default_log(gpr_log_func_args* args) {
strcpy(time_buffer, "error:strftime");
}
- TString prefix = y_absl::StrFormat(
- "%s%s.%09d %7" PRIdPTR " %s:%d]", gpr_log_severity_string(args->severity),
- time_buffer, (int)(now.tv_nsec), sys_gettid(), display_file, args->line);
- fprintf(stderr, "%-70s %s\n", prefix.c_str(), args->message);
+ TString prefix = y_absl::StrFormat(
+ "%s%s.%09d %7" PRIdPTR " %s:%d]", gpr_log_severity_string(args->severity),
+ time_buffer, (int)(now.tv_nsec), sys_gettid(), display_file, args->line);
+ fprintf(stderr, "%-70s %s\n", prefix.c_str(), args->message);
}
#endif /* defined(GPR_POSIX_LOG) */
diff --git a/contrib/libs/grpc/src/core/lib/gpr/string.cc b/contrib/libs/grpc/src/core/lib/gpr/string.cc
index 2785fa4afd..28f1ae437d 100644
--- a/contrib/libs/grpc/src/core/lib/gpr/string.cc
+++ b/contrib/libs/grpc/src/core/lib/gpr/string.cc
@@ -28,8 +28,8 @@
#include <string.h>
#include <time.h>
-#include "y_absl/strings/str_cat.h"
-
+#include "y_absl/strings/str_cat.h"
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
@@ -52,7 +52,7 @@ char* gpr_strdup(const char* src) {
return dst;
}
-TString gpr_format_timespec(gpr_timespec tm) {
+TString gpr_format_timespec(gpr_timespec tm) {
char time_buffer[35];
char ns_buffer[11]; // '.' + 9 digits of precision
struct tm* tm_info = localtime((const time_t*)&tm.tv_sec);
@@ -73,15 +73,15 @@ TString gpr_format_timespec(gpr_timespec tm) {
break;
}
}
- return y_absl::StrCat(time_buffer, ns_buffer, "Z");
+ return y_absl::StrCat(time_buffer, ns_buffer, "Z");
}
-struct dump_out {
- size_t capacity;
- size_t length;
- char* data;
-};
-
+struct dump_out {
+ size_t capacity;
+ size_t length;
+ char* data;
+};
+
static dump_out dump_out_create(void) {
dump_out r = {0, 0, nullptr};
return r;
diff --git a/contrib/libs/grpc/src/core/lib/gpr/string.h b/contrib/libs/grpc/src/core/lib/gpr/string.h
index d44f79d7fb..4b348198b8 100644
--- a/contrib/libs/grpc/src/core/lib/gpr/string.h
+++ b/contrib/libs/grpc/src/core/lib/gpr/string.h
@@ -26,8 +26,8 @@
#include <stdbool.h>
#include <stddef.h>
-#include <util/generic/string.h>
-
+#include <util/generic/string.h>
+
/* String utility functions */
/* Flags for gpr_dump function. */
@@ -90,13 +90,13 @@ char* gpr_strjoin_sep(const char** strs, size_t nstrs, const char* sep,
void gpr_string_split(const char* input, const char* sep, char*** strs,
size_t* nstrs);
-/* Returns a string that represents tm according to RFC-3339, and,
+/* Returns a string that represents tm according to RFC-3339, and,
more specifically, follows:
https://developers.google.com/protocol-buffers/docs/proto3#json
Uses RFC 3339, where generated output will always be Z-normalized and uses
0, 3, 6 or 9 fractional digits. */
-TString gpr_format_timespec(gpr_timespec);
+TString gpr_format_timespec(gpr_timespec);
/** Case insensitive string comparison... return <0 if lower(a)<lower(b), ==0 if
lower(a)==lower(b), >0 if lower(a)>lower(b) */
diff --git a/contrib/libs/grpc/src/core/lib/gpr/sync_abseil.cc b/contrib/libs/grpc/src/core/lib/gpr/sync_abseil.cc
index 09f8f592b6..c224be2eee 100644
--- a/contrib/libs/grpc/src/core/lib/gpr/sync_abseil.cc
+++ b/contrib/libs/grpc/src/core/lib/gpr/sync_abseil.cc
@@ -1,116 +1,116 @@
-/*
- *
- * Copyright 2020 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <grpc/support/port_platform.h>
-
-#if defined(GPR_ABSEIL_SYNC) && !defined(GPR_CUSTOM_SYNC)
-
-#include <grpc/support/alloc.h>
-
-#include <errno.h>
-#include <grpc/support/log.h>
-#include <grpc/support/sync.h>
-#include <grpc/support/time.h>
-#include <time.h>
-#include "src/core/lib/profiling/timers.h"
-
-#include "y_absl/base/call_once.h"
-#include "y_absl/synchronization/mutex.h"
-#include "y_absl/time/clock.h"
-#include "y_absl/time/time.h"
-
-#ifdef GPR_LOW_LEVEL_COUNTERS
-gpr_atm gpr_mu_locks = 0;
-gpr_atm gpr_counter_atm_cas = 0;
-gpr_atm gpr_counter_atm_add = 0;
-#endif
-
-void gpr_mu_init(gpr_mu* mu) {
- static_assert(sizeof(gpr_mu) == sizeof(y_absl::Mutex),
- "gpr_mu and Mutex must be the same size");
- new (mu) y_absl::Mutex;
-}
-
-void gpr_mu_destroy(gpr_mu* mu) {
- reinterpret_cast<y_absl::Mutex*>(mu)->~Mutex();
-}
-
-void gpr_mu_lock(gpr_mu* mu) ABSL_NO_THREAD_SAFETY_ANALYSIS {
- GPR_TIMER_SCOPE("gpr_mu_lock", 0);
- reinterpret_cast<y_absl::Mutex*>(mu)->Lock();
-}
-
-void gpr_mu_unlock(gpr_mu* mu) ABSL_NO_THREAD_SAFETY_ANALYSIS {
- GPR_TIMER_SCOPE("gpr_mu_unlock", 0);
- reinterpret_cast<y_absl::Mutex*>(mu)->Unlock();
-}
-
-int gpr_mu_trylock(gpr_mu* mu) {
- GPR_TIMER_SCOPE("gpr_mu_trylock", 0);
- int ret = reinterpret_cast<y_absl::Mutex*>(mu)->TryLock() == true;
- return ret;
-}
-
-/*----------------------------------------*/
-
-void gpr_cv_init(gpr_cv* cv) {
- static_assert(sizeof(gpr_cv) == sizeof(y_absl::CondVar),
- "gpr_cv and CondVar must be the same size");
- new (cv) y_absl::CondVar;
-}
-
-void gpr_cv_destroy(gpr_cv* cv) {
- reinterpret_cast<y_absl::CondVar*>(cv)->~CondVar();
-}
-
-int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu, gpr_timespec abs_deadline) {
- GPR_TIMER_SCOPE("gpr_cv_wait", 0);
- if (gpr_time_cmp(abs_deadline, gpr_inf_future(abs_deadline.clock_type)) ==
- 0) {
- reinterpret_cast<y_absl::CondVar*>(cv)->Wait(
- reinterpret_cast<y_absl::Mutex*>(mu));
- return 0;
- }
- abs_deadline = gpr_convert_clock_type(abs_deadline, GPR_CLOCK_REALTIME);
- timespec ts = {static_cast<decltype(ts.tv_sec)>(abs_deadline.tv_sec),
- static_cast<decltype(ts.tv_nsec)>(abs_deadline.tv_nsec)};
- int ret = reinterpret_cast<y_absl::CondVar*>(cv)->WaitWithDeadline(
- reinterpret_cast<y_absl::Mutex*>(mu),
- y_absl::TimeFromTimespec(ts)) == true;
- return ret;
-}
-
-void gpr_cv_signal(gpr_cv* cv) {
- GPR_TIMER_MARK("gpr_cv_signal", 0);
- reinterpret_cast<y_absl::CondVar*>(cv)->Signal();
-}
-
-void gpr_cv_broadcast(gpr_cv* cv) {
- GPR_TIMER_MARK("gpr_cv_broadcast", 0);
- reinterpret_cast<y_absl::CondVar*>(cv)->SignalAll();
-}
-
-/*----------------------------------------*/
-
-void gpr_once_init(gpr_once* once, void (*init_function)(void)) {
- static_assert(sizeof(gpr_once) == sizeof(y_absl::once_flag),
- "gpr_once and y_absl::once_flag must be the same size");
- y_absl::call_once(*reinterpret_cast<y_absl::once_flag*>(once), init_function);
-}
-
-#endif /* defined(GPR_ABSEIL_SYNC) && !defined(GPR_CUSTOM_SYNC) */
+/*
+ *
+ * Copyright 2020 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <grpc/support/port_platform.h>
+
+#if defined(GPR_ABSEIL_SYNC) && !defined(GPR_CUSTOM_SYNC)
+
+#include <grpc/support/alloc.h>
+
+#include <errno.h>
+#include <grpc/support/log.h>
+#include <grpc/support/sync.h>
+#include <grpc/support/time.h>
+#include <time.h>
+#include "src/core/lib/profiling/timers.h"
+
+#include "y_absl/base/call_once.h"
+#include "y_absl/synchronization/mutex.h"
+#include "y_absl/time/clock.h"
+#include "y_absl/time/time.h"
+
+#ifdef GPR_LOW_LEVEL_COUNTERS
+gpr_atm gpr_mu_locks = 0;
+gpr_atm gpr_counter_atm_cas = 0;
+gpr_atm gpr_counter_atm_add = 0;
+#endif
+
+void gpr_mu_init(gpr_mu* mu) {
+ static_assert(sizeof(gpr_mu) == sizeof(y_absl::Mutex),
+ "gpr_mu and Mutex must be the same size");
+ new (mu) y_absl::Mutex;
+}
+
+void gpr_mu_destroy(gpr_mu* mu) {
+ reinterpret_cast<y_absl::Mutex*>(mu)->~Mutex();
+}
+
+void gpr_mu_lock(gpr_mu* mu) ABSL_NO_THREAD_SAFETY_ANALYSIS {
+ GPR_TIMER_SCOPE("gpr_mu_lock", 0);
+ reinterpret_cast<y_absl::Mutex*>(mu)->Lock();
+}
+
+void gpr_mu_unlock(gpr_mu* mu) ABSL_NO_THREAD_SAFETY_ANALYSIS {
+ GPR_TIMER_SCOPE("gpr_mu_unlock", 0);
+ reinterpret_cast<y_absl::Mutex*>(mu)->Unlock();
+}
+
+int gpr_mu_trylock(gpr_mu* mu) {
+ GPR_TIMER_SCOPE("gpr_mu_trylock", 0);
+ int ret = reinterpret_cast<y_absl::Mutex*>(mu)->TryLock() == true;
+ return ret;
+}
+
+/*----------------------------------------*/
+
+void gpr_cv_init(gpr_cv* cv) {
+ static_assert(sizeof(gpr_cv) == sizeof(y_absl::CondVar),
+ "gpr_cv and CondVar must be the same size");
+ new (cv) y_absl::CondVar;
+}
+
+void gpr_cv_destroy(gpr_cv* cv) {
+ reinterpret_cast<y_absl::CondVar*>(cv)->~CondVar();
+}
+
+int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu, gpr_timespec abs_deadline) {
+ GPR_TIMER_SCOPE("gpr_cv_wait", 0);
+ if (gpr_time_cmp(abs_deadline, gpr_inf_future(abs_deadline.clock_type)) ==
+ 0) {
+ reinterpret_cast<y_absl::CondVar*>(cv)->Wait(
+ reinterpret_cast<y_absl::Mutex*>(mu));
+ return 0;
+ }
+ abs_deadline = gpr_convert_clock_type(abs_deadline, GPR_CLOCK_REALTIME);
+ timespec ts = {static_cast<decltype(ts.tv_sec)>(abs_deadline.tv_sec),
+ static_cast<decltype(ts.tv_nsec)>(abs_deadline.tv_nsec)};
+ int ret = reinterpret_cast<y_absl::CondVar*>(cv)->WaitWithDeadline(
+ reinterpret_cast<y_absl::Mutex*>(mu),
+ y_absl::TimeFromTimespec(ts)) == true;
+ return ret;
+}
+
+void gpr_cv_signal(gpr_cv* cv) {
+ GPR_TIMER_MARK("gpr_cv_signal", 0);
+ reinterpret_cast<y_absl::CondVar*>(cv)->Signal();
+}
+
+void gpr_cv_broadcast(gpr_cv* cv) {
+ GPR_TIMER_MARK("gpr_cv_broadcast", 0);
+ reinterpret_cast<y_absl::CondVar*>(cv)->SignalAll();
+}
+
+/*----------------------------------------*/
+
+void gpr_once_init(gpr_once* once, void (*init_function)(void)) {
+ static_assert(sizeof(gpr_once) == sizeof(y_absl::once_flag),
+ "gpr_once and y_absl::once_flag must be the same size");
+ y_absl::call_once(*reinterpret_cast<y_absl::once_flag*>(once), init_function);
+}
+
+#endif /* defined(GPR_ABSEIL_SYNC) && !defined(GPR_CUSTOM_SYNC) */
diff --git a/contrib/libs/grpc/src/core/lib/gpr/sync_posix.cc b/contrib/libs/grpc/src/core/lib/gpr/sync_posix.cc
index faa0925d5e..fdd278be23 100644
--- a/contrib/libs/grpc/src/core/lib/gpr/sync_posix.cc
+++ b/contrib/libs/grpc/src/core/lib/gpr/sync_posix.cc
@@ -18,17 +18,17 @@
#include <grpc/support/port_platform.h>
-#if defined(GPR_POSIX_SYNC) && !defined(GPR_ABSEIL_SYNC) && \
- !defined(GPR_CUSTOM_SYNC)
-
+#if defined(GPR_POSIX_SYNC) && !defined(GPR_ABSEIL_SYNC) && \
+ !defined(GPR_CUSTOM_SYNC)
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
-
-#include <errno.h>
+
+#include <errno.h>
#include <time.h>
-
+
#include "src/core/lib/profiling/timers.h"
#ifdef GPR_LOW_LEVEL_COUNTERS
@@ -128,9 +128,9 @@ int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu, gpr_timespec abs_deadline) {
} else {
struct timespec abs_deadline_ts;
#if GPR_LINUX
- abs_deadline = gpr_convert_clock_type(abs_deadline, GPR_CLOCK_MONOTONIC);
+ abs_deadline = gpr_convert_clock_type(abs_deadline, GPR_CLOCK_MONOTONIC);
#else
- abs_deadline = gpr_convert_clock_type(abs_deadline, GPR_CLOCK_REALTIME);
+ abs_deadline = gpr_convert_clock_type(abs_deadline, GPR_CLOCK_REALTIME);
#endif // GPR_LINUX
abs_deadline_ts.tv_sec = static_cast<time_t>(abs_deadline.tv_sec);
abs_deadline_ts.tv_nsec = abs_deadline.tv_nsec;
@@ -166,5 +166,5 @@ void gpr_once_init(gpr_once* once, void (*init_function)(void)) {
GPR_ASSERT(pthread_once(once, init_function) == 0);
}
-#endif /* defined(GPR_POSIX_SYNC) && !defined(GPR_ABSEIL_SYNC) && \
- !defined(GPR_CUSTOM_SYNC) */
+#endif /* defined(GPR_POSIX_SYNC) && !defined(GPR_ABSEIL_SYNC) && \
+ !defined(GPR_CUSTOM_SYNC) */
diff --git a/contrib/libs/grpc/src/core/lib/gpr/sync_windows.cc b/contrib/libs/grpc/src/core/lib/gpr/sync_windows.cc
index 1ffe06b095..64eec7c2e1 100644
--- a/contrib/libs/grpc/src/core/lib/gpr/sync_windows.cc
+++ b/contrib/libs/grpc/src/core/lib/gpr/sync_windows.cc
@@ -20,8 +20,8 @@
#include <grpc/support/port_platform.h>
-#if defined(GPR_WINDOWS) && !defined(GPR_ABSEIL_SYNC) && \
- !defined(GPR_CUSTOM_SYNC)
+#if defined(GPR_WINDOWS) && !defined(GPR_ABSEIL_SYNC) && \
+ !defined(GPR_CUSTOM_SYNC)
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
@@ -116,5 +116,5 @@ void gpr_once_init(gpr_once* once, void (*init_function)(void)) {
InitOnceExecuteOnce(once, run_once_func, &arg, &dummy);
}
-#endif /* defined(GPR_WINDOWS) && !defined(GPR_ABSEIL_SYNC) && \
- !defined(GPR_CUSTOM_SYNC) */
+#endif /* defined(GPR_WINDOWS) && !defined(GPR_ABSEIL_SYNC) && \
+ !defined(GPR_CUSTOM_SYNC) */
diff --git a/contrib/libs/grpc/src/core/lib/gpr/time.cc b/contrib/libs/grpc/src/core/lib/gpr/time.cc
index 2c96c5b2ba..db5a7f64f7 100644
--- a/contrib/libs/grpc/src/core/lib/gpr/time.cc
+++ b/contrib/libs/grpc/src/core/lib/gpr/time.cc
@@ -254,10 +254,10 @@ gpr_timespec gpr_convert_clock_type(gpr_timespec t, gpr_clock_type clock_type) {
return gpr_time_add(gpr_now(clock_type), t);
}
- // If the given input hits this code, the same result is not guaranteed for
- // the same input because it relies on `gpr_now` to calculate the difference
- // between two different clocks. Please be careful when you want to use this
- // function in unit tests. (e.g. https://github.com/grpc/grpc/pull/22655)
+ // If the given input hits this code, the same result is not guaranteed for
+ // the same input because it relies on `gpr_now` to calculate the difference
+ // between two different clocks. Please be careful when you want to use this
+ // function in unit tests. (e.g. https://github.com/grpc/grpc/pull/22655)
return gpr_time_add(gpr_now(clock_type),
gpr_time_sub(t, gpr_now(t.clock_type)));
}
diff --git a/contrib/libs/grpc/src/core/lib/gpr/time_posix.cc b/contrib/libs/grpc/src/core/lib/gpr/time_posix.cc
index 61f5e0f14d..0a9e1158b3 100644
--- a/contrib/libs/grpc/src/core/lib/gpr/time_posix.cc
+++ b/contrib/libs/grpc/src/core/lib/gpr/time_posix.cc
@@ -82,7 +82,7 @@ static gpr_timespec now_impl(gpr_clock_type clock_type) {
}
}
#else
-/* For some reason Apple's OSes haven't implemented clock_gettime. */
+/* For some reason Apple's OSes haven't implemented clock_gettime. */
#include <mach/mach.h>
#include <mach/mach_time.h>
diff --git a/contrib/libs/grpc/src/core/lib/gpr/time_precise.cc b/contrib/libs/grpc/src/core/lib/gpr/time_precise.cc
index 20f27d84ec..4d1b64b8b2 100644
--- a/contrib/libs/grpc/src/core/lib/gpr/time_precise.cc
+++ b/contrib/libs/grpc/src/core/lib/gpr/time_precise.cc
@@ -31,8 +31,8 @@
#include "src/core/lib/gpr/time_precise.h"
-#ifndef GPR_CYCLE_COUNTER_CUSTOM
-#if GPR_CYCLE_COUNTER_RDTSC_32 || GPR_CYCLE_COUNTER_RDTSC_64
+#ifndef GPR_CYCLE_COUNTER_CUSTOM
+#if GPR_CYCLE_COUNTER_RDTSC_32 || GPR_CYCLE_COUNTER_RDTSC_64
#if GPR_LINUX
static bool read_freq_from_kernel(double* freq) {
// Google production kernel export the frequency for us in kHz.
@@ -164,4 +164,4 @@ gpr_timespec gpr_cycle_counter_sub(gpr_cycle_counter a, gpr_cycle_counter b) {
gpr_cycle_counter_to_time(b));
}
#endif /* GPR_CYCLE_COUNTER_FALLBACK */
-#endif /* !GPR_CYCLE_COUNTER_CUSTOM */
+#endif /* !GPR_CYCLE_COUNTER_CUSTOM */
diff --git a/contrib/libs/grpc/src/core/lib/gpr/time_precise.h b/contrib/libs/grpc/src/core/lib/gpr/time_precise.h
index a68ce28477..1dcfa3b57e 100644
--- a/contrib/libs/grpc/src/core/lib/gpr/time_precise.h
+++ b/contrib/libs/grpc/src/core/lib/gpr/time_precise.h
@@ -31,11 +31,11 @@
// Using gpr_get_cycle_counter() is preferred to using ExecCtx::Get()->Now()
// whenever possible.
-#if GPR_CYCLE_COUNTER_CUSTOM
+#if GPR_CYCLE_COUNTER_CUSTOM
+typedef int64_t gpr_cycle_counter;
+gpr_cycle_counter gpr_get_cycle_counter();
+#elif GPR_CYCLE_COUNTER_RDTSC_32
typedef int64_t gpr_cycle_counter;
-gpr_cycle_counter gpr_get_cycle_counter();
-#elif GPR_CYCLE_COUNTER_RDTSC_32
-typedef int64_t gpr_cycle_counter;
inline gpr_cycle_counter gpr_get_cycle_counter() {
int64_t ret;
__asm__ volatile("rdtsc" : "=A"(ret));
@@ -57,8 +57,8 @@ gpr_cycle_counter gpr_get_cycle_counter();
#else
#error Must define exactly one of \
GPR_CYCLE_COUNTER_RDTSC_32, \
- GPR_CYCLE_COUNTER_RDTSC_64, \
- GPR_CYCLE_COUNTER_CUSTOM, or \
+ GPR_CYCLE_COUNTER_RDTSC_64, \
+ GPR_CYCLE_COUNTER_CUSTOM, or \
GPR_CYCLE_COUNTER_FALLBACK
#endif
diff --git a/contrib/libs/grpc/src/core/lib/gprpp/debug_location.h b/contrib/libs/grpc/src/core/lib/gprpp/debug_location.h
index 6b92b4e89a..a96e06e235 100644
--- a/contrib/libs/grpc/src/core/lib/gprpp/debug_location.h
+++ b/contrib/libs/grpc/src/core/lib/gprpp/debug_location.h
@@ -26,7 +26,7 @@ namespace grpc_core {
// Callers can use the DEBUG_LOCATION macro in either case.
#ifndef NDEBUG
// TODO(roth): See if there's a way to automatically populate this,
-// similarly to how y_absl::SourceLocation::current() works, so that
+// similarly to how y_absl::SourceLocation::current() works, so that
// callers don't need to explicitly pass DEBUG_LOCATION anywhere.
class DebugLocation {
public:
diff --git a/contrib/libs/grpc/src/core/lib/gprpp/dual_ref_counted.h b/contrib/libs/grpc/src/core/lib/gprpp/dual_ref_counted.h
index fef7da530d..66935bbdea 100644
--- a/contrib/libs/grpc/src/core/lib/gprpp/dual_ref_counted.h
+++ b/contrib/libs/grpc/src/core/lib/gprpp/dual_ref_counted.h
@@ -1,336 +1,336 @@
-//
-// Copyright 2020 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-#ifndef GRPC_CORE_LIB_GPRPP_DUAL_REF_COUNTED_H
-#define GRPC_CORE_LIB_GPRPP_DUAL_REF_COUNTED_H
-
-#include <grpc/support/port_platform.h>
-
-#include <grpc/support/atm.h>
-#include <grpc/support/log.h>
-#include <grpc/support/sync.h>
-
-#include <atomic>
-#include <cassert>
-#include <cinttypes>
-
-#include "src/core/lib/debug/trace.h"
-#include "src/core/lib/gprpp/atomic.h"
-#include "src/core/lib/gprpp/debug_location.h"
-#include "src/core/lib/gprpp/orphanable.h"
-#include "src/core/lib/gprpp/ref_counted_ptr.h"
-
-namespace grpc_core {
-
-// DualRefCounted is an interface for reference-counted objects with two
-// classes of refs: strong refs (usually just called "refs") and weak refs.
-// This supports cases where an object needs to start shutting down when
-// all external callers are done with it (represented by strong refs) but
-// cannot be destroyed until all internal callbacks are complete
-// (represented by weak refs).
-//
-// Each class of refs can be incremented and decremented independently.
-// Objects start with 1 strong ref and 0 weak refs at instantiation.
-// When the strong refcount reaches 0, the object's Orphan() method is called.
-// When the weak refcount reaches 0, the object is destroyed.
-//
-// This will be used by CRTP (curiously-recurring template pattern), e.g.:
-// class MyClass : public RefCounted<MyClass> { ... };
-template <typename Child>
-class DualRefCounted : public Orphanable {
- public:
- virtual ~DualRefCounted() = default;
-
- RefCountedPtr<Child> Ref() GRPC_MUST_USE_RESULT {
- IncrementRefCount();
- return RefCountedPtr<Child>(static_cast<Child*>(this));
- }
-
- RefCountedPtr<Child> Ref(const DebugLocation& location,
- const char* reason) GRPC_MUST_USE_RESULT {
- IncrementRefCount(location, reason);
- return RefCountedPtr<Child>(static_cast<Child*>(this));
- }
-
- void Unref() {
- // Convert strong ref to weak ref.
- const uint64_t prev_ref_pair =
- refs_.FetchAdd(MakeRefPair(-1, 1), MemoryOrder::ACQ_REL);
- const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
-#ifndef NDEBUG
- const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
- if (trace_flag_ != nullptr && trace_flag_->enabled()) {
- gpr_log(GPR_INFO, "%s:%p unref %d -> %d, weak_ref %d -> %d",
- trace_flag_->name(), this, strong_refs, strong_refs - 1,
- weak_refs, weak_refs + 1);
- }
- GPR_ASSERT(strong_refs > 0);
-#endif
- if (GPR_UNLIKELY(strong_refs == 1)) {
- Orphan();
- }
- // Now drop the weak ref.
- WeakUnref();
- }
- void Unref(const DebugLocation& location, const char* reason) {
- const uint64_t prev_ref_pair =
- refs_.FetchAdd(MakeRefPair(-1, 1), MemoryOrder::ACQ_REL);
- const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
-#ifndef NDEBUG
- const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
- if (trace_flag_ != nullptr && trace_flag_->enabled()) {
- gpr_log(GPR_INFO, "%s:%p %s:%d unref %d -> %d, weak_ref %d -> %d) %s",
- trace_flag_->name(), this, location.file(), location.line(),
- strong_refs, strong_refs - 1, weak_refs, weak_refs + 1, reason);
- }
- GPR_ASSERT(strong_refs > 0);
-#else
- // Avoid unused-parameter warnings for debug-only parameters
- (void)location;
- (void)reason;
-#endif
- if (GPR_UNLIKELY(strong_refs == 1)) {
- Orphan();
- }
- // Now drop the weak ref.
- WeakUnref(location, reason);
- }
-
- RefCountedPtr<Child> RefIfNonZero() GRPC_MUST_USE_RESULT {
- uint64_t prev_ref_pair = refs_.Load(MemoryOrder::ACQUIRE);
- do {
- const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
-#ifndef NDEBUG
- const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
- if (trace_flag_ != nullptr && trace_flag_->enabled()) {
- gpr_log(GPR_INFO, "%s:%p ref_if_non_zero %d -> %d (weak_refs=%d)",
- trace_flag_->name(), this, strong_refs, strong_refs + 1,
- weak_refs);
- }
-#endif
- if (strong_refs == 0) return nullptr;
- } while (!refs_.CompareExchangeWeak(
- &prev_ref_pair, prev_ref_pair + MakeRefPair(1, 0), MemoryOrder::ACQ_REL,
- MemoryOrder::ACQUIRE));
- return RefCountedPtr<Child>(static_cast<Child*>(this));
- }
-
- RefCountedPtr<Child> RefIfNonZero(const DebugLocation& location,
- const char* reason) GRPC_MUST_USE_RESULT {
- uint64_t prev_ref_pair = refs_.Load(MemoryOrder::ACQUIRE);
- do {
- const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
-#ifndef NDEBUG
- const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
- if (trace_flag_ != nullptr && trace_flag_->enabled()) {
- gpr_log(GPR_INFO,
- "%s:%p %s:%d ref_if_non_zero %d -> %d (weak_refs=%d) %s",
- trace_flag_->name(), this, location.file(), location.line(),
- strong_refs, strong_refs + 1, weak_refs, reason);
- }
-#else
- // Avoid unused-parameter warnings for debug-only parameters
- (void)location;
- (void)reason;
-#endif
- if (strong_refs == 0) return nullptr;
- } while (!refs_.CompareExchangeWeak(
- &prev_ref_pair, prev_ref_pair + MakeRefPair(1, 0), MemoryOrder::ACQ_REL,
- MemoryOrder::ACQUIRE));
- return RefCountedPtr<Child>(static_cast<Child*>(this));
- }
-
- WeakRefCountedPtr<Child> WeakRef() GRPC_MUST_USE_RESULT {
- IncrementWeakRefCount();
- return WeakRefCountedPtr<Child>(static_cast<Child*>(this));
- }
-
- WeakRefCountedPtr<Child> WeakRef(const DebugLocation& location,
- const char* reason) GRPC_MUST_USE_RESULT {
- IncrementWeakRefCount(location, reason);
- return WeakRefCountedPtr<Child>(static_cast<Child*>(this));
- }
-
- void WeakUnref() {
-#ifndef NDEBUG
- // Grab a copy of the trace flag before the atomic change, since we
- // can't safely access it afterwards if we're going to be freed.
- auto* trace_flag = trace_flag_;
-#endif
- const uint64_t prev_ref_pair =
- refs_.FetchSub(MakeRefPair(0, 1), MemoryOrder::ACQ_REL);
- const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
-#ifndef NDEBUG
- const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
- if (trace_flag != nullptr && trace_flag->enabled()) {
- gpr_log(GPR_INFO, "%s:%p weak_unref %d -> %d (refs=%d)",
- trace_flag->name(), this, weak_refs, weak_refs - 1, strong_refs);
- }
- GPR_ASSERT(weak_refs > 0);
-#endif
- if (GPR_UNLIKELY(prev_ref_pair == MakeRefPair(0, 1))) {
- delete static_cast<Child*>(this);
- }
- }
- void WeakUnref(const DebugLocation& location, const char* reason) {
-#ifndef NDEBUG
- // Grab a copy of the trace flag before the atomic change, since we
- // can't safely access it afterwards if we're going to be freed.
- auto* trace_flag = trace_flag_;
-#endif
- const uint64_t prev_ref_pair =
- refs_.FetchSub(MakeRefPair(0, 1), MemoryOrder::ACQ_REL);
- const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
-#ifndef NDEBUG
- const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
- if (trace_flag != nullptr && trace_flag->enabled()) {
- gpr_log(GPR_INFO, "%s:%p %s:%d weak_unref %d -> %d (refs=%d) %s",
- trace_flag->name(), this, location.file(), location.line(),
- weak_refs, weak_refs - 1, strong_refs, reason);
- }
- GPR_ASSERT(weak_refs > 0);
-#else
- // Avoid unused-parameter warnings for debug-only parameters
- (void)location;
- (void)reason;
-#endif
- if (GPR_UNLIKELY(prev_ref_pair == MakeRefPair(0, 1))) {
- delete static_cast<Child*>(this);
- }
- }
-
- // Not copyable nor movable.
- DualRefCounted(const DualRefCounted&) = delete;
- DualRefCounted& operator=(const DualRefCounted&) = delete;
-
- protected:
- // TraceFlagT is defined to accept both DebugOnlyTraceFlag and TraceFlag.
- // Note: RefCount tracing is only enabled on debug builds, even when a
- // TraceFlag is used.
- template <typename TraceFlagT = TraceFlag>
- explicit DualRefCounted(
- TraceFlagT*
-#ifndef NDEBUG
- // Leave unnamed if NDEBUG to avoid unused parameter warning
- trace_flag
-#endif
- = nullptr,
- int32_t initial_refcount = 1)
- :
-#ifndef NDEBUG
- trace_flag_(trace_flag),
-#endif
- refs_(MakeRefPair(initial_refcount, 0)) {
- }
-
- private:
- // Allow RefCountedPtr<> to access IncrementRefCount().
- template <typename T>
- friend class RefCountedPtr;
- // Allow WeakRefCountedPtr<> to access IncrementWeakRefCount().
- template <typename T>
- friend class WeakRefCountedPtr;
-
- // First 32 bits are strong refs, next 32 bits are weak refs.
- static uint64_t MakeRefPair(uint32_t strong, uint32_t weak) {
- return (static_cast<uint64_t>(strong) << 32) + static_cast<int64_t>(weak);
- }
- static uint32_t GetStrongRefs(uint64_t ref_pair) {
- return static_cast<uint32_t>(ref_pair >> 32);
- }
- static uint32_t GetWeakRefs(uint64_t ref_pair) {
- return static_cast<uint32_t>(ref_pair & 0xffffffffu);
- }
-
- void IncrementRefCount() {
-#ifndef NDEBUG
- const uint64_t prev_ref_pair =
- refs_.FetchAdd(MakeRefPair(1, 0), MemoryOrder::RELAXED);
- const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
- const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
- GPR_ASSERT(strong_refs != 0);
- if (trace_flag_ != nullptr && trace_flag_->enabled()) {
- gpr_log(GPR_INFO, "%s:%p ref %d -> %d; (weak_refs=%d)",
- trace_flag_->name(), this, strong_refs, strong_refs + 1,
- weak_refs);
- }
-#else
- refs_.FetchAdd(MakeRefPair(1, 0), MemoryOrder::RELAXED);
-#endif
- }
- void IncrementRefCount(const DebugLocation& location, const char* reason) {
-#ifndef NDEBUG
- const uint64_t prev_ref_pair =
- refs_.FetchAdd(MakeRefPair(1, 0), MemoryOrder::RELAXED);
- const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
- const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
- GPR_ASSERT(strong_refs != 0);
- if (trace_flag_ != nullptr && trace_flag_->enabled()) {
- gpr_log(GPR_INFO, "%s:%p %s:%d ref %d -> %d (weak_refs=%d) %s",
- trace_flag_->name(), this, location.file(), location.line(),
- strong_refs, strong_refs + 1, weak_refs, reason);
- }
-#else
- // Use conditionally-important parameters
- (void)location;
- (void)reason;
- refs_.FetchAdd(MakeRefPair(1, 0), MemoryOrder::RELAXED);
-#endif
- }
-
- void IncrementWeakRefCount() {
-#ifndef NDEBUG
- const uint64_t prev_ref_pair =
- refs_.FetchAdd(MakeRefPair(0, 1), MemoryOrder::RELAXED);
- const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
- const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
- if (trace_flag_ != nullptr && trace_flag_->enabled()) {
- gpr_log(GPR_INFO, "%s:%p weak_ref %d -> %d; (refs=%d)",
- trace_flag_->name(), this, weak_refs, weak_refs + 1, strong_refs);
- }
-#else
- refs_.FetchAdd(MakeRefPair(0, 1), MemoryOrder::RELAXED);
-#endif
- }
- void IncrementWeakRefCount(const DebugLocation& location,
- const char* reason) {
-#ifndef NDEBUG
- const uint64_t prev_ref_pair =
- refs_.FetchAdd(MakeRefPair(0, 1), MemoryOrder::RELAXED);
- const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
- const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
- if (trace_flag_ != nullptr && trace_flag_->enabled()) {
- gpr_log(GPR_INFO, "%s:%p %s:%d weak_ref %d -> %d (refs=%d) %s",
- trace_flag_->name(), this, location.file(), location.line(),
- weak_refs, weak_refs + 1, strong_refs, reason);
- }
-#else
- // Use conditionally-important parameters
- (void)location;
- (void)reason;
- refs_.FetchAdd(MakeRefPair(0, 1), MemoryOrder::RELAXED);
-#endif
- }
-
-#ifndef NDEBUG
- TraceFlag* trace_flag_;
-#endif
- Atomic<uint64_t> refs_;
-};
-
-} // namespace grpc_core
-
-#endif /* GRPC_CORE_LIB_GPRPP_DUAL_REF_COUNTED_H */
+//
+// Copyright 2020 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef GRPC_CORE_LIB_GPRPP_DUAL_REF_COUNTED_H
+#define GRPC_CORE_LIB_GPRPP_DUAL_REF_COUNTED_H
+
+#include <grpc/support/port_platform.h>
+
+#include <grpc/support/atm.h>
+#include <grpc/support/log.h>
+#include <grpc/support/sync.h>
+
+#include <atomic>
+#include <cassert>
+#include <cinttypes>
+
+#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/gprpp/atomic.h"
+#include "src/core/lib/gprpp/debug_location.h"
+#include "src/core/lib/gprpp/orphanable.h"
+#include "src/core/lib/gprpp/ref_counted_ptr.h"
+
+namespace grpc_core {
+
+// DualRefCounted is an interface for reference-counted objects with two
+// classes of refs: strong refs (usually just called "refs") and weak refs.
+// This supports cases where an object needs to start shutting down when
+// all external callers are done with it (represented by strong refs) but
+// cannot be destroyed until all internal callbacks are complete
+// (represented by weak refs).
+//
+// Each class of refs can be incremented and decremented independently.
+// Objects start with 1 strong ref and 0 weak refs at instantiation.
+// When the strong refcount reaches 0, the object's Orphan() method is called.
+// When the weak refcount reaches 0, the object is destroyed.
+//
+// This will be used by CRTP (curiously-recurring template pattern), e.g.:
+// class MyClass : public RefCounted<MyClass> { ... };
+template <typename Child>
+class DualRefCounted : public Orphanable {
+ public:
+ virtual ~DualRefCounted() = default;
+
+ RefCountedPtr<Child> Ref() GRPC_MUST_USE_RESULT {
+ IncrementRefCount();
+ return RefCountedPtr<Child>(static_cast<Child*>(this));
+ }
+
+ RefCountedPtr<Child> Ref(const DebugLocation& location,
+ const char* reason) GRPC_MUST_USE_RESULT {
+ IncrementRefCount(location, reason);
+ return RefCountedPtr<Child>(static_cast<Child*>(this));
+ }
+
+ void Unref() {
+ // Convert strong ref to weak ref.
+ const uint64_t prev_ref_pair =
+ refs_.FetchAdd(MakeRefPair(-1, 1), MemoryOrder::ACQ_REL);
+ const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
+#ifndef NDEBUG
+ const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
+ if (trace_flag_ != nullptr && trace_flag_->enabled()) {
+ gpr_log(GPR_INFO, "%s:%p unref %d -> %d, weak_ref %d -> %d",
+ trace_flag_->name(), this, strong_refs, strong_refs - 1,
+ weak_refs, weak_refs + 1);
+ }
+ GPR_ASSERT(strong_refs > 0);
+#endif
+ if (GPR_UNLIKELY(strong_refs == 1)) {
+ Orphan();
+ }
+ // Now drop the weak ref.
+ WeakUnref();
+ }
+ void Unref(const DebugLocation& location, const char* reason) {
+ const uint64_t prev_ref_pair =
+ refs_.FetchAdd(MakeRefPair(-1, 1), MemoryOrder::ACQ_REL);
+ const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
+#ifndef NDEBUG
+ const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
+ if (trace_flag_ != nullptr && trace_flag_->enabled()) {
+ gpr_log(GPR_INFO, "%s:%p %s:%d unref %d -> %d, weak_ref %d -> %d) %s",
+ trace_flag_->name(), this, location.file(), location.line(),
+ strong_refs, strong_refs - 1, weak_refs, weak_refs + 1, reason);
+ }
+ GPR_ASSERT(strong_refs > 0);
+#else
+ // Avoid unused-parameter warnings for debug-only parameters
+ (void)location;
+ (void)reason;
+#endif
+ if (GPR_UNLIKELY(strong_refs == 1)) {
+ Orphan();
+ }
+ // Now drop the weak ref.
+ WeakUnref(location, reason);
+ }
+
+ RefCountedPtr<Child> RefIfNonZero() GRPC_MUST_USE_RESULT {
+ uint64_t prev_ref_pair = refs_.Load(MemoryOrder::ACQUIRE);
+ do {
+ const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
+#ifndef NDEBUG
+ const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
+ if (trace_flag_ != nullptr && trace_flag_->enabled()) {
+ gpr_log(GPR_INFO, "%s:%p ref_if_non_zero %d -> %d (weak_refs=%d)",
+ trace_flag_->name(), this, strong_refs, strong_refs + 1,
+ weak_refs);
+ }
+#endif
+ if (strong_refs == 0) return nullptr;
+ } while (!refs_.CompareExchangeWeak(
+ &prev_ref_pair, prev_ref_pair + MakeRefPair(1, 0), MemoryOrder::ACQ_REL,
+ MemoryOrder::ACQUIRE));
+ return RefCountedPtr<Child>(static_cast<Child*>(this));
+ }
+
+ RefCountedPtr<Child> RefIfNonZero(const DebugLocation& location,
+ const char* reason) GRPC_MUST_USE_RESULT {
+ uint64_t prev_ref_pair = refs_.Load(MemoryOrder::ACQUIRE);
+ do {
+ const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
+#ifndef NDEBUG
+ const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
+ if (trace_flag_ != nullptr && trace_flag_->enabled()) {
+ gpr_log(GPR_INFO,
+ "%s:%p %s:%d ref_if_non_zero %d -> %d (weak_refs=%d) %s",
+ trace_flag_->name(), this, location.file(), location.line(),
+ strong_refs, strong_refs + 1, weak_refs, reason);
+ }
+#else
+ // Avoid unused-parameter warnings for debug-only parameters
+ (void)location;
+ (void)reason;
+#endif
+ if (strong_refs == 0) return nullptr;
+ } while (!refs_.CompareExchangeWeak(
+ &prev_ref_pair, prev_ref_pair + MakeRefPair(1, 0), MemoryOrder::ACQ_REL,
+ MemoryOrder::ACQUIRE));
+ return RefCountedPtr<Child>(static_cast<Child*>(this));
+ }
+
+ WeakRefCountedPtr<Child> WeakRef() GRPC_MUST_USE_RESULT {
+ IncrementWeakRefCount();
+ return WeakRefCountedPtr<Child>(static_cast<Child*>(this));
+ }
+
+ WeakRefCountedPtr<Child> WeakRef(const DebugLocation& location,
+ const char* reason) GRPC_MUST_USE_RESULT {
+ IncrementWeakRefCount(location, reason);
+ return WeakRefCountedPtr<Child>(static_cast<Child*>(this));
+ }
+
+ void WeakUnref() {
+#ifndef NDEBUG
+ // Grab a copy of the trace flag before the atomic change, since we
+ // can't safely access it afterwards if we're going to be freed.
+ auto* trace_flag = trace_flag_;
+#endif
+ const uint64_t prev_ref_pair =
+ refs_.FetchSub(MakeRefPair(0, 1), MemoryOrder::ACQ_REL);
+ const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
+#ifndef NDEBUG
+ const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
+ if (trace_flag != nullptr && trace_flag->enabled()) {
+ gpr_log(GPR_INFO, "%s:%p weak_unref %d -> %d (refs=%d)",
+ trace_flag->name(), this, weak_refs, weak_refs - 1, strong_refs);
+ }
+ GPR_ASSERT(weak_refs > 0);
+#endif
+ if (GPR_UNLIKELY(prev_ref_pair == MakeRefPair(0, 1))) {
+ delete static_cast<Child*>(this);
+ }
+ }
+ void WeakUnref(const DebugLocation& location, const char* reason) {
+#ifndef NDEBUG
+ // Grab a copy of the trace flag before the atomic change, since we
+ // can't safely access it afterwards if we're going to be freed.
+ auto* trace_flag = trace_flag_;
+#endif
+ const uint64_t prev_ref_pair =
+ refs_.FetchSub(MakeRefPair(0, 1), MemoryOrder::ACQ_REL);
+ const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
+#ifndef NDEBUG
+ const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
+ if (trace_flag != nullptr && trace_flag->enabled()) {
+ gpr_log(GPR_INFO, "%s:%p %s:%d weak_unref %d -> %d (refs=%d) %s",
+ trace_flag->name(), this, location.file(), location.line(),
+ weak_refs, weak_refs - 1, strong_refs, reason);
+ }
+ GPR_ASSERT(weak_refs > 0);
+#else
+ // Avoid unused-parameter warnings for debug-only parameters
+ (void)location;
+ (void)reason;
+#endif
+ if (GPR_UNLIKELY(prev_ref_pair == MakeRefPair(0, 1))) {
+ delete static_cast<Child*>(this);
+ }
+ }
+
+ // Not copyable nor movable.
+ DualRefCounted(const DualRefCounted&) = delete;
+ DualRefCounted& operator=(const DualRefCounted&) = delete;
+
+ protected:
+ // TraceFlagT is defined to accept both DebugOnlyTraceFlag and TraceFlag.
+ // Note: RefCount tracing is only enabled on debug builds, even when a
+ // TraceFlag is used.
+ template <typename TraceFlagT = TraceFlag>
+ explicit DualRefCounted(
+ TraceFlagT*
+#ifndef NDEBUG
+ // Leave unnamed if NDEBUG to avoid unused parameter warning
+ trace_flag
+#endif
+ = nullptr,
+ int32_t initial_refcount = 1)
+ :
+#ifndef NDEBUG
+ trace_flag_(trace_flag),
+#endif
+ refs_(MakeRefPair(initial_refcount, 0)) {
+ }
+
+ private:
+ // Allow RefCountedPtr<> to access IncrementRefCount().
+ template <typename T>
+ friend class RefCountedPtr;
+ // Allow WeakRefCountedPtr<> to access IncrementWeakRefCount().
+ template <typename T>
+ friend class WeakRefCountedPtr;
+
+ // First 32 bits are strong refs, next 32 bits are weak refs.
+ static uint64_t MakeRefPair(uint32_t strong, uint32_t weak) {
+ return (static_cast<uint64_t>(strong) << 32) + static_cast<int64_t>(weak);
+ }
+ static uint32_t GetStrongRefs(uint64_t ref_pair) {
+ return static_cast<uint32_t>(ref_pair >> 32);
+ }
+ static uint32_t GetWeakRefs(uint64_t ref_pair) {
+ return static_cast<uint32_t>(ref_pair & 0xffffffffu);
+ }
+
+ void IncrementRefCount() {
+#ifndef NDEBUG
+ const uint64_t prev_ref_pair =
+ refs_.FetchAdd(MakeRefPair(1, 0), MemoryOrder::RELAXED);
+ const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
+ const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
+ GPR_ASSERT(strong_refs != 0);
+ if (trace_flag_ != nullptr && trace_flag_->enabled()) {
+ gpr_log(GPR_INFO, "%s:%p ref %d -> %d; (weak_refs=%d)",
+ trace_flag_->name(), this, strong_refs, strong_refs + 1,
+ weak_refs);
+ }
+#else
+ refs_.FetchAdd(MakeRefPair(1, 0), MemoryOrder::RELAXED);
+#endif
+ }
+ void IncrementRefCount(const DebugLocation& location, const char* reason) {
+#ifndef NDEBUG
+ const uint64_t prev_ref_pair =
+ refs_.FetchAdd(MakeRefPair(1, 0), MemoryOrder::RELAXED);
+ const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
+ const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
+ GPR_ASSERT(strong_refs != 0);
+ if (trace_flag_ != nullptr && trace_flag_->enabled()) {
+ gpr_log(GPR_INFO, "%s:%p %s:%d ref %d -> %d (weak_refs=%d) %s",
+ trace_flag_->name(), this, location.file(), location.line(),
+ strong_refs, strong_refs + 1, weak_refs, reason);
+ }
+#else
+ // Use conditionally-important parameters
+ (void)location;
+ (void)reason;
+ refs_.FetchAdd(MakeRefPair(1, 0), MemoryOrder::RELAXED);
+#endif
+ }
+
+ void IncrementWeakRefCount() {
+#ifndef NDEBUG
+ const uint64_t prev_ref_pair =
+ refs_.FetchAdd(MakeRefPair(0, 1), MemoryOrder::RELAXED);
+ const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
+ const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
+ if (trace_flag_ != nullptr && trace_flag_->enabled()) {
+ gpr_log(GPR_INFO, "%s:%p weak_ref %d -> %d; (refs=%d)",
+ trace_flag_->name(), this, weak_refs, weak_refs + 1, strong_refs);
+ }
+#else
+ refs_.FetchAdd(MakeRefPair(0, 1), MemoryOrder::RELAXED);
+#endif
+ }
+ void IncrementWeakRefCount(const DebugLocation& location,
+ const char* reason) {
+#ifndef NDEBUG
+ const uint64_t prev_ref_pair =
+ refs_.FetchAdd(MakeRefPair(0, 1), MemoryOrder::RELAXED);
+ const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
+ const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
+ if (trace_flag_ != nullptr && trace_flag_->enabled()) {
+ gpr_log(GPR_INFO, "%s:%p %s:%d weak_ref %d -> %d (refs=%d) %s",
+ trace_flag_->name(), this, location.file(), location.line(),
+ weak_refs, weak_refs + 1, strong_refs, reason);
+ }
+#else
+ // Use conditionally-important parameters
+ (void)location;
+ (void)reason;
+ refs_.FetchAdd(MakeRefPair(0, 1), MemoryOrder::RELAXED);
+#endif
+ }
+
+#ifndef NDEBUG
+ TraceFlag* trace_flag_;
+#endif
+ Atomic<uint64_t> refs_;
+};
+
+} // namespace grpc_core
+
+#endif /* GRPC_CORE_LIB_GPRPP_DUAL_REF_COUNTED_H */
diff --git a/contrib/libs/grpc/src/core/lib/gprpp/fork.cc b/contrib/libs/grpc/src/core/lib/gprpp/fork.cc
index cbee829806..51d1c80e67 100644
--- a/contrib/libs/grpc/src/core/lib/gprpp/fork.cc
+++ b/contrib/libs/grpc/src/core/lib/gprpp/fork.cc
@@ -164,7 +164,7 @@ class ThreadState {
int count_;
};
-} // namespace internal
+} // namespace internal
void Fork::GlobalInit() {
if (!override_enabled_) {
diff --git a/contrib/libs/grpc/src/core/lib/gprpp/global_config_env.cc b/contrib/libs/grpc/src/core/lib/gprpp/global_config_env.cc
index f8f27b7bd0..72e3760661 100644
--- a/contrib/libs/grpc/src/core/lib/gprpp/global_config_env.cc
+++ b/contrib/libs/grpc/src/core/lib/gprpp/global_config_env.cc
@@ -30,10 +30,10 @@
#include <ctype.h>
#include <string.h>
-#include <util/generic/string.h>
-
-#include "y_absl/strings/str_format.h"
-
+#include <util/generic/string.h>
+
+#include "y_absl/strings/str_format.h"
+
namespace grpc_core {
namespace {
@@ -46,10 +46,10 @@ GlobalConfigEnvErrorFunctionType g_global_config_env_error_func =
DefaultGlobalConfigEnvErrorFunction;
void LogParsingError(const char* name, const char* value) {
- TString error_message = y_absl::StrFormat(
- "Illegal value '%s' specified for environment variable '%s'", value,
- name);
- (*g_global_config_env_error_func)(error_message.c_str());
+ TString error_message = y_absl::StrFormat(
+ "Illegal value '%s' specified for environment variable '%s'", value,
+ name);
+ (*g_global_config_env_error_func)(error_message.c_str());
}
} // namespace
diff --git a/contrib/libs/grpc/src/core/lib/gprpp/host_port.cc b/contrib/libs/grpc/src/core/lib/gprpp/host_port.cc
index 9355a71abf..e9db87f938 100644
--- a/contrib/libs/grpc/src/core/lib/gprpp/host_port.cc
+++ b/contrib/libs/grpc/src/core/lib/gprpp/host_port.cc
@@ -20,36 +20,36 @@
#include "src/core/lib/gprpp/host_port.h"
-#include "y_absl/strings/str_format.h"
-#include "y_absl/strings/string_view.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/string_view.h"
#include <grpc/support/log.h>
-namespace grpc_core {
+namespace grpc_core {
-TString JoinHostPort(y_absl::string_view host, int port) {
- if (!host.empty() && host[0] != '[' && host.rfind(':') != host.npos) {
- // IPv6 literals must be enclosed in brackets.
- return y_absl::StrFormat("[%s]:%d", host, port);
+TString JoinHostPort(y_absl::string_view host, int port) {
+ if (!host.empty() && host[0] != '[' && host.rfind(':') != host.npos) {
+ // IPv6 literals must be enclosed in brackets.
+ return y_absl::StrFormat("[%s]:%d", host, port);
}
- // Ordinary non-bracketed host:port.
- return y_absl::StrFormat("%s:%d", host, port);
+ // Ordinary non-bracketed host:port.
+ return y_absl::StrFormat("%s:%d", host, port);
}
namespace {
-bool DoSplitHostPort(y_absl::string_view name, y_absl::string_view* host,
- y_absl::string_view* port, bool* has_port) {
+bool DoSplitHostPort(y_absl::string_view name, y_absl::string_view* host,
+ y_absl::string_view* port, bool* has_port) {
*has_port = false;
- if (!name.empty() && name[0] == '[') {
+ if (!name.empty() && name[0] == '[') {
/* Parse a bracketed host, typically an IPv6 literal. */
const size_t rbracket = name.find(']', 1);
- if (rbracket == y_absl::string_view::npos) {
+ if (rbracket == y_absl::string_view::npos) {
/* Unmatched [ */
return false;
}
if (rbracket == name.size() - 1) {
/* ]<end> */
- *port = y_absl::string_view();
+ *port = y_absl::string_view();
} else if (name[rbracket + 1] == ':') {
/* ]:<port?> */
*port = name.substr(rbracket + 2, name.size() - rbracket - 2);
@@ -59,16 +59,16 @@ bool DoSplitHostPort(y_absl::string_view name, y_absl::string_view* host,
return false;
}
*host = name.substr(1, rbracket - 1);
- if (host->find(':') == y_absl::string_view::npos) {
+ if (host->find(':') == y_absl::string_view::npos) {
/* Require all bracketed hosts to contain a colon, because a hostname or
IPv4 address should never use brackets. */
- *host = y_absl::string_view();
+ *host = y_absl::string_view();
return false;
}
} else {
size_t colon = name.find(':');
- if (colon != y_absl::string_view::npos &&
- name.find(':', colon + 1) == y_absl::string_view::npos) {
+ if (colon != y_absl::string_view::npos &&
+ name.find(':', colon + 1) == y_absl::string_view::npos) {
/* Exactly 1 colon. Split into host:port. */
*host = name.substr(0, colon);
*port = name.substr(colon + 1, name.size() - colon - 1);
@@ -76,37 +76,37 @@ bool DoSplitHostPort(y_absl::string_view name, y_absl::string_view* host,
} else {
/* 0 or 2+ colons. Bare hostname or IPv6 litearal. */
*host = name;
- *port = y_absl::string_view();
+ *port = y_absl::string_view();
}
}
return true;
}
} // namespace
-bool SplitHostPort(y_absl::string_view name, y_absl::string_view* host,
- y_absl::string_view* port) {
+bool SplitHostPort(y_absl::string_view name, y_absl::string_view* host,
+ y_absl::string_view* port) {
bool unused;
return DoSplitHostPort(name, host, port, &unused);
}
-bool SplitHostPort(y_absl::string_view name, TString* host,
- TString* port) {
- GPR_DEBUG_ASSERT(host != nullptr && host->empty());
- GPR_DEBUG_ASSERT(port != nullptr && port->empty());
- y_absl::string_view host_view;
- y_absl::string_view port_view;
+bool SplitHostPort(y_absl::string_view name, TString* host,
+ TString* port) {
+ GPR_DEBUG_ASSERT(host != nullptr && host->empty());
+ GPR_DEBUG_ASSERT(port != nullptr && port->empty());
+ y_absl::string_view host_view;
+ y_absl::string_view port_view;
bool has_port;
const bool ret = DoSplitHostPort(name, &host_view, &port_view, &has_port);
if (ret) {
// We always set the host, but port is set only when DoSplitHostPort find a
// port in the string, to remain backward compatible with the old
// gpr_split_host_port API.
- *host = TString(host_view);
+ *host = TString(host_view);
if (has_port) {
- *port = TString(port_view);
+ *port = TString(port_view);
}
}
return ret;
}
-
+
} // namespace grpc_core
diff --git a/contrib/libs/grpc/src/core/lib/gprpp/host_port.h b/contrib/libs/grpc/src/core/lib/gprpp/host_port.h
index 3f42cc7482..4591b85817 100644
--- a/contrib/libs/grpc/src/core/lib/gprpp/host_port.h
+++ b/contrib/libs/grpc/src/core/lib/gprpp/host_port.h
@@ -21,24 +21,24 @@
#include <grpc/support/port_platform.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
+
+#include "y_absl/strings/string_view.h"
-#include "y_absl/strings/string_view.h"
-
namespace grpc_core {
-// Given a host and port, creates a newly-allocated string of the form
-// "host:port" or "[ho:st]:port", depending on whether the host contains colons
-// like an IPv6 literal. If the host is already bracketed, then additional
-// brackets will not be added.
-TString JoinHostPort(y_absl::string_view host, int port);
+// Given a host and port, creates a newly-allocated string of the form
+// "host:port" or "[ho:st]:port", depending on whether the host contains colons
+// like an IPv6 literal. If the host is already bracketed, then additional
+// brackets will not be added.
+TString JoinHostPort(y_absl::string_view host, int port);
/** Given a name in the form "host:port" or "[ho:st]:port", split into hostname
and port number.
There are two variants of this method:
- 1) y_absl::string_view output: port and host are returned as views on name.
- 2) TString output: port and host are copied into newly allocated strings.
+ 1) y_absl::string_view output: port and host are returned as views on name.
+ 2) TString output: port and host are copied into newly allocated strings.
Prefer variant (1) over (2), because no allocation or copy is performed in
variant (1). Use (2) only when interacting with C API that mandate
@@ -46,10 +46,10 @@ TString JoinHostPort(y_absl::string_view host, int port);
Return true on success, false on failure. Guarantees *host and *port are
cleared on failure. */
-bool SplitHostPort(y_absl::string_view name, y_absl::string_view* host,
- y_absl::string_view* port);
-bool SplitHostPort(y_absl::string_view name, TString* host,
- TString* port);
+bool SplitHostPort(y_absl::string_view name, y_absl::string_view* host,
+ y_absl::string_view* port);
+bool SplitHostPort(y_absl::string_view name, TString* host,
+ TString* port);
} // namespace grpc_core
diff --git a/contrib/libs/grpc/src/core/lib/gprpp/map.h b/contrib/libs/grpc/src/core/lib/gprpp/map.h
index 08124843a3..741b0b1ed5 100644
--- a/contrib/libs/grpc/src/core/lib/gprpp/map.h
+++ b/contrib/libs/grpc/src/core/lib/gprpp/map.h
@@ -25,10 +25,10 @@
#include <map>
-#include "y_absl/strings/string_view.h"
+#include "y_absl/strings/string_view.h"
+
+#include "src/core/lib/gprpp/memory.h"
-#include "src/core/lib/gprpp/memory.h"
-
namespace grpc_core {
struct StringLess {
@@ -39,8 +39,8 @@ struct StringLess {
const grpc_core::UniquePtr<char>& b) const {
return strcmp(a.get(), b.get()) < 0;
}
- bool operator()(const y_absl::string_view& a,
- const y_absl::string_view& b) const {
+ bool operator()(const y_absl::string_view& a,
+ const y_absl::string_view& b) const {
const size_t min_size = std::min(a.size(), b.size());
int c = strncmp(a.data(), b.data(), min_size);
if (c != 0) return c < 0;
diff --git a/contrib/libs/grpc/src/core/lib/gprpp/memory.h b/contrib/libs/grpc/src/core/lib/gprpp/memory.h
index d16cbb9588..becf273510 100644
--- a/contrib/libs/grpc/src/core/lib/gprpp/memory.h
+++ b/contrib/libs/grpc/src/core/lib/gprpp/memory.h
@@ -28,8 +28,8 @@
#include <memory>
#include <utility>
-#include "y_absl/memory/memory.h"
-
+#include "y_absl/memory/memory.h"
+
namespace grpc_core {
class DefaultDeleteChar {
@@ -41,7 +41,7 @@ class DefaultDeleteChar {
};
// UniquePtr<T> is only allowed for char and UniquePtr<char> is deprecated
-// in favor of TString. UniquePtr<char> is equivalent std::unique_ptr
+// in favor of TString. UniquePtr<char> is equivalent std::unique_ptr
// except that it uses gpr_free for deleter.
template <typename T>
using UniquePtr = std::unique_ptr<T, DefaultDeleteChar>;
diff --git a/contrib/libs/grpc/src/core/lib/gprpp/ref_counted.h b/contrib/libs/grpc/src/core/lib/gprpp/ref_counted.h
index 10306648db..d05ff6e44c 100644
--- a/contrib/libs/grpc/src/core/lib/gprpp/ref_counted.h
+++ b/contrib/libs/grpc/src/core/lib/gprpp/ref_counted.h
@@ -204,46 +204,46 @@ class RefCount {
Atomic<Value> value_;
};
-// PolymorphicRefCount enforces polymorphic destruction of RefCounted.
-class PolymorphicRefCount {
- public:
- virtual ~PolymorphicRefCount() = default;
-};
-
-// NonPolymorphicRefCount does not enforce polymorphic destruction of
-// RefCounted. Please refer to grpc_core::RefCounted for more details, and
-// when in doubt use PolymorphicRefCount.
-class NonPolymorphicRefCount {
- public:
- ~NonPolymorphicRefCount() = default;
-};
-
-namespace internal {
-template <typename T, bool DoDelete>
-class Delete;
-template <typename T>
-class Delete<T, true> {
- public:
- Delete(T* t) { delete t; }
-};
-template <typename T>
-class Delete<T, false> {
- public:
- Delete(T* /*t*/) {}
-};
-} // namespace internal
-
+// PolymorphicRefCount enforces polymorphic destruction of RefCounted.
+class PolymorphicRefCount {
+ public:
+ virtual ~PolymorphicRefCount() = default;
+};
+
+// NonPolymorphicRefCount does not enforce polymorphic destruction of
+// RefCounted. Please refer to grpc_core::RefCounted for more details, and
+// when in doubt use PolymorphicRefCount.
+class NonPolymorphicRefCount {
+ public:
+ ~NonPolymorphicRefCount() = default;
+};
+
+namespace internal {
+template <typename T, bool DoDelete>
+class Delete;
+template <typename T>
+class Delete<T, true> {
+ public:
+ Delete(T* t) { delete t; }
+};
+template <typename T>
+class Delete<T, false> {
+ public:
+ Delete(T* /*t*/) {}
+};
+} // namespace internal
+
// A base class for reference-counted objects.
-// New objects should be created via new and start with a refcount of 1.
-// When the refcount reaches 0, the object will be deleted via delete.
+// New objects should be created via new and start with a refcount of 1.
+// When the refcount reaches 0, the object will be deleted via delete.
+//
+// If DeleteUponUnref is false, deletion will not occur when the ref
+// count reaches 0. This is useful in cases where all existing objects
+// must be tracked in a registry but the object's entry in the registry
+// cannot be removed from the object's dtor due to synchronization issues.
+// In this case, the registry can be cleaned up later by identifying
+// entries for which RefIfNonZero() returns null.
//
-// If DeleteUponUnref is false, deletion will not occur when the ref
-// count reaches 0. This is useful in cases where all existing objects
-// must be tracked in a registry but the object's entry in the registry
-// cannot be removed from the object's dtor due to synchronization issues.
-// In this case, the registry can be cleaned up later by identifying
-// entries for which RefIfNonZero() returns null.
-//
// This will commonly be used by CRTP (curiously-recurring template pattern)
// e.g., class MyClass : public RefCounted<MyClass>
//
@@ -266,8 +266,8 @@ class Delete<T, false> {
// Child* ch;
// ch->Unref();
//
-template <typename Child, typename Impl = PolymorphicRefCount,
- bool DeleteUponUnref = true>
+template <typename Child, typename Impl = PolymorphicRefCount,
+ bool DeleteUponUnref = true>
class RefCounted : public Impl {
public:
// Note: Depending on the Impl used, this dtor can be implicitly virtual.
@@ -290,25 +290,25 @@ class RefCounted : public Impl {
// friend of this class.
void Unref() {
if (GPR_UNLIKELY(refs_.Unref())) {
- internal::Delete<Child, DeleteUponUnref>(static_cast<Child*>(this));
+ internal::Delete<Child, DeleteUponUnref>(static_cast<Child*>(this));
}
}
void Unref(const DebugLocation& location, const char* reason) {
if (GPR_UNLIKELY(refs_.Unref(location, reason))) {
- internal::Delete<Child, DeleteUponUnref>(static_cast<Child*>(this));
+ internal::Delete<Child, DeleteUponUnref>(static_cast<Child*>(this));
}
}
- RefCountedPtr<Child> RefIfNonZero() GRPC_MUST_USE_RESULT {
- return RefCountedPtr<Child>(refs_.RefIfNonZero() ? static_cast<Child*>(this)
- : nullptr);
+ RefCountedPtr<Child> RefIfNonZero() GRPC_MUST_USE_RESULT {
+ return RefCountedPtr<Child>(refs_.RefIfNonZero() ? static_cast<Child*>(this)
+ : nullptr);
+ }
+ RefCountedPtr<Child> RefIfNonZero(const DebugLocation& location,
+ const char* reason) GRPC_MUST_USE_RESULT {
+ return RefCountedPtr<Child>(refs_.RefIfNonZero(location, reason)
+ ? static_cast<Child*>(this)
+ : nullptr);
}
- RefCountedPtr<Child> RefIfNonZero(const DebugLocation& location,
- const char* reason) GRPC_MUST_USE_RESULT {
- return RefCountedPtr<Child>(refs_.RefIfNonZero(location, reason)
- ? static_cast<Child*>(this)
- : nullptr);
- }
// Not copyable nor movable.
RefCounted(const RefCounted&) = delete;
diff --git a/contrib/libs/grpc/src/core/lib/gprpp/ref_counted_ptr.h b/contrib/libs/grpc/src/core/lib/gprpp/ref_counted_ptr.h
index f178d393b1..c28e762532 100644
--- a/contrib/libs/grpc/src/core/lib/gprpp/ref_counted_ptr.h
+++ b/contrib/libs/grpc/src/core/lib/gprpp/ref_counted_ptr.h
@@ -177,169 +177,169 @@ class RefCountedPtr {
T* value_ = nullptr;
};
-// A smart pointer class for objects that provide IncrementWeakRefCount() and
-// WeakUnref() methods, such as those provided by the DualRefCounted base class.
-template <typename T>
-class WeakRefCountedPtr {
- public:
- WeakRefCountedPtr() {}
- WeakRefCountedPtr(std::nullptr_t) {}
-
- // If value is non-null, we take ownership of a ref to it.
- template <typename Y>
- explicit WeakRefCountedPtr(Y* value) {
- value_ = value;
- }
-
- // Move ctors.
- WeakRefCountedPtr(WeakRefCountedPtr&& other) {
- value_ = other.value_;
- other.value_ = nullptr;
- }
- template <typename Y>
- WeakRefCountedPtr(WeakRefCountedPtr<Y>&& other) {
- value_ = static_cast<T*>(other.value_);
- other.value_ = nullptr;
- }
-
- // Move assignment.
- WeakRefCountedPtr& operator=(WeakRefCountedPtr&& other) {
- reset(other.value_);
- other.value_ = nullptr;
- return *this;
- }
- template <typename Y>
- WeakRefCountedPtr& operator=(WeakRefCountedPtr<Y>&& other) {
- reset(other.value_);
- other.value_ = nullptr;
- return *this;
- }
-
- // Copy ctors.
- WeakRefCountedPtr(const WeakRefCountedPtr& other) {
- if (other.value_ != nullptr) other.value_->IncrementWeakRefCount();
- value_ = other.value_;
- }
- template <typename Y>
- WeakRefCountedPtr(const WeakRefCountedPtr<Y>& other) {
- static_assert(std::has_virtual_destructor<T>::value,
- "T does not have a virtual dtor");
- if (other.value_ != nullptr) other.value_->IncrementWeakRefCount();
- value_ = static_cast<T*>(other.value_);
- }
-
- // Copy assignment.
- WeakRefCountedPtr& operator=(const WeakRefCountedPtr& other) {
- // Note: Order of reffing and unreffing is important here in case value_
- // and other.value_ are the same object.
- if (other.value_ != nullptr) other.value_->IncrementWeakRefCount();
- reset(other.value_);
- return *this;
- }
- template <typename Y>
- WeakRefCountedPtr& operator=(const WeakRefCountedPtr<Y>& other) {
- static_assert(std::has_virtual_destructor<T>::value,
- "T does not have a virtual dtor");
- // Note: Order of reffing and unreffing is important here in case value_
- // and other.value_ are the same object.
- if (other.value_ != nullptr) other.value_->IncrementWeakRefCount();
- reset(other.value_);
- return *this;
- }
-
- ~WeakRefCountedPtr() {
- if (value_ != nullptr) value_->WeakUnref();
- }
-
- void swap(WeakRefCountedPtr& other) { std::swap(value_, other.value_); }
-
- // If value is non-null, we take ownership of a ref to it.
- void reset(T* value = nullptr) {
- if (value_ != nullptr) value_->WeakUnref();
- value_ = value;
- }
- void reset(const DebugLocation& location, const char* reason,
- T* value = nullptr) {
- if (value_ != nullptr) value_->WeakUnref(location, reason);
- value_ = value;
- }
- template <typename Y>
- void reset(Y* value = nullptr) {
- static_assert(std::has_virtual_destructor<T>::value,
- "T does not have a virtual dtor");
- if (value_ != nullptr) value_->WeakUnref();
- value_ = static_cast<T*>(value);
- }
- template <typename Y>
- void reset(const DebugLocation& location, const char* reason,
- Y* value = nullptr) {
- static_assert(std::has_virtual_destructor<T>::value,
- "T does not have a virtual dtor");
- if (value_ != nullptr) value_->WeakUnref(location, reason);
- value_ = static_cast<T*>(value);
- }
-
- // TODO(roth): This method exists solely as a transition mechanism to allow
- // us to pass a ref to idiomatic C code that does not use WeakRefCountedPtr<>.
- // Once all of our code has been converted to idiomatic C++, this
- // method should go away.
- T* release() {
- T* value = value_;
- value_ = nullptr;
- return value;
- }
-
- T* get() const { return value_; }
-
- T& operator*() const { return *value_; }
- T* operator->() const { return value_; }
-
- template <typename Y>
- bool operator==(const WeakRefCountedPtr<Y>& other) const {
- return value_ == other.value_;
- }
-
- template <typename Y>
- bool operator==(const Y* other) const {
- return value_ == other;
- }
-
- bool operator==(std::nullptr_t) const { return value_ == nullptr; }
-
- template <typename Y>
- bool operator!=(const WeakRefCountedPtr<Y>& other) const {
- return value_ != other.value_;
- }
-
- template <typename Y>
- bool operator!=(const Y* other) const {
- return value_ != other;
- }
-
- bool operator!=(std::nullptr_t) const { return value_ != nullptr; }
-
- private:
- template <typename Y>
- friend class WeakRefCountedPtr;
-
- T* value_ = nullptr;
-};
-
+// A smart pointer class for objects that provide IncrementWeakRefCount() and
+// WeakUnref() methods, such as those provided by the DualRefCounted base class.
+template <typename T>
+class WeakRefCountedPtr {
+ public:
+ WeakRefCountedPtr() {}
+ WeakRefCountedPtr(std::nullptr_t) {}
+
+ // If value is non-null, we take ownership of a ref to it.
+ template <typename Y>
+ explicit WeakRefCountedPtr(Y* value) {
+ value_ = value;
+ }
+
+ // Move ctors.
+ WeakRefCountedPtr(WeakRefCountedPtr&& other) {
+ value_ = other.value_;
+ other.value_ = nullptr;
+ }
+ template <typename Y>
+ WeakRefCountedPtr(WeakRefCountedPtr<Y>&& other) {
+ value_ = static_cast<T*>(other.value_);
+ other.value_ = nullptr;
+ }
+
+ // Move assignment.
+ WeakRefCountedPtr& operator=(WeakRefCountedPtr&& other) {
+ reset(other.value_);
+ other.value_ = nullptr;
+ return *this;
+ }
+ template <typename Y>
+ WeakRefCountedPtr& operator=(WeakRefCountedPtr<Y>&& other) {
+ reset(other.value_);
+ other.value_ = nullptr;
+ return *this;
+ }
+
+ // Copy ctors.
+ WeakRefCountedPtr(const WeakRefCountedPtr& other) {
+ if (other.value_ != nullptr) other.value_->IncrementWeakRefCount();
+ value_ = other.value_;
+ }
+ template <typename Y>
+ WeakRefCountedPtr(const WeakRefCountedPtr<Y>& other) {
+ static_assert(std::has_virtual_destructor<T>::value,
+ "T does not have a virtual dtor");
+ if (other.value_ != nullptr) other.value_->IncrementWeakRefCount();
+ value_ = static_cast<T*>(other.value_);
+ }
+
+ // Copy assignment.
+ WeakRefCountedPtr& operator=(const WeakRefCountedPtr& other) {
+ // Note: Order of reffing and unreffing is important here in case value_
+ // and other.value_ are the same object.
+ if (other.value_ != nullptr) other.value_->IncrementWeakRefCount();
+ reset(other.value_);
+ return *this;
+ }
+ template <typename Y>
+ WeakRefCountedPtr& operator=(const WeakRefCountedPtr<Y>& other) {
+ static_assert(std::has_virtual_destructor<T>::value,
+ "T does not have a virtual dtor");
+ // Note: Order of reffing and unreffing is important here in case value_
+ // and other.value_ are the same object.
+ if (other.value_ != nullptr) other.value_->IncrementWeakRefCount();
+ reset(other.value_);
+ return *this;
+ }
+
+ ~WeakRefCountedPtr() {
+ if (value_ != nullptr) value_->WeakUnref();
+ }
+
+ void swap(WeakRefCountedPtr& other) { std::swap(value_, other.value_); }
+
+ // If value is non-null, we take ownership of a ref to it.
+ void reset(T* value = nullptr) {
+ if (value_ != nullptr) value_->WeakUnref();
+ value_ = value;
+ }
+ void reset(const DebugLocation& location, const char* reason,
+ T* value = nullptr) {
+ if (value_ != nullptr) value_->WeakUnref(location, reason);
+ value_ = value;
+ }
+ template <typename Y>
+ void reset(Y* value = nullptr) {
+ static_assert(std::has_virtual_destructor<T>::value,
+ "T does not have a virtual dtor");
+ if (value_ != nullptr) value_->WeakUnref();
+ value_ = static_cast<T*>(value);
+ }
+ template <typename Y>
+ void reset(const DebugLocation& location, const char* reason,
+ Y* value = nullptr) {
+ static_assert(std::has_virtual_destructor<T>::value,
+ "T does not have a virtual dtor");
+ if (value_ != nullptr) value_->WeakUnref(location, reason);
+ value_ = static_cast<T*>(value);
+ }
+
+ // TODO(roth): This method exists solely as a transition mechanism to allow
+ // us to pass a ref to idiomatic C code that does not use WeakRefCountedPtr<>.
+ // Once all of our code has been converted to idiomatic C++, this
+ // method should go away.
+ T* release() {
+ T* value = value_;
+ value_ = nullptr;
+ return value;
+ }
+
+ T* get() const { return value_; }
+
+ T& operator*() const { return *value_; }
+ T* operator->() const { return value_; }
+
+ template <typename Y>
+ bool operator==(const WeakRefCountedPtr<Y>& other) const {
+ return value_ == other.value_;
+ }
+
+ template <typename Y>
+ bool operator==(const Y* other) const {
+ return value_ == other;
+ }
+
+ bool operator==(std::nullptr_t) const { return value_ == nullptr; }
+
+ template <typename Y>
+ bool operator!=(const WeakRefCountedPtr<Y>& other) const {
+ return value_ != other.value_;
+ }
+
+ template <typename Y>
+ bool operator!=(const Y* other) const {
+ return value_ != other;
+ }
+
+ bool operator!=(std::nullptr_t) const { return value_ != nullptr; }
+
+ private:
+ template <typename Y>
+ friend class WeakRefCountedPtr;
+
+ T* value_ = nullptr;
+};
+
template <typename T, typename... Args>
inline RefCountedPtr<T> MakeRefCounted(Args&&... args) {
return RefCountedPtr<T>(new T(std::forward<Args>(args)...));
}
-template <typename T>
-bool operator<(const RefCountedPtr<T>& p1, const RefCountedPtr<T>& p2) {
- return p1.get() < p2.get();
-}
-
-template <typename T>
-bool operator<(const WeakRefCountedPtr<T>& p1, const WeakRefCountedPtr<T>& p2) {
- return p1.get() < p2.get();
-}
-
+template <typename T>
+bool operator<(const RefCountedPtr<T>& p1, const RefCountedPtr<T>& p2) {
+ return p1.get() < p2.get();
+}
+
+template <typename T>
+bool operator<(const WeakRefCountedPtr<T>& p1, const WeakRefCountedPtr<T>& p2) {
+ return p1.get() < p2.get();
+}
+
} // namespace grpc_core
#endif /* GRPC_CORE_LIB_GPRPP_REF_COUNTED_PTR_H */
diff --git a/contrib/libs/grpc/src/core/lib/gprpp/sync.h b/contrib/libs/grpc/src/core/lib/gprpp/sync.h
index bca408a582..0a911b1cd2 100644
--- a/contrib/libs/grpc/src/core/lib/gprpp/sync.h
+++ b/contrib/libs/grpc/src/core/lib/gprpp/sync.h
@@ -117,15 +117,15 @@ class CondVar {
}
}
- // Returns true iff we timed-out
- template <typename Predicate>
- bool WaitUntil(Mutex* mu, Predicate pred, const gpr_timespec& deadline) {
- while (!pred()) {
- if (Wait(mu, deadline)) return true;
- }
- return false;
- }
-
+ // Returns true iff we timed-out
+ template <typename Predicate>
+ bool WaitUntil(Mutex* mu, Predicate pred, const gpr_timespec& deadline) {
+ while (!pred()) {
+ if (Wait(mu, deadline)) return true;
+ }
+ return false;
+ }
+
private:
gpr_cv cv_;
};
diff --git a/contrib/libs/grpc/src/core/lib/http/format_request.cc b/contrib/libs/grpc/src/core/lib/http/format_request.cc
index 3dface847e..d9294324bd 100644
--- a/contrib/libs/grpc/src/core/lib/http/format_request.cc
+++ b/contrib/libs/grpc/src/core/lib/http/format_request.cc
@@ -24,80 +24,80 @@
#include <stdio.h>
#include <string.h>
-#include <vector>
-
-#include "y_absl/strings/str_format.h"
-#include "y_absl/strings/str_join.h"
-
+#include <vector>
+
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/str_join.h"
+
#include <grpc/slice.h>
#include <grpc/support/alloc.h>
#include <grpc/support/string_util.h>
#include "src/core/lib/gpr/string.h"
static void fill_common_header(const grpc_httpcli_request* request,
- bool connection_close,
- std::vector<TString>* buf) {
- buf->push_back(request->http.path);
- buf->push_back(" HTTP/1.0\r\n");
+ bool connection_close,
+ std::vector<TString>* buf) {
+ buf->push_back(request->http.path);
+ buf->push_back(" HTTP/1.0\r\n");
/* just in case some crazy server really expects HTTP/1.1 */
- buf->push_back("Host: ");
- buf->push_back(request->host);
- buf->push_back("\r\n");
- if (connection_close) buf->push_back("Connection: close\r\n");
- buf->push_back("User-Agent: " GRPC_HTTPCLI_USER_AGENT "\r\n");
+ buf->push_back("Host: ");
+ buf->push_back(request->host);
+ buf->push_back("\r\n");
+ if (connection_close) buf->push_back("Connection: close\r\n");
+ buf->push_back("User-Agent: " GRPC_HTTPCLI_USER_AGENT "\r\n");
/* user supplied headers */
- for (size_t i = 0; i < request->http.hdr_count; i++) {
- buf->push_back(request->http.hdrs[i].key);
- buf->push_back(": ");
- buf->push_back(request->http.hdrs[i].value);
- buf->push_back("\r\n");
+ for (size_t i = 0; i < request->http.hdr_count; i++) {
+ buf->push_back(request->http.hdrs[i].key);
+ buf->push_back(": ");
+ buf->push_back(request->http.hdrs[i].value);
+ buf->push_back("\r\n");
}
}
grpc_slice grpc_httpcli_format_get_request(
const grpc_httpcli_request* request) {
- std::vector<TString> out;
- out.push_back("GET ");
- fill_common_header(request, true, &out);
- out.push_back("\r\n");
- TString req = y_absl::StrJoin(out, "");
- return grpc_slice_from_copied_buffer(req.data(), req.size());
+ std::vector<TString> out;
+ out.push_back("GET ");
+ fill_common_header(request, true, &out);
+ out.push_back("\r\n");
+ TString req = y_absl::StrJoin(out, "");
+ return grpc_slice_from_copied_buffer(req.data(), req.size());
}
grpc_slice grpc_httpcli_format_post_request(const grpc_httpcli_request* request,
const char* body_bytes,
size_t body_size) {
- std::vector<TString> out;
- out.push_back("POST ");
- fill_common_header(request, true, &out);
- if (body_bytes != nullptr) {
- bool has_content_type = false;
- for (size_t i = 0; i < request->http.hdr_count; i++) {
+ std::vector<TString> out;
+ out.push_back("POST ");
+ fill_common_header(request, true, &out);
+ if (body_bytes != nullptr) {
+ bool has_content_type = false;
+ for (size_t i = 0; i < request->http.hdr_count; i++) {
if (strcmp(request->http.hdrs[i].key, "Content-Type") == 0) {
- has_content_type = true;
+ has_content_type = true;
break;
}
}
if (!has_content_type) {
- out.push_back("Content-Type: text/plain\r\n");
+ out.push_back("Content-Type: text/plain\r\n");
}
- out.push_back(y_absl::StrFormat("Content-Length: %lu\r\n",
- static_cast<unsigned long>(body_size)));
+ out.push_back(y_absl::StrFormat("Content-Length: %lu\r\n",
+ static_cast<unsigned long>(body_size)));
}
- out.push_back("\r\n");
- TString req = y_absl::StrJoin(out, "");
- if (body_bytes != nullptr) {
- y_absl::StrAppend(&req, y_absl::string_view(body_bytes, body_size));
+ out.push_back("\r\n");
+ TString req = y_absl::StrJoin(out, "");
+ if (body_bytes != nullptr) {
+ y_absl::StrAppend(&req, y_absl::string_view(body_bytes, body_size));
}
- return grpc_slice_from_copied_buffer(req.data(), req.size());
+ return grpc_slice_from_copied_buffer(req.data(), req.size());
}
grpc_slice grpc_httpcli_format_connect_request(
const grpc_httpcli_request* request) {
- std::vector<TString> out;
- out.push_back("CONNECT ");
- fill_common_header(request, false, &out);
- out.push_back("\r\n");
- TString req = y_absl::StrJoin(out, "");
- return grpc_slice_from_copied_buffer(req.data(), req.size());
+ std::vector<TString> out;
+ out.push_back("CONNECT ");
+ fill_common_header(request, false, &out);
+ out.push_back("\r\n");
+ TString req = y_absl::StrJoin(out, "");
+ return grpc_slice_from_copied_buffer(req.data(), req.size());
}
diff --git a/contrib/libs/grpc/src/core/lib/http/httpcli.cc b/contrib/libs/grpc/src/core/lib/http/httpcli.cc
index f6741d5264..c196a8faac 100644
--- a/contrib/libs/grpc/src/core/lib/http/httpcli.cc
+++ b/contrib/libs/grpc/src/core/lib/http/httpcli.cc
@@ -22,10 +22,10 @@
#include <string.h>
-#include <util/generic/string.h>
-
-#include "y_absl/strings/str_format.h"
-
+#include <util/generic/string.h>
+
+#include "y_absl/strings/str_format.h"
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
@@ -116,11 +116,11 @@ static void append_error(internal_request* req, grpc_error* error) {
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed HTTP/1 client request");
}
grpc_resolved_address* addr = &req->addresses->addrs[req->next_address - 1];
- TString addr_text = grpc_sockaddr_to_uri(addr);
+ TString addr_text = grpc_sockaddr_to_uri(addr);
req->overall_error = grpc_error_add_child(
req->overall_error,
grpc_error_set_str(error, GRPC_ERROR_STR_TARGET_ADDRESS,
- grpc_slice_from_cpp_string(std::move(addr_text))));
+ grpc_slice_from_cpp_string(std::move(addr_text))));
}
static void do_read(internal_request* req) {
@@ -273,10 +273,10 @@ void grpc_httpcli_get(grpc_httpcli_context* context,
if (g_get_override && g_get_override(request, deadline, on_done, response)) {
return;
}
- TString name =
- y_absl::StrFormat("HTTP:GET:%s:%s", request->host, request->http.path);
+ TString name =
+ y_absl::StrFormat("HTTP:GET:%s:%s", request->host, request->http.path);
internal_request_begin(context, pollent, resource_quota, request, deadline,
- on_done, response, name.c_str(),
+ on_done, response, name.c_str(),
grpc_httpcli_format_get_request(request));
}
@@ -291,12 +291,12 @@ void grpc_httpcli_post(grpc_httpcli_context* context,
deadline, on_done, response)) {
return;
}
- TString name =
- y_absl::StrFormat("HTTP:POST:%s:%s", request->host, request->http.path);
+ TString name =
+ y_absl::StrFormat("HTTP:POST:%s:%s", request->host, request->http.path);
internal_request_begin(
context, pollent, resource_quota, request, deadline, on_done, response,
- name.c_str(),
- grpc_httpcli_format_post_request(request, body_bytes, body_size));
+ name.c_str(),
+ grpc_httpcli_format_post_request(request, body_bytes, body_size));
}
void grpc_httpcli_set_override(grpc_httpcli_get_override get,
diff --git a/contrib/libs/grpc/src/core/lib/http/httpcli_security_connector.cc b/contrib/libs/grpc/src/core/lib/http/httpcli_security_connector.cc
index c495619bc7..62643186ad 100644
--- a/contrib/libs/grpc/src/core/lib/http/httpcli_security_connector.cc
+++ b/contrib/libs/grpc/src/core/lib/http/httpcli_security_connector.cc
@@ -22,9 +22,9 @@
#include <string.h>
-#include "y_absl/strings/str_cat.h"
-#include "y_absl/strings/string_view.h"
-
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/string_view.h"
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
@@ -96,10 +96,10 @@ class grpc_httpcli_ssl_channel_security_connector final
/* Check the peer name. */
if (secure_peer_name_ != nullptr &&
!tsi_ssl_peer_matches_name(&peer, secure_peer_name_)) {
- error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
- y_absl::StrCat("Peer name ", secure_peer_name_,
- " is not in peer certificate")
- .c_str());
+ error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
+ y_absl::StrCat("Peer name ", secure_peer_name_,
+ " is not in peer certificate")
+ .c_str());
}
grpc_core::ExecCtx::Run(DEBUG_LOCATION, on_peer_checked, error);
tsi_peer_destruct(&peer);
@@ -112,7 +112,7 @@ class grpc_httpcli_ssl_channel_security_connector final
return strcmp(secure_peer_name_, other->secure_peer_name_);
}
- bool check_call_host(y_absl::string_view /*host*/,
+ bool check_call_host(y_absl::string_view /*host*/,
grpc_auth_context* /*auth_context*/,
grpc_closure* /*on_call_host_checked*/,
grpc_error** error) override {
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/buffer_list.cc b/contrib/libs/grpc/src/core/lib/iomgr/buffer_list.cc
index a525815e17..e1b87da4d0 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/buffer_list.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/buffer_list.cc
@@ -66,27 +66,27 @@ void extract_opt_stats_from_tcp_info(ConnectionMetrics* metrics,
return;
}
if (info->length > offsetof(grpc_core::tcp_info, tcpi_sndbuf_limited)) {
- metrics->recurring_retrans.emplace(info->tcpi_retransmits);
- metrics->is_delivery_rate_app_limited.emplace(
+ metrics->recurring_retrans.emplace(info->tcpi_retransmits);
+ metrics->is_delivery_rate_app_limited.emplace(
info->tcpi_delivery_rate_app_limited);
- metrics->congestion_window.emplace(info->tcpi_snd_cwnd);
- metrics->reordering.emplace(info->tcpi_reordering);
- metrics->packet_retx.emplace(info->tcpi_total_retrans);
- metrics->pacing_rate.emplace(info->tcpi_pacing_rate);
- metrics->data_notsent.emplace(info->tcpi_notsent_bytes);
+ metrics->congestion_window.emplace(info->tcpi_snd_cwnd);
+ metrics->reordering.emplace(info->tcpi_reordering);
+ metrics->packet_retx.emplace(info->tcpi_total_retrans);
+ metrics->pacing_rate.emplace(info->tcpi_pacing_rate);
+ metrics->data_notsent.emplace(info->tcpi_notsent_bytes);
if (info->tcpi_min_rtt != UINT32_MAX) {
- metrics->min_rtt.emplace(info->tcpi_min_rtt);
+ metrics->min_rtt.emplace(info->tcpi_min_rtt);
}
- metrics->packet_sent.emplace(info->tcpi_data_segs_out);
- metrics->delivery_rate.emplace(info->tcpi_delivery_rate);
- metrics->busy_usec.emplace(info->tcpi_busy_time);
- metrics->rwnd_limited_usec.emplace(info->tcpi_rwnd_limited);
- metrics->sndbuf_limited_usec.emplace(info->tcpi_sndbuf_limited);
+ metrics->packet_sent.emplace(info->tcpi_data_segs_out);
+ metrics->delivery_rate.emplace(info->tcpi_delivery_rate);
+ metrics->busy_usec.emplace(info->tcpi_busy_time);
+ metrics->rwnd_limited_usec.emplace(info->tcpi_rwnd_limited);
+ metrics->sndbuf_limited_usec.emplace(info->tcpi_sndbuf_limited);
}
if (info->length > offsetof(grpc_core::tcp_info, tcpi_dsack_dups)) {
- metrics->data_sent.emplace(info->tcpi_bytes_sent);
- metrics->data_retx.emplace(info->tcpi_bytes_retrans);
- metrics->packet_spurious_retx.emplace(info->tcpi_dsack_dups);
+ metrics->data_sent.emplace(info->tcpi_bytes_sent);
+ metrics->data_retx.emplace(info->tcpi_bytes_retrans);
+ metrics->packet_spurious_retx.emplace(info->tcpi_dsack_dups);
}
}
@@ -107,80 +107,80 @@ void extract_opt_stats_from_cmsg(ConnectionMetrics* metrics,
const void* val = data + offset + NLA_HDRLEN;
switch (attr->nla_type) {
case TCP_NLA_BUSY: {
- metrics->busy_usec.emplace(read_unaligned<uint64_t>(val));
+ metrics->busy_usec.emplace(read_unaligned<uint64_t>(val));
break;
}
case TCP_NLA_RWND_LIMITED: {
- metrics->rwnd_limited_usec.emplace(read_unaligned<uint64_t>(val));
+ metrics->rwnd_limited_usec.emplace(read_unaligned<uint64_t>(val));
break;
}
case TCP_NLA_SNDBUF_LIMITED: {
- metrics->sndbuf_limited_usec.emplace(read_unaligned<uint64_t>(val));
+ metrics->sndbuf_limited_usec.emplace(read_unaligned<uint64_t>(val));
break;
}
case TCP_NLA_PACING_RATE: {
- metrics->pacing_rate.emplace(read_unaligned<uint64_t>(val));
+ metrics->pacing_rate.emplace(read_unaligned<uint64_t>(val));
break;
}
case TCP_NLA_DELIVERY_RATE: {
- metrics->delivery_rate.emplace(read_unaligned<uint64_t>(val));
+ metrics->delivery_rate.emplace(read_unaligned<uint64_t>(val));
break;
}
case TCP_NLA_DELIVERY_RATE_APP_LMT: {
- metrics->is_delivery_rate_app_limited.emplace(
- read_unaligned<uint8_t>(val));
+ metrics->is_delivery_rate_app_limited.emplace(
+ read_unaligned<uint8_t>(val));
break;
}
case TCP_NLA_SND_CWND: {
- metrics->congestion_window.emplace(read_unaligned<uint32_t>(val));
+ metrics->congestion_window.emplace(read_unaligned<uint32_t>(val));
break;
}
case TCP_NLA_MIN_RTT: {
- metrics->min_rtt.emplace(read_unaligned<uint32_t>(val));
+ metrics->min_rtt.emplace(read_unaligned<uint32_t>(val));
break;
}
case TCP_NLA_SRTT: {
- metrics->srtt.emplace(read_unaligned<uint32_t>(val));
+ metrics->srtt.emplace(read_unaligned<uint32_t>(val));
break;
}
case TCP_NLA_RECUR_RETRANS: {
- metrics->recurring_retrans.emplace(read_unaligned<uint8_t>(val));
+ metrics->recurring_retrans.emplace(read_unaligned<uint8_t>(val));
break;
}
case TCP_NLA_BYTES_SENT: {
- metrics->data_sent.emplace(read_unaligned<uint64_t>(val));
+ metrics->data_sent.emplace(read_unaligned<uint64_t>(val));
break;
}
case TCP_NLA_DATA_SEGS_OUT: {
- metrics->packet_sent.emplace(read_unaligned<uint64_t>(val));
+ metrics->packet_sent.emplace(read_unaligned<uint64_t>(val));
break;
}
case TCP_NLA_TOTAL_RETRANS: {
- metrics->packet_retx.emplace(read_unaligned<uint64_t>(val));
+ metrics->packet_retx.emplace(read_unaligned<uint64_t>(val));
break;
}
case TCP_NLA_DELIVERED: {
- metrics->packet_delivered.emplace(read_unaligned<uint32_t>(val));
+ metrics->packet_delivered.emplace(read_unaligned<uint32_t>(val));
break;
}
case TCP_NLA_DELIVERED_CE: {
- metrics->packet_delivered_ce.emplace(read_unaligned<uint32_t>(val));
+ metrics->packet_delivered_ce.emplace(read_unaligned<uint32_t>(val));
break;
}
case TCP_NLA_BYTES_RETRANS: {
- metrics->data_retx.emplace(read_unaligned<uint64_t>(val));
+ metrics->data_retx.emplace(read_unaligned<uint64_t>(val));
break;
}
case TCP_NLA_DSACK_DUPS: {
- metrics->packet_spurious_retx.emplace(read_unaligned<uint32_t>(val));
+ metrics->packet_spurious_retx.emplace(read_unaligned<uint32_t>(val));
break;
}
case TCP_NLA_REORDERING: {
- metrics->reordering.emplace(read_unaligned<uint32_t>(val));
+ metrics->reordering.emplace(read_unaligned<uint32_t>(val));
break;
}
case TCP_NLA_SND_SSTHRESH: {
- metrics->snd_ssthresh.emplace(read_unaligned<uint32_t>(val));
+ metrics->snd_ssthresh.emplace(read_unaligned<uint32_t>(val));
break;
}
}
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/buffer_list.h b/contrib/libs/grpc/src/core/lib/iomgr/buffer_list.h
index e38bd1dcde..54a2dc748f 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/buffer_list.h
+++ b/contrib/libs/grpc/src/core/lib/iomgr/buffer_list.h
@@ -21,8 +21,8 @@
#include <grpc/support/port_platform.h>
-#include "y_absl/types/optional.h"
-
+#include "y_absl/types/optional.h"
+
#include "src/core/lib/iomgr/port.h"
#include <grpc/support/time.h>
@@ -35,52 +35,52 @@ namespace grpc_core {
struct ConnectionMetrics {
/* Delivery rate in Bytes/s. */
- y_absl::optional<uint64_t> delivery_rate;
+ y_absl::optional<uint64_t> delivery_rate;
/* If the delivery rate is limited by the application, this is set to true. */
- y_absl::optional<bool> is_delivery_rate_app_limited;
+ y_absl::optional<bool> is_delivery_rate_app_limited;
/* Total packets retransmitted. */
- y_absl::optional<uint32_t> packet_retx;
+ y_absl::optional<uint32_t> packet_retx;
/* Total packets retransmitted spuriously. This metric is smaller than or
equal to packet_retx. */
- y_absl::optional<uint32_t> packet_spurious_retx;
+ y_absl::optional<uint32_t> packet_spurious_retx;
/* Total packets sent. */
- y_absl::optional<uint32_t> packet_sent;
+ y_absl::optional<uint32_t> packet_sent;
/* Total packets delivered. */
- y_absl::optional<uint32_t> packet_delivered;
+ y_absl::optional<uint32_t> packet_delivered;
/* Total packets delivered with ECE marked. This metric is smaller than or
equal to packet_delivered. */
- y_absl::optional<uint32_t> packet_delivered_ce;
+ y_absl::optional<uint32_t> packet_delivered_ce;
/* Total bytes lost so far. */
- y_absl::optional<uint64_t> data_retx;
+ y_absl::optional<uint64_t> data_retx;
/* Total bytes sent so far. */
- y_absl::optional<uint64_t> data_sent;
+ y_absl::optional<uint64_t> data_sent;
/* Total bytes in write queue but not sent. */
- y_absl::optional<uint64_t> data_notsent;
+ y_absl::optional<uint64_t> data_notsent;
/* Pacing rate of the connection in Bps */
- y_absl::optional<uint64_t> pacing_rate;
+ y_absl::optional<uint64_t> pacing_rate;
/* Minimum RTT observed in usec. */
- y_absl::optional<uint32_t> min_rtt;
+ y_absl::optional<uint32_t> min_rtt;
/* Smoothed RTT in usec */
- y_absl::optional<uint32_t> srtt;
+ y_absl::optional<uint32_t> srtt;
/* Send congestion window. */
- y_absl::optional<uint32_t> congestion_window;
+ y_absl::optional<uint32_t> congestion_window;
/* Slow start threshold in packets. */
- y_absl::optional<uint32_t> snd_ssthresh;
+ y_absl::optional<uint32_t> snd_ssthresh;
/* Maximum degree of reordering (i.e., maximum number of packets reodered)
on the connection. */
- y_absl::optional<uint32_t> reordering;
+ y_absl::optional<uint32_t> reordering;
/* Represents the number of recurring retransmissions of the first sequence
that is not acknowledged yet. */
- y_absl::optional<uint8_t> recurring_retrans;
+ y_absl::optional<uint8_t> recurring_retrans;
/* The cumulative time (in usec) that the transport protocol was busy
sending data. */
- y_absl::optional<uint64_t> busy_usec;
+ y_absl::optional<uint64_t> busy_usec;
/* The cumulative time (in usec) that the transport protocol was limited by
the receive window size. */
- y_absl::optional<uint64_t> rwnd_limited_usec;
+ y_absl::optional<uint64_t> rwnd_limited_usec;
/* The cumulative time (in usec) that the transport protocol was limited by
the send buffer size. */
- y_absl::optional<uint64_t> sndbuf_limited_usec;
+ y_absl::optional<uint64_t> sndbuf_limited_usec;
};
struct Timestamp {
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/call_combiner.h b/contrib/libs/grpc/src/core/lib/iomgr/call_combiner.h
index ffe79b3534..aed847c972 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/call_combiner.h
+++ b/contrib/libs/grpc/src/core/lib/iomgr/call_combiner.h
@@ -23,8 +23,8 @@
#include <stddef.h>
-#include "y_absl/container/inlined_vector.h"
-
+#include "y_absl/container/inlined_vector.h"
+
#include <grpc/support/atm.h>
#include "src/core/lib/gprpp/mpscq.h"
@@ -209,7 +209,7 @@ class CallCombinerClosureList {
// There are generally a maximum of 6 closures to run in the call
// combiner, one for each pending op.
- y_absl::InlinedVector<CallCombinerClosure, 6> closures_;
+ y_absl::InlinedVector<CallCombinerClosure, 6> closures_;
};
} // namespace grpc_core
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/cfstream_handle.cc b/contrib/libs/grpc/src/core/lib/iomgr/cfstream_handle.cc
index e8ff3a54d0..46914e5175 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/cfstream_handle.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/cfstream_handle.cc
@@ -32,7 +32,7 @@
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/error_cfstream.h"
-#include "src/core/lib/iomgr/ev_apple.h"
+#include "src/core/lib/iomgr/ev_apple.h"
#include "src/core/lib/iomgr/exec_ctx.h"
extern grpc_core::TraceFlag grpc_tcp_trace;
@@ -148,15 +148,15 @@ CFStreamHandle::CFStreamHandle(CFReadStreamRef read_stream,
kCFStreamEventOpenCompleted | kCFStreamEventCanAcceptBytes |
kCFStreamEventErrorOccurred | kCFStreamEventEndEncountered,
CFStreamHandle::WriteCallback, &ctx);
- grpc_apple_register_read_stream(read_stream, dispatch_queue_);
- grpc_apple_register_write_stream(write_stream, dispatch_queue_);
+ grpc_apple_register_read_stream(read_stream, dispatch_queue_);
+ grpc_apple_register_write_stream(write_stream, dispatch_queue_);
}
CFStreamHandle::~CFStreamHandle() {
open_event_.DestroyEvent();
read_event_.DestroyEvent();
write_event_.DestroyEvent();
- dispatch_release(dispatch_queue_);
+ dispatch_release(dispatch_queue_);
}
void CFStreamHandle::NotifyOnOpen(grpc_closure* closure) {
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/dualstack_socket_posix.cc b/contrib/libs/grpc/src/core/lib/iomgr/dualstack_socket_posix.cc
index 2d58d97799..dc0eafebf9 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/dualstack_socket_posix.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/dualstack_socket_posix.cc
@@ -1,47 +1,47 @@
-/*
- *
- * Copyright 2020 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <grpc/support/port_platform.h>
-
-#include "src/core/lib/iomgr/port.h"
-
-#ifdef GRPC_POSIX_SOCKET_UTILS_COMMON
-
-#include <netinet/in.h>
-#include "src/core/lib/iomgr/socket_utils_posix.h"
-
-#ifndef GRPC_SET_SOCKET_DUALSTACK_CUSTOM
-
-/* This should be 0 in production, but it may be enabled for testing or
- debugging purposes, to simulate an environment where IPv6 sockets can't
- also speak IPv4. */
-int grpc_forbid_dualstack_sockets_for_testing = 0;
-
-int grpc_set_socket_dualstack(int fd) {
- if (!grpc_forbid_dualstack_sockets_for_testing) {
- const int off = 0;
- return 0 == setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &off, sizeof(off));
- } else {
- /* Force an IPv6-only socket, for testing purposes. */
- const int on = 1;
- setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on));
- return 0;
- }
-}
-#endif // GRPC_SET_SOCKET_DUALSTACK_CUSTOM
-#endif // GRPC_POSIX_SOCKET_UTILS_COMMON
+/*
+ *
+ * Copyright 2020 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <grpc/support/port_platform.h>
+
+#include "src/core/lib/iomgr/port.h"
+
+#ifdef GRPC_POSIX_SOCKET_UTILS_COMMON
+
+#include <netinet/in.h>
+#include "src/core/lib/iomgr/socket_utils_posix.h"
+
+#ifndef GRPC_SET_SOCKET_DUALSTACK_CUSTOM
+
+/* This should be 0 in production, but it may be enabled for testing or
+ debugging purposes, to simulate an environment where IPv6 sockets can't
+ also speak IPv4. */
+int grpc_forbid_dualstack_sockets_for_testing = 0;
+
+int grpc_set_socket_dualstack(int fd) {
+ if (!grpc_forbid_dualstack_sockets_for_testing) {
+ const int off = 0;
+ return 0 == setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &off, sizeof(off));
+ } else {
+ /* Force an IPv6-only socket, for testing purposes. */
+ const int on = 1;
+ setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on));
+ return 0;
+ }
+}
+#endif // GRPC_SET_SOCKET_DUALSTACK_CUSTOM
+#endif // GRPC_POSIX_SOCKET_UTILS_COMMON
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/endpoint.cc b/contrib/libs/grpc/src/core/lib/iomgr/endpoint.cc
index 5a5d2620ad..37e0400102 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/endpoint.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/endpoint.cc
@@ -52,14 +52,14 @@ void grpc_endpoint_shutdown(grpc_endpoint* ep, grpc_error* why) {
void grpc_endpoint_destroy(grpc_endpoint* ep) { ep->vtable->destroy(ep); }
-y_absl::string_view grpc_endpoint_get_peer(grpc_endpoint* ep) {
+y_absl::string_view grpc_endpoint_get_peer(grpc_endpoint* ep) {
return ep->vtable->get_peer(ep);
}
-y_absl::string_view grpc_endpoint_get_local_address(grpc_endpoint* ep) {
- return ep->vtable->get_local_address(ep);
-}
-
+y_absl::string_view grpc_endpoint_get_local_address(grpc_endpoint* ep) {
+ return ep->vtable->get_local_address(ep);
+}
+
int grpc_endpoint_get_fd(grpc_endpoint* ep) { return ep->vtable->get_fd(ep); }
grpc_resource_user* grpc_endpoint_get_resource_user(grpc_endpoint* ep) {
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/endpoint.h b/contrib/libs/grpc/src/core/lib/iomgr/endpoint.h
index 15b2107fa9..e704c3be49 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/endpoint.h
+++ b/contrib/libs/grpc/src/core/lib/iomgr/endpoint.h
@@ -21,8 +21,8 @@
#include <grpc/support/port_platform.h>
-#include "y_absl/strings/string_view.h"
-
+#include "y_absl/strings/string_view.h"
+
#include <grpc/slice.h>
#include <grpc/slice_buffer.h>
#include <grpc/support/time.h>
@@ -47,8 +47,8 @@ struct grpc_endpoint_vtable {
void (*shutdown)(grpc_endpoint* ep, grpc_error* why);
void (*destroy)(grpc_endpoint* ep);
grpc_resource_user* (*get_resource_user)(grpc_endpoint* ep);
- y_absl::string_view (*get_peer)(grpc_endpoint* ep);
- y_absl::string_view (*get_local_address)(grpc_endpoint* ep);
+ y_absl::string_view (*get_peer)(grpc_endpoint* ep);
+ y_absl::string_view (*get_local_address)(grpc_endpoint* ep);
int (*get_fd)(grpc_endpoint* ep);
bool (*can_track_err)(grpc_endpoint* ep);
};
@@ -61,10 +61,10 @@ struct grpc_endpoint_vtable {
void grpc_endpoint_read(grpc_endpoint* ep, grpc_slice_buffer* slices,
grpc_closure* cb, bool urgent);
-y_absl::string_view grpc_endpoint_get_peer(grpc_endpoint* ep);
+y_absl::string_view grpc_endpoint_get_peer(grpc_endpoint* ep);
+
+y_absl::string_view grpc_endpoint_get_local_address(grpc_endpoint* ep);
-y_absl::string_view grpc_endpoint_get_local_address(grpc_endpoint* ep);
-
/* Get the file descriptor used by \a ep. Return -1 if \a ep is not using an fd.
*/
int grpc_endpoint_get_fd(grpc_endpoint* ep);
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/endpoint_cfstream.cc b/contrib/libs/grpc/src/core/lib/iomgr/endpoint_cfstream.cc
index aac574c60a..d3a9c9b200 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/endpoint_cfstream.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/endpoint_cfstream.cc
@@ -34,8 +34,8 @@
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/iomgr/error_cfstream.h"
-#include "src/core/lib/iomgr/sockaddr.h"
-#include "src/core/lib/iomgr/sockaddr_utils.h"
+#include "src/core/lib/iomgr/sockaddr.h"
+#include "src/core/lib/iomgr/sockaddr_utils.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
@@ -57,8 +57,8 @@ struct CFStreamEndpoint {
grpc_closure read_action;
grpc_closure write_action;
- TString peer_string;
- TString local_address;
+ TString peer_string;
+ TString local_address;
grpc_resource_user* resource_user;
grpc_resource_user_slice_allocator slice_allocator;
};
@@ -67,7 +67,7 @@ static void CFStreamFree(CFStreamEndpoint* ep) {
CFRelease(ep->read_stream);
CFRelease(ep->write_stream);
CFSTREAM_HANDLE_UNREF(ep->stream_sync, "free");
- delete ep;
+ delete ep;
}
#ifndef NDEBUG
@@ -112,7 +112,7 @@ static grpc_error* CFStreamAnnotateError(grpc_error* src_error,
grpc_error_set_int(src_error, GRPC_ERROR_INT_GRPC_STATUS,
GRPC_STATUS_UNAVAILABLE),
GRPC_ERROR_STR_TARGET_ADDRESS,
- grpc_slice_from_copied_string(ep->peer_string.c_str()));
+ grpc_slice_from_copied_string(ep->peer_string.c_str()));
}
static void CallReadCb(CFStreamEndpoint* ep, grpc_error* error) {
@@ -126,8 +126,8 @@ static void CallReadCb(CFStreamEndpoint* ep, grpc_error* error) {
for (i = 0; i < ep->read_slices->count; i++) {
char* dump = grpc_dump_slice(ep->read_slices->slices[i],
GPR_DUMP_HEX | GPR_DUMP_ASCII);
- gpr_log(GPR_DEBUG, "READ %p (peer=%s): %s", ep, ep->peer_string.c_str(),
- dump);
+ gpr_log(GPR_DEBUG, "READ %p (peer=%s): %s", ep, ep->peer_string.c_str(),
+ dump);
gpr_free(dump);
}
}
@@ -233,8 +233,8 @@ static void WriteAction(void* arg, grpc_error* error) {
if (grpc_tcp_trace.enabled()) {
grpc_slice trace_slice = grpc_slice_sub(slice, 0, write_size);
char* dump = grpc_dump_slice(trace_slice, GPR_DUMP_HEX | GPR_DUMP_ASCII);
- gpr_log(GPR_DEBUG, "WRITE %p (peer=%s): %s", ep, ep->peer_string.c_str(),
- dump);
+ gpr_log(GPR_DEBUG, "WRITE %p (peer=%s): %s", ep, ep->peer_string.c_str(),
+ dump);
gpr_free(dump);
grpc_slice_unref_internal(trace_slice);
}
@@ -313,16 +313,16 @@ grpc_resource_user* CFStreamGetResourceUser(grpc_endpoint* ep) {
return ep_impl->resource_user;
}
-y_absl::string_view CFStreamGetPeer(grpc_endpoint* ep) {
+y_absl::string_view CFStreamGetPeer(grpc_endpoint* ep) {
CFStreamEndpoint* ep_impl = reinterpret_cast<CFStreamEndpoint*>(ep);
- return ep_impl->peer_string;
+ return ep_impl->peer_string;
+}
+
+y_absl::string_view CFStreamGetLocalAddress(grpc_endpoint* ep) {
+ CFStreamEndpoint* ep_impl = reinterpret_cast<CFStreamEndpoint*>(ep);
+ return ep_impl->local_address;
}
-y_absl::string_view CFStreamGetLocalAddress(grpc_endpoint* ep) {
- CFStreamEndpoint* ep_impl = reinterpret_cast<CFStreamEndpoint*>(ep);
- return ep_impl->local_address;
-}
-
int CFStreamGetFD(grpc_endpoint* ep) { return 0; }
bool CFStreamCanTrackErr(grpc_endpoint* ep) { return false; }
@@ -341,7 +341,7 @@ static const grpc_endpoint_vtable vtable = {CFStreamRead,
CFStreamDestroy,
CFStreamGetResourceUser,
CFStreamGetPeer,
- CFStreamGetLocalAddress,
+ CFStreamGetLocalAddress,
CFStreamGetFD,
CFStreamCanTrackErr};
@@ -349,7 +349,7 @@ grpc_endpoint* grpc_cfstream_endpoint_create(
CFReadStreamRef read_stream, CFWriteStreamRef write_stream,
const char* peer_string, grpc_resource_quota* resource_quota,
CFStreamHandle* stream_sync) {
- CFStreamEndpoint* ep_impl = new CFStreamEndpoint;
+ CFStreamEndpoint* ep_impl = new CFStreamEndpoint;
if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG,
"CFStream endpoint:%p create readStream:%p writeStream: %p",
@@ -364,23 +364,23 @@ grpc_endpoint* grpc_cfstream_endpoint_create(
ep_impl->stream_sync = stream_sync;
CFSTREAM_HANDLE_REF(ep_impl->stream_sync, "endpoint create");
- ep_impl->peer_string = peer_string;
- grpc_resolved_address resolved_local_addr;
- resolved_local_addr.len = sizeof(resolved_local_addr.addr);
- CFDataRef native_handle = static_cast<CFDataRef>(CFReadStreamCopyProperty(
- ep_impl->read_stream, kCFStreamPropertySocketNativeHandle));
- CFSocketNativeHandle sockfd;
- CFDataGetBytes(native_handle, CFRangeMake(0, sizeof(CFSocketNativeHandle)),
- (UInt8*)&sockfd);
- if (native_handle) {
- CFRelease(native_handle);
- }
- if (getsockname(sockfd, reinterpret_cast<sockaddr*>(resolved_local_addr.addr),
- &resolved_local_addr.len) < 0) {
- ep_impl->local_address = "";
- } else {
- ep_impl->local_address = grpc_sockaddr_to_uri(&resolved_local_addr);
- }
+ ep_impl->peer_string = peer_string;
+ grpc_resolved_address resolved_local_addr;
+ resolved_local_addr.len = sizeof(resolved_local_addr.addr);
+ CFDataRef native_handle = static_cast<CFDataRef>(CFReadStreamCopyProperty(
+ ep_impl->read_stream, kCFStreamPropertySocketNativeHandle));
+ CFSocketNativeHandle sockfd;
+ CFDataGetBytes(native_handle, CFRangeMake(0, sizeof(CFSocketNativeHandle)),
+ (UInt8*)&sockfd);
+ if (native_handle) {
+ CFRelease(native_handle);
+ }
+ if (getsockname(sockfd, reinterpret_cast<sockaddr*>(resolved_local_addr.addr),
+ &resolved_local_addr.len) < 0) {
+ ep_impl->local_address = "";
+ } else {
+ ep_impl->local_address = grpc_sockaddr_to_uri(&resolved_local_addr);
+ }
ep_impl->read_cb = nil;
ep_impl->write_cb = nil;
ep_impl->read_slices = nil;
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/endpoint_pair_posix.cc b/contrib/libs/grpc/src/core/lib/iomgr/endpoint_pair_posix.cc
index ad4d0fda1c..7f95da7365 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/endpoint_pair_posix.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/endpoint_pair_posix.cc
@@ -32,10 +32,10 @@
#include <sys/socket.h>
#include <sys/types.h>
-#include <util/generic/string.h>
-
-#include "y_absl/strings/str_cat.h"
-
+#include <util/generic/string.h>
+
+#include "y_absl/strings/str_cat.h"
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/lib/gpr/string.h"
@@ -60,12 +60,12 @@ grpc_endpoint_pair grpc_iomgr_create_endpoint_pair(const char* name,
grpc_core::ExecCtx exec_ctx;
- TString final_name = y_absl::StrCat(name, ":client");
- p.client = grpc_tcp_create(grpc_fd_create(sv[1], final_name.c_str(), false),
- args, "socketpair-server");
- final_name = y_absl::StrCat(name, ":server");
- p.server = grpc_tcp_create(grpc_fd_create(sv[0], final_name.c_str(), false),
- args, "socketpair-client");
+ TString final_name = y_absl::StrCat(name, ":client");
+ p.client = grpc_tcp_create(grpc_fd_create(sv[1], final_name.c_str(), false),
+ args, "socketpair-server");
+ final_name = y_absl::StrCat(name, ":server");
+ p.server = grpc_tcp_create(grpc_fd_create(sv[0], final_name.c_str(), false),
+ args, "socketpair-client");
return p;
}
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/error.h b/contrib/libs/grpc/src/core/lib/iomgr/error.h
index a1075d36a1..ac3ff87628 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/error.h
+++ b/contrib/libs/grpc/src/core/lib/iomgr/error.h
@@ -200,10 +200,10 @@ inline void grpc_error_unref(grpc_error* err) {
// Consumes all the errors in the vector and forms a referencing error from
// them. If the vector is empty, return GRPC_ERROR_NONE.
-template <typename VectorType>
-static grpc_error* grpc_error_create_from_vector(const char* file, int line,
- const char* desc,
- VectorType* error_list) {
+template <typename VectorType>
+static grpc_error* grpc_error_create_from_vector(const char* file, int line,
+ const char* desc,
+ VectorType* error_list) {
grpc_error* error = GRPC_ERROR_NONE;
if (error_list->size() != 0) {
error = grpc_error_create(file, line, grpc_slice_from_static_string(desc),
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/error_cfstream.cc b/contrib/libs/grpc/src/core/lib/iomgr/error_cfstream.cc
index 6c6e89fc9e..62f6bc1d40 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/error_cfstream.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/error_cfstream.cc
@@ -19,10 +19,10 @@
#include <grpc/support/port_platform.h>
#ifdef GRPC_CFSTREAM
-#include <util/generic/string.h>
-
-#include "y_absl/strings/str_format.h"
-
+#include <util/generic/string.h>
+
+#include "y_absl/strings/str_format.h"
+
#include <CoreFoundation/CoreFoundation.h>
#include <grpc/support/alloc.h>
@@ -43,11 +43,11 @@ grpc_error* grpc_error_create_from_cferror(const char* file, int line,
kCFStringEncodingUTF8);
CFStringGetCString(desc, buf_desc, MAX_ERROR_DESCRIPTION,
kCFStringEncodingUTF8);
- TString error_msg =
- y_absl::StrFormat("%s (error domain:%s, code:%ld, description:%s)",
- custom_desc, buf_domain, code, buf_desc);
+ TString error_msg =
+ y_absl::StrFormat("%s (error domain:%s, code:%ld, description:%s)",
+ custom_desc, buf_domain, code, buf_desc);
CFRelease(desc);
- return grpc_error_create(
- file, line, grpc_slice_from_copied_string(error_msg.c_str()), NULL, 0);
+ return grpc_error_create(
+ file, line, grpc_slice_from_copied_string(error_msg.c_str()), NULL, 0);
}
#endif /* GRPC_CFSTREAM */
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/ev_apple.cc b/contrib/libs/grpc/src/core/lib/iomgr/ev_apple.cc
index b0a352524b..d152582886 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/ev_apple.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/ev_apple.cc
@@ -1,356 +1,356 @@
-/*
- *
- * Copyright 2020 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/// Event engine based on Apple's CFRunLoop API family. If the CFRunLoop engine
-/// is enabled (see iomgr_posix_cfstream.cc), a global thread is started to
-/// handle and trigger all the CFStream events. The CFStream streams register
-/// themselves with the run loop with functions grpc_apple_register_read_stream
-/// and grpc_apple_register_read_stream. Pollsets are dummy and block on a
-/// condition variable in pollset_work().
-
-#include <grpc/support/port_platform.h>
-
-#include "src/core/lib/iomgr/port.h"
-
-#ifdef GRPC_APPLE_EV
-
-#include <CoreFoundation/CoreFoundation.h>
-
-#include <list>
-
-#include "src/core/lib/gprpp/thd.h"
-#include "src/core/lib/iomgr/ev_apple.h"
-
-grpc_core::DebugOnlyTraceFlag grpc_apple_polling_trace(false, "apple_polling");
-
-#ifndef NDEBUG
-#define GRPC_POLLING_TRACE(format, ...) \
- if (GRPC_TRACE_FLAG_ENABLED(grpc_apple_polling_trace)) { \
- gpr_log(GPR_DEBUG, "(polling) " format, __VA_ARGS__); \
- }
-#else
-#define GRPC_POLLING_TRACE(...)
-#endif // NDEBUG
-
-#define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker*)1)
-
-struct GlobalRunLoopContext {
- grpc_core::CondVar init_cv;
- grpc_core::CondVar input_source_cv;
-
- grpc_core::Mutex mu;
-
- // Whether an input source registration is pending. Protected by mu.
- bool input_source_registered = false;
-
- // The reference to the global run loop object. Protected by mu.
- CFRunLoopRef run_loop;
-
- // Whether the pollset has been globally shut down. Protected by mu.
- bool is_shutdown = false;
-};
-
-struct GrpcAppleWorker {
- // The condition varible to kick the worker. Works with the pollset's lock
- // (GrpcApplePollset.mu).
- grpc_core::CondVar cv;
-
- // Whether the worker is kicked. Protected by the pollset's lock
- // (GrpcApplePollset.mu).
- bool kicked = false;
-};
-
-struct GrpcApplePollset {
- grpc_core::Mutex mu;
-
- // Tracks the current workers in the pollset. Protected by mu.
- std::list<GrpcAppleWorker*> workers;
-
- // Whether the pollset is shut down. Protected by mu.
- bool is_shutdown = false;
-
- // Closure to call when shutdown is done. Protected by mu.
- grpc_closure* shutdown_closure;
-
- // Whether there's an outstanding kick that was not processed. Protected by
- // mu.
- bool kicked_without_poller = false;
-};
-
-static GlobalRunLoopContext* gGlobalRunLoopContext = nullptr;
-static grpc_core::Thread* gGlobalRunLoopThread = nullptr;
-
-/// Register the stream with the dispatch queue. Callbacks of the stream will be
-/// issued to the dispatch queue when a network event happens and will be
-/// managed by Grand Central Dispatch.
-static void grpc_apple_register_read_stream_queue(
- CFReadStreamRef read_stream, dispatch_queue_t dispatch_queue) {
- CFReadStreamSetDispatchQueue(read_stream, dispatch_queue);
-}
-
-/// Register the stream with the dispatch queue. Callbacks of the stream will be
-/// issued to the dispatch queue when a network event happens and will be
-/// managed by Grand Central Dispatch.
-static void grpc_apple_register_write_stream_queue(
- CFWriteStreamRef write_stream, dispatch_queue_t dispatch_queue) {
- CFWriteStreamSetDispatchQueue(write_stream, dispatch_queue);
-}
-
-/// Register the stream with the global run loop. Callbacks of the stream will
-/// be issued to the run loop when a network event happens and will be driven by
-/// the global run loop thread gGlobalRunLoopThread.
-static void grpc_apple_register_read_stream_run_loop(
- CFReadStreamRef read_stream, dispatch_queue_t dispatch_queue) {
- GRPC_POLLING_TRACE("Register read stream: %p", read_stream);
- grpc_core::MutexLock lock(&gGlobalRunLoopContext->mu);
- CFReadStreamScheduleWithRunLoop(read_stream, gGlobalRunLoopContext->run_loop,
- kCFRunLoopDefaultMode);
- gGlobalRunLoopContext->input_source_registered = true;
- gGlobalRunLoopContext->input_source_cv.Signal();
-}
-
-/// Register the stream with the global run loop. Callbacks of the stream will
-/// be issued to the run loop when a network event happens, and will be driven
-/// by the global run loop thread gGlobalRunLoopThread.
-static void grpc_apple_register_write_stream_run_loop(
- CFWriteStreamRef write_stream, dispatch_queue_t dispatch_queue) {
- GRPC_POLLING_TRACE("Register write stream: %p", write_stream);
- grpc_core::MutexLock lock(&gGlobalRunLoopContext->mu);
- CFWriteStreamScheduleWithRunLoop(
- write_stream, gGlobalRunLoopContext->run_loop, kCFRunLoopDefaultMode);
- gGlobalRunLoopContext->input_source_registered = true;
- gGlobalRunLoopContext->input_source_cv.Signal();
-}
-
-/// The default implementation of stream registration is to register the stream
-/// to a dispatch queue. However, if the CFRunLoop based pollset is enabled (by
-/// macro and environment variable, see docs in iomgr_posix_cfstream.cc), the
-/// CFStream streams are registered with the global run loop instead (see
-/// pollset_global_init below).
-static void (*grpc_apple_register_read_stream_impl)(
- CFReadStreamRef, dispatch_queue_t) = grpc_apple_register_read_stream_queue;
-static void (*grpc_apple_register_write_stream_impl)(CFWriteStreamRef,
- dispatch_queue_t) =
- grpc_apple_register_write_stream_queue;
-
-void grpc_apple_register_read_stream(CFReadStreamRef read_stream,
- dispatch_queue_t dispatch_queue) {
- grpc_apple_register_read_stream_impl(read_stream, dispatch_queue);
-}
-
-void grpc_apple_register_write_stream(CFWriteStreamRef write_stream,
- dispatch_queue_t dispatch_queue) {
- grpc_apple_register_write_stream_impl(write_stream, dispatch_queue);
-}
-
-/// Drive the run loop in a global singleton thread until the global run loop is
-/// shutdown.
-static void GlobalRunLoopFunc(void* arg) {
- grpc_core::ReleasableMutexLock lock(&gGlobalRunLoopContext->mu);
- gGlobalRunLoopContext->run_loop = CFRunLoopGetCurrent();
- gGlobalRunLoopContext->init_cv.Signal();
-
- while (!gGlobalRunLoopContext->is_shutdown) {
- // CFRunLoopRun() will return immediately if no stream is registered on it.
- // So we wait on a conditional variable until a stream is registered;
- // otherwise we'll be running a spinning loop.
- while (!gGlobalRunLoopContext->input_source_registered) {
- gGlobalRunLoopContext->input_source_cv.Wait(&gGlobalRunLoopContext->mu);
- }
- gGlobalRunLoopContext->input_source_registered = false;
- lock.Unlock();
- CFRunLoopRun();
- lock.Lock();
- }
- lock.Unlock();
-}
-
-// pollset implementation
-
-static void pollset_global_init(void) {
- gGlobalRunLoopContext = new GlobalRunLoopContext;
-
- grpc_apple_register_read_stream_impl =
- grpc_apple_register_read_stream_run_loop;
- grpc_apple_register_write_stream_impl =
- grpc_apple_register_write_stream_run_loop;
-
- grpc_core::MutexLock lock(&gGlobalRunLoopContext->mu);
- gGlobalRunLoopThread =
- new grpc_core::Thread("apple_ev", GlobalRunLoopFunc, nullptr);
- gGlobalRunLoopThread->Start();
- while (gGlobalRunLoopContext->run_loop == NULL)
- gGlobalRunLoopContext->init_cv.Wait(&gGlobalRunLoopContext->mu);
-}
-
-static void pollset_global_shutdown(void) {
- {
- grpc_core::MutexLock lock(&gGlobalRunLoopContext->mu);
- gGlobalRunLoopContext->is_shutdown = true;
- CFRunLoopStop(gGlobalRunLoopContext->run_loop);
- }
- gGlobalRunLoopThread->Join();
- delete gGlobalRunLoopThread;
- delete gGlobalRunLoopContext;
-}
-
-/// The caller must acquire the lock GrpcApplePollset.mu before calling this
-/// function. The lock may be temporarily released when waiting on the condition
-/// variable but will be re-acquired before the function returns.
-///
-/// The Apple pollset simply waits on a condition variable until it is kicked.
-/// The network events are handled in the global run loop thread. Processing of
-/// these events will eventually trigger the kick.
-static grpc_error* pollset_work(grpc_pollset* pollset,
- grpc_pollset_worker** worker,
- grpc_millis deadline) {
- GRPC_POLLING_TRACE("pollset work: %p, worker: %p, deadline: %" PRIu64,
- pollset, worker, deadline);
- GrpcApplePollset* apple_pollset =
- reinterpret_cast<GrpcApplePollset*>(pollset);
- GrpcAppleWorker actual_worker;
- if (worker) {
- *worker = reinterpret_cast<grpc_pollset_worker*>(&actual_worker);
- }
-
- if (apple_pollset->kicked_without_poller) {
- // Process the outstanding kick and reset the flag. Do not block.
- apple_pollset->kicked_without_poller = false;
- } else {
- // Block until kicked, timed out, or the pollset shuts down.
- apple_pollset->workers.push_front(&actual_worker);
- auto it = apple_pollset->workers.begin();
-
- while (!actual_worker.kicked && !apple_pollset->is_shutdown) {
- if (actual_worker.cv.Wait(
- &apple_pollset->mu,
- grpc_millis_to_timespec(deadline, GPR_CLOCK_REALTIME))) {
- // timed out
- break;
- }
- }
-
- apple_pollset->workers.erase(it);
-
- // If the pollset is shut down asynchronously and this is the last pending
- // worker, the shutdown process is complete at this moment and the shutdown
- // callback will be called.
- if (apple_pollset->is_shutdown && apple_pollset->workers.empty()) {
- grpc_core::ExecCtx::Run(DEBUG_LOCATION, apple_pollset->shutdown_closure,
- GRPC_ERROR_NONE);
- }
- }
-
- return GRPC_ERROR_NONE;
-}
-
-/// Kick a specific worker. The caller must acquire the lock GrpcApplePollset.mu
-/// before calling this function.
-static void kick_worker(GrpcAppleWorker* worker) {
- worker->kicked = true;
- worker->cv.Signal();
-}
-
-/// The caller must acquire the lock GrpcApplePollset.mu before calling this
-/// function. The kick action simply signals the condition variable of the
-/// worker.
-static grpc_error* pollset_kick(grpc_pollset* pollset,
- grpc_pollset_worker* specific_worker) {
- GrpcApplePollset* apple_pollset =
- reinterpret_cast<GrpcApplePollset*>(pollset);
-
- GRPC_POLLING_TRACE("pollset kick: %p, worker:%p", pollset, specific_worker);
-
- if (specific_worker == nullptr) {
- if (apple_pollset->workers.empty()) {
- apple_pollset->kicked_without_poller = true;
- } else {
- GrpcAppleWorker* actual_worker = apple_pollset->workers.front();
- kick_worker(actual_worker);
- }
- } else if (specific_worker == GRPC_POLLSET_KICK_BROADCAST) {
- for (auto& actual_worker : apple_pollset->workers) {
- kick_worker(actual_worker);
- }
- } else {
- GrpcAppleWorker* actual_worker =
- reinterpret_cast<GrpcAppleWorker*>(specific_worker);
- kick_worker(actual_worker);
- }
-
- return GRPC_ERROR_NONE;
-}
-
-static void pollset_init(grpc_pollset* pollset, gpr_mu** mu) {
- GRPC_POLLING_TRACE("pollset init: %p", pollset);
- GrpcApplePollset* apple_pollset = new (pollset) GrpcApplePollset();
- *mu = apple_pollset->mu.get();
-}
-
-/// The caller must acquire the lock GrpcApplePollset.mu before calling this
-/// function.
-static void pollset_shutdown(grpc_pollset* pollset, grpc_closure* closure) {
- GRPC_POLLING_TRACE("pollset shutdown: %p", pollset);
-
- GrpcApplePollset* apple_pollset =
- reinterpret_cast<GrpcApplePollset*>(pollset);
- apple_pollset->is_shutdown = true;
- pollset_kick(pollset, GRPC_POLLSET_KICK_BROADCAST);
-
- // If there is any worker blocked, shutdown will be done asynchronously.
- if (apple_pollset->workers.empty()) {
- grpc_core::ExecCtx::Run(DEBUG_LOCATION, closure, GRPC_ERROR_NONE);
- } else {
- apple_pollset->shutdown_closure = closure;
- }
-}
-
-static void pollset_destroy(grpc_pollset* pollset) {
- GRPC_POLLING_TRACE("pollset destroy: %p", pollset);
- GrpcApplePollset* apple_pollset =
- reinterpret_cast<GrpcApplePollset*>(pollset);
- apple_pollset->~GrpcApplePollset();
-}
-
-size_t pollset_size(void) { return sizeof(GrpcApplePollset); }
-
-grpc_pollset_vtable grpc_apple_pollset_vtable = {
- pollset_global_init, pollset_global_shutdown,
- pollset_init, pollset_shutdown,
- pollset_destroy, pollset_work,
- pollset_kick, pollset_size};
-
-// pollset_set implementation
-
-grpc_pollset_set* pollset_set_create(void) { return nullptr; }
-void pollset_set_destroy(grpc_pollset_set* pollset_set) {}
-void pollset_set_add_pollset(grpc_pollset_set* pollset_set,
- grpc_pollset* pollset) {}
-void pollset_set_del_pollset(grpc_pollset_set* pollset_set,
- grpc_pollset* pollset) {}
-void pollset_set_add_pollset_set(grpc_pollset_set* bag,
- grpc_pollset_set* item) {}
-void pollset_set_del_pollset_set(grpc_pollset_set* bag,
- grpc_pollset_set* item) {}
-
-grpc_pollset_set_vtable grpc_apple_pollset_set_vtable = {
- pollset_set_create, pollset_set_destroy,
- pollset_set_add_pollset, pollset_set_del_pollset,
- pollset_set_add_pollset_set, pollset_set_del_pollset_set};
-
-#endif
+/*
+ *
+ * Copyright 2020 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/// Event engine based on Apple's CFRunLoop API family. If the CFRunLoop engine
+/// is enabled (see iomgr_posix_cfstream.cc), a global thread is started to
+/// handle and trigger all the CFStream events. The CFStream streams register
+/// themselves with the run loop with functions grpc_apple_register_read_stream
+/// and grpc_apple_register_read_stream. Pollsets are dummy and block on a
+/// condition variable in pollset_work().
+
+#include <grpc/support/port_platform.h>
+
+#include "src/core/lib/iomgr/port.h"
+
+#ifdef GRPC_APPLE_EV
+
+#include <CoreFoundation/CoreFoundation.h>
+
+#include <list>
+
+#include "src/core/lib/gprpp/thd.h"
+#include "src/core/lib/iomgr/ev_apple.h"
+
+grpc_core::DebugOnlyTraceFlag grpc_apple_polling_trace(false, "apple_polling");
+
+#ifndef NDEBUG
+#define GRPC_POLLING_TRACE(format, ...) \
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_apple_polling_trace)) { \
+ gpr_log(GPR_DEBUG, "(polling) " format, __VA_ARGS__); \
+ }
+#else
+#define GRPC_POLLING_TRACE(...)
+#endif // NDEBUG
+
+#define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker*)1)
+
+struct GlobalRunLoopContext {
+ grpc_core::CondVar init_cv;
+ grpc_core::CondVar input_source_cv;
+
+ grpc_core::Mutex mu;
+
+ // Whether an input source registration is pending. Protected by mu.
+ bool input_source_registered = false;
+
+ // The reference to the global run loop object. Protected by mu.
+ CFRunLoopRef run_loop;
+
+ // Whether the pollset has been globally shut down. Protected by mu.
+ bool is_shutdown = false;
+};
+
+struct GrpcAppleWorker {
+ // The condition varible to kick the worker. Works with the pollset's lock
+ // (GrpcApplePollset.mu).
+ grpc_core::CondVar cv;
+
+ // Whether the worker is kicked. Protected by the pollset's lock
+ // (GrpcApplePollset.mu).
+ bool kicked = false;
+};
+
+struct GrpcApplePollset {
+ grpc_core::Mutex mu;
+
+ // Tracks the current workers in the pollset. Protected by mu.
+ std::list<GrpcAppleWorker*> workers;
+
+ // Whether the pollset is shut down. Protected by mu.
+ bool is_shutdown = false;
+
+ // Closure to call when shutdown is done. Protected by mu.
+ grpc_closure* shutdown_closure;
+
+ // Whether there's an outstanding kick that was not processed. Protected by
+ // mu.
+ bool kicked_without_poller = false;
+};
+
+static GlobalRunLoopContext* gGlobalRunLoopContext = nullptr;
+static grpc_core::Thread* gGlobalRunLoopThread = nullptr;
+
+/// Register the stream with the dispatch queue. Callbacks of the stream will be
+/// issued to the dispatch queue when a network event happens and will be
+/// managed by Grand Central Dispatch.
+static void grpc_apple_register_read_stream_queue(
+ CFReadStreamRef read_stream, dispatch_queue_t dispatch_queue) {
+ CFReadStreamSetDispatchQueue(read_stream, dispatch_queue);
+}
+
+/// Register the stream with the dispatch queue. Callbacks of the stream will be
+/// issued to the dispatch queue when a network event happens and will be
+/// managed by Grand Central Dispatch.
+static void grpc_apple_register_write_stream_queue(
+ CFWriteStreamRef write_stream, dispatch_queue_t dispatch_queue) {
+ CFWriteStreamSetDispatchQueue(write_stream, dispatch_queue);
+}
+
+/// Register the stream with the global run loop. Callbacks of the stream will
+/// be issued to the run loop when a network event happens and will be driven by
+/// the global run loop thread gGlobalRunLoopThread.
+static void grpc_apple_register_read_stream_run_loop(
+ CFReadStreamRef read_stream, dispatch_queue_t dispatch_queue) {
+ GRPC_POLLING_TRACE("Register read stream: %p", read_stream);
+ grpc_core::MutexLock lock(&gGlobalRunLoopContext->mu);
+ CFReadStreamScheduleWithRunLoop(read_stream, gGlobalRunLoopContext->run_loop,
+ kCFRunLoopDefaultMode);
+ gGlobalRunLoopContext->input_source_registered = true;
+ gGlobalRunLoopContext->input_source_cv.Signal();
+}
+
+/// Register the stream with the global run loop. Callbacks of the stream will
+/// be issued to the run loop when a network event happens, and will be driven
+/// by the global run loop thread gGlobalRunLoopThread.
+static void grpc_apple_register_write_stream_run_loop(
+ CFWriteStreamRef write_stream, dispatch_queue_t dispatch_queue) {
+ GRPC_POLLING_TRACE("Register write stream: %p", write_stream);
+ grpc_core::MutexLock lock(&gGlobalRunLoopContext->mu);
+ CFWriteStreamScheduleWithRunLoop(
+ write_stream, gGlobalRunLoopContext->run_loop, kCFRunLoopDefaultMode);
+ gGlobalRunLoopContext->input_source_registered = true;
+ gGlobalRunLoopContext->input_source_cv.Signal();
+}
+
+/// The default implementation of stream registration is to register the stream
+/// to a dispatch queue. However, if the CFRunLoop based pollset is enabled (by
+/// macro and environment variable, see docs in iomgr_posix_cfstream.cc), the
+/// CFStream streams are registered with the global run loop instead (see
+/// pollset_global_init below).
+static void (*grpc_apple_register_read_stream_impl)(
+ CFReadStreamRef, dispatch_queue_t) = grpc_apple_register_read_stream_queue;
+static void (*grpc_apple_register_write_stream_impl)(CFWriteStreamRef,
+ dispatch_queue_t) =
+ grpc_apple_register_write_stream_queue;
+
+void grpc_apple_register_read_stream(CFReadStreamRef read_stream,
+ dispatch_queue_t dispatch_queue) {
+ grpc_apple_register_read_stream_impl(read_stream, dispatch_queue);
+}
+
+void grpc_apple_register_write_stream(CFWriteStreamRef write_stream,
+ dispatch_queue_t dispatch_queue) {
+ grpc_apple_register_write_stream_impl(write_stream, dispatch_queue);
+}
+
+/// Drive the run loop in a global singleton thread until the global run loop is
+/// shutdown.
+static void GlobalRunLoopFunc(void* arg) {
+ grpc_core::ReleasableMutexLock lock(&gGlobalRunLoopContext->mu);
+ gGlobalRunLoopContext->run_loop = CFRunLoopGetCurrent();
+ gGlobalRunLoopContext->init_cv.Signal();
+
+ while (!gGlobalRunLoopContext->is_shutdown) {
+ // CFRunLoopRun() will return immediately if no stream is registered on it.
+ // So we wait on a conditional variable until a stream is registered;
+ // otherwise we'll be running a spinning loop.
+ while (!gGlobalRunLoopContext->input_source_registered) {
+ gGlobalRunLoopContext->input_source_cv.Wait(&gGlobalRunLoopContext->mu);
+ }
+ gGlobalRunLoopContext->input_source_registered = false;
+ lock.Unlock();
+ CFRunLoopRun();
+ lock.Lock();
+ }
+ lock.Unlock();
+}
+
+// pollset implementation
+
+static void pollset_global_init(void) {
+ gGlobalRunLoopContext = new GlobalRunLoopContext;
+
+ grpc_apple_register_read_stream_impl =
+ grpc_apple_register_read_stream_run_loop;
+ grpc_apple_register_write_stream_impl =
+ grpc_apple_register_write_stream_run_loop;
+
+ grpc_core::MutexLock lock(&gGlobalRunLoopContext->mu);
+ gGlobalRunLoopThread =
+ new grpc_core::Thread("apple_ev", GlobalRunLoopFunc, nullptr);
+ gGlobalRunLoopThread->Start();
+ while (gGlobalRunLoopContext->run_loop == NULL)
+ gGlobalRunLoopContext->init_cv.Wait(&gGlobalRunLoopContext->mu);
+}
+
+static void pollset_global_shutdown(void) {
+ {
+ grpc_core::MutexLock lock(&gGlobalRunLoopContext->mu);
+ gGlobalRunLoopContext->is_shutdown = true;
+ CFRunLoopStop(gGlobalRunLoopContext->run_loop);
+ }
+ gGlobalRunLoopThread->Join();
+ delete gGlobalRunLoopThread;
+ delete gGlobalRunLoopContext;
+}
+
+/// The caller must acquire the lock GrpcApplePollset.mu before calling this
+/// function. The lock may be temporarily released when waiting on the condition
+/// variable but will be re-acquired before the function returns.
+///
+/// The Apple pollset simply waits on a condition variable until it is kicked.
+/// The network events are handled in the global run loop thread. Processing of
+/// these events will eventually trigger the kick.
+static grpc_error* pollset_work(grpc_pollset* pollset,
+ grpc_pollset_worker** worker,
+ grpc_millis deadline) {
+ GRPC_POLLING_TRACE("pollset work: %p, worker: %p, deadline: %" PRIu64,
+ pollset, worker, deadline);
+ GrpcApplePollset* apple_pollset =
+ reinterpret_cast<GrpcApplePollset*>(pollset);
+ GrpcAppleWorker actual_worker;
+ if (worker) {
+ *worker = reinterpret_cast<grpc_pollset_worker*>(&actual_worker);
+ }
+
+ if (apple_pollset->kicked_without_poller) {
+ // Process the outstanding kick and reset the flag. Do not block.
+ apple_pollset->kicked_without_poller = false;
+ } else {
+ // Block until kicked, timed out, or the pollset shuts down.
+ apple_pollset->workers.push_front(&actual_worker);
+ auto it = apple_pollset->workers.begin();
+
+ while (!actual_worker.kicked && !apple_pollset->is_shutdown) {
+ if (actual_worker.cv.Wait(
+ &apple_pollset->mu,
+ grpc_millis_to_timespec(deadline, GPR_CLOCK_REALTIME))) {
+ // timed out
+ break;
+ }
+ }
+
+ apple_pollset->workers.erase(it);
+
+ // If the pollset is shut down asynchronously and this is the last pending
+ // worker, the shutdown process is complete at this moment and the shutdown
+ // callback will be called.
+ if (apple_pollset->is_shutdown && apple_pollset->workers.empty()) {
+ grpc_core::ExecCtx::Run(DEBUG_LOCATION, apple_pollset->shutdown_closure,
+ GRPC_ERROR_NONE);
+ }
+ }
+
+ return GRPC_ERROR_NONE;
+}
+
+/// Kick a specific worker. The caller must acquire the lock GrpcApplePollset.mu
+/// before calling this function.
+static void kick_worker(GrpcAppleWorker* worker) {
+ worker->kicked = true;
+ worker->cv.Signal();
+}
+
+/// The caller must acquire the lock GrpcApplePollset.mu before calling this
+/// function. The kick action simply signals the condition variable of the
+/// worker.
+static grpc_error* pollset_kick(grpc_pollset* pollset,
+ grpc_pollset_worker* specific_worker) {
+ GrpcApplePollset* apple_pollset =
+ reinterpret_cast<GrpcApplePollset*>(pollset);
+
+ GRPC_POLLING_TRACE("pollset kick: %p, worker:%p", pollset, specific_worker);
+
+ if (specific_worker == nullptr) {
+ if (apple_pollset->workers.empty()) {
+ apple_pollset->kicked_without_poller = true;
+ } else {
+ GrpcAppleWorker* actual_worker = apple_pollset->workers.front();
+ kick_worker(actual_worker);
+ }
+ } else if (specific_worker == GRPC_POLLSET_KICK_BROADCAST) {
+ for (auto& actual_worker : apple_pollset->workers) {
+ kick_worker(actual_worker);
+ }
+ } else {
+ GrpcAppleWorker* actual_worker =
+ reinterpret_cast<GrpcAppleWorker*>(specific_worker);
+ kick_worker(actual_worker);
+ }
+
+ return GRPC_ERROR_NONE;
+}
+
+static void pollset_init(grpc_pollset* pollset, gpr_mu** mu) {
+ GRPC_POLLING_TRACE("pollset init: %p", pollset);
+ GrpcApplePollset* apple_pollset = new (pollset) GrpcApplePollset();
+ *mu = apple_pollset->mu.get();
+}
+
+/// The caller must acquire the lock GrpcApplePollset.mu before calling this
+/// function.
+static void pollset_shutdown(grpc_pollset* pollset, grpc_closure* closure) {
+ GRPC_POLLING_TRACE("pollset shutdown: %p", pollset);
+
+ GrpcApplePollset* apple_pollset =
+ reinterpret_cast<GrpcApplePollset*>(pollset);
+ apple_pollset->is_shutdown = true;
+ pollset_kick(pollset, GRPC_POLLSET_KICK_BROADCAST);
+
+ // If there is any worker blocked, shutdown will be done asynchronously.
+ if (apple_pollset->workers.empty()) {
+ grpc_core::ExecCtx::Run(DEBUG_LOCATION, closure, GRPC_ERROR_NONE);
+ } else {
+ apple_pollset->shutdown_closure = closure;
+ }
+}
+
+static void pollset_destroy(grpc_pollset* pollset) {
+ GRPC_POLLING_TRACE("pollset destroy: %p", pollset);
+ GrpcApplePollset* apple_pollset =
+ reinterpret_cast<GrpcApplePollset*>(pollset);
+ apple_pollset->~GrpcApplePollset();
+}
+
+size_t pollset_size(void) { return sizeof(GrpcApplePollset); }
+
+grpc_pollset_vtable grpc_apple_pollset_vtable = {
+ pollset_global_init, pollset_global_shutdown,
+ pollset_init, pollset_shutdown,
+ pollset_destroy, pollset_work,
+ pollset_kick, pollset_size};
+
+// pollset_set implementation
+
+grpc_pollset_set* pollset_set_create(void) { return nullptr; }
+void pollset_set_destroy(grpc_pollset_set* pollset_set) {}
+void pollset_set_add_pollset(grpc_pollset_set* pollset_set,
+ grpc_pollset* pollset) {}
+void pollset_set_del_pollset(grpc_pollset_set* pollset_set,
+ grpc_pollset* pollset) {}
+void pollset_set_add_pollset_set(grpc_pollset_set* bag,
+ grpc_pollset_set* item) {}
+void pollset_set_del_pollset_set(grpc_pollset_set* bag,
+ grpc_pollset_set* item) {}
+
+grpc_pollset_set_vtable grpc_apple_pollset_set_vtable = {
+ pollset_set_create, pollset_set_destroy,
+ pollset_set_add_pollset, pollset_set_del_pollset,
+ pollset_set_add_pollset_set, pollset_set_del_pollset_set};
+
+#endif
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/ev_apple.h b/contrib/libs/grpc/src/core/lib/iomgr/ev_apple.h
index 74692077fb..a05f91ce15 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/ev_apple.h
+++ b/contrib/libs/grpc/src/core/lib/iomgr/ev_apple.h
@@ -1,43 +1,43 @@
-/*
- *
- * Copyright 2020 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef GRPC_CORE_LIB_IOMGR_EV_APPLE_H
-#define GRPC_CORE_LIB_IOMGR_EV_APPLE_H
-
-#include <grpc/support/port_platform.h>
-
-#ifdef GRPC_APPLE_EV
-
-#include <CoreFoundation/CoreFoundation.h>
-
-#include "src/core/lib/iomgr/pollset.h"
-#include "src/core/lib/iomgr/pollset_set.h"
-
-void grpc_apple_register_read_stream(CFReadStreamRef read_stream,
- dispatch_queue_t dispatch_queue);
-
-void grpc_apple_register_write_stream(CFWriteStreamRef write_stream,
- dispatch_queue_t dispatch_queue);
-
-extern grpc_pollset_vtable grpc_apple_pollset_vtable;
-
-extern grpc_pollset_set_vtable grpc_apple_pollset_set_vtable;
-
-#endif
-
-#endif
+/*
+ *
+ * Copyright 2020 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef GRPC_CORE_LIB_IOMGR_EV_APPLE_H
+#define GRPC_CORE_LIB_IOMGR_EV_APPLE_H
+
+#include <grpc/support/port_platform.h>
+
+#ifdef GRPC_APPLE_EV
+
+#include <CoreFoundation/CoreFoundation.h>
+
+#include "src/core/lib/iomgr/pollset.h"
+#include "src/core/lib/iomgr/pollset_set.h"
+
+void grpc_apple_register_read_stream(CFReadStreamRef read_stream,
+ dispatch_queue_t dispatch_queue);
+
+void grpc_apple_register_write_stream(CFWriteStreamRef write_stream,
+ dispatch_queue_t dispatch_queue);
+
+extern grpc_pollset_vtable grpc_apple_pollset_vtable;
+
+extern grpc_pollset_set_vtable grpc_apple_pollset_set_vtable;
+
+#endif
+
+#endif
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/ev_epoll1_linux.cc b/contrib/libs/grpc/src/core/lib/iomgr/ev_epoll1_linux.cc
index bebd39665b..f09dcee0c0 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/ev_epoll1_linux.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/ev_epoll1_linux.cc
@@ -38,13 +38,13 @@
#include <sys/socket.h>
#include <unistd.h>
-#include <util/generic/string.h>
-#include <vector>
-
-#include "y_absl/strings/str_cat.h"
-#include "y_absl/strings/str_format.h"
-#include "y_absl/strings/str_join.h"
-
+#include <util/generic/string.h>
+#include <vector>
+
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/str_join.h"
+
#include <grpc/support/alloc.h>
#include <grpc/support/cpu.h>
@@ -352,12 +352,12 @@ static grpc_fd* fd_create(int fd, const char* name, bool track_err) {
new_fd->freelist_next = nullptr;
- TString fd_name = y_absl::StrCat(name, " fd=", fd);
- grpc_iomgr_register_object(&new_fd->iomgr_object, fd_name.c_str());
+ TString fd_name = y_absl::StrCat(name, " fd=", fd);
+ grpc_iomgr_register_object(&new_fd->iomgr_object, fd_name.c_str());
fork_fd_list_add_grpc_fd(new_fd);
#ifndef NDEBUG
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_fd_refcount)) {
- gpr_log(GPR_DEBUG, "FD %d %p create %s", fd, new_fd, fd_name.c_str());
+ gpr_log(GPR_DEBUG, "FD %d %p create %s", fd, new_fd, fd_name.c_str());
}
#endif
@@ -1068,23 +1068,23 @@ static grpc_error* pollset_kick(grpc_pollset* pollset,
GRPC_STATS_INC_POLLSET_KICK();
grpc_error* ret_err = GRPC_ERROR_NONE;
if (GRPC_TRACE_FLAG_ENABLED(grpc_polling_trace)) {
- std::vector<TString> log;
- log.push_back(y_absl::StrFormat(
- "PS:%p KICK:%p curps=%p curworker=%p root=%p", pollset, specific_worker,
- (void*)gpr_tls_get(&g_current_thread_pollset),
- (void*)gpr_tls_get(&g_current_thread_worker), pollset->root_worker));
+ std::vector<TString> log;
+ log.push_back(y_absl::StrFormat(
+ "PS:%p KICK:%p curps=%p curworker=%p root=%p", pollset, specific_worker,
+ (void*)gpr_tls_get(&g_current_thread_pollset),
+ (void*)gpr_tls_get(&g_current_thread_worker), pollset->root_worker));
if (pollset->root_worker != nullptr) {
- log.push_back(y_absl::StrFormat(
- " {kick_state=%s next=%p {kick_state=%s}}",
- kick_state_string(pollset->root_worker->state),
- pollset->root_worker->next,
- kick_state_string(pollset->root_worker->next->state)));
+ log.push_back(y_absl::StrFormat(
+ " {kick_state=%s next=%p {kick_state=%s}}",
+ kick_state_string(pollset->root_worker->state),
+ pollset->root_worker->next,
+ kick_state_string(pollset->root_worker->next->state)));
}
if (specific_worker != nullptr) {
- log.push_back(y_absl::StrFormat(" worker_kick_state=%s",
- kick_state_string(specific_worker->state)));
+ log.push_back(y_absl::StrFormat(" worker_kick_state=%s",
+ kick_state_string(specific_worker->state)));
}
- gpr_log(GPR_DEBUG, "%s", y_absl::StrJoin(log, "").c_str());
+ gpr_log(GPR_DEBUG, "%s", y_absl::StrJoin(log, "").c_str());
}
if (specific_worker == nullptr) {
@@ -1113,8 +1113,8 @@ static grpc_error* pollset_kick(grpc_pollset* pollset,
}
SET_KICK_STATE(next_worker, KICKED);
goto done;
- } else if (root_worker == next_worker && // only try and wake up a poller
- // if there is no next worker
+ } else if (root_worker == next_worker && // only try and wake up a poller
+ // if there is no next worker
root_worker == (grpc_pollset_worker*)gpr_atm_no_barrier_load(
&g_active_poller)) {
GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD();
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/ev_epollex_linux.cc b/contrib/libs/grpc/src/core/lib/iomgr/ev_epollex_linux.cc
index 94033e7ca7..2dd9bbdffd 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/ev_epollex_linux.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/ev_epollex_linux.cc
@@ -38,12 +38,12 @@
#include <sys/syscall.h>
#include <unistd.h>
-#include <util/generic/string.h>
-
-#include "y_absl/container/inlined_vector.h"
-#include "y_absl/strings/str_cat.h"
-#include "y_absl/strings/str_format.h"
-
+#include <util/generic/string.h>
+
+#include "y_absl/container/inlined_vector.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_format.h"
+
#include <grpc/support/alloc.h>
#include "src/core/lib/debug/stats.h"
@@ -124,10 +124,10 @@ static const char* pollable_type_string(pollable_type t) {
return "<invalid>";
}
-static TString pollable_desc(pollable* p) {
- return y_absl::StrFormat("type=%s epfd=%d wakeup=%d",
- pollable_type_string(p->type), p->epfd,
- p->wakeup.read_fd);
+static TString pollable_desc(pollable* p) {
+ return y_absl::StrFormat("type=%s epfd=%d wakeup=%d",
+ pollable_type_string(p->type), p->epfd,
+ p->wakeup.read_fd);
}
/// Shared empty pollable - used by pollset to poll on until the first fd is
@@ -169,11 +169,11 @@ struct grpc_fd {
write_closure.InitEvent();
error_closure.InitEvent();
- TString fd_name = y_absl::StrCat(name, " fd=", fd);
- grpc_iomgr_register_object(&iomgr_object, fd_name.c_str());
+ TString fd_name = y_absl::StrCat(name, " fd=", fd);
+ grpc_iomgr_register_object(&iomgr_object, fd_name.c_str());
#ifndef NDEBUG
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_fd_refcount)) {
- gpr_log(GPR_DEBUG, "FD %d %p create %s", fd, this, fd_name.c_str());
+ gpr_log(GPR_DEBUG, "FD %d %p create %s", fd, this, fd_name.c_str());
}
#endif
}
@@ -187,15 +187,15 @@ struct grpc_fd {
grpc_iomgr_unregister_object(&iomgr_object);
POLLABLE_UNREF(pollable_obj, "fd_pollable");
-
- // To clear out the allocations of pollset_fds, we need to swap its
- // contents with a newly-constructed (and soon to be destructed) local
- // variable of its same type. This is because InlinedVector::clear is _not_
- // guaranteed to actually free up allocations and this is important since
- // this object doesn't have a conventional destructor.
- y_absl::InlinedVector<int, 1> pollset_fds_tmp;
- pollset_fds_tmp.swap(pollset_fds);
-
+
+ // To clear out the allocations of pollset_fds, we need to swap its
+ // contents with a newly-constructed (and soon to be destructed) local
+ // variable of its same type. This is because InlinedVector::clear is _not_
+ // guaranteed to actually free up allocations and this is important since
+ // this object doesn't have a conventional destructor.
+ y_absl::InlinedVector<int, 1> pollset_fds_tmp;
+ pollset_fds_tmp.swap(pollset_fds);
+
gpr_mu_destroy(&pollable_mu);
gpr_mu_destroy(&orphan_mu);
@@ -237,8 +237,8 @@ struct grpc_fd {
// Protects pollable_obj and pollset_fds.
gpr_mu pollable_mu;
- y_absl::InlinedVector<int, 1> pollset_fds; // Used in PO_MULTI.
- pollable* pollable_obj = nullptr; // Used in PO_FD.
+ y_absl::InlinedVector<int, 1> pollset_fds; // Used in PO_MULTI.
+ pollable* pollable_obj = nullptr; // Used in PO_FD.
grpc_core::LockfreeEvent read_closure;
grpc_core::LockfreeEvent write_closure;
@@ -929,8 +929,8 @@ static grpc_error* pollable_epoll(pollable* p, grpc_millis deadline) {
int timeout = poll_deadline_to_millis_timeout(deadline);
if (GRPC_TRACE_FLAG_ENABLED(grpc_polling_trace)) {
- gpr_log(GPR_INFO, "POLLABLE:%p[%s] poll for %dms", p,
- pollable_desc(p).c_str(), timeout);
+ gpr_log(GPR_INFO, "POLLABLE:%p[%s] poll for %dms", p,
+ pollable_desc(p).c_str(), timeout);
}
if (timeout != 0) {
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/ev_poll_posix.cc b/contrib/libs/grpc/src/core/lib/iomgr/ev_poll_posix.cc
index 3c296e2418..a46ab7ea0d 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/ev_poll_posix.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/ev_poll_posix.cc
@@ -32,10 +32,10 @@
#include <sys/socket.h>
#include <unistd.h>
-#include <util/generic/string.h>
-
-#include "y_absl/strings/str_cat.h"
-
+#include <util/generic/string.h>
+
+#include "y_absl/strings/str_cat.h"
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@@ -310,9 +310,9 @@ static void fork_fd_list_add_wakeup_fd(grpc_cached_wakeup_fd* fd) {
}
}
-/*******************************************************************************
- * fd_posix.c
- */
+/*******************************************************************************
+ * fd_posix.c
+ */
#ifndef NDEBUG
#define REF_BY(fd, n, reason) ref_by(fd, n, reason, __FILE__, __LINE__)
@@ -384,8 +384,8 @@ static grpc_fd* fd_create(int fd, const char* name, bool track_err) {
r->released = 0;
gpr_atm_no_barrier_store(&r->pollhup, 0);
- TString name2 = y_absl::StrCat(name, " fd=", fd);
- grpc_iomgr_register_object(&r->iomgr_object, name2.c_str());
+ TString name2 = y_absl::StrCat(name, " fd=", fd);
+ grpc_iomgr_register_object(&r->iomgr_object, name2.c_str());
fork_fd_list_add_grpc_fd(r);
return r;
}
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/exec_ctx.h b/contrib/libs/grpc/src/core/lib/iomgr/exec_ctx.h
index f66910c4f1..6b4e184cad 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/exec_ctx.h
+++ b/contrib/libs/grpc/src/core/lib/iomgr/exec_ctx.h
@@ -21,8 +21,8 @@
#include <grpc/support/port_platform.h>
-#include <limits>
-
+#include <limits>
+
#include <grpc/impl/codegen/grpc_types.h>
#include <grpc/support/atm.h>
#include <grpc/support/cpu.h>
@@ -134,12 +134,12 @@ class ExecCtx {
ExecCtx(const ExecCtx&) = delete;
ExecCtx& operator=(const ExecCtx&) = delete;
- unsigned starting_cpu() {
- if (starting_cpu_ == std::numeric_limits<unsigned>::max()) {
- starting_cpu_ = gpr_cpu_current_cpu();
- }
- return starting_cpu_;
- }
+ unsigned starting_cpu() {
+ if (starting_cpu_ == std::numeric_limits<unsigned>::max()) {
+ starting_cpu_ = gpr_cpu_current_cpu();
+ }
+ return starting_cpu_;
+ }
struct CombinerData {
/* currently active combiner: updated only via combiner.c */
@@ -246,7 +246,7 @@ class ExecCtx {
CombinerData combiner_data_ = {nullptr, nullptr};
uintptr_t flags_;
- unsigned starting_cpu_ = std::numeric_limits<unsigned>::max();
+ unsigned starting_cpu_ = std::numeric_limits<unsigned>::max();
bool now_is_valid_ = false;
grpc_millis now_ = 0;
@@ -331,15 +331,15 @@ class ApplicationCallbackExecCtx {
}
}
- uintptr_t Flags() { return flags_; }
-
- static ApplicationCallbackExecCtx* Get() {
- return reinterpret_cast<ApplicationCallbackExecCtx*>(
- gpr_tls_get(&callback_exec_ctx_));
- }
-
+ uintptr_t Flags() { return flags_; }
+
+ static ApplicationCallbackExecCtx* Get() {
+ return reinterpret_cast<ApplicationCallbackExecCtx*>(
+ gpr_tls_get(&callback_exec_ctx_));
+ }
+
static void Set(ApplicationCallbackExecCtx* exec_ctx, uintptr_t flags) {
- if (Get() == nullptr) {
+ if (Get() == nullptr) {
if (!(GRPC_APP_CALLBACK_EXEC_CTX_FLAG_IS_INTERNAL_THREAD & flags)) {
grpc_core::Fork::IncExecCtxCount();
}
@@ -352,7 +352,7 @@ class ApplicationCallbackExecCtx {
functor->internal_success = is_success;
functor->internal_next = nullptr;
- ApplicationCallbackExecCtx* ctx = Get();
+ ApplicationCallbackExecCtx* ctx = Get();
if (ctx->head_ == nullptr) {
ctx->head_ = functor;
@@ -369,8 +369,8 @@ class ApplicationCallbackExecCtx {
/** Global shutdown for ApplicationCallbackExecCtx. Called by init. */
static void GlobalShutdown(void) { gpr_tls_destroy(&callback_exec_ctx_); }
- static bool Available() { return Get() != nullptr; }
-
+ static bool Available() { return Get() != nullptr; }
+
private:
uintptr_t flags_{0u};
grpc_experimental_completion_queue_functor* head_{nullptr};
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/executor.cc b/contrib/libs/grpc/src/core/lib/iomgr/executor.cc
index e0b8581992..10b2f948ec 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/executor.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/executor.cc
@@ -154,7 +154,7 @@ void Executor::SetThreading(bool threading) {
if (threading) {
if (curr_num_threads > 0) {
- EXECUTOR_TRACE("(%s) SetThreading(true). curr_num_threads > 0", name_);
+ EXECUTOR_TRACE("(%s) SetThreading(true). curr_num_threads > 0", name_);
return;
}
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/fork_posix.cc b/contrib/libs/grpc/src/core/lib/iomgr/fork_posix.cc
index fec48ccb3f..82654b5a88 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/fork_posix.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/fork_posix.cc
@@ -22,10 +22,10 @@
#ifdef GRPC_POSIX_FORK
-#ifdef GRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK
-#include <pthread.h>
-#endif
-
+#ifdef GRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK
+#include <pthread.h>
+#endif
+
#include <string.h>
#include <grpc/fork.h>
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/iomgr_posix_cfstream.cc b/contrib/libs/grpc/src/core/lib/iomgr/iomgr_posix_cfstream.cc
index feae0996ba..30c44edb5d 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/iomgr_posix_cfstream.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/iomgr_posix_cfstream.cc
@@ -16,20 +16,20 @@
*
*/
-/// CFStream is build-enabled on iOS by default and disabled by default on other
-/// platforms (see port_platform.h). To enable CFStream build on another
-/// platform, the users need to define macro "GRPC_CFSTREAM=1" when building
-/// gRPC.
-///
-/// When CFStream is to be built (either by default on iOS or by macro on other
-/// platforms), the users can disable CFStream with environment variable
-/// "grpc_cfstream=0". This will let gRPC to fallback to use POSIX sockets. In
-/// addition, the users may choose to use an alternative CFRunLoop based pollset
-/// "ev_apple" by setting environment variable "GRPC_CFSTREAM_RUN_LOOP=1". This
-/// pollset resolves a bug from Apple when CFStream streams dispatch events to
-/// dispatch queues. The caveat of this pollset is that users may not be able to
-/// run a gRPC server in the same process.
-
+/// CFStream is build-enabled on iOS by default and disabled by default on other
+/// platforms (see port_platform.h). To enable CFStream build on another
+/// platform, the users need to define macro "GRPC_CFSTREAM=1" when building
+/// gRPC.
+///
+/// When CFStream is to be built (either by default on iOS or by macro on other
+/// platforms), the users can disable CFStream with environment variable
+/// "grpc_cfstream=0". This will let gRPC to fallback to use POSIX sockets. In
+/// addition, the users may choose to use an alternative CFRunLoop based pollset
+/// "ev_apple" by setting environment variable "GRPC_CFSTREAM_RUN_LOOP=1". This
+/// pollset resolves a bug from Apple when CFStream streams dispatch events to
+/// dispatch queues. The caveat of this pollset is that users may not be able to
+/// run a gRPC server in the same process.
+
#include <grpc/support/port_platform.h>
#include "src/core/lib/iomgr/port.h"
@@ -37,7 +37,7 @@
#ifdef GRPC_CFSTREAM_IOMGR
#include "src/core/lib/debug/trace.h"
-#include "src/core/lib/iomgr/ev_apple.h"
+#include "src/core/lib/iomgr/ev_apple.h"
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/iomgr_internal.h"
#include "src/core/lib/iomgr/iomgr_posix.h"
@@ -48,7 +48,7 @@
#include "src/core/lib/iomgr/timer.h"
static const char* grpc_cfstream_env_var = "grpc_cfstream";
-static const char* grpc_cfstream_run_loop_env_var = "GRPC_CFSTREAM_RUN_LOOP";
+static const char* grpc_cfstream_run_loop_env_var = "GRPC_CFSTREAM_RUN_LOOP";
extern grpc_tcp_server_vtable grpc_posix_tcp_server_vtable;
extern grpc_tcp_client_vtable grpc_posix_tcp_client_vtable;
@@ -58,33 +58,33 @@ extern grpc_pollset_vtable grpc_posix_pollset_vtable;
extern grpc_pollset_set_vtable grpc_posix_pollset_set_vtable;
extern grpc_address_resolver_vtable grpc_posix_resolver_vtable;
-static void apple_iomgr_platform_init(void) { grpc_pollset_global_init(); }
-
-static void apple_iomgr_platform_flush(void) {}
-
-static void apple_iomgr_platform_shutdown(void) {
- grpc_pollset_global_shutdown();
-}
-
-static void apple_iomgr_platform_shutdown_background_closure(void) {}
-
-static bool apple_iomgr_platform_is_any_background_poller_thread(void) {
- return false;
-}
-
-static bool apple_iomgr_platform_add_closure_to_background_poller(
- grpc_closure* closure, grpc_error* error) {
- return false;
-}
-
-static grpc_iomgr_platform_vtable apple_vtable = {
- apple_iomgr_platform_init,
- apple_iomgr_platform_flush,
- apple_iomgr_platform_shutdown,
- apple_iomgr_platform_shutdown_background_closure,
- apple_iomgr_platform_is_any_background_poller_thread,
- apple_iomgr_platform_add_closure_to_background_poller};
-
+static void apple_iomgr_platform_init(void) { grpc_pollset_global_init(); }
+
+static void apple_iomgr_platform_flush(void) {}
+
+static void apple_iomgr_platform_shutdown(void) {
+ grpc_pollset_global_shutdown();
+}
+
+static void apple_iomgr_platform_shutdown_background_closure(void) {}
+
+static bool apple_iomgr_platform_is_any_background_poller_thread(void) {
+ return false;
+}
+
+static bool apple_iomgr_platform_add_closure_to_background_poller(
+ grpc_closure* closure, grpc_error* error) {
+ return false;
+}
+
+static grpc_iomgr_platform_vtable apple_vtable = {
+ apple_iomgr_platform_init,
+ apple_iomgr_platform_flush,
+ apple_iomgr_platform_shutdown,
+ apple_iomgr_platform_shutdown_background_closure,
+ apple_iomgr_platform_is_any_background_poller_thread,
+ apple_iomgr_platform_add_closure_to_background_poller};
+
static void iomgr_platform_init(void) {
grpc_wakeup_fd_global_init();
grpc_event_engine_init();
@@ -119,53 +119,53 @@ static grpc_iomgr_platform_vtable vtable = {
iomgr_platform_add_closure_to_background_poller};
void grpc_set_default_iomgr_platform() {
- char* enable_cfstream_str = getenv(grpc_cfstream_env_var);
- bool enable_cfstream =
- enable_cfstream_str == nullptr || enable_cfstream_str[0] != '0';
- char* enable_cfstream_run_loop_str = getenv(grpc_cfstream_run_loop_env_var);
- // CFStream run-loop is disabled by default. The user has to enable it
- // explicitly with environment variable.
- bool enable_cfstream_run_loop = enable_cfstream_run_loop_str != nullptr &&
- enable_cfstream_run_loop_str[0] == '1';
- if (!enable_cfstream) {
- // Use POSIX sockets for both client and server
- grpc_set_tcp_client_impl(&grpc_posix_tcp_client_vtable);
- grpc_set_tcp_server_impl(&grpc_posix_tcp_server_vtable);
- grpc_set_pollset_vtable(&grpc_posix_pollset_vtable);
- grpc_set_pollset_set_vtable(&grpc_posix_pollset_set_vtable);
- grpc_set_iomgr_platform_vtable(&vtable);
- } else if (enable_cfstream && !enable_cfstream_run_loop) {
- // Use CFStream with dispatch queue for client; use POSIX sockets for server
- grpc_set_tcp_client_impl(&grpc_cfstream_client_vtable);
- grpc_set_tcp_server_impl(&grpc_posix_tcp_server_vtable);
- grpc_set_pollset_vtable(&grpc_posix_pollset_vtable);
- grpc_set_pollset_set_vtable(&grpc_posix_pollset_set_vtable);
- grpc_set_iomgr_platform_vtable(&vtable);
- } else {
- // Use CFStream with CFRunLoop for client; server not supported
- grpc_set_tcp_client_impl(&grpc_cfstream_client_vtable);
- grpc_set_pollset_vtable(&grpc_apple_pollset_vtable);
- grpc_set_pollset_set_vtable(&grpc_apple_pollset_set_vtable);
- grpc_set_iomgr_platform_vtable(&apple_vtable);
+ char* enable_cfstream_str = getenv(grpc_cfstream_env_var);
+ bool enable_cfstream =
+ enable_cfstream_str == nullptr || enable_cfstream_str[0] != '0';
+ char* enable_cfstream_run_loop_str = getenv(grpc_cfstream_run_loop_env_var);
+ // CFStream run-loop is disabled by default. The user has to enable it
+ // explicitly with environment variable.
+ bool enable_cfstream_run_loop = enable_cfstream_run_loop_str != nullptr &&
+ enable_cfstream_run_loop_str[0] == '1';
+ if (!enable_cfstream) {
+ // Use POSIX sockets for both client and server
+ grpc_set_tcp_client_impl(&grpc_posix_tcp_client_vtable);
+ grpc_set_tcp_server_impl(&grpc_posix_tcp_server_vtable);
+ grpc_set_pollset_vtable(&grpc_posix_pollset_vtable);
+ grpc_set_pollset_set_vtable(&grpc_posix_pollset_set_vtable);
+ grpc_set_iomgr_platform_vtable(&vtable);
+ } else if (enable_cfstream && !enable_cfstream_run_loop) {
+ // Use CFStream with dispatch queue for client; use POSIX sockets for server
+ grpc_set_tcp_client_impl(&grpc_cfstream_client_vtable);
+ grpc_set_tcp_server_impl(&grpc_posix_tcp_server_vtable);
+ grpc_set_pollset_vtable(&grpc_posix_pollset_vtable);
+ grpc_set_pollset_set_vtable(&grpc_posix_pollset_set_vtable);
+ grpc_set_iomgr_platform_vtable(&vtable);
+ } else {
+ // Use CFStream with CFRunLoop for client; server not supported
+ grpc_set_tcp_client_impl(&grpc_cfstream_client_vtable);
+ grpc_set_pollset_vtable(&grpc_apple_pollset_vtable);
+ grpc_set_pollset_set_vtable(&grpc_apple_pollset_set_vtable);
+ grpc_set_iomgr_platform_vtable(&apple_vtable);
}
grpc_set_timer_impl(&grpc_generic_timer_vtable);
grpc_set_resolver_impl(&grpc_posix_resolver_vtable);
}
bool grpc_iomgr_run_in_background() {
- char* enable_cfstream_str = getenv(grpc_cfstream_env_var);
- bool enable_cfstream =
- enable_cfstream_str == nullptr || enable_cfstream_str[0] != '0';
- char* enable_cfstream_run_loop_str = getenv(grpc_cfstream_run_loop_env_var);
- // CFStream run-loop is disabled by default. The user has to enable it
- // explicitly with environment variable.
- bool enable_cfstream_run_loop = enable_cfstream_run_loop_str != nullptr &&
- enable_cfstream_run_loop_str[0] == '1';
- if (enable_cfstream && enable_cfstream_run_loop) {
- return false;
- } else {
- return grpc_event_engine_run_in_background();
- }
+ char* enable_cfstream_str = getenv(grpc_cfstream_env_var);
+ bool enable_cfstream =
+ enable_cfstream_str == nullptr || enable_cfstream_str[0] != '0';
+ char* enable_cfstream_run_loop_str = getenv(grpc_cfstream_run_loop_env_var);
+ // CFStream run-loop is disabled by default. The user has to enable it
+ // explicitly with environment variable.
+ bool enable_cfstream_run_loop = enable_cfstream_run_loop_str != nullptr &&
+ enable_cfstream_run_loop_str[0] == '1';
+ if (enable_cfstream && enable_cfstream_run_loop) {
+ return false;
+ } else {
+ return grpc_event_engine_run_in_background();
+ }
}
#endif /* GRPC_CFSTREAM_IOMGR */
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/is_epollexclusive_available.cc b/contrib/libs/grpc/src/core/lib/iomgr/is_epollexclusive_available.cc
index b9daf1f79c..abc901efbe 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/is_epollexclusive_available.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/is_epollexclusive_available.cc
@@ -93,20 +93,20 @@ bool grpc_is_epollexclusive_available(void) {
close(evfd);
return false;
}
- // Check that EPOLLEXCLUSIVE is supported at all.
- ev.events = static_cast<uint32_t>(EPOLLET | EPOLLIN | EPOLLEXCLUSIVE);
- if (epoll_ctl(fd, EPOLL_CTL_ADD, evfd, &ev) != 0) {
- if (!logged_why_not) {
- gpr_log(GPR_DEBUG,
- "epoll_ctl with EPOLLEXCLUSIVE failed with error: "
- "%d. Not using epollex polling engine.",
- errno);
- logged_why_not = true;
- }
- close(fd);
- close(evfd);
- return false;
- }
+ // Check that EPOLLEXCLUSIVE is supported at all.
+ ev.events = static_cast<uint32_t>(EPOLLET | EPOLLIN | EPOLLEXCLUSIVE);
+ if (epoll_ctl(fd, EPOLL_CTL_ADD, evfd, &ev) != 0) {
+ if (!logged_why_not) {
+ gpr_log(GPR_DEBUG,
+ "epoll_ctl with EPOLLEXCLUSIVE failed with error: "
+ "%d. Not using epollex polling engine.",
+ errno);
+ logged_why_not = true;
+ }
+ close(fd);
+ close(evfd);
+ return false;
+ }
close(evfd);
close(fd);
return true;
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/load_file.cc b/contrib/libs/grpc/src/core/lib/iomgr/load_file.cc
index ed193b56cb..4bed6275dc 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/load_file.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/load_file.cc
@@ -53,7 +53,7 @@ grpc_error* grpc_load_file(const char* filename, int add_null_terminator,
gpr_malloc(contents_size + (add_null_terminator ? 1 : 0)));
bytes_read = fread(contents, 1, contents_size, file);
if (bytes_read < contents_size) {
- gpr_free(contents);
+ gpr_free(contents);
error = GRPC_OS_ERROR(errno, "fread");
GPR_ASSERT(ferror(file));
goto end;
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/parse_address.cc b/contrib/libs/grpc/src/core/lib/iomgr/parse_address.cc
index a1bbacd8f5..af514c81cd 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/parse_address.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/parse_address.cc
@@ -1,238 +1,238 @@
-/*
- *
- * Copyright 2016 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <grpc/support/port_platform.h>
-
-#include "src/core/lib/iomgr/grpc_if_nametoindex.h"
-#include "src/core/lib/iomgr/parse_address.h"
-#include "src/core/lib/iomgr/sockaddr.h"
-#include "src/core/lib/iomgr/socket_utils.h"
-
-#include <stdio.h>
-#include <string.h>
-#ifdef GRPC_HAVE_UNIX_SOCKET
-#include <sys/un.h>
-#endif
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/string_util.h>
-
-#include "src/core/lib/gpr/string.h"
-#include "src/core/lib/gprpp/host_port.h"
-
-#ifdef GRPC_POSIX_SOCKET
-#include <errno.h>
-#include <net/if.h>
-#endif
-
-#ifdef GRPC_HAVE_UNIX_SOCKET
-
-bool grpc_parse_unix(const grpc_uri* uri,
- grpc_resolved_address* resolved_addr) {
- if (strcmp("unix", uri->scheme) != 0) {
- gpr_log(GPR_ERROR, "Expected 'unix' scheme, got '%s'", uri->scheme);
- return false;
- }
- struct sockaddr_un* un =
- reinterpret_cast<struct sockaddr_un*>(resolved_addr->addr);
- const size_t maxlen = sizeof(un->sun_path);
- const size_t path_len = strnlen(uri->path, maxlen);
- if (path_len == maxlen) return false;
- un->sun_family = AF_UNIX;
- strcpy(un->sun_path, uri->path);
- resolved_addr->len = static_cast<socklen_t>(sizeof(*un));
- return true;
-}
-
-#else /* GRPC_HAVE_UNIX_SOCKET */
-
-bool grpc_parse_unix(const grpc_uri* uri,
- grpc_resolved_address* resolved_addr) {
- abort();
-}
-
-#endif /* GRPC_HAVE_UNIX_SOCKET */
-
-bool grpc_parse_ipv4_hostport(const char* hostport, grpc_resolved_address* addr,
- bool log_errors) {
- bool success = false;
- // Split host and port.
- TString host;
- TString port;
- if (!grpc_core::SplitHostPort(hostport, &host, &port)) {
- if (log_errors) {
- gpr_log(GPR_ERROR, "Failed gpr_split_host_port(%s, ...)", hostport);
- }
- return false;
- }
- // Parse IP address.
- memset(addr, 0, sizeof(*addr));
- addr->len = static_cast<socklen_t>(sizeof(grpc_sockaddr_in));
- grpc_sockaddr_in* in = reinterpret_cast<grpc_sockaddr_in*>(addr->addr);
- in->sin_family = GRPC_AF_INET;
- if (grpc_inet_pton(GRPC_AF_INET, host.c_str(), &in->sin_addr) == 0) {
- if (log_errors) {
- gpr_log(GPR_ERROR, "invalid ipv4 address: '%s'", host.c_str());
- }
- goto done;
- }
- // Parse port.
- if (port.empty()) {
- if (log_errors) gpr_log(GPR_ERROR, "no port given for ipv4 scheme");
- goto done;
- }
- int port_num;
- if (sscanf(port.c_str(), "%d", &port_num) != 1 || port_num < 0 ||
- port_num > 65535) {
- if (log_errors) gpr_log(GPR_ERROR, "invalid ipv4 port: '%s'", port.c_str());
- goto done;
- }
- in->sin_port = grpc_htons(static_cast<uint16_t>(port_num));
- success = true;
-done:
- return success;
-}
-
-bool grpc_parse_ipv4(const grpc_uri* uri,
- grpc_resolved_address* resolved_addr) {
- if (strcmp("ipv4", uri->scheme) != 0) {
- gpr_log(GPR_ERROR, "Expected 'ipv4' scheme, got '%s'", uri->scheme);
- return false;
- }
- const char* host_port = uri->path;
- if (*host_port == '/') ++host_port;
- return grpc_parse_ipv4_hostport(host_port, resolved_addr,
- true /* log_errors */);
-}
-
-bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr,
- bool log_errors) {
- bool success = false;
- // Split host and port.
- TString host;
- TString port;
- if (!grpc_core::SplitHostPort(hostport, &host, &port)) {
- if (log_errors) {
- gpr_log(GPR_ERROR, "Failed gpr_split_host_port(%s, ...)", hostport);
- }
- return false;
- }
- // Parse IP address.
- memset(addr, 0, sizeof(*addr));
- addr->len = static_cast<socklen_t>(sizeof(grpc_sockaddr_in6));
- grpc_sockaddr_in6* in6 = reinterpret_cast<grpc_sockaddr_in6*>(addr->addr);
- in6->sin6_family = GRPC_AF_INET6;
- // Handle the RFC6874 syntax for IPv6 zone identifiers.
- char* host_end =
- static_cast<char*>(gpr_memrchr(host.c_str(), '%', host.size()));
- if (host_end != nullptr) {
- GPR_ASSERT(host_end >= host.c_str());
- char host_without_scope[GRPC_INET6_ADDRSTRLEN + 1];
- size_t host_without_scope_len =
- static_cast<size_t>(host_end - host.c_str());
- uint32_t sin6_scope_id = 0;
- if (host_without_scope_len > GRPC_INET6_ADDRSTRLEN) {
- if (log_errors) {
- gpr_log(
- GPR_ERROR,
- "invalid ipv6 address length %zu. Length cannot be greater than "
- "GRPC_INET6_ADDRSTRLEN i.e %d)",
- host_without_scope_len, GRPC_INET6_ADDRSTRLEN);
- }
- goto done;
- }
- strncpy(host_without_scope, host.c_str(), host_without_scope_len);
- host_without_scope[host_without_scope_len] = '\0';
- if (grpc_inet_pton(GRPC_AF_INET6, host_without_scope, &in6->sin6_addr) ==
- 0) {
- if (log_errors) {
- gpr_log(GPR_ERROR, "invalid ipv6 address: '%s'", host_without_scope);
- }
- goto done;
- }
- if (gpr_parse_bytes_to_uint32(host_end + 1,
- host.size() - host_without_scope_len - 1,
- &sin6_scope_id) == 0) {
- if ((sin6_scope_id = grpc_if_nametoindex(host_end + 1)) == 0) {
- gpr_log(GPR_ERROR,
- "Invalid interface name: '%s'. "
- "Non-numeric and failed if_nametoindex.",
- host_end + 1);
- goto done;
- }
- }
- // Handle "sin6_scope_id" being type "u_long". See grpc issue #10027.
- in6->sin6_scope_id = sin6_scope_id;
- } else {
- if (grpc_inet_pton(GRPC_AF_INET6, host.c_str(), &in6->sin6_addr) == 0) {
- if (log_errors) {
- gpr_log(GPR_ERROR, "invalid ipv6 address: '%s'", host.c_str());
- }
- goto done;
- }
- }
- // Parse port.
- if (port.empty()) {
- if (log_errors) gpr_log(GPR_ERROR, "no port given for ipv6 scheme");
- goto done;
- }
- int port_num;
- if (sscanf(port.c_str(), "%d", &port_num) != 1 || port_num < 0 ||
- port_num > 65535) {
- if (log_errors) gpr_log(GPR_ERROR, "invalid ipv6 port: '%s'", port.c_str());
- goto done;
- }
- in6->sin6_port = grpc_htons(static_cast<uint16_t>(port_num));
- success = true;
-done:
- return success;
-}
-
-bool grpc_parse_ipv6(const grpc_uri* uri,
- grpc_resolved_address* resolved_addr) {
- if (strcmp("ipv6", uri->scheme) != 0) {
- gpr_log(GPR_ERROR, "Expected 'ipv6' scheme, got '%s'", uri->scheme);
- return false;
- }
- const char* host_port = uri->path;
- if (*host_port == '/') ++host_port;
- return grpc_parse_ipv6_hostport(host_port, resolved_addr,
- true /* log_errors */);
-}
-
-bool grpc_parse_uri(const grpc_uri* uri, grpc_resolved_address* resolved_addr) {
- if (strcmp("unix", uri->scheme) == 0) {
- return grpc_parse_unix(uri, resolved_addr);
- } else if (strcmp("ipv4", uri->scheme) == 0) {
- return grpc_parse_ipv4(uri, resolved_addr);
- } else if (strcmp("ipv6", uri->scheme) == 0) {
- return grpc_parse_ipv6(uri, resolved_addr);
- }
- gpr_log(GPR_ERROR, "Can't parse scheme '%s'", uri->scheme);
- return false;
-}
-
-uint16_t grpc_strhtons(const char* port) {
- if (strcmp(port, "http") == 0) {
- return htons(80);
- } else if (strcmp(port, "https") == 0) {
- return htons(443);
- }
- return htons(static_cast<unsigned short>(atoi(port)));
-}
+/*
+ *
+ * Copyright 2016 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <grpc/support/port_platform.h>
+
+#include "src/core/lib/iomgr/grpc_if_nametoindex.h"
+#include "src/core/lib/iomgr/parse_address.h"
+#include "src/core/lib/iomgr/sockaddr.h"
+#include "src/core/lib/iomgr/socket_utils.h"
+
+#include <stdio.h>
+#include <string.h>
+#ifdef GRPC_HAVE_UNIX_SOCKET
+#include <sys/un.h>
+#endif
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gprpp/host_port.h"
+
+#ifdef GRPC_POSIX_SOCKET
+#include <errno.h>
+#include <net/if.h>
+#endif
+
+#ifdef GRPC_HAVE_UNIX_SOCKET
+
+bool grpc_parse_unix(const grpc_uri* uri,
+ grpc_resolved_address* resolved_addr) {
+ if (strcmp("unix", uri->scheme) != 0) {
+ gpr_log(GPR_ERROR, "Expected 'unix' scheme, got '%s'", uri->scheme);
+ return false;
+ }
+ struct sockaddr_un* un =
+ reinterpret_cast<struct sockaddr_un*>(resolved_addr->addr);
+ const size_t maxlen = sizeof(un->sun_path);
+ const size_t path_len = strnlen(uri->path, maxlen);
+ if (path_len == maxlen) return false;
+ un->sun_family = AF_UNIX;
+ strcpy(un->sun_path, uri->path);
+ resolved_addr->len = static_cast<socklen_t>(sizeof(*un));
+ return true;
+}
+
+#else /* GRPC_HAVE_UNIX_SOCKET */
+
+bool grpc_parse_unix(const grpc_uri* uri,
+ grpc_resolved_address* resolved_addr) {
+ abort();
+}
+
+#endif /* GRPC_HAVE_UNIX_SOCKET */
+
+bool grpc_parse_ipv4_hostport(const char* hostport, grpc_resolved_address* addr,
+ bool log_errors) {
+ bool success = false;
+ // Split host and port.
+ TString host;
+ TString port;
+ if (!grpc_core::SplitHostPort(hostport, &host, &port)) {
+ if (log_errors) {
+ gpr_log(GPR_ERROR, "Failed gpr_split_host_port(%s, ...)", hostport);
+ }
+ return false;
+ }
+ // Parse IP address.
+ memset(addr, 0, sizeof(*addr));
+ addr->len = static_cast<socklen_t>(sizeof(grpc_sockaddr_in));
+ grpc_sockaddr_in* in = reinterpret_cast<grpc_sockaddr_in*>(addr->addr);
+ in->sin_family = GRPC_AF_INET;
+ if (grpc_inet_pton(GRPC_AF_INET, host.c_str(), &in->sin_addr) == 0) {
+ if (log_errors) {
+ gpr_log(GPR_ERROR, "invalid ipv4 address: '%s'", host.c_str());
+ }
+ goto done;
+ }
+ // Parse port.
+ if (port.empty()) {
+ if (log_errors) gpr_log(GPR_ERROR, "no port given for ipv4 scheme");
+ goto done;
+ }
+ int port_num;
+ if (sscanf(port.c_str(), "%d", &port_num) != 1 || port_num < 0 ||
+ port_num > 65535) {
+ if (log_errors) gpr_log(GPR_ERROR, "invalid ipv4 port: '%s'", port.c_str());
+ goto done;
+ }
+ in->sin_port = grpc_htons(static_cast<uint16_t>(port_num));
+ success = true;
+done:
+ return success;
+}
+
+bool grpc_parse_ipv4(const grpc_uri* uri,
+ grpc_resolved_address* resolved_addr) {
+ if (strcmp("ipv4", uri->scheme) != 0) {
+ gpr_log(GPR_ERROR, "Expected 'ipv4' scheme, got '%s'", uri->scheme);
+ return false;
+ }
+ const char* host_port = uri->path;
+ if (*host_port == '/') ++host_port;
+ return grpc_parse_ipv4_hostport(host_port, resolved_addr,
+ true /* log_errors */);
+}
+
+bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr,
+ bool log_errors) {
+ bool success = false;
+ // Split host and port.
+ TString host;
+ TString port;
+ if (!grpc_core::SplitHostPort(hostport, &host, &port)) {
+ if (log_errors) {
+ gpr_log(GPR_ERROR, "Failed gpr_split_host_port(%s, ...)", hostport);
+ }
+ return false;
+ }
+ // Parse IP address.
+ memset(addr, 0, sizeof(*addr));
+ addr->len = static_cast<socklen_t>(sizeof(grpc_sockaddr_in6));
+ grpc_sockaddr_in6* in6 = reinterpret_cast<grpc_sockaddr_in6*>(addr->addr);
+ in6->sin6_family = GRPC_AF_INET6;
+ // Handle the RFC6874 syntax for IPv6 zone identifiers.
+ char* host_end =
+ static_cast<char*>(gpr_memrchr(host.c_str(), '%', host.size()));
+ if (host_end != nullptr) {
+ GPR_ASSERT(host_end >= host.c_str());
+ char host_without_scope[GRPC_INET6_ADDRSTRLEN + 1];
+ size_t host_without_scope_len =
+ static_cast<size_t>(host_end - host.c_str());
+ uint32_t sin6_scope_id = 0;
+ if (host_without_scope_len > GRPC_INET6_ADDRSTRLEN) {
+ if (log_errors) {
+ gpr_log(
+ GPR_ERROR,
+ "invalid ipv6 address length %zu. Length cannot be greater than "
+ "GRPC_INET6_ADDRSTRLEN i.e %d)",
+ host_without_scope_len, GRPC_INET6_ADDRSTRLEN);
+ }
+ goto done;
+ }
+ strncpy(host_without_scope, host.c_str(), host_without_scope_len);
+ host_without_scope[host_without_scope_len] = '\0';
+ if (grpc_inet_pton(GRPC_AF_INET6, host_without_scope, &in6->sin6_addr) ==
+ 0) {
+ if (log_errors) {
+ gpr_log(GPR_ERROR, "invalid ipv6 address: '%s'", host_without_scope);
+ }
+ goto done;
+ }
+ if (gpr_parse_bytes_to_uint32(host_end + 1,
+ host.size() - host_without_scope_len - 1,
+ &sin6_scope_id) == 0) {
+ if ((sin6_scope_id = grpc_if_nametoindex(host_end + 1)) == 0) {
+ gpr_log(GPR_ERROR,
+ "Invalid interface name: '%s'. "
+ "Non-numeric and failed if_nametoindex.",
+ host_end + 1);
+ goto done;
+ }
+ }
+ // Handle "sin6_scope_id" being type "u_long". See grpc issue #10027.
+ in6->sin6_scope_id = sin6_scope_id;
+ } else {
+ if (grpc_inet_pton(GRPC_AF_INET6, host.c_str(), &in6->sin6_addr) == 0) {
+ if (log_errors) {
+ gpr_log(GPR_ERROR, "invalid ipv6 address: '%s'", host.c_str());
+ }
+ goto done;
+ }
+ }
+ // Parse port.
+ if (port.empty()) {
+ if (log_errors) gpr_log(GPR_ERROR, "no port given for ipv6 scheme");
+ goto done;
+ }
+ int port_num;
+ if (sscanf(port.c_str(), "%d", &port_num) != 1 || port_num < 0 ||
+ port_num > 65535) {
+ if (log_errors) gpr_log(GPR_ERROR, "invalid ipv6 port: '%s'", port.c_str());
+ goto done;
+ }
+ in6->sin6_port = grpc_htons(static_cast<uint16_t>(port_num));
+ success = true;
+done:
+ return success;
+}
+
+bool grpc_parse_ipv6(const grpc_uri* uri,
+ grpc_resolved_address* resolved_addr) {
+ if (strcmp("ipv6", uri->scheme) != 0) {
+ gpr_log(GPR_ERROR, "Expected 'ipv6' scheme, got '%s'", uri->scheme);
+ return false;
+ }
+ const char* host_port = uri->path;
+ if (*host_port == '/') ++host_port;
+ return grpc_parse_ipv6_hostport(host_port, resolved_addr,
+ true /* log_errors */);
+}
+
+bool grpc_parse_uri(const grpc_uri* uri, grpc_resolved_address* resolved_addr) {
+ if (strcmp("unix", uri->scheme) == 0) {
+ return grpc_parse_unix(uri, resolved_addr);
+ } else if (strcmp("ipv4", uri->scheme) == 0) {
+ return grpc_parse_ipv4(uri, resolved_addr);
+ } else if (strcmp("ipv6", uri->scheme) == 0) {
+ return grpc_parse_ipv6(uri, resolved_addr);
+ }
+ gpr_log(GPR_ERROR, "Can't parse scheme '%s'", uri->scheme);
+ return false;
+}
+
+uint16_t grpc_strhtons(const char* port) {
+ if (strcmp(port, "http") == 0) {
+ return htons(80);
+ } else if (strcmp(port, "https") == 0) {
+ return htons(443);
+ }
+ return htons(static_cast<unsigned short>(atoi(port)));
+}
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/parse_address.h b/contrib/libs/grpc/src/core/lib/iomgr/parse_address.h
index 5795fd7889..d42daac46a 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/parse_address.h
+++ b/contrib/libs/grpc/src/core/lib/iomgr/parse_address.h
@@ -1,53 +1,53 @@
-/*
- *
- * Copyright 2015 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef GRPC_CORE_LIB_IOMGR_PARSE_ADDRESS_H
-#define GRPC_CORE_LIB_IOMGR_PARSE_ADDRESS_H
-
-#include <grpc/support/port_platform.h>
-
-#include <stddef.h>
-
-#include "src/core/lib/iomgr/resolve_address.h"
-#include "src/core/lib/uri/uri_parser.h"
-
-/** Populate \a resolved_addr from \a uri, whose path is expected to contain a
- * unix socket path. Returns true upon success. */
-bool grpc_parse_unix(const grpc_uri* uri, grpc_resolved_address* resolved_addr);
-
-/** Populate \a resolved_addr from \a uri, whose path is expected to contain an
- * IPv4 host:port pair. Returns true upon success. */
-bool grpc_parse_ipv4(const grpc_uri* uri, grpc_resolved_address* resolved_addr);
-
-/** Populate \a resolved_addr from \a uri, whose path is expected to contain an
- * IPv6 host:port pair. Returns true upon success. */
-bool grpc_parse_ipv6(const grpc_uri* uri, grpc_resolved_address* resolved_addr);
-
-/** Populate \a resolved_addr from \a uri. Returns true upon success. */
-bool grpc_parse_uri(const grpc_uri* uri, grpc_resolved_address* resolved_addr);
-
-/** Parse bare IPv4 or IPv6 "IP:port" strings. */
-bool grpc_parse_ipv4_hostport(const char* hostport, grpc_resolved_address* addr,
- bool log_errors);
-bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr,
- bool log_errors);
-
-/* Converts named or numeric port to a uint16 suitable for use in a sockaddr. */
-uint16_t grpc_strhtons(const char* port);
-
-#endif /* GRPC_CORE_LIB_IOMGR_PARSE_ADDRESS_H */
+/*
+ *
+ * Copyright 2015 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef GRPC_CORE_LIB_IOMGR_PARSE_ADDRESS_H
+#define GRPC_CORE_LIB_IOMGR_PARSE_ADDRESS_H
+
+#include <grpc/support/port_platform.h>
+
+#include <stddef.h>
+
+#include "src/core/lib/iomgr/resolve_address.h"
+#include "src/core/lib/uri/uri_parser.h"
+
+/** Populate \a resolved_addr from \a uri, whose path is expected to contain a
+ * unix socket path. Returns true upon success. */
+bool grpc_parse_unix(const grpc_uri* uri, grpc_resolved_address* resolved_addr);
+
+/** Populate \a resolved_addr from \a uri, whose path is expected to contain an
+ * IPv4 host:port pair. Returns true upon success. */
+bool grpc_parse_ipv4(const grpc_uri* uri, grpc_resolved_address* resolved_addr);
+
+/** Populate \a resolved_addr from \a uri, whose path is expected to contain an
+ * IPv6 host:port pair. Returns true upon success. */
+bool grpc_parse_ipv6(const grpc_uri* uri, grpc_resolved_address* resolved_addr);
+
+/** Populate \a resolved_addr from \a uri. Returns true upon success. */
+bool grpc_parse_uri(const grpc_uri* uri, grpc_resolved_address* resolved_addr);
+
+/** Parse bare IPv4 or IPv6 "IP:port" strings. */
+bool grpc_parse_ipv4_hostport(const char* hostport, grpc_resolved_address* addr,
+ bool log_errors);
+bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr,
+ bool log_errors);
+
+/* Converts named or numeric port to a uint16 suitable for use in a sockaddr. */
+uint16_t grpc_strhtons(const char* port);
+
+#endif /* GRPC_CORE_LIB_IOMGR_PARSE_ADDRESS_H */
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/poller/eventmanager_libuv.cc b/contrib/libs/grpc/src/core/lib/iomgr/poller/eventmanager_libuv.cc
index 992d532ab7..e7045df585 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/poller/eventmanager_libuv.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/poller/eventmanager_libuv.cc
@@ -1,87 +1,87 @@
-/*
- *
- * Copyright 2019 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <grpc/support/port_platform.h>
-
-#include "src/core/lib/iomgr/poller/eventmanager_libuv.h"
-
-#include <grpc/support/time.h>
-
-grpc::experimental::LibuvEventManager::Options::Options() : num_workers_(-1) {}
-grpc::experimental::LibuvEventManager::Options::Options(int num_workers)
- : num_workers_(num_workers) {}
-
-grpc::experimental::LibuvEventManager::LibuvEventManager(const Options& options)
- : options_(options) {
- int num_workers = options_.num_workers();
- // Number of workers can't be 0 if we do not accept thread donation.
- // TODO(guantaol): replaces the hard-coded number with a flag.
- if (num_workers <= 0) num_workers = 32;
-
- for (int i = 0; i < num_workers; i++) {
- workers_.emplace_back(
- options_.thread_name_prefix().c_str(),
- [](void* em) { static_cast<LibuvEventManager*>(em)->RunWorkerLoop(); },
- this);
- workers_.back().Start();
- }
-}
-
-grpc::experimental::LibuvEventManager::~LibuvEventManager() {
- Shutdown();
- for (auto& th : workers_) {
- th.Join();
- }
-}
-
-void grpc::experimental::LibuvEventManager::RunWorkerLoop() {
- while (true) {
- // TODO(guantaol): extend the worker loop with real work.
- if (ShouldStop()) return;
- gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
- gpr_time_from_micros(10, GPR_TIMESPAN)));
- }
-}
-
-bool grpc::experimental::LibuvEventManager::ShouldStop() {
- return should_stop_.Load(grpc_core::MemoryOrder::ACQUIRE) != 0;
-}
-
-void grpc::experimental::LibuvEventManager::Shutdown() {
- if (should_stop_.Load(grpc_core::MemoryOrder::ACQUIRE))
- return; // Already shut down.
-
- {
- grpc_core::MutexLock lock(&shutdown_mu_);
- while (shutdown_refcount_.Load(grpc_core::MemoryOrder::ACQUIRE) > 0) {
- shutdown_cv_.Wait(&shutdown_mu_);
- }
- }
- should_stop_.Store(true, grpc_core::MemoryOrder::RELEASE);
-}
-
-void grpc::experimental::LibuvEventManager::ShutdownRef() {
- shutdown_refcount_.FetchAdd(1, grpc_core::MemoryOrder::RELAXED);
-}
-
-void grpc::experimental::LibuvEventManager::ShutdownUnref() {
- if (shutdown_refcount_.FetchSub(1, grpc_core::MemoryOrder::ACQ_REL) == 1) {
- grpc_core::MutexLock lock(&shutdown_mu_);
- shutdown_cv_.Signal();
- }
-}
+/*
+ *
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <grpc/support/port_platform.h>
+
+#include "src/core/lib/iomgr/poller/eventmanager_libuv.h"
+
+#include <grpc/support/time.h>
+
+grpc::experimental::LibuvEventManager::Options::Options() : num_workers_(-1) {}
+grpc::experimental::LibuvEventManager::Options::Options(int num_workers)
+ : num_workers_(num_workers) {}
+
+grpc::experimental::LibuvEventManager::LibuvEventManager(const Options& options)
+ : options_(options) {
+ int num_workers = options_.num_workers();
+ // Number of workers can't be 0 if we do not accept thread donation.
+ // TODO(guantaol): replaces the hard-coded number with a flag.
+ if (num_workers <= 0) num_workers = 32;
+
+ for (int i = 0; i < num_workers; i++) {
+ workers_.emplace_back(
+ options_.thread_name_prefix().c_str(),
+ [](void* em) { static_cast<LibuvEventManager*>(em)->RunWorkerLoop(); },
+ this);
+ workers_.back().Start();
+ }
+}
+
+grpc::experimental::LibuvEventManager::~LibuvEventManager() {
+ Shutdown();
+ for (auto& th : workers_) {
+ th.Join();
+ }
+}
+
+void grpc::experimental::LibuvEventManager::RunWorkerLoop() {
+ while (true) {
+ // TODO(guantaol): extend the worker loop with real work.
+ if (ShouldStop()) return;
+ gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
+ gpr_time_from_micros(10, GPR_TIMESPAN)));
+ }
+}
+
+bool grpc::experimental::LibuvEventManager::ShouldStop() {
+ return should_stop_.Load(grpc_core::MemoryOrder::ACQUIRE) != 0;
+}
+
+void grpc::experimental::LibuvEventManager::Shutdown() {
+ if (should_stop_.Load(grpc_core::MemoryOrder::ACQUIRE))
+ return; // Already shut down.
+
+ {
+ grpc_core::MutexLock lock(&shutdown_mu_);
+ while (shutdown_refcount_.Load(grpc_core::MemoryOrder::ACQUIRE) > 0) {
+ shutdown_cv_.Wait(&shutdown_mu_);
+ }
+ }
+ should_stop_.Store(true, grpc_core::MemoryOrder::RELEASE);
+}
+
+void grpc::experimental::LibuvEventManager::ShutdownRef() {
+ shutdown_refcount_.FetchAdd(1, grpc_core::MemoryOrder::RELAXED);
+}
+
+void grpc::experimental::LibuvEventManager::ShutdownUnref() {
+ if (shutdown_refcount_.FetchSub(1, grpc_core::MemoryOrder::ACQ_REL) == 1) {
+ grpc_core::MutexLock lock(&shutdown_mu_);
+ shutdown_cv_.Signal();
+ }
+}
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/poller/eventmanager_libuv.h b/contrib/libs/grpc/src/core/lib/iomgr/poller/eventmanager_libuv.h
index ee6f8037d8..88988a1890 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/poller/eventmanager_libuv.h
+++ b/contrib/libs/grpc/src/core/lib/iomgr/poller/eventmanager_libuv.h
@@ -1,88 +1,88 @@
-/*
- *
- * Copyright 2019 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef GRPC_CORE_LIB_IOMGR_POLLER_EVENTMANAGER_LIBUV_H
-#define GRPC_CORE_LIB_IOMGR_POLLER_EVENTMANAGER_LIBUV_H
-
-#include <grpc/support/port_platform.h>
-
-#include <util/generic/string.h>
-#include <vector>
-
-#include "src/core/lib/gprpp/atomic.h"
-#include "src/core/lib/gprpp/sync.h"
-#include "src/core/lib/gprpp/thd.h"
-
-namespace grpc {
-namespace experimental {
-
-class LibuvEventManager {
- public:
- class Options {
- public:
- Options();
- Options(int num_workers);
-
- int num_workers() const { return num_workers_; }
- void set_num_workers(int num) { num_workers_ = num; }
-
- const TString& thread_name_prefix() const {
- return thread_name_prefix_;
- }
- void set_thread_name_prefix(const TString& name) {
- thread_name_prefix_ = name;
- }
-
- private:
- // Number of worker threads to create at startup. If less than 0, uses the
- // default value of 32.
- int num_workers_;
- // Name prefix used for worker.
- TString thread_name_prefix_;
- };
-
- explicit LibuvEventManager(const Options& options);
- virtual ~LibuvEventManager();
-
- void Shutdown();
- void ShutdownRef();
- void ShutdownUnref();
-
- private:
- // Function run by the worker threads.
- void RunWorkerLoop();
-
- // Whether the EventManager has been shut down.
- bool ShouldStop();
-
- const Options options_;
- // Whether the EventManager workers should be stopped.
- grpc_core::Atomic<bool> should_stop_{false};
- // A refcount preventing the EventManager from shutdown.
- grpc_core::Atomic<int> shutdown_refcount_{0};
- // Worker threads of the EventManager.
- std::vector<grpc_core::Thread> workers_;
- // Mutex and condition variable used for shutdown.
- grpc_core::Mutex shutdown_mu_;
- grpc_core::CondVar shutdown_cv_;
-};
-
-} // namespace experimental
-} // namespace grpc
-
-#endif /* GRPC_CORE_LIB_IOMGR_POLLER_EVENTMANAGER_LIBUV_H */
+/*
+ *
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef GRPC_CORE_LIB_IOMGR_POLLER_EVENTMANAGER_LIBUV_H
+#define GRPC_CORE_LIB_IOMGR_POLLER_EVENTMANAGER_LIBUV_H
+
+#include <grpc/support/port_platform.h>
+
+#include <util/generic/string.h>
+#include <vector>
+
+#include "src/core/lib/gprpp/atomic.h"
+#include "src/core/lib/gprpp/sync.h"
+#include "src/core/lib/gprpp/thd.h"
+
+namespace grpc {
+namespace experimental {
+
+class LibuvEventManager {
+ public:
+ class Options {
+ public:
+ Options();
+ Options(int num_workers);
+
+ int num_workers() const { return num_workers_; }
+ void set_num_workers(int num) { num_workers_ = num; }
+
+ const TString& thread_name_prefix() const {
+ return thread_name_prefix_;
+ }
+ void set_thread_name_prefix(const TString& name) {
+ thread_name_prefix_ = name;
+ }
+
+ private:
+ // Number of worker threads to create at startup. If less than 0, uses the
+ // default value of 32.
+ int num_workers_;
+ // Name prefix used for worker.
+ TString thread_name_prefix_;
+ };
+
+ explicit LibuvEventManager(const Options& options);
+ virtual ~LibuvEventManager();
+
+ void Shutdown();
+ void ShutdownRef();
+ void ShutdownUnref();
+
+ private:
+ // Function run by the worker threads.
+ void RunWorkerLoop();
+
+ // Whether the EventManager has been shut down.
+ bool ShouldStop();
+
+ const Options options_;
+ // Whether the EventManager workers should be stopped.
+ grpc_core::Atomic<bool> should_stop_{false};
+ // A refcount preventing the EventManager from shutdown.
+ grpc_core::Atomic<int> shutdown_refcount_{0};
+ // Worker threads of the EventManager.
+ std::vector<grpc_core::Thread> workers_;
+ // Mutex and condition variable used for shutdown.
+ grpc_core::Mutex shutdown_mu_;
+ grpc_core::CondVar shutdown_cv_;
+};
+
+} // namespace experimental
+} // namespace grpc
+
+#endif /* GRPC_CORE_LIB_IOMGR_POLLER_EVENTMANAGER_LIBUV_H */
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/pollset_set_custom.cc b/contrib/libs/grpc/src/core/lib/iomgr/pollset_set_custom.cc
index 6ef086b1a9..2c1df60819 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/pollset_set_custom.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/pollset_set_custom.cc
@@ -22,23 +22,23 @@
#include "src/core/lib/iomgr/pollset_set.h"
-static grpc_pollset_set* pollset_set_create(void) {
+static grpc_pollset_set* pollset_set_create(void) {
return (grpc_pollset_set*)((intptr_t)0xdeafbeef);
}
-static void pollset_set_destroy(grpc_pollset_set* /*pollset_set*/) {}
+static void pollset_set_destroy(grpc_pollset_set* /*pollset_set*/) {}
-static void pollset_set_add_pollset(grpc_pollset_set* /*pollset_set*/,
- grpc_pollset* /*pollset*/) {}
+static void pollset_set_add_pollset(grpc_pollset_set* /*pollset_set*/,
+ grpc_pollset* /*pollset*/) {}
-static void pollset_set_del_pollset(grpc_pollset_set* /*pollset_set*/,
- grpc_pollset* /*pollset*/) {}
+static void pollset_set_del_pollset(grpc_pollset_set* /*pollset_set*/,
+ grpc_pollset* /*pollset*/) {}
-static void pollset_set_add_pollset_set(grpc_pollset_set* /*bag*/,
- grpc_pollset_set* /*item*/) {}
+static void pollset_set_add_pollset_set(grpc_pollset_set* /*bag*/,
+ grpc_pollset_set* /*item*/) {}
-static void pollset_set_del_pollset_set(grpc_pollset_set* /*bag*/,
- grpc_pollset_set* /*item*/) {}
+static void pollset_set_del_pollset_set(grpc_pollset_set* /*bag*/,
+ grpc_pollset_set* /*item*/) {}
static grpc_pollset_set_vtable vtable = {
pollset_set_create, pollset_set_destroy,
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/port.h b/contrib/libs/grpc/src/core/lib/iomgr/port.h
index ea7d92b1ed..2a8d67b261 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/port.h
+++ b/contrib/libs/grpc/src/core/lib/iomgr/port.h
@@ -84,7 +84,7 @@
*/
#define GRPC_LINUX_TCP_H 1
#endif /* __GLIBC_PREREQ(2, 17) */
-#endif
+#endif
#ifndef __GLIBC__
#define GRPC_LINUX_EPOLL 1
#define GRPC_LINUX_EPOLL_CREATE1 1
@@ -109,7 +109,7 @@
#define GRPC_CFSTREAM_IOMGR 1
#define GRPC_CFSTREAM_CLIENT 1
#define GRPC_CFSTREAM_ENDPOINT 1
-#define GRPC_APPLE_EV 1
+#define GRPC_APPLE_EV 1
#define GRPC_POSIX_SOCKET_ARES_EV_DRIVER 1
#define GRPC_POSIX_SOCKET_EV 1
#define GRPC_POSIX_SOCKET_EV_EPOLL1 1
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/resolve_address_custom.cc b/contrib/libs/grpc/src/core/lib/iomgr/resolve_address_custom.cc
index 06d00f005f..69b4382b2b 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/resolve_address_custom.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/resolve_address_custom.cc
@@ -18,30 +18,30 @@
#include <grpc/support/port_platform.h>
-#include "src/core/lib/iomgr/resolve_address_custom.h"
-
-#include <string.h>
-
-#include <util/generic/string.h>
-
-#include "y_absl/strings/str_format.h"
-
+#include "src/core/lib/iomgr/resolve_address_custom.h"
+
+#include <string.h>
+
+#include <util/generic/string.h>
+
+#include "y_absl/strings/str_format.h"
+
#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
+#include <grpc/support/log.h>
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/gprpp/host_port.h"
#include "src/core/lib/iomgr/iomgr_custom.h"
-#include "src/core/lib/iomgr/port.h"
+#include "src/core/lib/iomgr/port.h"
#include "src/core/lib/iomgr/sockaddr_utils.h"
-struct grpc_custom_resolver {
- grpc_closure* on_done = nullptr;
- grpc_resolved_addresses** addresses = nullptr;
- TString host;
- TString port;
-};
+struct grpc_custom_resolver {
+ grpc_closure* on_done = nullptr;
+ grpc_resolved_addresses** addresses = nullptr;
+ TString host;
+ TString port;
+};
static grpc_custom_resolver_vtable* resolve_address_vtable = nullptr;
@@ -50,18 +50,18 @@ static int retry_named_port_failure(grpc_custom_resolver* r,
// This loop is copied from resolve_address_posix.c
const char* svc[][2] = {{"http", "80"}, {"https", "443"}};
for (size_t i = 0; i < GPR_ARRAY_SIZE(svc); i++) {
- if (r->port == svc[i][0]) {
- r->port = svc[i][1];
+ if (r->port == svc[i][0]) {
+ r->port = svc[i][1];
if (res) {
- grpc_error* error = resolve_address_vtable->resolve(
- r->host.c_str(), r->port.c_str(), res);
+ grpc_error* error = resolve_address_vtable->resolve(
+ r->host.c_str(), r->port.c_str(), res);
if (error != GRPC_ERROR_NONE) {
GRPC_ERROR_UNREF(error);
return 0;
}
} else {
- resolve_address_vtable->resolve_async(r, r->host.c_str(),
- r->port.c_str());
+ resolve_address_vtable->resolve_async(r, r->host.c_str(),
+ r->port.c_str());
}
return 1;
}
@@ -83,25 +83,25 @@ void grpc_custom_resolve_callback(grpc_custom_resolver* r,
if (r->on_done) {
grpc_core::ExecCtx::Run(DEBUG_LOCATION, r->on_done, error);
}
- delete r;
+ delete r;
}
static grpc_error* try_split_host_port(const char* name,
const char* default_port,
- TString* host, TString* port) {
+ TString* host, TString* port) {
/* parse name, splitting it into host and port parts */
grpc_core::SplitHostPort(name, host, port);
- if (host->empty()) {
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
- y_absl::StrFormat("unparseable host:port: '%s'", name).c_str());
+ if (host->empty()) {
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
+ y_absl::StrFormat("unparseable host:port: '%s'", name).c_str());
}
- if (port->empty()) {
+ if (port->empty()) {
// TODO(murgatroid99): add tests for this case
if (default_port == nullptr) {
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
- y_absl::StrFormat("no port in name '%s'", name).c_str());
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
+ y_absl::StrFormat("no port in name '%s'", name).c_str());
}
- *port = default_port;
+ *port = default_port;
}
return GRPC_ERROR_NONE;
}
@@ -111,9 +111,9 @@ static grpc_error* blocking_resolve_address_impl(
grpc_resolved_addresses** addresses) {
GRPC_CUSTOM_IOMGR_ASSERT_SAME_THREAD();
- grpc_custom_resolver resolver;
- grpc_error* err =
- try_split_host_port(name, default_port, &resolver.host, &resolver.port);
+ grpc_custom_resolver resolver;
+ grpc_error* err =
+ try_split_host_port(name, default_port, &resolver.host, &resolver.port);
if (err != GRPC_ERROR_NONE) {
return err;
}
@@ -122,8 +122,8 @@ static grpc_error* blocking_resolve_address_impl(
grpc_resolved_addresses* addrs;
grpc_core::ExecCtx* curr = grpc_core::ExecCtx::Get();
grpc_core::ExecCtx::Set(nullptr);
- err = resolve_address_vtable->resolve(resolver.host.c_str(),
- resolver.port.c_str(), &addrs);
+ err = resolve_address_vtable->resolve(resolver.host.c_str(),
+ resolver.port.c_str(), &addrs);
if (err != GRPC_ERROR_NONE) {
if (retry_named_port_failure(&resolver, &addrs)) {
GRPC_ERROR_UNREF(err);
@@ -142,21 +142,21 @@ static void resolve_address_impl(const char* name, const char* default_port,
grpc_closure* on_done,
grpc_resolved_addresses** addrs) {
GRPC_CUSTOM_IOMGR_ASSERT_SAME_THREAD();
- TString host;
- TString port;
- grpc_error* err = try_split_host_port(name, default_port, &host, &port);
+ TString host;
+ TString port;
+ grpc_error* err = try_split_host_port(name, default_port, &host, &port);
if (err != GRPC_ERROR_NONE) {
grpc_core::ExecCtx::Run(DEBUG_LOCATION, on_done, err);
return;
}
- grpc_custom_resolver* r = new grpc_custom_resolver();
+ grpc_custom_resolver* r = new grpc_custom_resolver();
r->on_done = on_done;
r->addresses = addrs;
- r->host = std::move(host);
- r->port = std::move(port);
+ r->host = std::move(host);
+ r->port = std::move(port);
/* Call getaddrinfo */
- resolve_address_vtable->resolve_async(r, r->host.c_str(), r->port.c_str());
+ resolve_address_vtable->resolve_async(r, r->host.c_str(), r->port.c_str());
}
static grpc_address_resolver_vtable custom_resolver_vtable = {
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/resolve_address_custom.h b/contrib/libs/grpc/src/core/lib/iomgr/resolve_address_custom.h
index 48a7bb7604..f5f68ca32d 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/resolve_address_custom.h
+++ b/contrib/libs/grpc/src/core/lib/iomgr/resolve_address_custom.h
@@ -29,10 +29,10 @@
typedef struct grpc_custom_resolver grpc_custom_resolver;
typedef struct grpc_custom_resolver_vtable {
- grpc_error* (*resolve)(const char* host, const char* port,
- grpc_resolved_addresses** res);
- void (*resolve_async)(grpc_custom_resolver* resolver, const char* host,
- const char* port);
+ grpc_error* (*resolve)(const char* host, const char* port,
+ grpc_resolved_addresses** res);
+ void (*resolve_async)(grpc_custom_resolver* resolver, const char* host,
+ const char* port);
} grpc_custom_resolver_vtable;
void grpc_custom_resolve_callback(grpc_custom_resolver* resolver,
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/resolve_address_posix.cc b/contrib/libs/grpc/src/core/lib/iomgr/resolve_address_posix.cc
index 0bfba602d2..4f29087391 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/resolve_address_posix.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/resolve_address_posix.cc
@@ -57,24 +57,24 @@ static grpc_error* posix_blocking_resolve_address(
return grpc_resolve_unix_domain_address(name + 5, addresses);
}
- TString host;
- TString port;
+ TString host;
+ TString port;
/* parse name, splitting it into host and port parts */
grpc_core::SplitHostPort(name, &host, &port);
- if (host.empty()) {
+ if (host.empty()) {
err = grpc_error_set_str(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("unparseable host:port"),
GRPC_ERROR_STR_TARGET_ADDRESS, grpc_slice_from_copied_string(name));
goto done;
}
- if (port.empty()) {
+ if (port.empty()) {
if (default_port == nullptr) {
err = grpc_error_set_str(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("no port in name"),
GRPC_ERROR_STR_TARGET_ADDRESS, grpc_slice_from_copied_string(name));
goto done;
}
- port = default_port;
+ port = default_port;
}
/* Call getaddrinfo */
@@ -84,16 +84,16 @@ static grpc_error* posix_blocking_resolve_address(
hints.ai_flags = AI_PASSIVE; /* for wildcard IP address */
GRPC_SCHEDULING_START_BLOCKING_REGION;
- s = getaddrinfo(host.c_str(), port.c_str(), &hints, &result);
+ s = getaddrinfo(host.c_str(), port.c_str(), &hints, &result);
GRPC_SCHEDULING_END_BLOCKING_REGION;
if (s != 0) {
/* Retry if well-known service name is recognized */
const char* svc[][2] = {{"http", "80"}, {"https", "443"}};
for (i = 0; i < GPR_ARRAY_SIZE(svc); i++) {
- if (port == svc[i][0]) {
+ if (port == svc[i][0]) {
GRPC_SCHEDULING_START_BLOCKING_REGION;
- s = getaddrinfo(host.c_str(), svc[i][1], &hints, &result);
+ s = getaddrinfo(host.c_str(), svc[i][1], &hints, &result);
GRPC_SCHEDULING_END_BLOCKING_REGION;
break;
}
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/resolve_address_windows.cc b/contrib/libs/grpc/src/core/lib/iomgr/resolve_address_windows.cc
index 6d7bbf1b96..9922b88065 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/resolve_address_windows.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/resolve_address_windows.cc
@@ -29,10 +29,10 @@
#include <string.h>
#include <sys/types.h>
-#include <util/generic/string.h>
-
-#include "y_absl/strings/str_format.h"
-
+#include <util/generic/string.h>
+
+#include "y_absl/strings/str_format.h"
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/log_windows.h>
@@ -65,21 +65,21 @@ static grpc_error* windows_blocking_resolve_address(
grpc_error* error = GRPC_ERROR_NONE;
/* parse name, splitting it into host and port parts */
- TString host;
- TString port;
+ TString host;
+ TString port;
grpc_core::SplitHostPort(name, &host, &port);
- if (host.empty()) {
- error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
- y_absl::StrFormat("unparseable host:port: '%s'", name).c_str());
+ if (host.empty()) {
+ error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
+ y_absl::StrFormat("unparseable host:port: '%s'", name).c_str());
goto done;
}
- if (port.empty()) {
+ if (port.empty()) {
if (default_port == NULL) {
- error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
- y_absl::StrFormat("no port in name '%s'", name).c_str());
+ error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
+ y_absl::StrFormat("no port in name '%s'", name).c_str());
goto done;
}
- port = default_port;
+ port = default_port;
}
/* Call getaddrinfo */
@@ -89,7 +89,7 @@ static grpc_error* windows_blocking_resolve_address(
hints.ai_flags = AI_PASSIVE; /* for wildcard IP address */
GRPC_SCHEDULING_START_BLOCKING_REGION;
- s = getaddrinfo(host.c_str(), port.c_str(), &hints, &result);
+ s = getaddrinfo(host.c_str(), port.c_str(), &hints, &result);
GRPC_SCHEDULING_END_BLOCKING_REGION;
if (s != 0) {
error = GRPC_WSA_ERROR(WSAGetLastError(), "getaddrinfo");
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/resource_quota.cc b/contrib/libs/grpc/src/core/lib/iomgr/resource_quota.cc
index 724357ee15..f416e096f4 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/resource_quota.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/resource_quota.cc
@@ -25,10 +25,10 @@
#include <stdint.h>
#include <string.h>
-#include <util/generic/string.h>
-
-#include "y_absl/strings/str_cat.h"
-
+#include <util/generic/string.h>
+
+#include "y_absl/strings/str_cat.h"
+
#include <grpc/slice_buffer.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@@ -121,7 +121,7 @@ struct grpc_resource_user {
grpc_resource_user_link links[GRPC_RULIST_COUNT];
/* The name of this resource user, for debugging/tracing */
- TString name;
+ TString name;
};
struct grpc_resource_quota {
@@ -184,7 +184,7 @@ struct grpc_resource_quota {
/* Roots of all resource user lists */
grpc_resource_user* roots[GRPC_RULIST_COUNT];
- TString name;
+ TString name;
};
static void ru_unref_by(grpc_resource_user* resource_user, gpr_atm amount);
@@ -323,9 +323,9 @@ static bool rq_alloc(grpc_resource_quota* resource_quota) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_resource_quota_trace)) {
gpr_log(GPR_INFO,
"RQ: check allocation for user %p shutdown=%" PRIdPTR
- " free_pool=%" PRId64 " outstanding_allocations=%" PRId64,
+ " free_pool=%" PRId64 " outstanding_allocations=%" PRId64,
resource_user, gpr_atm_no_barrier_load(&resource_user->shutdown),
- resource_user->free_pool, resource_user->outstanding_allocations);
+ resource_user->free_pool, resource_user->outstanding_allocations);
}
if (gpr_atm_no_barrier_load(&resource_user->shutdown)) {
resource_user->allocating = false;
@@ -337,9 +337,9 @@ static bool rq_alloc(grpc_resource_quota* resource_quota) {
resource_user->free_pool += aborted_allocations;
grpc_core::ExecCtx::RunList(DEBUG_LOCATION, &resource_user->on_allocated);
gpr_mu_unlock(&resource_user->mu);
- if (aborted_allocations > 0) {
- ru_unref_by(resource_user, static_cast<gpr_atm>(aborted_allocations));
- }
+ if (aborted_allocations > 0) {
+ ru_unref_by(resource_user, static_cast<gpr_atm>(aborted_allocations));
+ }
continue;
}
if (resource_user->free_pool < 0 &&
@@ -352,13 +352,13 @@ static bool rq_alloc(grpc_resource_quota* resource_quota) {
gpr_log(GPR_INFO,
"RQ %s %s: grant alloc %" PRId64
" bytes; rq_free_pool -> %" PRId64,
- resource_quota->name.c_str(), resource_user->name.c_str(), amt,
+ resource_quota->name.c_str(), resource_user->name.c_str(), amt,
resource_quota->free_pool);
}
} else if (GRPC_TRACE_FLAG_ENABLED(grpc_resource_quota_trace) &&
resource_user->free_pool >= 0) {
gpr_log(GPR_INFO, "RQ %s %s: discard already satisfied alloc request",
- resource_quota->name.c_str(), resource_user->name.c_str());
+ resource_quota->name.c_str(), resource_user->name.c_str());
}
if (resource_user->free_pool >= 0) {
resource_user->allocating = false;
@@ -391,7 +391,7 @@ static bool rq_reclaim_from_per_user_free_pool(
gpr_log(GPR_INFO,
"RQ %s %s: reclaim_from_per_user_free_pool %" PRId64
" bytes; rq_free_pool -> %" PRId64,
- resource_quota->name.c_str(), resource_user->name.c_str(), amt,
+ resource_quota->name.c_str(), resource_user->name.c_str(), amt,
resource_quota->free_pool);
}
gpr_mu_unlock(&resource_user->mu);
@@ -401,7 +401,7 @@ static bool rq_reclaim_from_per_user_free_pool(
gpr_log(GPR_INFO,
"RQ %s %s: failed to reclaim_from_per_user_free_pool; "
"free_pool = %" PRId64 "; rq_free_pool = %" PRId64,
- resource_quota->name.c_str(), resource_user->name.c_str(),
+ resource_quota->name.c_str(), resource_user->name.c_str(),
resource_user->free_pool, resource_quota->free_pool);
}
gpr_mu_unlock(&resource_user->mu);
@@ -418,9 +418,9 @@ static bool rq_reclaim(grpc_resource_quota* resource_quota, bool destructive) {
grpc_resource_user* resource_user = rulist_pop_head(resource_quota, list);
if (resource_user == nullptr) return false;
if (GRPC_TRACE_FLAG_ENABLED(grpc_resource_quota_trace)) {
- gpr_log(GPR_INFO, "RQ %s %s: initiate %s reclamation",
- resource_quota->name.c_str(), resource_user->name.c_str(),
- destructive ? "destructive" : "benign");
+ gpr_log(GPR_INFO, "RQ %s %s: initiate %s reclamation",
+ resource_quota->name.c_str(), resource_user->name.c_str(),
+ destructive ? "destructive" : "benign");
}
resource_quota->reclaiming = true;
grpc_resource_quota_ref_internal(resource_quota);
@@ -589,7 +589,7 @@ static void ru_destroy(void* ru, grpc_error* /*error*/) {
}
grpc_resource_quota_unref_internal(resource_user->resource_quota);
gpr_mu_destroy(&resource_user->mu);
- delete resource_user;
+ delete resource_user;
}
static void ru_alloc_slices(
@@ -643,7 +643,7 @@ static void rq_reclamation_done(void* rq, grpc_error* /*error*/) {
/* Public API */
grpc_resource_quota* grpc_resource_quota_create(const char* name) {
- grpc_resource_quota* resource_quota = new grpc_resource_quota;
+ grpc_resource_quota* resource_quota = new grpc_resource_quota;
gpr_ref_init(&resource_quota->refs, 1);
resource_quota->combiner = grpc_combiner_create();
resource_quota->free_pool = INT64_MAX;
@@ -657,10 +657,10 @@ grpc_resource_quota* grpc_resource_quota_create(const char* name) {
resource_quota->reclaiming = false;
gpr_atm_no_barrier_store(&resource_quota->memory_usage_estimation, 0);
if (name != nullptr) {
- resource_quota->name = name;
+ resource_quota->name = name;
} else {
- resource_quota->name =
- y_absl::StrCat("anonymous_pool_", (intptr_t)resource_quota);
+ resource_quota->name =
+ y_absl::StrCat("anonymous_pool_", (intptr_t)resource_quota);
}
GRPC_CLOSURE_INIT(&resource_quota->rq_step_closure, rq_step, resource_quota,
nullptr);
@@ -678,7 +678,7 @@ void grpc_resource_quota_unref_internal(grpc_resource_quota* resource_quota) {
GPR_ASSERT(resource_quota->num_threads_allocated == 0);
GRPC_COMBINER_UNREF(resource_quota->combiner, "resource_quota");
gpr_mu_destroy(&resource_quota->thread_count_mu);
- delete resource_quota;
+ delete resource_quota;
}
}
@@ -775,7 +775,7 @@ const grpc_arg_pointer_vtable* grpc_resource_quota_arg_vtable(void) {
grpc_resource_user* grpc_resource_user_create(
grpc_resource_quota* resource_quota, const char* name) {
- grpc_resource_user* resource_user = new grpc_resource_user;
+ grpc_resource_user* resource_user = new grpc_resource_user;
resource_user->resource_quota =
grpc_resource_quota_ref_internal(resource_quota);
GRPC_CLOSURE_INIT(&resource_user->allocate_closure, &ru_allocate,
@@ -805,10 +805,10 @@ grpc_resource_user* grpc_resource_user_create(
resource_user->links[i].next = resource_user->links[i].prev = nullptr;
}
if (name != nullptr) {
- resource_user->name = name;
+ resource_user->name = name;
} else {
- resource_user->name =
- y_absl::StrCat("anonymous_resource_user_", (intptr_t)resource_user);
+ resource_user->name =
+ y_absl::StrCat("anonymous_resource_user_", (intptr_t)resource_user);
}
return resource_user;
}
@@ -890,8 +890,8 @@ static bool resource_user_alloc_locked(grpc_resource_user* resource_user,
resource_user->free_pool -= static_cast<int64_t>(size);
if (GRPC_TRACE_FLAG_ENABLED(grpc_resource_quota_trace)) {
gpr_log(GPR_INFO, "RQ %s %s: alloc %" PRIdPTR "; free_pool -> %" PRId64,
- resource_user->resource_quota->name.c_str(),
- resource_user->name.c_str(), size, resource_user->free_pool);
+ resource_user->resource_quota->name.c_str(),
+ resource_user->name.c_str(), size, resource_user->free_pool);
}
if (GPR_LIKELY(resource_user->free_pool >= 0)) return true;
// Slow path: We need to wait for the free pool to refill.
@@ -951,8 +951,8 @@ void grpc_resource_user_free(grpc_resource_user* resource_user, size_t size) {
resource_user->free_pool += static_cast<int64_t>(size);
if (GRPC_TRACE_FLAG_ENABLED(grpc_resource_quota_trace)) {
gpr_log(GPR_INFO, "RQ %s %s: free %" PRIdPTR "; free_pool -> %" PRId64,
- resource_user->resource_quota->name.c_str(),
- resource_user->name.c_str(), size, resource_user->free_pool);
+ resource_user->resource_quota->name.c_str(),
+ resource_user->name.c_str(), size, resource_user->free_pool);
}
bool is_bigger_than_zero = resource_user->free_pool > 0;
if (is_bigger_than_zero && was_zero_or_negative &&
@@ -977,8 +977,8 @@ void grpc_resource_user_post_reclaimer(grpc_resource_user* resource_user,
void grpc_resource_user_finish_reclamation(grpc_resource_user* resource_user) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_resource_quota_trace)) {
gpr_log(GPR_INFO, "RQ %s %s: reclamation complete",
- resource_user->resource_quota->name.c_str(),
- resource_user->name.c_str());
+ resource_user->resource_quota->name.c_str(),
+ resource_user->name.c_str());
}
resource_user->resource_quota->combiner->Run(
&resource_user->resource_quota->rq_reclamation_done_closure,
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/sockaddr_utils.cc b/contrib/libs/grpc/src/core/lib/iomgr/sockaddr_utils.cc
index 8b3c2dc965..b43dbc9923 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/sockaddr_utils.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/sockaddr_utils.cc
@@ -24,11 +24,11 @@
#include <inttypes.h>
#include <string.h>
-#include <util/generic/string.h>
-
-#include "y_absl/strings/str_cat.h"
-#include "y_absl/strings/str_format.h"
-
+#include <util/generic/string.h>
+
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_format.h"
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@@ -154,15 +154,15 @@ void grpc_sockaddr_make_wildcard6(int port,
resolved_wild_out->len = static_cast<socklen_t>(sizeof(grpc_sockaddr_in6));
}
-TString grpc_sockaddr_to_string(const grpc_resolved_address* resolved_addr,
- bool normalize) {
+TString grpc_sockaddr_to_string(const grpc_resolved_address* resolved_addr,
+ bool normalize) {
const int save_errno = errno;
grpc_resolved_address addr_normalized;
- if (normalize && grpc_sockaddr_is_v4mapped(resolved_addr, &addr_normalized)) {
- resolved_addr = &addr_normalized;
- }
- const grpc_sockaddr* addr =
- reinterpret_cast<const grpc_sockaddr*>(resolved_addr->addr);
+ if (normalize && grpc_sockaddr_is_v4mapped(resolved_addr, &addr_normalized)) {
+ resolved_addr = &addr_normalized;
+ }
+ const grpc_sockaddr* addr =
+ reinterpret_cast<const grpc_sockaddr*>(resolved_addr->addr);
const void* ip = nullptr;
int port = 0;
uint32_t sin6_scope_id = 0;
@@ -178,28 +178,28 @@ TString grpc_sockaddr_to_string(const grpc_resolved_address* resolved_addr,
port = grpc_ntohs(addr6->sin6_port);
sin6_scope_id = addr6->sin6_scope_id;
}
- char ntop_buf[GRPC_INET6_ADDRSTRLEN];
- TString out;
+ char ntop_buf[GRPC_INET6_ADDRSTRLEN];
+ TString out;
if (ip != nullptr && grpc_inet_ntop(addr->sa_family, ip, ntop_buf,
sizeof(ntop_buf)) != nullptr) {
if (sin6_scope_id != 0) {
- // Enclose sin6_scope_id with the format defined in RFC 6784 section 2.
- TString host_with_scope =
- y_absl::StrFormat("%s%%25%" PRIu32, ntop_buf, sin6_scope_id);
- out = grpc_core::JoinHostPort(host_with_scope, port);
+ // Enclose sin6_scope_id with the format defined in RFC 6784 section 2.
+ TString host_with_scope =
+ y_absl::StrFormat("%s%%25%" PRIu32, ntop_buf, sin6_scope_id);
+ out = grpc_core::JoinHostPort(host_with_scope, port);
} else {
- out = grpc_core::JoinHostPort(ntop_buf, port);
+ out = grpc_core::JoinHostPort(ntop_buf, port);
}
} else {
- out = y_absl::StrFormat("(sockaddr family=%d)", addr->sa_family);
+ out = y_absl::StrFormat("(sockaddr family=%d)", addr->sa_family);
}
/* This is probably redundant, but we wouldn't want to log the wrong error. */
errno = save_errno;
- return out;
+ return out;
}
-void grpc_string_to_sockaddr(grpc_resolved_address* out, const char* addr,
- int port) {
+void grpc_string_to_sockaddr(grpc_resolved_address* out, const char* addr,
+ int port) {
memset(out, 0, sizeof(grpc_resolved_address));
grpc_sockaddr_in6* addr6 = (grpc_sockaddr_in6*)out->addr;
grpc_sockaddr_in* addr4 = (grpc_sockaddr_in*)out->addr;
@@ -215,8 +215,8 @@ void grpc_string_to_sockaddr(grpc_resolved_address* out, const char* addr,
grpc_sockaddr_set_port(out, port);
}
-TString grpc_sockaddr_to_uri(const grpc_resolved_address* resolved_addr) {
- if (resolved_addr->len == 0) return "";
+TString grpc_sockaddr_to_uri(const grpc_resolved_address* resolved_addr) {
+ if (resolved_addr->len == 0) return "";
grpc_resolved_address addr_normalized;
if (grpc_sockaddr_is_v4mapped(resolved_addr, &addr_normalized)) {
resolved_addr = &addr_normalized;
@@ -225,13 +225,13 @@ TString grpc_sockaddr_to_uri(const grpc_resolved_address* resolved_addr) {
if (scheme == nullptr || strcmp("unix", scheme) == 0) {
return grpc_sockaddr_to_uri_unix_if_possible(resolved_addr);
}
- TString path =
- grpc_sockaddr_to_string(resolved_addr, false /* normalize */);
- TString uri_str;
- if (scheme != nullptr) {
- uri_str = y_absl::StrCat(scheme, ":", path);
+ TString path =
+ grpc_sockaddr_to_string(resolved_addr, false /* normalize */);
+ TString uri_str;
+ if (scheme != nullptr) {
+ uri_str = y_absl::StrCat(scheme, ":", path);
}
- return uri_str;
+ return uri_str;
}
const char* grpc_sockaddr_get_uri_scheme(
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/sockaddr_utils.h b/contrib/libs/grpc/src/core/lib/iomgr/sockaddr_utils.h
index 7d9fe64239..eeedeeb90c 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/sockaddr_utils.h
+++ b/contrib/libs/grpc/src/core/lib/iomgr/sockaddr_utils.h
@@ -21,8 +21,8 @@
#include <grpc/support/port_platform.h>
-#include <util/generic/string.h>
-
+#include <util/generic/string.h>
+
#include "src/core/lib/iomgr/resolve_address.h"
/* Returns true if addr is an IPv4-mapped IPv6 address within the
@@ -58,19 +58,19 @@ int grpc_sockaddr_get_port(const grpc_resolved_address* addr);
/* Set IP port number of a sockaddr */
int grpc_sockaddr_set_port(const grpc_resolved_address* addr, int port);
-// Converts a sockaddr into a newly-allocated human-readable string.
-//
-// Currently, only the AF_INET and AF_INET6 families are recognized.
-// If the normalize flag is enabled, ::ffff:0.0.0.0/96 IPv6 addresses are
-// displayed as plain IPv4.
-TString grpc_sockaddr_to_string(const grpc_resolved_address* addr,
- bool normalize);
+// Converts a sockaddr into a newly-allocated human-readable string.
+//
+// Currently, only the AF_INET and AF_INET6 families are recognized.
+// If the normalize flag is enabled, ::ffff:0.0.0.0/96 IPv6 addresses are
+// displayed as plain IPv4.
+TString grpc_sockaddr_to_string(const grpc_resolved_address* addr,
+ bool normalize);
-void grpc_string_to_sockaddr(grpc_resolved_address* out, const char* addr,
- int port);
+void grpc_string_to_sockaddr(grpc_resolved_address* out, const char* addr,
+ int port);
/* Returns the URI string corresponding to \a addr */
-TString grpc_sockaddr_to_uri(const grpc_resolved_address* addr);
+TString grpc_sockaddr_to_uri(const grpc_resolved_address* addr);
/* Returns the URI scheme corresponding to \a addr */
const char* grpc_sockaddr_get_uri_scheme(const grpc_resolved_address* addr);
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/socket_utils_common_posix.cc b/contrib/libs/grpc/src/core/lib/iomgr/socket_utils_common_posix.cc
index 2d099db85d..8a8d4d3a22 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/socket_utils_common_posix.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/socket_utils_common_posix.cc
@@ -41,8 +41,8 @@
#include <sys/types.h>
#include <unistd.h>
-#include <util/generic/string.h>
-
+#include <util/generic/string.h>
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
@@ -63,19 +63,19 @@ extern "C" bool IsReusePortAvailable();
#define TCP_USER_TIMEOUT 18 /* How long for loss retry before timeout */
#endif
-/* set a socket to use zerocopy */
-grpc_error* grpc_set_socket_zerocopy(int fd) {
-#ifdef GRPC_LINUX_ERRQUEUE
- const int enable = 1;
- auto err = setsockopt(fd, SOL_SOCKET, SO_ZEROCOPY, &enable, sizeof(enable));
- if (err != 0) {
- return GRPC_OS_ERROR(errno, "setsockopt(SO_ZEROCOPY)");
- }
- return GRPC_ERROR_NONE;
-#else
- return GRPC_OS_ERROR(ENOSYS, "setsockopt(SO_ZEROCOPY)");
-#endif
-}
+/* set a socket to use zerocopy */
+grpc_error* grpc_set_socket_zerocopy(int fd) {
+#ifdef GRPC_LINUX_ERRQUEUE
+ const int enable = 1;
+ auto err = setsockopt(fd, SOL_SOCKET, SO_ZEROCOPY, &enable, sizeof(enable));
+ if (err != 0) {
+ return GRPC_OS_ERROR(errno, "setsockopt(SO_ZEROCOPY)");
+ }
+ return GRPC_ERROR_NONE;
+#else
+ return GRPC_OS_ERROR(ENOSYS, "setsockopt(SO_ZEROCOPY)");
+#endif
+}
/* set a socket to non blocking mode */
grpc_error* grpc_set_socket_nonblocking(int fd, int non_blocking) {
@@ -270,27 +270,27 @@ static int g_default_server_tcp_user_timeout_ms =
static bool g_default_client_tcp_user_timeout_enabled = false;
static bool g_default_server_tcp_user_timeout_enabled = true;
-#if GPR_LINUX == 1
-// For Linux, it will be detected to support TCP_USER_TIMEOUT
-#ifndef TCP_USER_TIMEOUT
-#define TCP_USER_TIMEOUT 18
-#endif
-#define SOCKET_SUPPORTS_TCP_USER_TIMEOUT_DEFAULT 0
-#else
-// For non-Linux, TCP_USER_TIMEOUT will be used if TCP_USER_TIMEOUT is defined.
-#ifdef TCP_USER_TIMEOUT
-#define SOCKET_SUPPORTS_TCP_USER_TIMEOUT_DEFAULT 0
-#else
-#define TCP_USER_TIMEOUT 0
-#define SOCKET_SUPPORTS_TCP_USER_TIMEOUT_DEFAULT -1
-#endif // TCP_USER_TIMEOUT
-#endif // GPR_LINUX == 1
-
-// Whether the socket supports TCP_USER_TIMEOUT option.
-// (0: don't know, 1: support, -1: not support)
-static std::atomic<int> g_socket_supports_tcp_user_timeout(
- SOCKET_SUPPORTS_TCP_USER_TIMEOUT_DEFAULT);
-
+#if GPR_LINUX == 1
+// For Linux, it will be detected to support TCP_USER_TIMEOUT
+#ifndef TCP_USER_TIMEOUT
+#define TCP_USER_TIMEOUT 18
+#endif
+#define SOCKET_SUPPORTS_TCP_USER_TIMEOUT_DEFAULT 0
+#else
+// For non-Linux, TCP_USER_TIMEOUT will be used if TCP_USER_TIMEOUT is defined.
+#ifdef TCP_USER_TIMEOUT
+#define SOCKET_SUPPORTS_TCP_USER_TIMEOUT_DEFAULT 0
+#else
+#define TCP_USER_TIMEOUT 0
+#define SOCKET_SUPPORTS_TCP_USER_TIMEOUT_DEFAULT -1
+#endif // TCP_USER_TIMEOUT
+#endif // GPR_LINUX == 1
+
+// Whether the socket supports TCP_USER_TIMEOUT option.
+// (0: don't know, 1: support, -1: not support)
+static std::atomic<int> g_socket_supports_tcp_user_timeout(
+ SOCKET_SUPPORTS_TCP_USER_TIMEOUT_DEFAULT);
+
void config_default_tcp_user_timeout(bool enable, int timeout, bool is_client) {
if (is_client) {
g_default_client_tcp_user_timeout_enabled = enable;
@@ -312,85 +312,85 @@ grpc_error* grpc_set_socket_tcp_user_timeout(
(void)fd;
(void)channel_args;
(void)is_client;
- extern grpc_core::TraceFlag grpc_tcp_trace;
- if (g_socket_supports_tcp_user_timeout.load() >= 0) {
- bool enable;
- int timeout;
- if (is_client) {
- enable = g_default_client_tcp_user_timeout_enabled;
- timeout = g_default_client_tcp_user_timeout_ms;
- } else {
- enable = g_default_server_tcp_user_timeout_enabled;
- timeout = g_default_server_tcp_user_timeout_ms;
- }
- if (channel_args) {
- for (unsigned int i = 0; i < channel_args->num_args; i++) {
- if (0 ==
- strcmp(channel_args->args[i].key, GRPC_ARG_KEEPALIVE_TIME_MS)) {
- const int value = grpc_channel_arg_get_integer(
- &channel_args->args[i], grpc_integer_options{0, 1, INT_MAX});
- /* Continue using default if value is 0 */
- if (value == 0) {
- continue;
- }
- /* Disable if value is INT_MAX */
- enable = value != INT_MAX;
- } else if (0 == strcmp(channel_args->args[i].key,
- GRPC_ARG_KEEPALIVE_TIMEOUT_MS)) {
- const int value = grpc_channel_arg_get_integer(
- &channel_args->args[i], grpc_integer_options{0, 1, INT_MAX});
- /* Continue using default if value is 0 */
- if (value == 0) {
- continue;
- }
- timeout = value;
+ extern grpc_core::TraceFlag grpc_tcp_trace;
+ if (g_socket_supports_tcp_user_timeout.load() >= 0) {
+ bool enable;
+ int timeout;
+ if (is_client) {
+ enable = g_default_client_tcp_user_timeout_enabled;
+ timeout = g_default_client_tcp_user_timeout_ms;
+ } else {
+ enable = g_default_server_tcp_user_timeout_enabled;
+ timeout = g_default_server_tcp_user_timeout_ms;
+ }
+ if (channel_args) {
+ for (unsigned int i = 0; i < channel_args->num_args; i++) {
+ if (0 ==
+ strcmp(channel_args->args[i].key, GRPC_ARG_KEEPALIVE_TIME_MS)) {
+ const int value = grpc_channel_arg_get_integer(
+ &channel_args->args[i], grpc_integer_options{0, 1, INT_MAX});
+ /* Continue using default if value is 0 */
+ if (value == 0) {
+ continue;
+ }
+ /* Disable if value is INT_MAX */
+ enable = value != INT_MAX;
+ } else if (0 == strcmp(channel_args->args[i].key,
+ GRPC_ARG_KEEPALIVE_TIMEOUT_MS)) {
+ const int value = grpc_channel_arg_get_integer(
+ &channel_args->args[i], grpc_integer_options{0, 1, INT_MAX});
+ /* Continue using default if value is 0 */
+ if (value == 0) {
+ continue;
+ }
+ timeout = value;
}
- }
- }
- if (enable) {
- int newval;
- socklen_t len = sizeof(newval);
- // If this is the first time to use TCP_USER_TIMEOUT, try to check
- // if it is available.
- if (g_socket_supports_tcp_user_timeout.load() == 0) {
- if (0 != getsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &newval, &len)) {
- gpr_log(GPR_INFO,
- "TCP_USER_TIMEOUT is not available. TCP_USER_TIMEOUT won't "
- "be used thereafter");
- g_socket_supports_tcp_user_timeout.store(-1);
- } else {
- gpr_log(GPR_INFO,
- "TCP_USER_TIMEOUT is available. TCP_USER_TIMEOUT will be "
- "used thereafter");
- g_socket_supports_tcp_user_timeout.store(1);
+ }
+ }
+ if (enable) {
+ int newval;
+ socklen_t len = sizeof(newval);
+ // If this is the first time to use TCP_USER_TIMEOUT, try to check
+ // if it is available.
+ if (g_socket_supports_tcp_user_timeout.load() == 0) {
+ if (0 != getsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &newval, &len)) {
+ gpr_log(GPR_INFO,
+ "TCP_USER_TIMEOUT is not available. TCP_USER_TIMEOUT won't "
+ "be used thereafter");
+ g_socket_supports_tcp_user_timeout.store(-1);
+ } else {
+ gpr_log(GPR_INFO,
+ "TCP_USER_TIMEOUT is available. TCP_USER_TIMEOUT will be "
+ "used thereafter");
+ g_socket_supports_tcp_user_timeout.store(1);
+ }
+ }
+ if (g_socket_supports_tcp_user_timeout.load() > 0) {
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) {
+ gpr_log(GPR_INFO, "Enabling TCP_USER_TIMEOUT with a timeout of %d ms",
+ timeout);
+ }
+ if (0 != setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &timeout,
+ sizeof(timeout))) {
+ gpr_log(GPR_ERROR, "setsockopt(TCP_USER_TIMEOUT) %s",
+ strerror(errno));
+ return GRPC_ERROR_NONE;
+ }
+ if (0 != getsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &newval, &len)) {
+ gpr_log(GPR_ERROR, "getsockopt(TCP_USER_TIMEOUT) %s",
+ strerror(errno));
+ return GRPC_ERROR_NONE;
+ }
+ if (newval != timeout) {
+ /* Do not fail on failing to set TCP_USER_TIMEOUT for now. */
+ gpr_log(GPR_ERROR, "Failed to set TCP_USER_TIMEOUT");
+ return GRPC_ERROR_NONE;
}
}
- if (g_socket_supports_tcp_user_timeout.load() > 0) {
- if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) {
- gpr_log(GPR_INFO, "Enabling TCP_USER_TIMEOUT with a timeout of %d ms",
- timeout);
- }
- if (0 != setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &timeout,
- sizeof(timeout))) {
- gpr_log(GPR_ERROR, "setsockopt(TCP_USER_TIMEOUT) %s",
- strerror(errno));
- return GRPC_ERROR_NONE;
- }
- if (0 != getsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &newval, &len)) {
- gpr_log(GPR_ERROR, "getsockopt(TCP_USER_TIMEOUT) %s",
- strerror(errno));
- return GRPC_ERROR_NONE;
- }
- if (newval != timeout) {
- /* Do not fail on failing to set TCP_USER_TIMEOUT for now. */
- gpr_log(GPR_ERROR, "Failed to set TCP_USER_TIMEOUT");
- return GRPC_ERROR_NONE;
- }
- }
}
- } else {
+ } else {
if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) {
- gpr_log(GPR_INFO, "TCP_USER_TIMEOUT not supported for this platform");
+ gpr_log(GPR_INFO, "TCP_USER_TIMEOUT not supported for this platform");
}
}
return GRPC_ERROR_NONE;
@@ -448,10 +448,10 @@ int grpc_ipv6_loopback_available(void) {
static grpc_error* error_for_fd(int fd, const grpc_resolved_address* addr) {
if (fd >= 0) return GRPC_ERROR_NONE;
- TString addr_str = grpc_sockaddr_to_string(addr, false);
- grpc_error* err = grpc_error_set_str(
- GRPC_OS_ERROR(errno, "socket"), GRPC_ERROR_STR_TARGET_ADDRESS,
- grpc_slice_from_copied_string(addr_str.c_str()));
+ TString addr_str = grpc_sockaddr_to_string(addr, false);
+ grpc_error* err = grpc_error_set_str(
+ GRPC_OS_ERROR(errno, "socket"), GRPC_ERROR_STR_TARGET_ADDRESS,
+ grpc_slice_from_copied_string(addr_str.c_str()));
return err;
}
@@ -483,7 +483,7 @@ grpc_error* grpc_create_dualstack_socket_using_factory(
errno = EAFNOSUPPORT;
}
/* Check if we've got a valid dualstack socket. */
- if (*newfd >= 0 && grpc_set_socket_dualstack(*newfd)) {
+ if (*newfd >= 0 && grpc_set_socket_dualstack(*newfd)) {
*dsmode = GRPC_DSMODE_DUALSTACK;
return GRPC_ERROR_NONE;
}
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/socket_utils_posix.h b/contrib/libs/grpc/src/core/lib/iomgr/socket_utils_posix.h
index 59cde06ac6..b4dc909d1e 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/socket_utils_posix.h
+++ b/contrib/libs/grpc/src/core/lib/iomgr/socket_utils_posix.h
@@ -31,22 +31,22 @@
#include "src/core/lib/iomgr/socket_factory_posix.h"
#include "src/core/lib/iomgr/socket_mutator.h"
-#ifdef GRPC_LINUX_ERRQUEUE
-#ifndef SO_ZEROCOPY
-#define SO_ZEROCOPY 60
-#endif
-#ifndef SO_EE_ORIGIN_ZEROCOPY
-#define SO_EE_ORIGIN_ZEROCOPY 5
-#endif
-#endif /* ifdef GRPC_LINUX_ERRQUEUE */
-
+#ifdef GRPC_LINUX_ERRQUEUE
+#ifndef SO_ZEROCOPY
+#define SO_ZEROCOPY 60
+#endif
+#ifndef SO_EE_ORIGIN_ZEROCOPY
+#define SO_EE_ORIGIN_ZEROCOPY 5
+#endif
+#endif /* ifdef GRPC_LINUX_ERRQUEUE */
+
/* a wrapper for accept or accept4 */
int grpc_accept4(int sockfd, grpc_resolved_address* resolved_addr, int nonblock,
int cloexec);
-/* set a socket to use zerocopy */
-grpc_error* grpc_set_socket_zerocopy(int fd);
-
+/* set a socket to use zerocopy */
+grpc_error* grpc_set_socket_zerocopy(int fd);
+
/* set a socket to non blocking mode */
grpc_error* grpc_set_socket_nonblocking(int fd, int non_blocking);
@@ -126,9 +126,9 @@ typedef enum grpc_dualstack_mode {
/* Only tests should use this flag. */
extern int grpc_forbid_dualstack_sockets_for_testing;
-/* Tries to set the socket to dualstack. Returns 1 on success. */
-int grpc_set_socket_dualstack(int fd);
-
+/* Tries to set the socket to dualstack. Returns 1 on success. */
+int grpc_set_socket_dualstack(int fd);
+
/* Creates a new socket for connecting to (or listening on) an address.
If addr is AF_INET6, this creates an IPv6 socket first. If that fails,
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/socket_windows.cc b/contrib/libs/grpc/src/core/lib/iomgr/socket_windows.cc
index 04d266d725..f117653c49 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/socket_windows.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/socket_windows.cc
@@ -31,8 +31,8 @@
#undef OPTIONAL
-#include "y_absl/strings/str_format.h"
-
+#include "y_absl/strings/str_format.h"
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/log_windows.h>
@@ -51,8 +51,8 @@ grpc_winsocket* grpc_winsocket_create(SOCKET socket, const char* name) {
memset(r, 0, sizeof(grpc_winsocket));
r->socket = socket;
gpr_mu_init(&r->state_mu);
- grpc_iomgr_register_object(
- &r->iomgr_object, y_absl::StrFormat("%s:socket=0x%p", name, r).c_str());
+ grpc_iomgr_register_object(
+ &r->iomgr_object, y_absl::StrFormat("%s:socket=0x%p", name, r).c_str());
grpc_iocp_add_socket(r);
return r;
}
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_cfstream.cc b/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_cfstream.cc
index 7ba74ba535..eafa885e2c 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_cfstream.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_cfstream.cc
@@ -46,7 +46,7 @@
extern grpc_core::TraceFlag grpc_tcp_trace;
-struct CFStreamConnect {
+struct CFStreamConnect {
gpr_mu mu;
gpr_refcount refcount;
@@ -65,9 +65,9 @@ struct CFStreamConnect {
grpc_closure* closure;
grpc_endpoint** endpoint;
int refs;
- TString addr_name;
+ TString addr_name;
grpc_resource_quota* resource_quota;
-};
+};
static void CFStreamConnectCleanup(CFStreamConnect* connect) {
grpc_resource_quota_unref_internal(connect->resource_quota);
@@ -75,7 +75,7 @@ static void CFStreamConnectCleanup(CFStreamConnect* connect) {
CFRelease(connect->read_stream);
CFRelease(connect->write_stream);
gpr_mu_destroy(&connect->mu);
- delete connect;
+ delete connect;
}
static void OnAlarm(void* arg, grpc_error* error) {
@@ -129,9 +129,9 @@ static void OnOpen(void* arg, grpc_error* error) {
}
if (error == GRPC_ERROR_NONE) {
*endpoint = grpc_cfstream_endpoint_create(
- connect->read_stream, connect->write_stream,
- connect->addr_name.c_str(), connect->resource_quota,
- connect->stream_handle);
+ connect->read_stream, connect->write_stream,
+ connect->addr_name.c_str(), connect->resource_quota,
+ connect->stream_handle);
}
} else {
GRPC_ERROR_REF(error);
@@ -143,12 +143,12 @@ static void OnOpen(void* arg, grpc_error* error) {
static void ParseResolvedAddress(const grpc_resolved_address* addr,
CFStringRef* host, int* port) {
- TString host_port = grpc_sockaddr_to_string(addr, true);
- TString host_string;
- TString port_string;
+ TString host_port = grpc_sockaddr_to_string(addr, true);
+ TString host_string;
+ TString port_string;
grpc_core::SplitHostPort(host_port, &host_string, &port_string);
- *host = CFStringCreateWithCString(NULL, host_string.c_str(),
- kCFStringEncodingUTF8);
+ *host = CFStringCreateWithCString(NULL, host_string.c_str(),
+ kCFStringEncodingUTF8);
*port = grpc_sockaddr_get_port(addr);
}
@@ -157,7 +157,7 @@ static void CFStreamClientConnect(grpc_closure* closure, grpc_endpoint** ep,
const grpc_channel_args* channel_args,
const grpc_resolved_address* resolved_addr,
grpc_millis deadline) {
- CFStreamConnect* connect = new CFStreamConnect();
+ CFStreamConnect* connect = new CFStreamConnect();
connect->closure = closure;
connect->endpoint = ep;
connect->addr_name = grpc_sockaddr_to_uri(resolved_addr);
@@ -168,7 +168,7 @@ static void CFStreamClientConnect(grpc_closure* closure, grpc_endpoint** ep,
if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %p, %s: asynchronously connecting",
- connect, connect->addr_name.c_str());
+ connect, connect->addr_name.c_str());
}
grpc_resource_quota* resource_quota = grpc_resource_quota_create(NULL);
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_custom.cc b/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_custom.cc
index 1b63a5c23b..dbcf62c94f 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_custom.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_custom.cc
@@ -42,14 +42,14 @@ struct grpc_custom_tcp_connect {
grpc_closure* closure;
grpc_endpoint** endpoint;
int refs;
- TString addr_name;
+ TString addr_name;
grpc_resource_quota* resource_quota;
};
static void custom_tcp_connect_cleanup(grpc_custom_tcp_connect* connect) {
grpc_custom_socket* socket = connect->socket;
grpc_resource_quota_unref_internal(connect->resource_quota);
- delete connect;
+ delete connect;
socket->refs--;
if (socket->refs == 0) {
grpc_custom_socket_vtable->destroy(socket);
@@ -66,7 +66,7 @@ static void on_alarm(void* acp, grpc_error* error) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) {
const char* str = grpc_error_string(error);
gpr_log(GPR_INFO, "CLIENT_CONNECT: %s: on_alarm: error=%s",
- connect->addr_name.c_str(), str);
+ connect->addr_name.c_str(), str);
}
if (error == GRPC_ERROR_NONE) {
/* error == NONE implies that the timer ran out, and wasn't cancelled. If
@@ -88,7 +88,7 @@ static void custom_connect_callback_internal(grpc_custom_socket* socket,
grpc_timer_cancel(&connect->alarm);
if (error == GRPC_ERROR_NONE) {
*connect->endpoint = custom_tcp_endpoint_create(
- socket, connect->resource_quota, connect->addr_name.c_str());
+ socket, connect->resource_quota, connect->addr_name.c_str());
}
done = (--connect->refs == 0);
if (done) {
@@ -133,7 +133,7 @@ static void tcp_connect(grpc_closure* closure, grpc_endpoint** ep,
(grpc_custom_socket*)gpr_malloc(sizeof(grpc_custom_socket));
socket->refs = 2;
grpc_custom_socket_vtable->init(socket, GRPC_AF_UNSPEC);
- grpc_custom_tcp_connect* connect = new grpc_custom_tcp_connect();
+ grpc_custom_tcp_connect* connect = new grpc_custom_tcp_connect();
connect->closure = closure;
connect->endpoint = ep;
connect->addr_name = grpc_sockaddr_to_uri(resolved_addr);
@@ -146,7 +146,7 @@ static void tcp_connect(grpc_closure* closure, grpc_endpoint** ep,
if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) {
gpr_log(GPR_INFO, "CLIENT_CONNECT: %p %s: asynchronously connecting",
- socket, connect->addr_name.c_str());
+ socket, connect->addr_name.c_str());
}
GRPC_CLOSURE_INIT(&connect->on_alarm, on_alarm, socket,
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_posix.cc b/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_posix.cc
index 0d4aa82794..401ddd2f68 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_posix.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_posix.cc
@@ -29,8 +29,8 @@
#include <string.h>
#include <unistd.h>
-#include "y_absl/strings/str_cat.h"
-
+#include "y_absl/strings/str_cat.h"
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
@@ -58,12 +58,12 @@ struct async_connect {
int refs;
grpc_closure write_closure;
grpc_pollset_set* interested_parties;
- TString addr_str;
+ TString addr_str;
grpc_endpoint** ep;
grpc_closure* closure;
grpc_channel_args* channel_args;
};
-
+
static grpc_error* prepare_socket(const grpc_resolved_address* addr, int fd,
const grpc_channel_args* channel_args) {
grpc_error* err = GRPC_ERROR_NONE;
@@ -104,8 +104,8 @@ static void tc_on_alarm(void* acp, grpc_error* error) {
async_connect* ac = static_cast<async_connect*>(acp);
if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) {
const char* str = grpc_error_string(error);
- gpr_log(GPR_INFO, "CLIENT_CONNECT: %s: on_alarm: error=%s",
- ac->addr_str.c_str(), str);
+ gpr_log(GPR_INFO, "CLIENT_CONNECT: %s: on_alarm: error=%s",
+ ac->addr_str.c_str(), str);
}
gpr_mu_lock(&ac->mu);
if (ac->fd != nullptr) {
@@ -117,7 +117,7 @@ static void tc_on_alarm(void* acp, grpc_error* error) {
if (done) {
gpr_mu_destroy(&ac->mu);
grpc_channel_args_destroy(ac->channel_args);
- delete ac;
+ delete ac;
}
}
@@ -140,8 +140,8 @@ static void on_writable(void* acp, grpc_error* error) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) {
const char* str = grpc_error_string(error);
- gpr_log(GPR_INFO, "CLIENT_CONNECT: %s: on_writable: error=%s",
- ac->addr_str.c_str(), str);
+ gpr_log(GPR_INFO, "CLIENT_CONNECT: %s: on_writable: error=%s",
+ ac->addr_str.c_str(), str);
}
gpr_mu_lock(&ac->mu);
@@ -173,8 +173,8 @@ static void on_writable(void* acp, grpc_error* error) {
switch (so_error) {
case 0:
grpc_pollset_set_del_fd(ac->interested_parties, fd);
- *ep = grpc_tcp_client_create_from_fd(fd, ac->channel_args,
- ac->addr_str.c_str());
+ *ep = grpc_tcp_client_create_from_fd(fd, ac->channel_args,
+ ac->addr_str.c_str());
fd = nullptr;
break;
case ENOBUFS:
@@ -216,17 +216,17 @@ finish:
done = (--ac->refs == 0);
// Create a copy of the data from "ac" to be accessed after the unlock, as
// "ac" and its contents may be deallocated by the time they are read.
- const grpc_slice addr_str_slice = grpc_slice_from_cpp_string(ac->addr_str);
+ const grpc_slice addr_str_slice = grpc_slice_from_cpp_string(ac->addr_str);
gpr_mu_unlock(&ac->mu);
if (error != GRPC_ERROR_NONE) {
grpc_slice str;
bool ret = grpc_error_get_str(error, GRPC_ERROR_STR_DESCRIPTION, &str);
GPR_ASSERT(ret);
- TString description = y_absl::StrCat("Failed to connect to remote host: ",
- grpc_core::StringViewFromSlice(str));
- error =
- grpc_error_set_str(error, GRPC_ERROR_STR_DESCRIPTION,
- grpc_slice_from_cpp_string(std::move(description)));
+ TString description = y_absl::StrCat("Failed to connect to remote host: ",
+ grpc_core::StringViewFromSlice(str));
+ error =
+ grpc_error_set_str(error, GRPC_ERROR_STR_DESCRIPTION,
+ grpc_slice_from_cpp_string(std::move(description)));
error = grpc_error_set_str(error, GRPC_ERROR_STR_TARGET_ADDRESS,
addr_str_slice /* takes ownership */);
} else {
@@ -237,7 +237,7 @@ finish:
// populated *inside* the lock.
gpr_mu_destroy(&ac->mu);
grpc_channel_args_destroy(ac->channel_args);
- delete ac;
+ delete ac;
}
grpc_core::ExecCtx::Run(DEBUG_LOCATION, closure, error);
}
@@ -245,10 +245,10 @@ finish:
grpc_error* grpc_tcp_client_prepare_fd(const grpc_channel_args* channel_args,
const grpc_resolved_address* addr,
grpc_resolved_address* mapped_addr,
- int* fd) {
+ int* fd) {
grpc_dualstack_mode dsmode;
grpc_error* error;
- *fd = -1;
+ *fd = -1;
/* Use dualstack sockets where available. Set mapped to v6 or v4 mapped to
v6. */
if (!grpc_sockaddr_to_v4mapped(addr, mapped_addr)) {
@@ -256,7 +256,7 @@ grpc_error* grpc_tcp_client_prepare_fd(const grpc_channel_args* channel_args,
memcpy(mapped_addr, addr, sizeof(*mapped_addr));
}
error =
- grpc_create_dualstack_socket(mapped_addr, SOCK_STREAM, 0, &dsmode, fd);
+ grpc_create_dualstack_socket(mapped_addr, SOCK_STREAM, 0, &dsmode, fd);
if (error != GRPC_ERROR_NONE) {
return error;
}
@@ -266,7 +266,7 @@ grpc_error* grpc_tcp_client_prepare_fd(const grpc_channel_args* channel_args,
memcpy(mapped_addr, addr, sizeof(*mapped_addr));
}
}
- if ((error = prepare_socket(mapped_addr, *fd, channel_args)) !=
+ if ((error = prepare_socket(mapped_addr, *fd, channel_args)) !=
GRPC_ERROR_NONE) {
return error;
}
@@ -274,7 +274,7 @@ grpc_error* grpc_tcp_client_prepare_fd(const grpc_channel_args* channel_args,
}
void grpc_tcp_client_create_from_prepared_fd(
- grpc_pollset_set* interested_parties, grpc_closure* closure, const int fd,
+ grpc_pollset_set* interested_parties, grpc_closure* closure, const int fd,
const grpc_channel_args* channel_args, const grpc_resolved_address* addr,
grpc_millis deadline, grpc_endpoint** ep) {
int err;
@@ -282,29 +282,29 @@ void grpc_tcp_client_create_from_prepared_fd(
err = connect(fd, reinterpret_cast<const grpc_sockaddr*>(addr->addr),
addr->len);
} while (err < 0 && errno == EINTR);
-
- TString name = y_absl::StrCat("tcp-client:", grpc_sockaddr_to_uri(addr));
- grpc_fd* fdobj = grpc_fd_create(fd, name.c_str(), true);
-
+
+ TString name = y_absl::StrCat("tcp-client:", grpc_sockaddr_to_uri(addr));
+ grpc_fd* fdobj = grpc_fd_create(fd, name.c_str(), true);
+
if (err >= 0) {
- *ep = grpc_tcp_client_create_from_fd(fdobj, channel_args,
- grpc_sockaddr_to_uri(addr).c_str());
+ *ep = grpc_tcp_client_create_from_fd(fdobj, channel_args,
+ grpc_sockaddr_to_uri(addr).c_str());
grpc_core::ExecCtx::Run(DEBUG_LOCATION, closure, GRPC_ERROR_NONE);
return;
}
if (errno != EWOULDBLOCK && errno != EINPROGRESS) {
- grpc_error* error = GRPC_OS_ERROR(errno, "connect");
- error = grpc_error_set_str(
- error, GRPC_ERROR_STR_TARGET_ADDRESS,
- grpc_slice_from_cpp_string(grpc_sockaddr_to_uri(addr)));
+ grpc_error* error = GRPC_OS_ERROR(errno, "connect");
+ error = grpc_error_set_str(
+ error, GRPC_ERROR_STR_TARGET_ADDRESS,
+ grpc_slice_from_cpp_string(grpc_sockaddr_to_uri(addr)));
grpc_fd_orphan(fdobj, nullptr, nullptr, "tcp_client_connect_error");
- grpc_core::ExecCtx::Run(DEBUG_LOCATION, closure, error);
+ grpc_core::ExecCtx::Run(DEBUG_LOCATION, closure, error);
return;
}
grpc_pollset_set_add_fd(interested_parties, fdobj);
- async_connect* ac = new async_connect();
+ async_connect* ac = new async_connect();
ac->closure = closure;
ac->ep = ep;
ac->fd = fdobj;
@@ -318,7 +318,7 @@ void grpc_tcp_client_create_from_prepared_fd(
if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) {
gpr_log(GPR_INFO, "CLIENT_CONNECT: %s: asynchronously connecting fd %p",
- ac->addr_str.c_str(), fdobj);
+ ac->addr_str.c_str(), fdobj);
}
gpr_mu_lock(&ac->mu);
@@ -334,15 +334,15 @@ static void tcp_connect(grpc_closure* closure, grpc_endpoint** ep,
const grpc_resolved_address* addr,
grpc_millis deadline) {
grpc_resolved_address mapped_addr;
- int fd = -1;
+ int fd = -1;
grpc_error* error;
*ep = nullptr;
if ((error = grpc_tcp_client_prepare_fd(channel_args, addr, &mapped_addr,
- &fd)) != GRPC_ERROR_NONE) {
+ &fd)) != GRPC_ERROR_NONE) {
grpc_core::ExecCtx::Run(DEBUG_LOCATION, closure, error);
return;
}
- grpc_tcp_client_create_from_prepared_fd(interested_parties, closure, fd,
+ grpc_tcp_client_create_from_prepared_fd(interested_parties, closure, fd,
channel_args, &mapped_addr, deadline,
ep);
}
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_posix.h b/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_posix.h
index e27d8225e8..6f61866fc4 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_posix.h
+++ b/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_posix.h
@@ -35,33 +35,33 @@
grpc_endpoint* grpc_tcp_client_create_from_fd(
grpc_fd* fd, const grpc_channel_args* channel_args, const char* addr_str);
-/* Return a configured, unbound, unconnected TCP client fd.
+/* Return a configured, unbound, unconnected TCP client fd.
channel_args: may contain custom settings for the fd
addr: the destination address
mapped_addr: out parameter. addr mapped to an address appropriate to the
type of socket FD created. For example, if addr is IPv4 and dual stack
sockets are available, mapped_addr will be an IPv4-mapped IPv6 address
- fd: out parameter. The new FD
+ fd: out parameter. The new FD
Returns: error, if any. Out parameters are not set on error
*/
grpc_error* grpc_tcp_client_prepare_fd(const grpc_channel_args* channel_args,
const grpc_resolved_address* addr,
grpc_resolved_address* mapped_addr,
- int* fd);
+ int* fd);
-/* Connect a configured TCP client fd.
+/* Connect a configured TCP client fd.
interested_parties: a set of pollsets that would be interested in this
connection being established (in order to continue their work
closure: called when complete. On success, *ep will be set.
- fd: an FD returned from grpc_tcp_client_prepare_fd().
+ fd: an FD returned from grpc_tcp_client_prepare_fd().
channel_args: may contain custom settings for the endpoint
deadline: connection deadline
ep: out parameter. Set before closure is called if successful
*/
void grpc_tcp_client_create_from_prepared_fd(
- grpc_pollset_set* interested_parties, grpc_closure* closure, const int fd,
+ grpc_pollset_set* interested_parties, grpc_closure* closure, const int fd,
const grpc_channel_args* channel_args, const grpc_resolved_address* addr,
grpc_millis deadline, grpc_endpoint** ep);
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_windows.cc b/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_windows.cc
index 18c6e427b2..a57e7539f2 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_windows.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_windows.cc
@@ -39,7 +39,7 @@
#include "src/core/lib/iomgr/tcp_client.h"
#include "src/core/lib/iomgr/tcp_windows.h"
#include "src/core/lib/iomgr/timer.h"
-#include "src/core/lib/slice/slice_internal.h"
+#include "src/core/lib/slice/slice_internal.h"
struct async_connect {
grpc_closure* on_done;
@@ -47,13 +47,13 @@ struct async_connect {
grpc_winsocket* socket;
grpc_timer alarm;
grpc_closure on_alarm;
- TString addr_name;
+ TString addr_name;
int refs;
grpc_closure on_connect;
grpc_endpoint** endpoint;
grpc_channel_args* channel_args;
};
-
+
static void async_connect_unlock_and_cleanup(async_connect* ac,
grpc_winsocket* socket) {
int done = (--ac->refs == 0);
@@ -61,7 +61,7 @@ static void async_connect_unlock_and_cleanup(async_connect* ac,
if (done) {
grpc_channel_args_destroy(ac->channel_args);
gpr_mu_destroy(&ac->mu);
- delete ac;
+ delete ac;
}
if (socket != NULL) grpc_winsocket_destroy(socket);
}
@@ -106,7 +106,7 @@ static void on_connect(void* acp, grpc_error* error) {
error = GRPC_WSA_ERROR(WSAGetLastError(), "ConnectEx");
closesocket(socket->socket);
} else {
- *ep = grpc_tcp_create(socket, ac->channel_args, ac->addr_name.c_str());
+ *ep = grpc_tcp_create(socket, ac->channel_args, ac->addr_name.c_str());
socket = NULL;
}
} else {
@@ -138,7 +138,7 @@ static void tcp_connect(grpc_closure* on_done, grpc_endpoint** endpoint,
DWORD ioctl_num_bytes;
grpc_winsocket_callback_info* info;
grpc_error* error = GRPC_ERROR_NONE;
- async_connect* ac = NULL;
+ async_connect* ac = NULL;
*endpoint = NULL;
@@ -195,7 +195,7 @@ static void tcp_connect(grpc_closure* on_done, grpc_endpoint** endpoint,
}
}
- ac = new async_connect();
+ ac = new async_connect();
ac->on_done = on_done;
ac->socket = socket;
gpr_mu_init(&ac->mu);
@@ -212,12 +212,12 @@ static void tcp_connect(grpc_closure* on_done, grpc_endpoint** endpoint,
failure:
GPR_ASSERT(error != GRPC_ERROR_NONE);
- TString target_uri = grpc_sockaddr_to_uri(addr);
+ TString target_uri = grpc_sockaddr_to_uri(addr);
grpc_error* final_error =
grpc_error_set_str(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Failed to connect", &error, 1),
GRPC_ERROR_STR_TARGET_ADDRESS,
- grpc_slice_from_cpp_string(std::move(target_uri)));
+ grpc_slice_from_cpp_string(std::move(target_uri)));
GRPC_ERROR_UNREF(error);
if (socket != NULL) {
grpc_winsocket_destroy(socket);
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/tcp_custom.cc b/contrib/libs/grpc/src/core/lib/iomgr/tcp_custom.cc
index d2de7bc717..3e562da508 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/tcp_custom.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/tcp_custom.cc
@@ -32,7 +32,7 @@
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/iomgr_custom.h"
#include "src/core/lib/iomgr/resource_quota.h"
-#include "src/core/lib/iomgr/sockaddr_utils.h"
+#include "src/core/lib/iomgr/sockaddr_utils.h"
#include "src/core/lib/iomgr/tcp_client.h"
#include "src/core/lib/iomgr/tcp_custom.h"
#include "src/core/lib/iomgr/tcp_server.h"
@@ -58,24 +58,24 @@ struct custom_tcp_endpoint {
gpr_refcount refcount;
grpc_custom_socket* socket;
- grpc_closure* read_cb = nullptr;
- grpc_closure* write_cb = nullptr;
+ grpc_closure* read_cb = nullptr;
+ grpc_closure* write_cb = nullptr;
- grpc_slice_buffer* read_slices = nullptr;
- grpc_slice_buffer* write_slices = nullptr;
+ grpc_slice_buffer* read_slices = nullptr;
+ grpc_slice_buffer* write_slices = nullptr;
grpc_resource_user* resource_user;
grpc_resource_user_slice_allocator slice_allocator;
bool shutting_down;
- TString peer_string;
- TString local_address;
+ TString peer_string;
+ TString local_address;
};
static void tcp_free(grpc_custom_socket* s) {
custom_tcp_endpoint* tcp = (custom_tcp_endpoint*)s->endpoint;
grpc_resource_user_unref(tcp->resource_user);
- delete tcp;
+ delete tcp;
s->refs--;
if (s->refs == 0) {
grpc_custom_socket_vtable->destroy(s);
@@ -133,8 +133,8 @@ static void call_read_cb(custom_tcp_endpoint* tcp, grpc_error* error) {
for (i = 0; i < tcp->read_slices->count; i++) {
char* dump = grpc_dump_slice(tcp->read_slices->slices[i],
GPR_DUMP_HEX | GPR_DUMP_ASCII);
- gpr_log(GPR_INFO, "READ %p (peer=%s): %s", tcp, tcp->peer_string.c_str(),
- dump);
+ gpr_log(GPR_INFO, "READ %p (peer=%s): %s", tcp, tcp->peer_string.c_str(),
+ dump);
gpr_free(dump);
}
}
@@ -235,8 +235,8 @@ static void endpoint_write(grpc_endpoint* ep, grpc_slice_buffer* write_slices,
for (j = 0; j < write_slices->count; j++) {
char* data = grpc_dump_slice(write_slices->slices[j],
GPR_DUMP_HEX | GPR_DUMP_ASCII);
- gpr_log(GPR_INFO, "WRITE %p (peer=%s): %s", tcp->socket,
- tcp->peer_string.c_str(), data);
+ gpr_log(GPR_INFO, "WRITE %p (peer=%s): %s", tcp->socket,
+ tcp->peer_string.c_str(), data);
gpr_free(data);
}
}
@@ -319,16 +319,16 @@ static void endpoint_destroy(grpc_endpoint* ep) {
grpc_custom_socket_vtable->close(tcp->socket, custom_close_callback);
}
-static y_absl::string_view endpoint_get_peer(grpc_endpoint* ep) {
+static y_absl::string_view endpoint_get_peer(grpc_endpoint* ep) {
custom_tcp_endpoint* tcp = (custom_tcp_endpoint*)ep;
- return tcp->peer_string;
+ return tcp->peer_string;
+}
+
+static y_absl::string_view endpoint_get_local_address(grpc_endpoint* ep) {
+ custom_tcp_endpoint* tcp = (custom_tcp_endpoint*)ep;
+ return tcp->local_address;
}
-static y_absl::string_view endpoint_get_local_address(grpc_endpoint* ep) {
- custom_tcp_endpoint* tcp = (custom_tcp_endpoint*)ep;
- return tcp->local_address;
-}
-
static grpc_resource_user* endpoint_get_resource_user(grpc_endpoint* ep) {
custom_tcp_endpoint* tcp = (custom_tcp_endpoint*)ep;
return tcp->resource_user;
@@ -347,14 +347,14 @@ static grpc_endpoint_vtable vtable = {endpoint_read,
endpoint_destroy,
endpoint_get_resource_user,
endpoint_get_peer,
- endpoint_get_local_address,
+ endpoint_get_local_address,
endpoint_get_fd,
endpoint_can_track_err};
grpc_endpoint* custom_tcp_endpoint_create(grpc_custom_socket* socket,
grpc_resource_quota* resource_quota,
- const char* peer_string) {
- custom_tcp_endpoint* tcp = new custom_tcp_endpoint;
+ const char* peer_string) {
+ custom_tcp_endpoint* tcp = new custom_tcp_endpoint;
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
@@ -366,17 +366,17 @@ grpc_endpoint* custom_tcp_endpoint_create(grpc_custom_socket* socket,
tcp->socket = socket;
tcp->base.vtable = &vtable;
gpr_ref_init(&tcp->refcount, 1);
- tcp->peer_string = peer_string;
- grpc_resolved_address resolved_local_addr;
- resolved_local_addr.len = sizeof(resolved_local_addr.addr);
- if (grpc_custom_socket_vtable->getsockname(
- socket, reinterpret_cast<sockaddr*>(resolved_local_addr.addr),
- reinterpret_cast<int*>(&resolved_local_addr.len)) !=
- GRPC_ERROR_NONE) {
- tcp->local_address = "";
- } else {
- tcp->local_address = grpc_sockaddr_to_uri(&resolved_local_addr);
- }
+ tcp->peer_string = peer_string;
+ grpc_resolved_address resolved_local_addr;
+ resolved_local_addr.len = sizeof(resolved_local_addr.addr);
+ if (grpc_custom_socket_vtable->getsockname(
+ socket, reinterpret_cast<sockaddr*>(resolved_local_addr.addr),
+ reinterpret_cast<int*>(&resolved_local_addr.len)) !=
+ GRPC_ERROR_NONE) {
+ tcp->local_address = "";
+ } else {
+ tcp->local_address = grpc_sockaddr_to_uri(&resolved_local_addr);
+ }
tcp->shutting_down = false;
tcp->resource_user = grpc_resource_user_create(resource_quota, peer_string);
grpc_resource_user_slice_allocator_init(
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/tcp_custom.h b/contrib/libs/grpc/src/core/lib/iomgr/tcp_custom.h
index c7b08adee1..d32ed2b4b6 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/tcp_custom.h
+++ b/contrib/libs/grpc/src/core/lib/iomgr/tcp_custom.h
@@ -24,9 +24,9 @@
#include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/iomgr/sockaddr.h"
-// Same number as the micro of SO_REUSEPORT in kernel
-#define GRPC_CUSTOM_SOCKET_OPT_SO_REUSEPORT (0x00000200u)
-
+// Same number as the micro of SO_REUSEPORT in kernel
+#define GRPC_CUSTOM_SOCKET_OPT_SO_REUSEPORT (0x00000200u)
+
typedef struct grpc_tcp_listener grpc_tcp_listener;
typedef struct grpc_custom_tcp_connect grpc_custom_tcp_connect;
@@ -79,6 +79,6 @@ void grpc_custom_close_server_callback(grpc_tcp_listener* listener);
grpc_endpoint* custom_tcp_endpoint_create(grpc_custom_socket* socket,
grpc_resource_quota* resource_quota,
- const char* peer_string);
+ const char* peer_string);
#endif /* GRPC_CORE_LIB_IOMGR_TCP_CUSTOM_H */
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/tcp_posix.cc b/contrib/libs/grpc/src/core/lib/iomgr/tcp_posix.cc
index b6b4501702..b1cd892964 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/tcp_posix.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/tcp_posix.cc
@@ -36,7 +36,7 @@
#include <sys/types.h>
#include <unistd.h>
#include <algorithm>
-#include <unordered_map>
+#include <unordered_map>
#include <grpc/slice.h>
#include <grpc/support/alloc.h>
@@ -50,12 +50,12 @@
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gpr/useful.h"
-#include "src/core/lib/gprpp/sync.h"
+#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/iomgr/buffer_list.h"
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/executor.h"
-#include "src/core/lib/iomgr/sockaddr_utils.h"
-#include "src/core/lib/iomgr/socket_utils_posix.h"
+#include "src/core/lib/iomgr/sockaddr_utils.h"
+#include "src/core/lib/iomgr/socket_utils_posix.h"
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
@@ -75,15 +75,15 @@
#define SENDMSG_FLAGS 0
#endif
-// TCP zero copy sendmsg flag.
-// NB: We define this here as a fallback in case we're using an older set of
-// library headers that has not defined MSG_ZEROCOPY. Since this constant is
-// part of the kernel, we are guaranteed it will never change/disagree so
-// defining it here is safe.
-#ifndef MSG_ZEROCOPY
-#define MSG_ZEROCOPY 0x4000000
-#endif
-
+// TCP zero copy sendmsg flag.
+// NB: We define this here as a fallback in case we're using an older set of
+// library headers that has not defined MSG_ZEROCOPY. Since this constant is
+// part of the kernel, we are guaranteed it will never change/disagree so
+// defining it here is safe.
+#ifndef MSG_ZEROCOPY
+#define MSG_ZEROCOPY 0x4000000
+#endif
+
#ifdef GRPC_MSG_IOVLEN_TYPE
typedef GRPC_MSG_IOVLEN_TYPE msg_iovlen_type;
#else
@@ -92,268 +92,268 @@ typedef size_t msg_iovlen_type;
extern grpc_core::TraceFlag grpc_tcp_trace;
-namespace grpc_core {
-
-class TcpZerocopySendRecord {
- public:
- TcpZerocopySendRecord() { grpc_slice_buffer_init(&buf_); }
-
- ~TcpZerocopySendRecord() {
- AssertEmpty();
- grpc_slice_buffer_destroy_internal(&buf_);
- }
-
- // Given the slices that we wish to send, and the current offset into the
- // slice buffer (indicating which have already been sent), populate an iovec
- // array that will be used for a zerocopy enabled sendmsg().
- msg_iovlen_type PopulateIovs(size_t* unwind_slice_idx,
- size_t* unwind_byte_idx, size_t* sending_length,
- iovec* iov);
-
- // A sendmsg() may not be able to send the bytes that we requested at this
- // time, returning EAGAIN (possibly due to backpressure). In this case,
- // unwind the offset into the slice buffer so we retry sending these bytes.
- void UnwindIfThrottled(size_t unwind_slice_idx, size_t unwind_byte_idx) {
- out_offset_.byte_idx = unwind_byte_idx;
- out_offset_.slice_idx = unwind_slice_idx;
- }
-
- // Update the offset into the slice buffer based on how much we wanted to sent
- // vs. what sendmsg() actually sent (which may be lower, possibly due to
- // backpressure).
- void UpdateOffsetForBytesSent(size_t sending_length, size_t actually_sent);
-
- // Indicates whether all underlying data has been sent or not.
- bool AllSlicesSent() { return out_offset_.slice_idx == buf_.count; }
-
- // Reset this structure for a new tcp_write() with zerocopy.
- void PrepareForSends(grpc_slice_buffer* slices_to_send) {
- AssertEmpty();
- out_offset_.slice_idx = 0;
- out_offset_.byte_idx = 0;
- grpc_slice_buffer_swap(slices_to_send, &buf_);
- Ref();
- }
-
- // References: 1 reference per sendmsg(), and 1 for the tcp_write().
- void Ref() { ref_.FetchAdd(1, MemoryOrder::RELAXED); }
-
- // Unref: called when we get an error queue notification for a sendmsg(), if a
- // sendmsg() failed or when tcp_write() is done.
- bool Unref() {
- const intptr_t prior = ref_.FetchSub(1, MemoryOrder::ACQ_REL);
- GPR_DEBUG_ASSERT(prior > 0);
- if (prior == 1) {
- AllSendsComplete();
- return true;
- }
- return false;
- }
-
- private:
- struct OutgoingOffset {
- size_t slice_idx = 0;
- size_t byte_idx = 0;
- };
-
- void AssertEmpty() {
- GPR_DEBUG_ASSERT(buf_.count == 0);
- GPR_DEBUG_ASSERT(buf_.length == 0);
- GPR_DEBUG_ASSERT(ref_.Load(MemoryOrder::RELAXED) == 0);
- }
-
- // When all sendmsg() calls associated with this tcp_write() have been
- // completed (ie. we have received the notifications for each sequence number
- // for each sendmsg()) and all reference counts have been dropped, drop our
- // reference to the underlying data since we no longer need it.
- void AllSendsComplete() {
- GPR_DEBUG_ASSERT(ref_.Load(MemoryOrder::RELAXED) == 0);
- grpc_slice_buffer_reset_and_unref_internal(&buf_);
- }
-
- grpc_slice_buffer buf_;
- Atomic<intptr_t> ref_;
- OutgoingOffset out_offset_;
-};
-
-class TcpZerocopySendCtx {
- public:
- static constexpr int kDefaultMaxSends = 4;
- static constexpr size_t kDefaultSendBytesThreshold = 16 * 1024; // 16KB
-
- TcpZerocopySendCtx(int max_sends = kDefaultMaxSends,
- size_t send_bytes_threshold = kDefaultSendBytesThreshold)
- : max_sends_(max_sends),
- free_send_records_size_(max_sends),
- threshold_bytes_(send_bytes_threshold) {
- send_records_ = static_cast<TcpZerocopySendRecord*>(
- gpr_malloc(max_sends * sizeof(*send_records_)));
- free_send_records_ = static_cast<TcpZerocopySendRecord**>(
- gpr_malloc(max_sends * sizeof(*free_send_records_)));
- if (send_records_ == nullptr || free_send_records_ == nullptr) {
- gpr_free(send_records_);
- gpr_free(free_send_records_);
- gpr_log(GPR_INFO, "Disabling TCP TX zerocopy due to memory pressure.\n");
- memory_limited_ = true;
- } else {
- for (int idx = 0; idx < max_sends_; ++idx) {
- new (send_records_ + idx) TcpZerocopySendRecord();
- free_send_records_[idx] = send_records_ + idx;
- }
- }
- }
-
- ~TcpZerocopySendCtx() {
- if (send_records_ != nullptr) {
- for (int idx = 0; idx < max_sends_; ++idx) {
- send_records_[idx].~TcpZerocopySendRecord();
- }
- }
- gpr_free(send_records_);
- gpr_free(free_send_records_);
- }
-
- // True if we were unable to allocate the various bookkeeping structures at
- // transport initialization time. If memory limited, we do not zerocopy.
- bool memory_limited() const { return memory_limited_; }
-
- // TCP send zerocopy maintains an implicit sequence number for every
- // successful sendmsg() with zerocopy enabled; the kernel later gives us an
- // error queue notification with this sequence number indicating that the
- // underlying data buffers that we sent can now be released. Once that
- // notification is received, we can release the buffers associated with this
- // zerocopy send record. Here, we associate the sequence number with the data
- // buffers that were sent with the corresponding call to sendmsg().
- void NoteSend(TcpZerocopySendRecord* record) {
- record->Ref();
- AssociateSeqWithSendRecord(last_send_, record);
- ++last_send_;
- }
-
- // If sendmsg() actually failed, though, we need to revert the sequence number
- // that we speculatively bumped before calling sendmsg(). Note that we bump
- // this sequence number and perform relevant bookkeeping (see: NoteSend())
- // *before* calling sendmsg() since, if we called it *after* sendmsg(), then
- // there is a possible race with the release notification which could occur on
- // another thread before we do the necessary bookkeeping. Hence, calling
- // NoteSend() *before* sendmsg() and implementing an undo function is needed.
- void UndoSend() {
- --last_send_;
- if (ReleaseSendRecord(last_send_)->Unref()) {
- // We should still be holding the ref taken by tcp_write().
- GPR_DEBUG_ASSERT(0);
- }
- }
-
- // Simply associate this send record (and the underlying sent data buffers)
- // with the implicit sequence number for this zerocopy sendmsg().
- void AssociateSeqWithSendRecord(uint32_t seq, TcpZerocopySendRecord* record) {
- MutexLock guard(&lock_);
- ctx_lookup_.emplace(seq, record);
- }
-
- // Get a send record for a send that we wish to do with zerocopy.
- TcpZerocopySendRecord* GetSendRecord() {
- MutexLock guard(&lock_);
- return TryGetSendRecordLocked();
- }
-
- // A given send record corresponds to a single tcp_write() with zerocopy
- // enabled. This can result in several sendmsg() calls to flush all of the
- // data to wire. Each sendmsg() takes a reference on the
- // TcpZerocopySendRecord, and corresponds to a single sequence number.
- // ReleaseSendRecord releases a reference on TcpZerocopySendRecord for a
- // single sequence number. This is called either when we receive the relevant
- // error queue notification (saying that we can discard the underlying
- // buffers for this sendmsg()) is received from the kernel - or, in case
- // sendmsg() was unsuccessful to begin with.
- TcpZerocopySendRecord* ReleaseSendRecord(uint32_t seq) {
- MutexLock guard(&lock_);
- return ReleaseSendRecordLocked(seq);
- }
-
- // After all the references to a TcpZerocopySendRecord are released, we can
- // add it back to the pool (of size max_sends_). Note that we can only have
- // max_sends_ tcp_write() instances with zerocopy enabled in flight at the
- // same time.
- void PutSendRecord(TcpZerocopySendRecord* record) {
- GPR_DEBUG_ASSERT(record >= send_records_ &&
- record < send_records_ + max_sends_);
- MutexLock guard(&lock_);
- PutSendRecordLocked(record);
- }
-
- // Indicate that we are disposing of this zerocopy context. This indicator
- // will prevent new zerocopy writes from being issued.
- void Shutdown() { shutdown_.Store(true, MemoryOrder::RELEASE); }
-
- // Indicates that there are no inflight tcp_write() instances with zerocopy
- // enabled.
- bool AllSendRecordsEmpty() {
- MutexLock guard(&lock_);
- return free_send_records_size_ == max_sends_;
- }
-
- bool enabled() const { return enabled_; }
-
- void set_enabled(bool enabled) {
- GPR_DEBUG_ASSERT(!enabled || !memory_limited());
- enabled_ = enabled;
- }
-
- // Only use zerocopy if we are sending at least this many bytes. The
- // additional overhead of reading the error queue for notifications means that
- // zerocopy is not useful for small transfers.
- size_t threshold_bytes() const { return threshold_bytes_; }
-
- private:
- TcpZerocopySendRecord* ReleaseSendRecordLocked(uint32_t seq) {
- auto iter = ctx_lookup_.find(seq);
- GPR_DEBUG_ASSERT(iter != ctx_lookup_.end());
- TcpZerocopySendRecord* record = iter->second;
- ctx_lookup_.erase(iter);
- return record;
- }
-
- TcpZerocopySendRecord* TryGetSendRecordLocked() {
- if (shutdown_.Load(MemoryOrder::ACQUIRE)) {
- return nullptr;
- }
- if (free_send_records_size_ == 0) {
- return nullptr;
- }
- free_send_records_size_--;
- return free_send_records_[free_send_records_size_];
- }
-
- void PutSendRecordLocked(TcpZerocopySendRecord* record) {
- GPR_DEBUG_ASSERT(free_send_records_size_ < max_sends_);
- free_send_records_[free_send_records_size_] = record;
- free_send_records_size_++;
- }
-
- TcpZerocopySendRecord* send_records_;
- TcpZerocopySendRecord** free_send_records_;
- int max_sends_;
- int free_send_records_size_;
- Mutex lock_;
- uint32_t last_send_ = 0;
- Atomic<bool> shutdown_;
- bool enabled_ = false;
- size_t threshold_bytes_ = kDefaultSendBytesThreshold;
- std::unordered_map<uint32_t, TcpZerocopySendRecord*> ctx_lookup_;
- bool memory_limited_ = false;
-};
-
-} // namespace grpc_core
-
-using grpc_core::TcpZerocopySendCtx;
-using grpc_core::TcpZerocopySendRecord;
-
+namespace grpc_core {
+
+class TcpZerocopySendRecord {
+ public:
+ TcpZerocopySendRecord() { grpc_slice_buffer_init(&buf_); }
+
+ ~TcpZerocopySendRecord() {
+ AssertEmpty();
+ grpc_slice_buffer_destroy_internal(&buf_);
+ }
+
+ // Given the slices that we wish to send, and the current offset into the
+ // slice buffer (indicating which have already been sent), populate an iovec
+ // array that will be used for a zerocopy enabled sendmsg().
+ msg_iovlen_type PopulateIovs(size_t* unwind_slice_idx,
+ size_t* unwind_byte_idx, size_t* sending_length,
+ iovec* iov);
+
+ // A sendmsg() may not be able to send the bytes that we requested at this
+ // time, returning EAGAIN (possibly due to backpressure). In this case,
+ // unwind the offset into the slice buffer so we retry sending these bytes.
+ void UnwindIfThrottled(size_t unwind_slice_idx, size_t unwind_byte_idx) {
+ out_offset_.byte_idx = unwind_byte_idx;
+ out_offset_.slice_idx = unwind_slice_idx;
+ }
+
+ // Update the offset into the slice buffer based on how much we wanted to sent
+ // vs. what sendmsg() actually sent (which may be lower, possibly due to
+ // backpressure).
+ void UpdateOffsetForBytesSent(size_t sending_length, size_t actually_sent);
+
+ // Indicates whether all underlying data has been sent or not.
+ bool AllSlicesSent() { return out_offset_.slice_idx == buf_.count; }
+
+ // Reset this structure for a new tcp_write() with zerocopy.
+ void PrepareForSends(grpc_slice_buffer* slices_to_send) {
+ AssertEmpty();
+ out_offset_.slice_idx = 0;
+ out_offset_.byte_idx = 0;
+ grpc_slice_buffer_swap(slices_to_send, &buf_);
+ Ref();
+ }
+
+ // References: 1 reference per sendmsg(), and 1 for the tcp_write().
+ void Ref() { ref_.FetchAdd(1, MemoryOrder::RELAXED); }
+
+ // Unref: called when we get an error queue notification for a sendmsg(), if a
+ // sendmsg() failed or when tcp_write() is done.
+ bool Unref() {
+ const intptr_t prior = ref_.FetchSub(1, MemoryOrder::ACQ_REL);
+ GPR_DEBUG_ASSERT(prior > 0);
+ if (prior == 1) {
+ AllSendsComplete();
+ return true;
+ }
+ return false;
+ }
+
+ private:
+ struct OutgoingOffset {
+ size_t slice_idx = 0;
+ size_t byte_idx = 0;
+ };
+
+ void AssertEmpty() {
+ GPR_DEBUG_ASSERT(buf_.count == 0);
+ GPR_DEBUG_ASSERT(buf_.length == 0);
+ GPR_DEBUG_ASSERT(ref_.Load(MemoryOrder::RELAXED) == 0);
+ }
+
+ // When all sendmsg() calls associated with this tcp_write() have been
+ // completed (ie. we have received the notifications for each sequence number
+ // for each sendmsg()) and all reference counts have been dropped, drop our
+ // reference to the underlying data since we no longer need it.
+ void AllSendsComplete() {
+ GPR_DEBUG_ASSERT(ref_.Load(MemoryOrder::RELAXED) == 0);
+ grpc_slice_buffer_reset_and_unref_internal(&buf_);
+ }
+
+ grpc_slice_buffer buf_;
+ Atomic<intptr_t> ref_;
+ OutgoingOffset out_offset_;
+};
+
+class TcpZerocopySendCtx {
+ public:
+ static constexpr int kDefaultMaxSends = 4;
+ static constexpr size_t kDefaultSendBytesThreshold = 16 * 1024; // 16KB
+
+ TcpZerocopySendCtx(int max_sends = kDefaultMaxSends,
+ size_t send_bytes_threshold = kDefaultSendBytesThreshold)
+ : max_sends_(max_sends),
+ free_send_records_size_(max_sends),
+ threshold_bytes_(send_bytes_threshold) {
+ send_records_ = static_cast<TcpZerocopySendRecord*>(
+ gpr_malloc(max_sends * sizeof(*send_records_)));
+ free_send_records_ = static_cast<TcpZerocopySendRecord**>(
+ gpr_malloc(max_sends * sizeof(*free_send_records_)));
+ if (send_records_ == nullptr || free_send_records_ == nullptr) {
+ gpr_free(send_records_);
+ gpr_free(free_send_records_);
+ gpr_log(GPR_INFO, "Disabling TCP TX zerocopy due to memory pressure.\n");
+ memory_limited_ = true;
+ } else {
+ for (int idx = 0; idx < max_sends_; ++idx) {
+ new (send_records_ + idx) TcpZerocopySendRecord();
+ free_send_records_[idx] = send_records_ + idx;
+ }
+ }
+ }
+
+ ~TcpZerocopySendCtx() {
+ if (send_records_ != nullptr) {
+ for (int idx = 0; idx < max_sends_; ++idx) {
+ send_records_[idx].~TcpZerocopySendRecord();
+ }
+ }
+ gpr_free(send_records_);
+ gpr_free(free_send_records_);
+ }
+
+ // True if we were unable to allocate the various bookkeeping structures at
+ // transport initialization time. If memory limited, we do not zerocopy.
+ bool memory_limited() const { return memory_limited_; }
+
+ // TCP send zerocopy maintains an implicit sequence number for every
+ // successful sendmsg() with zerocopy enabled; the kernel later gives us an
+ // error queue notification with this sequence number indicating that the
+ // underlying data buffers that we sent can now be released. Once that
+ // notification is received, we can release the buffers associated with this
+ // zerocopy send record. Here, we associate the sequence number with the data
+ // buffers that were sent with the corresponding call to sendmsg().
+ void NoteSend(TcpZerocopySendRecord* record) {
+ record->Ref();
+ AssociateSeqWithSendRecord(last_send_, record);
+ ++last_send_;
+ }
+
+ // If sendmsg() actually failed, though, we need to revert the sequence number
+ // that we speculatively bumped before calling sendmsg(). Note that we bump
+ // this sequence number and perform relevant bookkeeping (see: NoteSend())
+ // *before* calling sendmsg() since, if we called it *after* sendmsg(), then
+ // there is a possible race with the release notification which could occur on
+ // another thread before we do the necessary bookkeeping. Hence, calling
+ // NoteSend() *before* sendmsg() and implementing an undo function is needed.
+ void UndoSend() {
+ --last_send_;
+ if (ReleaseSendRecord(last_send_)->Unref()) {
+ // We should still be holding the ref taken by tcp_write().
+ GPR_DEBUG_ASSERT(0);
+ }
+ }
+
+ // Simply associate this send record (and the underlying sent data buffers)
+ // with the implicit sequence number for this zerocopy sendmsg().
+ void AssociateSeqWithSendRecord(uint32_t seq, TcpZerocopySendRecord* record) {
+ MutexLock guard(&lock_);
+ ctx_lookup_.emplace(seq, record);
+ }
+
+ // Get a send record for a send that we wish to do with zerocopy.
+ TcpZerocopySendRecord* GetSendRecord() {
+ MutexLock guard(&lock_);
+ return TryGetSendRecordLocked();
+ }
+
+ // A given send record corresponds to a single tcp_write() with zerocopy
+ // enabled. This can result in several sendmsg() calls to flush all of the
+ // data to wire. Each sendmsg() takes a reference on the
+ // TcpZerocopySendRecord, and corresponds to a single sequence number.
+ // ReleaseSendRecord releases a reference on TcpZerocopySendRecord for a
+ // single sequence number. This is called either when we receive the relevant
+ // error queue notification (saying that we can discard the underlying
+ // buffers for this sendmsg()) is received from the kernel - or, in case
+ // sendmsg() was unsuccessful to begin with.
+ TcpZerocopySendRecord* ReleaseSendRecord(uint32_t seq) {
+ MutexLock guard(&lock_);
+ return ReleaseSendRecordLocked(seq);
+ }
+
+ // After all the references to a TcpZerocopySendRecord are released, we can
+ // add it back to the pool (of size max_sends_). Note that we can only have
+ // max_sends_ tcp_write() instances with zerocopy enabled in flight at the
+ // same time.
+ void PutSendRecord(TcpZerocopySendRecord* record) {
+ GPR_DEBUG_ASSERT(record >= send_records_ &&
+ record < send_records_ + max_sends_);
+ MutexLock guard(&lock_);
+ PutSendRecordLocked(record);
+ }
+
+ // Indicate that we are disposing of this zerocopy context. This indicator
+ // will prevent new zerocopy writes from being issued.
+ void Shutdown() { shutdown_.Store(true, MemoryOrder::RELEASE); }
+
+ // Indicates that there are no inflight tcp_write() instances with zerocopy
+ // enabled.
+ bool AllSendRecordsEmpty() {
+ MutexLock guard(&lock_);
+ return free_send_records_size_ == max_sends_;
+ }
+
+ bool enabled() const { return enabled_; }
+
+ void set_enabled(bool enabled) {
+ GPR_DEBUG_ASSERT(!enabled || !memory_limited());
+ enabled_ = enabled;
+ }
+
+ // Only use zerocopy if we are sending at least this many bytes. The
+ // additional overhead of reading the error queue for notifications means that
+ // zerocopy is not useful for small transfers.
+ size_t threshold_bytes() const { return threshold_bytes_; }
+
+ private:
+ TcpZerocopySendRecord* ReleaseSendRecordLocked(uint32_t seq) {
+ auto iter = ctx_lookup_.find(seq);
+ GPR_DEBUG_ASSERT(iter != ctx_lookup_.end());
+ TcpZerocopySendRecord* record = iter->second;
+ ctx_lookup_.erase(iter);
+ return record;
+ }
+
+ TcpZerocopySendRecord* TryGetSendRecordLocked() {
+ if (shutdown_.Load(MemoryOrder::ACQUIRE)) {
+ return nullptr;
+ }
+ if (free_send_records_size_ == 0) {
+ return nullptr;
+ }
+ free_send_records_size_--;
+ return free_send_records_[free_send_records_size_];
+ }
+
+ void PutSendRecordLocked(TcpZerocopySendRecord* record) {
+ GPR_DEBUG_ASSERT(free_send_records_size_ < max_sends_);
+ free_send_records_[free_send_records_size_] = record;
+ free_send_records_size_++;
+ }
+
+ TcpZerocopySendRecord* send_records_;
+ TcpZerocopySendRecord** free_send_records_;
+ int max_sends_;
+ int free_send_records_size_;
+ Mutex lock_;
+ uint32_t last_send_ = 0;
+ Atomic<bool> shutdown_;
+ bool enabled_ = false;
+ size_t threshold_bytes_ = kDefaultSendBytesThreshold;
+ std::unordered_map<uint32_t, TcpZerocopySendRecord*> ctx_lookup_;
+ bool memory_limited_ = false;
+};
+
+} // namespace grpc_core
+
+using grpc_core::TcpZerocopySendCtx;
+using grpc_core::TcpZerocopySendRecord;
+
namespace {
struct grpc_tcp {
- grpc_tcp(int max_sends, size_t send_bytes_threshold)
- : tcp_zerocopy_send_ctx(max_sends, send_bytes_threshold) {}
+ grpc_tcp(int max_sends, size_t send_bytes_threshold)
+ : tcp_zerocopy_send_ctx(max_sends, send_bytes_threshold) {}
grpc_endpoint base;
grpc_fd* em_fd;
int fd;
@@ -388,8 +388,8 @@ struct grpc_tcp {
grpc_closure write_done_closure;
grpc_closure error_closure;
- TString peer_string;
- TString local_address;
+ TString peer_string;
+ TString local_address;
grpc_resource_user* resource_user;
grpc_resource_user_slice_allocator slice_allocator;
@@ -416,8 +416,8 @@ struct grpc_tcp {
bool ts_capable; /* Cache whether we can set timestamping options */
gpr_atm stop_error_notification; /* Set to 1 if we do not want to be notified
on errors anymore */
- TcpZerocopySendCtx tcp_zerocopy_send_ctx;
- TcpZerocopySendRecord* current_zerocopy_send = nullptr;
+ TcpZerocopySendCtx tcp_zerocopy_send_ctx;
+ TcpZerocopySendRecord* current_zerocopy_send = nullptr;
};
struct backup_poller {
@@ -427,8 +427,8 @@ struct backup_poller {
} // namespace
-static void ZerocopyDisableAndWaitForRemaining(grpc_tcp* tcp);
-
+static void ZerocopyDisableAndWaitForRemaining(grpc_tcp* tcp);
+
#define BACKUP_POLLER_POLLSET(b) ((grpc_pollset*)((b) + 1))
static gpr_atm g_uncovered_notifications_pending;
@@ -609,7 +609,7 @@ static grpc_error* tcp_annotate_error(grpc_error* src_error, grpc_tcp* tcp) {
* choose to retry. */
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE),
GRPC_ERROR_STR_TARGET_ADDRESS,
- grpc_slice_from_copied_string(tcp->peer_string.c_str()));
+ grpc_slice_from_copied_string(tcp->peer_string.c_str()));
}
static void tcp_handle_read(void* arg /* grpc_tcp */, grpc_error* error);
@@ -617,7 +617,7 @@ static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error);
static void tcp_shutdown(grpc_endpoint* ep, grpc_error* why) {
grpc_tcp* tcp = reinterpret_cast<grpc_tcp*>(ep);
- ZerocopyDisableAndWaitForRemaining(tcp);
+ ZerocopyDisableAndWaitForRemaining(tcp);
grpc_fd_shutdown(tcp->em_fd, why);
grpc_resource_user_shutdown(tcp->resource_user);
}
@@ -635,7 +635,7 @@ static void tcp_free(grpc_tcp* tcp) {
gpr_mu_unlock(&tcp->tb_mu);
tcp->outgoing_buffer_arg = nullptr;
gpr_mu_destroy(&tcp->tb_mu);
- delete tcp;
+ delete tcp;
}
#ifndef NDEBUG
@@ -668,7 +668,7 @@ static void tcp_destroy(grpc_endpoint* ep) {
grpc_tcp* tcp = reinterpret_cast<grpc_tcp*>(ep);
grpc_slice_buffer_reset_and_unref_internal(&tcp->last_read_buffer);
if (grpc_event_engine_can_track_errors()) {
- ZerocopyDisableAndWaitForRemaining(tcp);
+ ZerocopyDisableAndWaitForRemaining(tcp);
gpr_atm_no_barrier_store(&tcp->stop_error_notification, true);
grpc_fd_set_error(tcp->em_fd);
}
@@ -682,8 +682,8 @@ static void call_read_cb(grpc_tcp* tcp, grpc_error* error) {
gpr_log(GPR_INFO, "TCP:%p call_cb %p %p:%p", tcp, cb, cb->cb, cb->cb_arg);
size_t i;
const char* str = grpc_error_string(error);
- gpr_log(GPR_INFO, "READ %p (peer=%s) error=%s", tcp,
- tcp->peer_string.c_str(), str);
+ gpr_log(GPR_INFO, "READ %p (peer=%s) error=%s", tcp,
+ tcp->peer_string.c_str(), str);
if (gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
for (i = 0; i < tcp->incoming_buffer->count; i++) {
@@ -932,13 +932,13 @@ static void tcp_read(grpc_endpoint* ep, grpc_slice_buffer* incoming_buffer,
/* A wrapper around sendmsg. It sends \a msg over \a fd and returns the number
* of bytes sent. */
-ssize_t tcp_send(int fd, const struct msghdr* msg, int additional_flags = 0) {
+ssize_t tcp_send(int fd, const struct msghdr* msg, int additional_flags = 0) {
GPR_TIMER_SCOPE("sendmsg", 1);
ssize_t sent_length;
do {
/* TODO(klempner): Cork if this is a partial write */
GRPC_STATS_INC_SYSCALL_WRITE();
- sent_length = sendmsg(fd, msg, SENDMSG_FLAGS | additional_flags);
+ sent_length = sendmsg(fd, msg, SENDMSG_FLAGS | additional_flags);
} while (sent_length < 0 && errno == EINTR);
return sent_length;
}
@@ -951,52 +951,52 @@ ssize_t tcp_send(int fd, const struct msghdr* msg, int additional_flags = 0) {
*/
static bool tcp_write_with_timestamps(grpc_tcp* tcp, struct msghdr* msg,
size_t sending_length,
- ssize_t* sent_length,
- int additional_flags = 0);
+ ssize_t* sent_length,
+ int additional_flags = 0);
/** The callback function to be invoked when we get an error on the socket. */
static void tcp_handle_error(void* arg /* grpc_tcp */, grpc_error* error);
-static TcpZerocopySendRecord* tcp_get_send_zerocopy_record(
- grpc_tcp* tcp, grpc_slice_buffer* buf);
-
+static TcpZerocopySendRecord* tcp_get_send_zerocopy_record(
+ grpc_tcp* tcp, grpc_slice_buffer* buf);
+
#ifdef GRPC_LINUX_ERRQUEUE
-static bool process_errors(grpc_tcp* tcp);
-
-static TcpZerocopySendRecord* tcp_get_send_zerocopy_record(
- grpc_tcp* tcp, grpc_slice_buffer* buf) {
- TcpZerocopySendRecord* zerocopy_send_record = nullptr;
- const bool use_zerocopy =
- tcp->tcp_zerocopy_send_ctx.enabled() &&
- tcp->tcp_zerocopy_send_ctx.threshold_bytes() < buf->length;
- if (use_zerocopy) {
- zerocopy_send_record = tcp->tcp_zerocopy_send_ctx.GetSendRecord();
- if (zerocopy_send_record == nullptr) {
- process_errors(tcp);
- zerocopy_send_record = tcp->tcp_zerocopy_send_ctx.GetSendRecord();
- }
- if (zerocopy_send_record != nullptr) {
- zerocopy_send_record->PrepareForSends(buf);
- GPR_DEBUG_ASSERT(buf->count == 0);
- GPR_DEBUG_ASSERT(buf->length == 0);
- tcp->outgoing_byte_idx = 0;
- tcp->outgoing_buffer = nullptr;
- }
- }
- return zerocopy_send_record;
-}
-
-static void ZerocopyDisableAndWaitForRemaining(grpc_tcp* tcp) {
- tcp->tcp_zerocopy_send_ctx.Shutdown();
- while (!tcp->tcp_zerocopy_send_ctx.AllSendRecordsEmpty()) {
- process_errors(tcp);
- }
-}
-
+static bool process_errors(grpc_tcp* tcp);
+
+static TcpZerocopySendRecord* tcp_get_send_zerocopy_record(
+ grpc_tcp* tcp, grpc_slice_buffer* buf) {
+ TcpZerocopySendRecord* zerocopy_send_record = nullptr;
+ const bool use_zerocopy =
+ tcp->tcp_zerocopy_send_ctx.enabled() &&
+ tcp->tcp_zerocopy_send_ctx.threshold_bytes() < buf->length;
+ if (use_zerocopy) {
+ zerocopy_send_record = tcp->tcp_zerocopy_send_ctx.GetSendRecord();
+ if (zerocopy_send_record == nullptr) {
+ process_errors(tcp);
+ zerocopy_send_record = tcp->tcp_zerocopy_send_ctx.GetSendRecord();
+ }
+ if (zerocopy_send_record != nullptr) {
+ zerocopy_send_record->PrepareForSends(buf);
+ GPR_DEBUG_ASSERT(buf->count == 0);
+ GPR_DEBUG_ASSERT(buf->length == 0);
+ tcp->outgoing_byte_idx = 0;
+ tcp->outgoing_buffer = nullptr;
+ }
+ }
+ return zerocopy_send_record;
+}
+
+static void ZerocopyDisableAndWaitForRemaining(grpc_tcp* tcp) {
+ tcp->tcp_zerocopy_send_ctx.Shutdown();
+ while (!tcp->tcp_zerocopy_send_ctx.AllSendRecordsEmpty()) {
+ process_errors(tcp);
+ }
+}
+
static bool tcp_write_with_timestamps(grpc_tcp* tcp, struct msghdr* msg,
size_t sending_length,
- ssize_t* sent_length,
- int additional_flags) {
+ ssize_t* sent_length,
+ int additional_flags) {
if (!tcp->socket_ts_enabled) {
uint32_t opt = grpc_core::kTimestampingSocketOptions;
if (setsockopt(tcp->fd, SOL_SOCKET, SO_TIMESTAMPING,
@@ -1024,7 +1024,7 @@ static bool tcp_write_with_timestamps(grpc_tcp* tcp, struct msghdr* msg,
msg->msg_controllen = CMSG_SPACE(sizeof(uint32_t));
/* If there was an error on sendmsg the logic in tcp_flush will handle it. */
- ssize_t length = tcp_send(tcp->fd, msg, additional_flags);
+ ssize_t length = tcp_send(tcp->fd, msg, additional_flags);
*sent_length = length;
/* Only save timestamps if all the bytes were taken by sendmsg. */
if (sending_length == static_cast<size_t>(length)) {
@@ -1038,43 +1038,43 @@ static bool tcp_write_with_timestamps(grpc_tcp* tcp, struct msghdr* msg,
return true;
}
-static void UnrefMaybePutZerocopySendRecord(grpc_tcp* tcp,
- TcpZerocopySendRecord* record,
- uint32_t seq, const char* tag);
-// Reads \a cmsg to process zerocopy control messages.
-static void process_zerocopy(grpc_tcp* tcp, struct cmsghdr* cmsg) {
- GPR_DEBUG_ASSERT(cmsg);
- auto serr = reinterpret_cast<struct sock_extended_err*>(CMSG_DATA(cmsg));
- GPR_DEBUG_ASSERT(serr->ee_errno == 0);
- GPR_DEBUG_ASSERT(serr->ee_origin == SO_EE_ORIGIN_ZEROCOPY);
- const uint32_t lo = serr->ee_info;
- const uint32_t hi = serr->ee_data;
- for (uint32_t seq = lo; seq <= hi; ++seq) {
- // TODO(arjunroy): It's likely that lo and hi refer to zerocopy sequence
- // numbers that are generated by a single call to grpc_endpoint_write; ie.
- // we can batch the unref operation. So, check if record is the same for
- // both; if so, batch the unref/put.
- TcpZerocopySendRecord* record =
- tcp->tcp_zerocopy_send_ctx.ReleaseSendRecord(seq);
- GPR_DEBUG_ASSERT(record);
- UnrefMaybePutZerocopySendRecord(tcp, record, seq, "CALLBACK RCVD");
- }
-}
-
-// Whether the cmsg received from error queue is of the IPv4 or IPv6 levels.
-static bool CmsgIsIpLevel(const cmsghdr& cmsg) {
- return (cmsg.cmsg_level == SOL_IPV6 && cmsg.cmsg_type == IPV6_RECVERR) ||
- (cmsg.cmsg_level == SOL_IP && cmsg.cmsg_type == IP_RECVERR);
-}
-
-static bool CmsgIsZeroCopy(const cmsghdr& cmsg) {
- if (!CmsgIsIpLevel(cmsg)) {
- return false;
- }
- auto serr = reinterpret_cast<const sock_extended_err*> CMSG_DATA(&cmsg);
- return serr->ee_errno == 0 && serr->ee_origin == SO_EE_ORIGIN_ZEROCOPY;
-}
-
+static void UnrefMaybePutZerocopySendRecord(grpc_tcp* tcp,
+ TcpZerocopySendRecord* record,
+ uint32_t seq, const char* tag);
+// Reads \a cmsg to process zerocopy control messages.
+static void process_zerocopy(grpc_tcp* tcp, struct cmsghdr* cmsg) {
+ GPR_DEBUG_ASSERT(cmsg);
+ auto serr = reinterpret_cast<struct sock_extended_err*>(CMSG_DATA(cmsg));
+ GPR_DEBUG_ASSERT(serr->ee_errno == 0);
+ GPR_DEBUG_ASSERT(serr->ee_origin == SO_EE_ORIGIN_ZEROCOPY);
+ const uint32_t lo = serr->ee_info;
+ const uint32_t hi = serr->ee_data;
+ for (uint32_t seq = lo; seq <= hi; ++seq) {
+ // TODO(arjunroy): It's likely that lo and hi refer to zerocopy sequence
+ // numbers that are generated by a single call to grpc_endpoint_write; ie.
+ // we can batch the unref operation. So, check if record is the same for
+ // both; if so, batch the unref/put.
+ TcpZerocopySendRecord* record =
+ tcp->tcp_zerocopy_send_ctx.ReleaseSendRecord(seq);
+ GPR_DEBUG_ASSERT(record);
+ UnrefMaybePutZerocopySendRecord(tcp, record, seq, "CALLBACK RCVD");
+ }
+}
+
+// Whether the cmsg received from error queue is of the IPv4 or IPv6 levels.
+static bool CmsgIsIpLevel(const cmsghdr& cmsg) {
+ return (cmsg.cmsg_level == SOL_IPV6 && cmsg.cmsg_type == IPV6_RECVERR) ||
+ (cmsg.cmsg_level == SOL_IP && cmsg.cmsg_type == IP_RECVERR);
+}
+
+static bool CmsgIsZeroCopy(const cmsghdr& cmsg) {
+ if (!CmsgIsIpLevel(cmsg)) {
+ return false;
+ }
+ auto serr = reinterpret_cast<const sock_extended_err*> CMSG_DATA(&cmsg);
+ return serr->ee_errno == 0 && serr->ee_origin == SO_EE_ORIGIN_ZEROCOPY;
+}
+
/** Reads \a cmsg to derive timestamps from the control messages. If a valid
* timestamp is found, the traced buffer list is updated with this timestamp.
* The caller of this function should be looping on the control messages found
@@ -1136,31 +1136,31 @@ struct cmsghdr* process_timestamp(grpc_tcp* tcp, msghdr* msg,
/** For linux platforms, reads the socket's error queue and processes error
* messages from the queue.
*/
-static bool process_errors(grpc_tcp* tcp) {
- bool processed_err = false;
- struct iovec iov;
- iov.iov_base = nullptr;
- iov.iov_len = 0;
- struct msghdr msg;
- msg.msg_name = nullptr;
- msg.msg_namelen = 0;
- msg.msg_iov = &iov;
- msg.msg_iovlen = 0;
- msg.msg_flags = 0;
- /* Allocate enough space so we don't need to keep increasing this as size
- * of OPT_STATS increase */
- constexpr size_t cmsg_alloc_space =
- CMSG_SPACE(sizeof(grpc_core::scm_timestamping)) +
- CMSG_SPACE(sizeof(sock_extended_err) + sizeof(sockaddr_in)) +
- CMSG_SPACE(32 * NLA_ALIGN(NLA_HDRLEN + sizeof(uint64_t)));
- /* Allocate aligned space for cmsgs received along with timestamps */
- union {
- char rbuf[cmsg_alloc_space];
- struct cmsghdr align;
- } aligned_buf;
- msg.msg_control = aligned_buf.rbuf;
- msg.msg_controllen = sizeof(aligned_buf.rbuf);
- int r, saved_errno;
+static bool process_errors(grpc_tcp* tcp) {
+ bool processed_err = false;
+ struct iovec iov;
+ iov.iov_base = nullptr;
+ iov.iov_len = 0;
+ struct msghdr msg;
+ msg.msg_name = nullptr;
+ msg.msg_namelen = 0;
+ msg.msg_iov = &iov;
+ msg.msg_iovlen = 0;
+ msg.msg_flags = 0;
+ /* Allocate enough space so we don't need to keep increasing this as size
+ * of OPT_STATS increase */
+ constexpr size_t cmsg_alloc_space =
+ CMSG_SPACE(sizeof(grpc_core::scm_timestamping)) +
+ CMSG_SPACE(sizeof(sock_extended_err) + sizeof(sockaddr_in)) +
+ CMSG_SPACE(32 * NLA_ALIGN(NLA_HDRLEN + sizeof(uint64_t)));
+ /* Allocate aligned space for cmsgs received along with timestamps */
+ union {
+ char rbuf[cmsg_alloc_space];
+ struct cmsghdr align;
+ } aligned_buf;
+ msg.msg_control = aligned_buf.rbuf;
+ msg.msg_controllen = sizeof(aligned_buf.rbuf);
+ int r, saved_errno;
while (true) {
do {
r = recvmsg(tcp->fd, &msg, MSG_ERRQUEUE);
@@ -1168,44 +1168,44 @@ static bool process_errors(grpc_tcp* tcp) {
} while (r < 0 && saved_errno == EINTR);
if (r == -1 && saved_errno == EAGAIN) {
- return processed_err; /* No more errors to process */
+ return processed_err; /* No more errors to process */
}
if (r == -1) {
- return processed_err;
+ return processed_err;
}
- if (GPR_UNLIKELY((msg.msg_flags & MSG_CTRUNC) != 0)) {
+ if (GPR_UNLIKELY((msg.msg_flags & MSG_CTRUNC) != 0)) {
gpr_log(GPR_ERROR, "Error message was truncated.");
}
if (msg.msg_controllen == 0) {
/* There was no control message found. It was probably spurious. */
- return processed_err;
+ return processed_err;
}
bool seen = false;
for (auto cmsg = CMSG_FIRSTHDR(&msg); cmsg && cmsg->cmsg_len;
cmsg = CMSG_NXTHDR(&msg, cmsg)) {
- if (CmsgIsZeroCopy(*cmsg)) {
- process_zerocopy(tcp, cmsg);
- seen = true;
- processed_err = true;
- } else if (cmsg->cmsg_level == SOL_SOCKET &&
- cmsg->cmsg_type == SCM_TIMESTAMPING) {
- cmsg = process_timestamp(tcp, &msg, cmsg);
- seen = true;
- processed_err = true;
- } else {
- /* Got a control message that is not a timestamp or zerocopy. Don't know
- * how to handle this. */
+ if (CmsgIsZeroCopy(*cmsg)) {
+ process_zerocopy(tcp, cmsg);
+ seen = true;
+ processed_err = true;
+ } else if (cmsg->cmsg_level == SOL_SOCKET &&
+ cmsg->cmsg_type == SCM_TIMESTAMPING) {
+ cmsg = process_timestamp(tcp, &msg, cmsg);
+ seen = true;
+ processed_err = true;
+ } else {
+ /* Got a control message that is not a timestamp or zerocopy. Don't know
+ * how to handle this. */
if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) {
gpr_log(GPR_INFO,
"unknown control message cmsg_level:%d cmsg_type:%d",
cmsg->cmsg_level, cmsg->cmsg_type);
}
- return processed_err;
+ return processed_err;
}
}
if (!seen) {
- return processed_err;
+ return processed_err;
}
}
}
@@ -1226,28 +1226,28 @@ static void tcp_handle_error(void* arg /* grpc_tcp */, grpc_error* error) {
/* We are still interested in collecting timestamps, so let's try reading
* them. */
- bool processed = process_errors(tcp);
+ bool processed = process_errors(tcp);
/* This might not a timestamps error. Set the read and write closures to be
* ready. */
- if (!processed) {
- grpc_fd_set_readable(tcp->em_fd);
- grpc_fd_set_writable(tcp->em_fd);
- }
+ if (!processed) {
+ grpc_fd_set_readable(tcp->em_fd);
+ grpc_fd_set_writable(tcp->em_fd);
+ }
grpc_fd_notify_on_error(tcp->em_fd, &tcp->error_closure);
}
#else /* GRPC_LINUX_ERRQUEUE */
-static TcpZerocopySendRecord* tcp_get_send_zerocopy_record(
- grpc_tcp* tcp, grpc_slice_buffer* buf) {
- return nullptr;
-}
-
-static void ZerocopyDisableAndWaitForRemaining(grpc_tcp* tcp) {}
-
+static TcpZerocopySendRecord* tcp_get_send_zerocopy_record(
+ grpc_tcp* tcp, grpc_slice_buffer* buf) {
+ return nullptr;
+}
+
+static void ZerocopyDisableAndWaitForRemaining(grpc_tcp* tcp) {}
+
static bool tcp_write_with_timestamps(grpc_tcp* /*tcp*/, struct msghdr* /*msg*/,
size_t /*sending_length*/,
- ssize_t* /*sent_length*/,
- int /*additional_flags*/) {
+ ssize_t* /*sent_length*/,
+ int /*additional_flags*/) {
gpr_log(GPR_ERROR, "Write with timestamps not supported for this platform");
GPR_ASSERT(0);
return false;
@@ -1278,134 +1278,134 @@ void tcp_shutdown_buffer_list(grpc_tcp* tcp) {
#else
#define MAX_WRITE_IOVEC 1000
#endif
-msg_iovlen_type TcpZerocopySendRecord::PopulateIovs(size_t* unwind_slice_idx,
- size_t* unwind_byte_idx,
- size_t* sending_length,
- iovec* iov) {
- msg_iovlen_type iov_size;
- *unwind_slice_idx = out_offset_.slice_idx;
- *unwind_byte_idx = out_offset_.byte_idx;
- for (iov_size = 0;
- out_offset_.slice_idx != buf_.count && iov_size != MAX_WRITE_IOVEC;
- iov_size++) {
- iov[iov_size].iov_base =
- GRPC_SLICE_START_PTR(buf_.slices[out_offset_.slice_idx]) +
- out_offset_.byte_idx;
- iov[iov_size].iov_len =
- GRPC_SLICE_LENGTH(buf_.slices[out_offset_.slice_idx]) -
- out_offset_.byte_idx;
- *sending_length += iov[iov_size].iov_len;
- ++(out_offset_.slice_idx);
- out_offset_.byte_idx = 0;
- }
- GPR_DEBUG_ASSERT(iov_size > 0);
- return iov_size;
-}
-
-void TcpZerocopySendRecord::UpdateOffsetForBytesSent(size_t sending_length,
- size_t actually_sent) {
- size_t trailing = sending_length - actually_sent;
- while (trailing > 0) {
- size_t slice_length;
- out_offset_.slice_idx--;
- slice_length = GRPC_SLICE_LENGTH(buf_.slices[out_offset_.slice_idx]);
- if (slice_length > trailing) {
- out_offset_.byte_idx = slice_length - trailing;
- break;
- } else {
- trailing -= slice_length;
- }
- }
-}
-
-// returns true if done, false if pending; if returning true, *error is set
-static bool do_tcp_flush_zerocopy(grpc_tcp* tcp, TcpZerocopySendRecord* record,
- grpc_error** error) {
- struct msghdr msg;
- struct iovec iov[MAX_WRITE_IOVEC];
- msg_iovlen_type iov_size;
- ssize_t sent_length = 0;
- size_t sending_length;
- size_t unwind_slice_idx;
- size_t unwind_byte_idx;
- while (true) {
- sending_length = 0;
- iov_size = record->PopulateIovs(&unwind_slice_idx, &unwind_byte_idx,
- &sending_length, iov);
- msg.msg_name = nullptr;
- msg.msg_namelen = 0;
- msg.msg_iov = iov;
- msg.msg_iovlen = iov_size;
- msg.msg_flags = 0;
- bool tried_sending_message = false;
- // Before calling sendmsg (with or without timestamps): we
- // take a single ref on the zerocopy send record.
- tcp->tcp_zerocopy_send_ctx.NoteSend(record);
- if (tcp->outgoing_buffer_arg != nullptr) {
- if (!tcp->ts_capable ||
- !tcp_write_with_timestamps(tcp, &msg, sending_length, &sent_length,
- MSG_ZEROCOPY)) {
- /* We could not set socket options to collect Fathom timestamps.
- * Fallback on writing without timestamps. */
- tcp->ts_capable = false;
- tcp_shutdown_buffer_list(tcp);
- } else {
- tried_sending_message = true;
- }
- }
- if (!tried_sending_message) {
- msg.msg_control = nullptr;
- msg.msg_controllen = 0;
- GRPC_STATS_INC_TCP_WRITE_SIZE(sending_length);
- GRPC_STATS_INC_TCP_WRITE_IOV_SIZE(iov_size);
- sent_length = tcp_send(tcp->fd, &msg, MSG_ZEROCOPY);
- }
- if (sent_length < 0) {
- // If this particular send failed, drop ref taken earlier in this method.
- tcp->tcp_zerocopy_send_ctx.UndoSend();
- if (errno == EAGAIN) {
- record->UnwindIfThrottled(unwind_slice_idx, unwind_byte_idx);
- return false;
- } else if (errno == EPIPE) {
- *error = tcp_annotate_error(GRPC_OS_ERROR(errno, "sendmsg"), tcp);
- tcp_shutdown_buffer_list(tcp);
- return true;
- } else {
- *error = tcp_annotate_error(GRPC_OS_ERROR(errno, "sendmsg"), tcp);
- tcp_shutdown_buffer_list(tcp);
- return true;
- }
- }
- tcp->bytes_counter += sent_length;
- record->UpdateOffsetForBytesSent(sending_length,
- static_cast<size_t>(sent_length));
- if (record->AllSlicesSent()) {
- *error = GRPC_ERROR_NONE;
- return true;
- }
- }
-}
-
-static void UnrefMaybePutZerocopySendRecord(grpc_tcp* tcp,
- TcpZerocopySendRecord* record,
- uint32_t seq,
- const char* /* tag */) {
- if (record->Unref()) {
- tcp->tcp_zerocopy_send_ctx.PutSendRecord(record);
- }
-}
-
-static bool tcp_flush_zerocopy(grpc_tcp* tcp, TcpZerocopySendRecord* record,
- grpc_error** error) {
- bool done = do_tcp_flush_zerocopy(tcp, record, error);
- if (done) {
- // Either we encountered an error, or we successfully sent all the bytes.
- // In either case, we're done with this record.
- UnrefMaybePutZerocopySendRecord(tcp, record, 0, "flush_done");
- }
- return done;
-}
-
+msg_iovlen_type TcpZerocopySendRecord::PopulateIovs(size_t* unwind_slice_idx,
+ size_t* unwind_byte_idx,
+ size_t* sending_length,
+ iovec* iov) {
+ msg_iovlen_type iov_size;
+ *unwind_slice_idx = out_offset_.slice_idx;
+ *unwind_byte_idx = out_offset_.byte_idx;
+ for (iov_size = 0;
+ out_offset_.slice_idx != buf_.count && iov_size != MAX_WRITE_IOVEC;
+ iov_size++) {
+ iov[iov_size].iov_base =
+ GRPC_SLICE_START_PTR(buf_.slices[out_offset_.slice_idx]) +
+ out_offset_.byte_idx;
+ iov[iov_size].iov_len =
+ GRPC_SLICE_LENGTH(buf_.slices[out_offset_.slice_idx]) -
+ out_offset_.byte_idx;
+ *sending_length += iov[iov_size].iov_len;
+ ++(out_offset_.slice_idx);
+ out_offset_.byte_idx = 0;
+ }
+ GPR_DEBUG_ASSERT(iov_size > 0);
+ return iov_size;
+}
+
+void TcpZerocopySendRecord::UpdateOffsetForBytesSent(size_t sending_length,
+ size_t actually_sent) {
+ size_t trailing = sending_length - actually_sent;
+ while (trailing > 0) {
+ size_t slice_length;
+ out_offset_.slice_idx--;
+ slice_length = GRPC_SLICE_LENGTH(buf_.slices[out_offset_.slice_idx]);
+ if (slice_length > trailing) {
+ out_offset_.byte_idx = slice_length - trailing;
+ break;
+ } else {
+ trailing -= slice_length;
+ }
+ }
+}
+
+// returns true if done, false if pending; if returning true, *error is set
+static bool do_tcp_flush_zerocopy(grpc_tcp* tcp, TcpZerocopySendRecord* record,
+ grpc_error** error) {
+ struct msghdr msg;
+ struct iovec iov[MAX_WRITE_IOVEC];
+ msg_iovlen_type iov_size;
+ ssize_t sent_length = 0;
+ size_t sending_length;
+ size_t unwind_slice_idx;
+ size_t unwind_byte_idx;
+ while (true) {
+ sending_length = 0;
+ iov_size = record->PopulateIovs(&unwind_slice_idx, &unwind_byte_idx,
+ &sending_length, iov);
+ msg.msg_name = nullptr;
+ msg.msg_namelen = 0;
+ msg.msg_iov = iov;
+ msg.msg_iovlen = iov_size;
+ msg.msg_flags = 0;
+ bool tried_sending_message = false;
+ // Before calling sendmsg (with or without timestamps): we
+ // take a single ref on the zerocopy send record.
+ tcp->tcp_zerocopy_send_ctx.NoteSend(record);
+ if (tcp->outgoing_buffer_arg != nullptr) {
+ if (!tcp->ts_capable ||
+ !tcp_write_with_timestamps(tcp, &msg, sending_length, &sent_length,
+ MSG_ZEROCOPY)) {
+ /* We could not set socket options to collect Fathom timestamps.
+ * Fallback on writing without timestamps. */
+ tcp->ts_capable = false;
+ tcp_shutdown_buffer_list(tcp);
+ } else {
+ tried_sending_message = true;
+ }
+ }
+ if (!tried_sending_message) {
+ msg.msg_control = nullptr;
+ msg.msg_controllen = 0;
+ GRPC_STATS_INC_TCP_WRITE_SIZE(sending_length);
+ GRPC_STATS_INC_TCP_WRITE_IOV_SIZE(iov_size);
+ sent_length = tcp_send(tcp->fd, &msg, MSG_ZEROCOPY);
+ }
+ if (sent_length < 0) {
+ // If this particular send failed, drop ref taken earlier in this method.
+ tcp->tcp_zerocopy_send_ctx.UndoSend();
+ if (errno == EAGAIN) {
+ record->UnwindIfThrottled(unwind_slice_idx, unwind_byte_idx);
+ return false;
+ } else if (errno == EPIPE) {
+ *error = tcp_annotate_error(GRPC_OS_ERROR(errno, "sendmsg"), tcp);
+ tcp_shutdown_buffer_list(tcp);
+ return true;
+ } else {
+ *error = tcp_annotate_error(GRPC_OS_ERROR(errno, "sendmsg"), tcp);
+ tcp_shutdown_buffer_list(tcp);
+ return true;
+ }
+ }
+ tcp->bytes_counter += sent_length;
+ record->UpdateOffsetForBytesSent(sending_length,
+ static_cast<size_t>(sent_length));
+ if (record->AllSlicesSent()) {
+ *error = GRPC_ERROR_NONE;
+ return true;
+ }
+ }
+}
+
+static void UnrefMaybePutZerocopySendRecord(grpc_tcp* tcp,
+ TcpZerocopySendRecord* record,
+ uint32_t seq,
+ const char* /* tag */) {
+ if (record->Unref()) {
+ tcp->tcp_zerocopy_send_ctx.PutSendRecord(record);
+ }
+}
+
+static bool tcp_flush_zerocopy(grpc_tcp* tcp, TcpZerocopySendRecord* record,
+ grpc_error** error) {
+ bool done = do_tcp_flush_zerocopy(tcp, record, error);
+ if (done) {
+ // Either we encountered an error, or we successfully sent all the bytes.
+ // In either case, we're done with this record.
+ UnrefMaybePutZerocopySendRecord(tcp, record, 0, "flush_done");
+ }
+ return done;
+}
+
static bool tcp_flush(grpc_tcp* tcp, grpc_error** error) {
struct msghdr msg;
struct iovec iov[MAX_WRITE_IOVEC];
@@ -1420,7 +1420,7 @@ static bool tcp_flush(grpc_tcp* tcp, grpc_error** error) {
// buffer as we write
size_t outgoing_slice_idx = 0;
- while (true) {
+ while (true) {
sending_length = 0;
unwind_slice_idx = outgoing_slice_idx;
unwind_byte_idx = tcp->outgoing_byte_idx;
@@ -1520,21 +1520,21 @@ static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error) {
if (error != GRPC_ERROR_NONE) {
cb = tcp->write_cb;
tcp->write_cb = nullptr;
- if (tcp->current_zerocopy_send != nullptr) {
- UnrefMaybePutZerocopySendRecord(tcp, tcp->current_zerocopy_send, 0,
- "handle_write_err");
- tcp->current_zerocopy_send = nullptr;
- }
+ if (tcp->current_zerocopy_send != nullptr) {
+ UnrefMaybePutZerocopySendRecord(tcp, tcp->current_zerocopy_send, 0,
+ "handle_write_err");
+ tcp->current_zerocopy_send = nullptr;
+ }
grpc_core::Closure::Run(DEBUG_LOCATION, cb, GRPC_ERROR_REF(error));
TCP_UNREF(tcp, "write");
return;
}
- bool flush_result =
- tcp->current_zerocopy_send != nullptr
- ? tcp_flush_zerocopy(tcp, tcp->current_zerocopy_send, &error)
- : tcp_flush(tcp, &error);
- if (!flush_result) {
+ bool flush_result =
+ tcp->current_zerocopy_send != nullptr
+ ? tcp_flush_zerocopy(tcp, tcp->current_zerocopy_send, &error)
+ : tcp_flush(tcp, &error);
+ if (!flush_result) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) {
gpr_log(GPR_INFO, "write: delayed");
}
@@ -1544,7 +1544,7 @@ static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error) {
} else {
cb = tcp->write_cb;
tcp->write_cb = nullptr;
- tcp->current_zerocopy_send = nullptr;
+ tcp->current_zerocopy_send = nullptr;
if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) {
const char* str = grpc_error_string(error);
gpr_log(GPR_INFO, "write: %s", str);
@@ -1560,13 +1560,13 @@ static void tcp_write(grpc_endpoint* ep, grpc_slice_buffer* buf,
GPR_TIMER_SCOPE("tcp_write", 0);
grpc_tcp* tcp = reinterpret_cast<grpc_tcp*>(ep);
grpc_error* error = GRPC_ERROR_NONE;
- TcpZerocopySendRecord* zerocopy_send_record = nullptr;
+ TcpZerocopySendRecord* zerocopy_send_record = nullptr;
if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) {
size_t i;
for (i = 0; i < buf->count; i++) {
- gpr_log(GPR_INFO, "WRITE %p (peer=%s)", tcp, tcp->peer_string.c_str());
+ gpr_log(GPR_INFO, "WRITE %p (peer=%s)", tcp, tcp->peer_string.c_str());
if (gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
char* data =
grpc_dump_slice(buf->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII);
@@ -1577,7 +1577,7 @@ static void tcp_write(grpc_endpoint* ep, grpc_slice_buffer* buf,
}
GPR_ASSERT(tcp->write_cb == nullptr);
- GPR_DEBUG_ASSERT(tcp->current_zerocopy_send == nullptr);
+ GPR_DEBUG_ASSERT(tcp->current_zerocopy_send == nullptr);
if (buf->length == 0) {
grpc_core::Closure::Run(
@@ -1589,26 +1589,26 @@ static void tcp_write(grpc_endpoint* ep, grpc_slice_buffer* buf,
tcp_shutdown_buffer_list(tcp);
return;
}
-
- zerocopy_send_record = tcp_get_send_zerocopy_record(tcp, buf);
- if (zerocopy_send_record == nullptr) {
- // Either not enough bytes, or couldn't allocate a zerocopy context.
- tcp->outgoing_buffer = buf;
- tcp->outgoing_byte_idx = 0;
- }
- tcp->outgoing_buffer_arg = arg;
+
+ zerocopy_send_record = tcp_get_send_zerocopy_record(tcp, buf);
+ if (zerocopy_send_record == nullptr) {
+ // Either not enough bytes, or couldn't allocate a zerocopy context.
+ tcp->outgoing_buffer = buf;
+ tcp->outgoing_byte_idx = 0;
+ }
+ tcp->outgoing_buffer_arg = arg;
if (arg) {
GPR_ASSERT(grpc_event_engine_can_track_errors());
}
- bool flush_result =
- zerocopy_send_record != nullptr
- ? tcp_flush_zerocopy(tcp, zerocopy_send_record, &error)
- : tcp_flush(tcp, &error);
- if (!flush_result) {
+ bool flush_result =
+ zerocopy_send_record != nullptr
+ ? tcp_flush_zerocopy(tcp, zerocopy_send_record, &error)
+ : tcp_flush(tcp, &error);
+ if (!flush_result) {
TCP_REF(tcp, "write");
tcp->write_cb = cb;
- tcp->current_zerocopy_send = zerocopy_send_record;
+ tcp->current_zerocopy_send = zerocopy_send_record;
if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) {
gpr_log(GPR_INFO, "write: delayed");
}
@@ -1636,20 +1636,20 @@ static void tcp_add_to_pollset_set(grpc_endpoint* ep,
static void tcp_delete_from_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset_set) {
grpc_tcp* tcp = reinterpret_cast<grpc_tcp*>(ep);
- ZerocopyDisableAndWaitForRemaining(tcp);
+ ZerocopyDisableAndWaitForRemaining(tcp);
grpc_pollset_set_del_fd(pollset_set, tcp->em_fd);
}
-static y_absl::string_view tcp_get_peer(grpc_endpoint* ep) {
+static y_absl::string_view tcp_get_peer(grpc_endpoint* ep) {
grpc_tcp* tcp = reinterpret_cast<grpc_tcp*>(ep);
- return tcp->peer_string;
+ return tcp->peer_string;
+}
+
+static y_absl::string_view tcp_get_local_address(grpc_endpoint* ep) {
+ grpc_tcp* tcp = reinterpret_cast<grpc_tcp*>(ep);
+ return tcp->local_address;
}
-static y_absl::string_view tcp_get_local_address(grpc_endpoint* ep) {
- grpc_tcp* tcp = reinterpret_cast<grpc_tcp*>(ep);
- return tcp->local_address;
-}
-
static int tcp_get_fd(grpc_endpoint* ep) {
grpc_tcp* tcp = reinterpret_cast<grpc_tcp*>(ep);
return tcp->fd;
@@ -1685,7 +1685,7 @@ static const grpc_endpoint_vtable vtable = {tcp_read,
tcp_destroy,
tcp_get_resource_user,
tcp_get_peer,
- tcp_get_local_address,
+ tcp_get_local_address,
tcp_get_fd,
tcp_can_track_err};
@@ -1694,15 +1694,15 @@ static const grpc_endpoint_vtable vtable = {tcp_read,
grpc_endpoint* grpc_tcp_create(grpc_fd* em_fd,
const grpc_channel_args* channel_args,
const char* peer_string) {
- static constexpr bool kZerocpTxEnabledDefault = false;
+ static constexpr bool kZerocpTxEnabledDefault = false;
int tcp_read_chunk_size = GRPC_TCP_DEFAULT_READ_SLICE_SIZE;
int tcp_max_read_chunk_size = 4 * 1024 * 1024;
int tcp_min_read_chunk_size = 256;
- bool tcp_tx_zerocopy_enabled = kZerocpTxEnabledDefault;
- int tcp_tx_zerocopy_send_bytes_thresh =
- grpc_core::TcpZerocopySendCtx::kDefaultSendBytesThreshold;
- int tcp_tx_zerocopy_max_simult_sends =
- grpc_core::TcpZerocopySendCtx::kDefaultMaxSends;
+ bool tcp_tx_zerocopy_enabled = kZerocpTxEnabledDefault;
+ int tcp_tx_zerocopy_send_bytes_thresh =
+ grpc_core::TcpZerocopySendCtx::kDefaultSendBytesThreshold;
+ int tcp_tx_zerocopy_max_simult_sends =
+ grpc_core::TcpZerocopySendCtx::kDefaultMaxSends;
grpc_resource_quota* resource_quota = grpc_resource_quota_create(nullptr);
if (channel_args != nullptr) {
for (size_t i = 0; i < channel_args->num_args; i++) {
@@ -1727,23 +1727,23 @@ grpc_endpoint* grpc_tcp_create(grpc_fd* em_fd,
resource_quota =
grpc_resource_quota_ref_internal(static_cast<grpc_resource_quota*>(
channel_args->args[i].value.pointer.p));
- } else if (0 == strcmp(channel_args->args[i].key,
- GRPC_ARG_TCP_TX_ZEROCOPY_ENABLED)) {
- tcp_tx_zerocopy_enabled = grpc_channel_arg_get_bool(
- &channel_args->args[i], kZerocpTxEnabledDefault);
- } else if (0 == strcmp(channel_args->args[i].key,
- GRPC_ARG_TCP_TX_ZEROCOPY_SEND_BYTES_THRESHOLD)) {
- grpc_integer_options options = {
- grpc_core::TcpZerocopySendCtx::kDefaultSendBytesThreshold, 0,
- INT_MAX};
- tcp_tx_zerocopy_send_bytes_thresh =
- grpc_channel_arg_get_integer(&channel_args->args[i], options);
- } else if (0 == strcmp(channel_args->args[i].key,
- GRPC_ARG_TCP_TX_ZEROCOPY_MAX_SIMULT_SENDS)) {
- grpc_integer_options options = {
- grpc_core::TcpZerocopySendCtx::kDefaultMaxSends, 0, INT_MAX};
- tcp_tx_zerocopy_max_simult_sends =
- grpc_channel_arg_get_integer(&channel_args->args[i], options);
+ } else if (0 == strcmp(channel_args->args[i].key,
+ GRPC_ARG_TCP_TX_ZEROCOPY_ENABLED)) {
+ tcp_tx_zerocopy_enabled = grpc_channel_arg_get_bool(
+ &channel_args->args[i], kZerocpTxEnabledDefault);
+ } else if (0 == strcmp(channel_args->args[i].key,
+ GRPC_ARG_TCP_TX_ZEROCOPY_SEND_BYTES_THRESHOLD)) {
+ grpc_integer_options options = {
+ grpc_core::TcpZerocopySendCtx::kDefaultSendBytesThreshold, 0,
+ INT_MAX};
+ tcp_tx_zerocopy_send_bytes_thresh =
+ grpc_channel_arg_get_integer(&channel_args->args[i], options);
+ } else if (0 == strcmp(channel_args->args[i].key,
+ GRPC_ARG_TCP_TX_ZEROCOPY_MAX_SIMULT_SENDS)) {
+ grpc_integer_options options = {
+ grpc_core::TcpZerocopySendCtx::kDefaultMaxSends, 0, INT_MAX};
+ tcp_tx_zerocopy_max_simult_sends =
+ grpc_channel_arg_get_integer(&channel_args->args[i], options);
}
}
}
@@ -1754,24 +1754,24 @@ grpc_endpoint* grpc_tcp_create(grpc_fd* em_fd,
tcp_read_chunk_size = GPR_CLAMP(tcp_read_chunk_size, tcp_min_read_chunk_size,
tcp_max_read_chunk_size);
- grpc_tcp* tcp = new grpc_tcp(tcp_tx_zerocopy_max_simult_sends,
- tcp_tx_zerocopy_send_bytes_thresh);
+ grpc_tcp* tcp = new grpc_tcp(tcp_tx_zerocopy_max_simult_sends,
+ tcp_tx_zerocopy_send_bytes_thresh);
tcp->base.vtable = &vtable;
- tcp->peer_string = peer_string;
+ tcp->peer_string = peer_string;
tcp->fd = grpc_fd_wrapped_fd(em_fd);
- grpc_resolved_address resolved_local_addr;
- memset(&resolved_local_addr, 0, sizeof(resolved_local_addr));
- resolved_local_addr.len = sizeof(resolved_local_addr.addr);
- if (getsockname(tcp->fd,
- reinterpret_cast<sockaddr*>(resolved_local_addr.addr),
- &resolved_local_addr.len) < 0) {
- tcp->local_address = "";
- } else {
- tcp->local_address = grpc_sockaddr_to_uri(&resolved_local_addr);
- }
+ grpc_resolved_address resolved_local_addr;
+ memset(&resolved_local_addr, 0, sizeof(resolved_local_addr));
+ resolved_local_addr.len = sizeof(resolved_local_addr.addr);
+ if (getsockname(tcp->fd,
+ reinterpret_cast<sockaddr*>(resolved_local_addr.addr),
+ &resolved_local_addr.len) < 0) {
+ tcp->local_address = "";
+ } else {
+ tcp->local_address = grpc_sockaddr_to_uri(&resolved_local_addr);
+ }
tcp->read_cb = nullptr;
tcp->write_cb = nullptr;
- tcp->current_zerocopy_send = nullptr;
+ tcp->current_zerocopy_send = nullptr;
tcp->release_fd_cb = nullptr;
tcp->release_fd = nullptr;
tcp->incoming_buffer = nullptr;
@@ -1785,18 +1785,18 @@ grpc_endpoint* grpc_tcp_create(grpc_fd* em_fd,
tcp->socket_ts_enabled = false;
tcp->ts_capable = true;
tcp->outgoing_buffer_arg = nullptr;
- if (tcp_tx_zerocopy_enabled && !tcp->tcp_zerocopy_send_ctx.memory_limited()) {
-#ifdef GRPC_LINUX_ERRQUEUE
- const int enable = 1;
- auto err =
- setsockopt(tcp->fd, SOL_SOCKET, SO_ZEROCOPY, &enable, sizeof(enable));
- if (err == 0) {
- tcp->tcp_zerocopy_send_ctx.set_enabled(true);
- } else {
- gpr_log(GPR_ERROR, "Failed to set zerocopy options on the socket.");
- }
-#endif
- }
+ if (tcp_tx_zerocopy_enabled && !tcp->tcp_zerocopy_send_ctx.memory_limited()) {
+#ifdef GRPC_LINUX_ERRQUEUE
+ const int enable = 1;
+ auto err =
+ setsockopt(tcp->fd, SOL_SOCKET, SO_ZEROCOPY, &enable, sizeof(enable));
+ if (err == 0) {
+ tcp->tcp_zerocopy_send_ctx.set_enabled(true);
+ } else {
+ gpr_log(GPR_ERROR, "Failed to set zerocopy options on the socket.");
+ }
+#endif
+ }
/* paired with unref in grpc_tcp_destroy */
new (&tcp->refcount) grpc_core::RefCount(1, &grpc_tcp_trace);
gpr_atm_no_barrier_store(&tcp->shutdown_count, 0);
@@ -1863,7 +1863,7 @@ void grpc_tcp_destroy_and_release_fd(grpc_endpoint* ep, int* fd,
grpc_slice_buffer_reset_and_unref_internal(&tcp->last_read_buffer);
if (grpc_event_engine_can_track_errors()) {
/* Stop errors notification. */
- ZerocopyDisableAndWaitForRemaining(tcp);
+ ZerocopyDisableAndWaitForRemaining(tcp);
gpr_atm_no_barrier_store(&tcp->stop_error_notification, true);
grpc_fd_set_error(tcp->em_fd);
}
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/tcp_server.cc b/contrib/libs/grpc/src/core/lib/iomgr/tcp_server.cc
index c48216e5df..046fd4979b 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/tcp_server.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/tcp_server.cc
@@ -28,10 +28,10 @@ grpc_error* grpc_tcp_server_create(grpc_closure* shutdown_complete,
return grpc_tcp_server_impl->create(shutdown_complete, args, server);
}
-void grpc_tcp_server_start(grpc_tcp_server* server,
- const std::vector<grpc_pollset*>* pollsets,
+void grpc_tcp_server_start(grpc_tcp_server* server,
+ const std::vector<grpc_pollset*>* pollsets,
grpc_tcp_server_cb on_accept_cb, void* cb_arg) {
- grpc_tcp_server_impl->start(server, pollsets, on_accept_cb, cb_arg);
+ grpc_tcp_server_impl->start(server, pollsets, on_accept_cb, cb_arg);
}
grpc_error* grpc_tcp_server_add_port(grpc_tcp_server* s,
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/tcp_server.h b/contrib/libs/grpc/src/core/lib/iomgr/tcp_server.h
index 10de37d999..6ba3513da5 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/tcp_server.h
+++ b/contrib/libs/grpc/src/core/lib/iomgr/tcp_server.h
@@ -24,8 +24,8 @@
#include <grpc/grpc.h>
#include <grpc/impl/codegen/grpc_types.h>
-#include <vector>
-
+#include <vector>
+
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/iomgr/resolve_address.h"
@@ -66,9 +66,9 @@ typedef struct grpc_tcp_server_vtable {
grpc_error* (*create)(grpc_closure* shutdown_complete,
const grpc_channel_args* args,
grpc_tcp_server** server);
- void (*start)(grpc_tcp_server* server,
- const std::vector<grpc_pollset*>* pollsets,
- grpc_tcp_server_cb on_accept_cb, void* cb_arg);
+ void (*start)(grpc_tcp_server* server,
+ const std::vector<grpc_pollset*>* pollsets,
+ grpc_tcp_server_cb on_accept_cb, void* cb_arg);
grpc_error* (*add_port)(grpc_tcp_server* s, const grpc_resolved_address* addr,
int* out_port);
grpc_core::TcpServerFdHandler* (*create_fd_handler)(grpc_tcp_server* s);
@@ -89,8 +89,8 @@ grpc_error* grpc_tcp_server_create(grpc_closure* shutdown_complete,
grpc_tcp_server** server);
/* Start listening to bound ports */
-void grpc_tcp_server_start(grpc_tcp_server* server,
- const std::vector<grpc_pollset*>* pollsets,
+void grpc_tcp_server_start(grpc_tcp_server* server,
+ const std::vector<grpc_pollset*>* pollsets,
grpc_tcp_server_cb on_accept_cb, void* cb_arg);
/* Add a port to the server, returning the newly allocated port on success, or
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/tcp_server_custom.cc b/contrib/libs/grpc/src/core/lib/iomgr/tcp_server_custom.cc
index bab706d683..0cffa1f571 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/tcp_server_custom.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/tcp_server_custom.cc
@@ -23,12 +23,12 @@
#include <assert.h>
#include <string.h>
-#include <util/generic/string.h>
-
+#include <util/generic/string.h>
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/iomgr/iomgr_custom.h"
@@ -75,7 +75,7 @@ struct grpc_tcp_server {
grpc_closure* shutdown_complete;
bool shutdown;
- bool so_reuseport;
+ bool so_reuseport;
grpc_resource_quota* resource_quota;
};
@@ -84,13 +84,13 @@ static grpc_error* tcp_server_create(grpc_closure* shutdown_complete,
const grpc_channel_args* args,
grpc_tcp_server** server) {
grpc_tcp_server* s = (grpc_tcp_server*)gpr_malloc(sizeof(grpc_tcp_server));
- // Let the implementation decide if so_reuseport can be enabled or not.
- s->so_reuseport = true;
+ // Let the implementation decide if so_reuseport can be enabled or not.
+ s->so_reuseport = true;
s->resource_quota = grpc_resource_quota_create(nullptr);
for (size_t i = 0; i < (args == nullptr ? 0 : args->num_args); i++) {
- if (!grpc_channel_args_find_bool(args, GRPC_ARG_ALLOW_REUSEPORT, true)) {
- s->so_reuseport = false;
- }
+ if (!grpc_channel_args_find_bool(args, GRPC_ARG_ALLOW_REUSEPORT, true)) {
+ s->so_reuseport = false;
+ }
if (0 == strcmp(GRPC_ARG_RESOURCE_QUOTA, args->args[i].key)) {
if (args->args[i].type == GRPC_ARG_POINTER) {
grpc_resource_quota_unref_internal(s->resource_quota);
@@ -216,7 +216,7 @@ static void finish_accept(grpc_tcp_listener* sp, grpc_custom_socket* socket) {
(grpc_tcp_server_acceptor*)gpr_malloc(sizeof(*acceptor));
grpc_endpoint* ep = nullptr;
grpc_resolved_address peer_name;
- TString peer_name_string;
+ TString peer_name_string;
grpc_error* err;
memset(&peer_name, 0, sizeof(grpc_resolved_address));
@@ -230,11 +230,11 @@ static void finish_accept(grpc_tcp_listener* sp, grpc_custom_socket* socket) {
GRPC_ERROR_UNREF(err);
}
if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) {
- gpr_log(GPR_INFO, "SERVER_CONNECT: %p accepted connection: %s", sp->server,
- peer_name_string.c_str());
+ gpr_log(GPR_INFO, "SERVER_CONNECT: %p accepted connection: %s", sp->server,
+ peer_name_string.c_str());
}
ep = custom_tcp_endpoint_create(socket, sp->server->resource_quota,
- peer_name_string.c_str());
+ peer_name_string.c_str());
acceptor->from_server = sp->server;
acceptor->port_index = sp->port_index;
acceptor->fd_index = 0;
@@ -283,15 +283,15 @@ static grpc_error* add_socket_to_server(grpc_tcp_server* s,
grpc_error* error;
grpc_resolved_address sockname_temp;
- // NOTE(lidiz) The last argument is "flags" which is unused by other
- // implementations. Python IO managers uses it to specify SO_REUSEPORT.
- int flags = 0;
- if (s->so_reuseport) {
- flags |= GRPC_CUSTOM_SOCKET_OPT_SO_REUSEPORT;
- }
-
+ // NOTE(lidiz) The last argument is "flags" which is unused by other
+ // implementations. Python IO managers uses it to specify SO_REUSEPORT.
+ int flags = 0;
+ if (s->so_reuseport) {
+ flags |= GRPC_CUSTOM_SOCKET_OPT_SO_REUSEPORT;
+ }
+
error = grpc_custom_socket_vtable->bind(socket, (grpc_sockaddr*)addr->addr,
- addr->len, flags);
+ addr->len, flags);
if (error != GRPC_ERROR_NONE) {
return error;
}
@@ -385,9 +385,9 @@ static grpc_error* tcp_server_add_port(grpc_tcp_server* s,
}
if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) {
- gpr_log(GPR_INFO, "SERVER %p add_port %s error=%s", s,
- grpc_sockaddr_to_string(addr, false).c_str(),
- grpc_error_string(error));
+ gpr_log(GPR_INFO, "SERVER %p add_port %s error=%s", s,
+ grpc_sockaddr_to_string(addr, false).c_str(),
+ grpc_error_string(error));
}
family = grpc_sockaddr_get_family(addr);
@@ -417,8 +417,8 @@ static grpc_error* tcp_server_add_port(grpc_tcp_server* s,
return error;
}
-static void tcp_server_start(grpc_tcp_server* server,
- const std::vector<grpc_pollset*>* /*pollsets*/,
+static void tcp_server_start(grpc_tcp_server* server,
+ const std::vector<grpc_pollset*>* /*pollsets*/,
grpc_tcp_server_cb on_accept_cb, void* cb_arg) {
grpc_tcp_listener* sp;
GRPC_CUSTOM_IOMGR_ASSERT_SAME_THREAD();
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/tcp_server_posix.cc b/contrib/libs/grpc/src/core/lib/iomgr/tcp_server_posix.cc
index 552ce67ab8..b3f3febe63 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/tcp_server_posix.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/tcp_server_posix.cc
@@ -37,11 +37,11 @@
#include <sys/types.h>
#include <unistd.h>
-#include <util/generic/string.h>
-
-#include "y_absl/strings/str_cat.h"
-#include "y_absl/strings/str_format.h"
-
+#include <util/generic/string.h>
+
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_format.h"
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
@@ -238,19 +238,19 @@ static void on_read(void* arg, grpc_error* err) {
grpc_set_socket_no_sigpipe_if_possible(fd);
- TString addr_str = grpc_sockaddr_to_uri(&addr);
+ TString addr_str = grpc_sockaddr_to_uri(&addr);
if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) {
- gpr_log(GPR_INFO, "SERVER_CONNECT: incoming connection: %s",
- addr_str.c_str());
+ gpr_log(GPR_INFO, "SERVER_CONNECT: incoming connection: %s",
+ addr_str.c_str());
}
- TString name = y_absl::StrCat("tcp-server-connection:", addr_str);
- grpc_fd* fdobj = grpc_fd_create(fd, name.c_str(), true);
+ TString name = y_absl::StrCat("tcp-server-connection:", addr_str);
+ grpc_fd* fdobj = grpc_fd_create(fd, name.c_str(), true);
- read_notifier_pollset = (*(sp->server->pollsets))
- [static_cast<size_t>(gpr_atm_no_barrier_fetch_add(
- &sp->server->next_pollset_to_assign, 1)) %
- sp->server->pollsets->size()];
+ read_notifier_pollset = (*(sp->server->pollsets))
+ [static_cast<size_t>(gpr_atm_no_barrier_fetch_add(
+ &sp->server->next_pollset_to_assign, 1)) %
+ sp->server->pollsets->size()];
grpc_pollset_add_fd(read_notifier_pollset, fdobj);
@@ -264,7 +264,7 @@ static void on_read(void* arg, grpc_error* err) {
sp->server->on_accept_cb(
sp->server->on_accept_cb_arg,
- grpc_tcp_create(fdobj, sp->server->channel_args, addr_str.c_str()),
+ grpc_tcp_create(fdobj, sp->server->channel_args, addr_str.c_str()),
read_notifier_pollset, acceptor);
}
@@ -348,7 +348,7 @@ static grpc_error* add_wildcard_addrs_to_server(grpc_tcp_server* s,
static grpc_error* clone_port(grpc_tcp_listener* listener, unsigned count) {
grpc_tcp_listener* sp = nullptr;
- TString addr_str;
+ TString addr_str;
grpc_error* err;
for (grpc_tcp_listener* l = listener->next; l && l->is_sibling; l = l->next) {
@@ -366,7 +366,7 @@ static grpc_error* clone_port(grpc_tcp_listener* listener, unsigned count) {
true, &port);
if (err != GRPC_ERROR_NONE) return err;
listener->server->nports++;
- addr_str = grpc_sockaddr_to_string(&listener->addr, true);
+ addr_str = grpc_sockaddr_to_string(&listener->addr, true);
sp = static_cast<grpc_tcp_listener*>(gpr_malloc(sizeof(grpc_tcp_listener)));
sp->next = listener->next;
listener->next = sp;
@@ -377,11 +377,11 @@ static grpc_error* clone_port(grpc_tcp_listener* listener, unsigned count) {
listener->sibling = sp;
sp->server = listener->server;
sp->fd = fd;
- sp->emfd = grpc_fd_create(
- fd,
- y_absl::StrFormat("tcp-server-listener:%s/clone-%d", addr_str.c_str(), i)
- .c_str(),
- true);
+ sp->emfd = grpc_fd_create(
+ fd,
+ y_absl::StrFormat("tcp-server-listener:%s/clone-%d", addr_str.c_str(), i)
+ .c_str(),
+ true);
memcpy(&sp->addr, &listener->addr, sizeof(grpc_resolved_address));
sp->port = port;
sp->port_index = listener->port_index;
@@ -487,8 +487,8 @@ static int tcp_server_port_fd(grpc_tcp_server* s, unsigned port_index,
return -1;
}
-static void tcp_server_start(grpc_tcp_server* s,
- const std::vector<grpc_pollset*>* pollsets,
+static void tcp_server_start(grpc_tcp_server* s,
+ const std::vector<grpc_pollset*>* pollsets,
grpc_tcp_server_cb on_accept_cb,
void* on_accept_cb_arg) {
size_t i;
@@ -503,11 +503,11 @@ static void tcp_server_start(grpc_tcp_server* s,
sp = s->head;
while (sp != nullptr) {
if (s->so_reuseport && !grpc_is_unix_socket(&sp->addr) &&
- pollsets->size() > 1) {
+ pollsets->size() > 1) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "clone_port", clone_port(sp, (unsigned)(pollsets->size() - 1))));
- for (i = 0; i < pollsets->size(); i++) {
- grpc_pollset_add_fd((*pollsets)[i], sp->emfd);
+ "clone_port", clone_port(sp, (unsigned)(pollsets->size() - 1))));
+ for (i = 0; i < pollsets->size(); i++) {
+ grpc_pollset_add_fd((*pollsets)[i], sp->emfd);
GRPC_CLOSURE_INIT(&sp->read_closure, on_read, sp,
grpc_schedule_on_exec_ctx);
grpc_fd_notify_on_read(sp->emfd, &sp->read_closure);
@@ -515,8 +515,8 @@ static void tcp_server_start(grpc_tcp_server* s,
sp = sp->next;
}
} else {
- for (i = 0; i < pollsets->size(); i++) {
- grpc_pollset_add_fd((*pollsets)[i], sp->emfd);
+ for (i = 0; i < pollsets->size(); i++) {
+ grpc_pollset_add_fd((*pollsets)[i], sp->emfd);
}
GRPC_CLOSURE_INIT(&sp->read_closure, on_read, sp,
grpc_schedule_on_exec_ctx);
@@ -585,17 +585,17 @@ class ExternalConnectionHandler : public grpc_core::TcpServerFdHandler {
return;
}
grpc_set_socket_no_sigpipe_if_possible(fd);
- TString addr_str = grpc_sockaddr_to_uri(&addr);
+ TString addr_str = grpc_sockaddr_to_uri(&addr);
if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_INFO, "SERVER_CONNECT: incoming external connection: %s",
- addr_str.c_str());
+ addr_str.c_str());
}
- TString name = y_absl::StrCat("tcp-server-connection:", addr_str);
- grpc_fd* fdobj = grpc_fd_create(fd, name.c_str(), true);
+ TString name = y_absl::StrCat("tcp-server-connection:", addr_str);
+ grpc_fd* fdobj = grpc_fd_create(fd, name.c_str(), true);
read_notifier_pollset =
- (*(s_->pollsets))[static_cast<size_t>(gpr_atm_no_barrier_fetch_add(
- &s_->next_pollset_to_assign, 1)) %
- s_->pollsets->size()];
+ (*(s_->pollsets))[static_cast<size_t>(gpr_atm_no_barrier_fetch_add(
+ &s_->next_pollset_to_assign, 1)) %
+ s_->pollsets->size()];
grpc_pollset_add_fd(read_notifier_pollset, fdobj);
grpc_tcp_server_acceptor* acceptor =
static_cast<grpc_tcp_server_acceptor*>(gpr_malloc(sizeof(*acceptor)));
@@ -606,7 +606,7 @@ class ExternalConnectionHandler : public grpc_core::TcpServerFdHandler {
acceptor->listener_fd = listener_fd;
acceptor->pending_data = buf;
s_->on_accept_cb(s_->on_accept_cb_arg,
- grpc_tcp_create(fdobj, s_->channel_args, addr_str.c_str()),
+ grpc_tcp_create(fdobj, s_->channel_args, addr_str.c_str()),
read_notifier_pollset, acceptor);
}
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/tcp_server_utils_posix.h b/contrib/libs/grpc/src/core/lib/iomgr/tcp_server_utils_posix.h
index 46c74c7127..6b8a5f9f20 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/tcp_server_utils_posix.h
+++ b/contrib/libs/grpc/src/core/lib/iomgr/tcp_server_utils_posix.h
@@ -82,9 +82,9 @@ struct grpc_tcp_server {
/* shutdown callback */
grpc_closure* shutdown_complete;
- /* all pollsets interested in new connections. The object pointed at is not
- * owned by this struct */
- const std::vector<grpc_pollset*>* pollsets;
+ /* all pollsets interested in new connections. The object pointed at is not
+ * owned by this struct */
+ const std::vector<grpc_pollset*>* pollsets;
/* next pollset to assign a channel to */
gpr_atm next_pollset_to_assign;
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/tcp_server_utils_posix_common.cc b/contrib/libs/grpc/src/core/lib/iomgr/tcp_server_utils_posix_common.cc
index 15cb4e5917..46bc18e5a0 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/tcp_server_utils_posix_common.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/tcp_server_utils_posix_common.cc
@@ -29,10 +29,10 @@
#include <stdio.h>
#include <string.h>
-#include <util/generic/string.h>
-
-#include "y_absl/strings/str_cat.h"
-
+#include <util/generic/string.h>
+
+#include "y_absl/strings/str_cat.h"
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
@@ -91,8 +91,8 @@ static grpc_error* add_socket_to_server(grpc_tcp_server* s, int fd,
grpc_tcp_server_prepare_socket(s, fd, addr, s->so_reuseport, &port);
if (err == GRPC_ERROR_NONE) {
GPR_ASSERT(port > 0);
- TString addr_str = grpc_sockaddr_to_string(addr, true);
- TString name = y_absl::StrCat("tcp-server-listener:", addr_str);
+ TString addr_str = grpc_sockaddr_to_string(addr, true);
+ TString name = y_absl::StrCat("tcp-server-listener:", addr_str);
gpr_mu_lock(&s->mu);
s->nports++;
GPR_ASSERT(!s->on_accept_cb && "must add ports before starting server");
@@ -106,7 +106,7 @@ static grpc_error* add_socket_to_server(grpc_tcp_server* s, int fd,
s->tail = sp;
sp->server = s;
sp->fd = fd;
- sp->emfd = grpc_fd_create(fd, name.c_str(), true);
+ sp->emfd = grpc_fd_create(fd, name.c_str(), true);
memcpy(&sp->addr, addr, sizeof(grpc_resolved_address));
sp->port = port;
sp->port_index = port_index;
@@ -156,14 +156,14 @@ grpc_error* grpc_tcp_server_prepare_socket(grpc_tcp_server* s, int fd,
if (err != GRPC_ERROR_NONE) goto error;
}
-#ifdef GRPC_LINUX_ERRQUEUE
- err = grpc_set_socket_zerocopy(fd);
- if (err != GRPC_ERROR_NONE) {
- /* it's not fatal, so just log it. */
- gpr_log(GPR_DEBUG, "Node does not support SO_ZEROCOPY, continuing.");
- GRPC_ERROR_UNREF(err);
- }
-#endif
+#ifdef GRPC_LINUX_ERRQUEUE
+ err = grpc_set_socket_zerocopy(fd);
+ if (err != GRPC_ERROR_NONE) {
+ /* it's not fatal, so just log it. */
+ gpr_log(GPR_DEBUG, "Node does not support SO_ZEROCOPY, continuing.");
+ GRPC_ERROR_UNREF(err);
+ }
+#endif
err = grpc_set_socket_nonblocking(fd, 1);
if (err != GRPC_ERROR_NONE) goto error;
err = grpc_set_socket_cloexec(fd, 1);
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc b/contrib/libs/grpc/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc
index 6c0fc41e26..1c7cd5cc10 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc
@@ -29,10 +29,10 @@
#include <stddef.h>
#include <string.h>
-#include <util/generic/string.h>
-
-#include "y_absl/strings/str_cat.h"
-
+#include <util/generic/string.h>
+
+#include "y_absl/strings/str_cat.h"
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@@ -133,21 +133,21 @@ grpc_error* grpc_tcp_server_add_all_local_addrs(grpc_tcp_server* s,
err = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed to set port");
break;
}
- TString addr_str = grpc_sockaddr_to_string(&addr, false);
+ TString addr_str = grpc_sockaddr_to_string(&addr, false);
gpr_log(GPR_DEBUG,
"Adding local addr from interface %s flags 0x%x to server: %s",
- ifa_name, ifa_it->ifa_flags, addr_str.c_str());
+ ifa_name, ifa_it->ifa_flags, addr_str.c_str());
/* We could have multiple interfaces with the same address (e.g., bonding),
so look for duplicates. */
if (find_listener_with_addr(s, &addr) != nullptr) {
- gpr_log(GPR_DEBUG, "Skipping duplicate addr %s on interface %s",
- addr_str.c_str(), ifa_name);
+ gpr_log(GPR_DEBUG, "Skipping duplicate addr %s on interface %s",
+ addr_str.c_str(), ifa_name);
continue;
}
if ((err = grpc_tcp_server_add_addr(s, &addr, port_index, fd_index, &dsmode,
&new_sp)) != GRPC_ERROR_NONE) {
- grpc_error* root_err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
- y_absl::StrCat("Failed to add listener: ", addr_str).c_str());
+ grpc_error* root_err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
+ y_absl::StrCat("Failed to add listener: ", addr_str).c_str());
err = grpc_error_add_child(root_err, err);
break;
} else {
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/tcp_server_windows.cc b/contrib/libs/grpc/src/core/lib/iomgr/tcp_server_windows.cc
index 4a3fef4eb1..13c17260dc 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/tcp_server_windows.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/tcp_server_windows.cc
@@ -27,10 +27,10 @@
#include <inttypes.h>
#include <io.h>
-#include <vector>
-
-#include "y_absl/strings/str_cat.h"
-
+#include <vector>
+
+#include "y_absl/strings/str_cat.h"
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/log_windows.h>
@@ -46,7 +46,7 @@
#include "src/core/lib/iomgr/socket_windows.h"
#include "src/core/lib/iomgr/tcp_server.h"
#include "src/core/lib/iomgr/tcp_windows.h"
-#include "src/core/lib/slice/slice_internal.h"
+#include "src/core/lib/slice/slice_internal.h"
#define MIN_SAFE_ACCEPT_QUEUE_SIZE 100
@@ -228,11 +228,11 @@ static grpc_error* prepare_socket(SOCKET sock,
failure:
GPR_ASSERT(error != GRPC_ERROR_NONE);
grpc_error_set_int(
- grpc_error_set_str(
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "Failed to prepare server socket", &error, 1),
- GRPC_ERROR_STR_TARGET_ADDRESS,
- grpc_slice_from_cpp_string(grpc_sockaddr_to_uri(addr))),
+ grpc_error_set_str(
+ GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Failed to prepare server socket", &error, 1),
+ GRPC_ERROR_STR_TARGET_ADDRESS,
+ grpc_slice_from_cpp_string(grpc_sockaddr_to_uri(addr))),
GRPC_ERROR_INT_FD, (intptr_t)sock);
GRPC_ERROR_UNREF(error);
if (sock != INVALID_SOCKET) closesocket(sock);
@@ -349,7 +349,7 @@ static void on_accept(void* arg, grpc_error* error) {
int peer_name_len = (int)peer_name.len;
err = getpeername(sock, (grpc_sockaddr*)peer_name.addr, &peer_name_len);
peer_name.len = (size_t)peer_name_len;
- TString peer_name_string;
+ TString peer_name_string;
if (!err) {
peer_name_string = grpc_sockaddr_to_uri(&peer_name);
} else {
@@ -357,9 +357,9 @@ static void on_accept(void* arg, grpc_error* error) {
gpr_log(GPR_ERROR, "getpeername error: %s", utf8_message);
gpr_free(utf8_message);
}
- TString fd_name = y_absl::StrCat("tcp_server:", peer_name_string);
- ep = grpc_tcp_create(grpc_winsocket_create(sock, fd_name.c_str()),
- sp->server->channel_args, peer_name_string.c_str());
+ TString fd_name = y_absl::StrCat("tcp_server:", peer_name_string);
+ ep = grpc_tcp_create(grpc_winsocket_create(sock, fd_name.c_str()),
+ sp->server->channel_args, peer_name_string.c_str());
} else {
closesocket(sock);
}
@@ -520,8 +520,8 @@ done:
return error;
}
-static void tcp_server_start(grpc_tcp_server* s,
- const std::vector<grpc_pollset*>* /*pollsets*/,
+static void tcp_server_start(grpc_tcp_server* s,
+ const std::vector<grpc_pollset*>* /*pollsets*/,
grpc_tcp_server_cb on_accept_cb,
void* on_accept_cb_arg) {
grpc_tcp_listener* sp;
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/tcp_uv.cc b/contrib/libs/grpc/src/core/lib/iomgr/tcp_uv.cc
index 9b484fadb8..371b38c991 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/tcp_uv.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/tcp_uv.cc
@@ -370,7 +370,7 @@ static void uv_resolve_callback(uv_getaddrinfo_t* req, int status,
tcp_error_create("getaddrinfo failed", status));
}
-static grpc_error* uv_resolve(const char* host, const char* port,
+static grpc_error* uv_resolve(const char* host, const char* port,
grpc_resolved_addresses** result) {
int status;
uv_getaddrinfo_t req;
@@ -388,8 +388,8 @@ static grpc_error* uv_resolve(const char* host, const char* port,
return tcp_error_create("getaddrinfo failed", status);
}
-static void uv_resolve_async(grpc_custom_resolver* r, const char* host,
- const char* port) {
+static void uv_resolve_async(grpc_custom_resolver* r, const char* host,
+ const char* port) {
int status;
uv_getaddrinfo_t* req =
(uv_getaddrinfo_t*)gpr_malloc(sizeof(uv_getaddrinfo_t));
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/tcp_windows.cc b/contrib/libs/grpc/src/core/lib/iomgr/tcp_windows.cc
index e219538c36..3d410a2d3f 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/tcp_windows.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/tcp_windows.cc
@@ -125,8 +125,8 @@ typedef struct grpc_tcp {
int shutting_down;
grpc_error* shutdown_error;
- TString peer_string;
- TString local_address;
+ TString peer_string;
+ TString local_address;
} grpc_tcp;
static void tcp_free(grpc_tcp* tcp) {
@@ -135,7 +135,7 @@ static void tcp_free(grpc_tcp* tcp) {
grpc_slice_buffer_destroy_internal(&tcp->last_read_buffer);
grpc_resource_user_unref(tcp->resource_user);
if (tcp->shutting_down) GRPC_ERROR_UNREF(tcp->shutdown_error);
- delete tcp;
+ delete tcp;
}
#ifndef NDEBUG
@@ -213,8 +213,8 @@ static void on_read(void* tcpp, grpc_error* error) {
for (i = 0; i < tcp->read_slices->count; i++) {
char* dump = grpc_dump_slice(tcp->read_slices->slices[i],
GPR_DUMP_HEX | GPR_DUMP_ASCII);
- gpr_log(GPR_INFO, "READ %p (peer=%s): %s", tcp,
- tcp->peer_string.c_str(), dump);
+ gpr_log(GPR_INFO, "READ %p (peer=%s): %s", tcp,
+ tcp->peer_string.c_str(), dump);
gpr_free(dump);
}
}
@@ -361,8 +361,8 @@ static void win_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
for (i = 0; i < slices->count; i++) {
char* data =
grpc_dump_slice(slices->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII);
- gpr_log(GPR_INFO, "WRITE %p (peer=%s): %s", tcp, tcp->peer_string.c_str(),
- data);
+ gpr_log(GPR_INFO, "WRITE %p (peer=%s): %s", tcp, tcp->peer_string.c_str(),
+ data);
gpr_free(data);
}
}
@@ -476,16 +476,16 @@ static void win_destroy(grpc_endpoint* ep) {
TCP_UNREF(tcp, "destroy");
}
-static y_absl::string_view win_get_peer(grpc_endpoint* ep) {
+static y_absl::string_view win_get_peer(grpc_endpoint* ep) {
grpc_tcp* tcp = (grpc_tcp*)ep;
- return tcp->peer_string;
+ return tcp->peer_string;
+}
+
+static y_absl::string_view win_get_local_address(grpc_endpoint* ep) {
+ grpc_tcp* tcp = (grpc_tcp*)ep;
+ return tcp->local_address;
}
-static y_absl::string_view win_get_local_address(grpc_endpoint* ep) {
- grpc_tcp* tcp = (grpc_tcp*)ep;
- return tcp->local_address;
-}
-
static grpc_resource_user* win_get_resource_user(grpc_endpoint* ep) {
grpc_tcp* tcp = (grpc_tcp*)ep;
return tcp->resource_user;
@@ -504,7 +504,7 @@ static grpc_endpoint_vtable vtable = {win_read,
win_destroy,
win_get_resource_user,
win_get_peer,
- win_get_local_address,
+ win_get_local_address,
win_get_fd,
win_can_track_err};
@@ -521,7 +521,7 @@ grpc_endpoint* grpc_tcp_create(grpc_winsocket* socket,
}
}
}
- grpc_tcp* tcp = new grpc_tcp;
+ grpc_tcp* tcp = new grpc_tcp;
memset(tcp, 0, sizeof(grpc_tcp));
tcp->base.vtable = &vtable;
tcp->socket = socket;
@@ -529,16 +529,16 @@ grpc_endpoint* grpc_tcp_create(grpc_winsocket* socket,
gpr_ref_init(&tcp->refcount, 1);
GRPC_CLOSURE_INIT(&tcp->on_read, on_read, tcp, grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&tcp->on_write, on_write, tcp, grpc_schedule_on_exec_ctx);
- grpc_resolved_address resolved_local_addr;
- resolved_local_addr.len = sizeof(resolved_local_addr.addr);
- if (getsockname(tcp->socket->socket,
- reinterpret_cast<sockaddr*>(resolved_local_addr.addr),
- &resolved_local_addr.len) < 0) {
- tcp->local_address = "";
- } else {
- tcp->local_address = grpc_sockaddr_to_uri(&resolved_local_addr);
- }
- tcp->peer_string = peer_string;
+ grpc_resolved_address resolved_local_addr;
+ resolved_local_addr.len = sizeof(resolved_local_addr.addr);
+ if (getsockname(tcp->socket->socket,
+ reinterpret_cast<sockaddr*>(resolved_local_addr.addr),
+ &resolved_local_addr.len) < 0) {
+ tcp->local_address = "";
+ } else {
+ tcp->local_address = grpc_sockaddr_to_uri(&resolved_local_addr);
+ }
+ tcp->peer_string = peer_string;
grpc_slice_buffer_init(&tcp->last_read_buffer);
tcp->resource_user = grpc_resource_user_create(resource_quota, peer_string);
grpc_resource_quota_unref_internal(resource_quota);
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/timer_generic.cc b/contrib/libs/grpc/src/core/lib/iomgr/timer_generic.cc
index 38ec91f56d..fb0e50c53c 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/timer_generic.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/timer_generic.cc
@@ -22,10 +22,10 @@
#include <inttypes.h>
-#include <util/generic/string.h>
-
-#include "y_absl/strings/str_cat.h"
-
+#include <util/generic/string.h>
+
+#include "y_absl/strings/str_cat.h"
+
#include "src/core/lib/iomgr/timer.h"
#include <grpc/support/alloc.h>
@@ -709,22 +709,22 @@ static grpc_timer_check_result timer_check(grpc_millis* next) {
// tracing
if (GRPC_TRACE_FLAG_ENABLED(grpc_timer_check_trace)) {
- TString next_str;
+ TString next_str;
if (next == nullptr) {
- next_str = "NULL";
+ next_str = "NULL";
} else {
- next_str = y_absl::StrCat(*next);
+ next_str = y_absl::StrCat(*next);
}
#if GPR_ARCH_64
gpr_log(GPR_INFO,
"TIMER CHECK BEGIN: now=%" PRId64 " next=%s tls_min=%" PRId64
" glob_min=%" PRId64,
- now, next_str.c_str(), min_timer,
+ now, next_str.c_str(), min_timer,
static_cast<grpc_millis>(gpr_atm_no_barrier_load(
(gpr_atm*)(&g_shared_mutables.min_timer))));
#else
gpr_log(GPR_INFO, "TIMER CHECK BEGIN: now=%" PRId64 " next=%s min=%" PRId64,
- now, next_str.c_str(), min_timer);
+ now, next_str.c_str(), min_timer);
#endif
}
// actual code
@@ -732,13 +732,13 @@ static grpc_timer_check_result timer_check(grpc_millis* next) {
run_some_expired_timers(now, next, shutdown_error);
// tracing
if (GRPC_TRACE_FLAG_ENABLED(grpc_timer_check_trace)) {
- TString next_str;
+ TString next_str;
if (next == nullptr) {
- next_str = "NULL";
+ next_str = "NULL";
} else {
- next_str = y_absl::StrCat(*next);
+ next_str = y_absl::StrCat(*next);
}
- gpr_log(GPR_INFO, "TIMER CHECK END: r=%d; next=%s", r, next_str.c_str());
+ gpr_log(GPR_INFO, "TIMER CHECK END: r=%d; next=%s", r, next_str.c_str());
}
return r;
}
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/udp_server.cc b/contrib/libs/grpc/src/core/lib/iomgr/udp_server.cc
index 0f32f004cd..1e7734d681 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/udp_server.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/udp_server.cc
@@ -44,12 +44,12 @@
#include <sys/types.h>
#include <unistd.h>
-#include <util/generic/string.h>
-#include <vector>
-
-#include "y_absl/container/inlined_vector.h"
-#include "y_absl/strings/str_cat.h"
-
+#include <util/generic/string.h>
+#include <vector>
+
+#include "y_absl/container/inlined_vector.h"
+#include "y_absl/strings/str_cat.h"
+
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@@ -78,7 +78,7 @@ class GrpcUdpListener {
~GrpcUdpListener();
/* Called when grpc server starts to listening on the grpc_fd. */
- void StartListening(const std::vector<grpc_pollset*>* pollsets,
+ void StartListening(const std::vector<grpc_pollset*>* pollsets,
GrpcUdpHandlerFactory* handler_factory);
/* Called when data is available to read from the socket.
@@ -152,9 +152,9 @@ GrpcUdpListener::GrpcUdpListener(grpc_udp_server* server, int fd,
server_(server),
orphan_notified_(false),
already_shutdown_(false) {
- TString addr_str = grpc_sockaddr_to_string(addr, true);
- TString name = y_absl::StrCat("udp-server-listener:", addr_str);
- emfd_ = grpc_fd_create(fd, name.c_str(), true);
+ TString addr_str = grpc_sockaddr_to_string(addr, true);
+ TString name = y_absl::StrCat("udp-server-listener:", addr_str);
+ emfd_ = grpc_fd_create(fd, name.c_str(), true);
memcpy(&addr_, addr, sizeof(grpc_resolved_address));
GPR_ASSERT(emfd_);
gpr_mu_init(&mutex_);
@@ -178,7 +178,7 @@ struct grpc_udp_server {
int shutdown;
/* An array of listeners */
- y_absl::InlinedVector<GrpcUdpListener, 16> listeners;
+ y_absl::InlinedVector<GrpcUdpListener, 16> listeners;
/* factory for use to create udp listeners */
GrpcUdpHandlerFactory* handler_factory;
@@ -186,9 +186,9 @@ struct grpc_udp_server {
/* shutdown callback */
grpc_closure* shutdown_complete;
- /* all pollsets interested in new connections. The object pointed at is not
- * owned by this struct. */
- const std::vector<grpc_pollset*>* pollsets;
+ /* all pollsets interested in new connections. The object pointed at is not
+ * owned by this struct. */
+ const std::vector<grpc_pollset*>* pollsets;
/* opaque object to pass to callbacks */
void* user_data;
@@ -282,7 +282,7 @@ static void deactivated_all_ports(grpc_udp_server* s) {
GPR_ASSERT(s->shutdown);
- if (s->listeners.empty()) {
+ if (s->listeners.empty()) {
gpr_mu_unlock(&s->mu);
finish_shutdown(s);
return;
@@ -412,8 +412,8 @@ static int prepare_socket(grpc_socket_factory* socket_factory, int fd,
}
if (bind_socket(socket_factory, fd, addr) < 0) {
- TString addr_str = grpc_sockaddr_to_string(addr, false);
- gpr_log(GPR_ERROR, "bind addr=%s: %s", addr_str.c_str(), strerror(errno));
+ TString addr_str = grpc_sockaddr_to_string(addr, false);
+ gpr_log(GPR_ERROR, "bind addr=%s: %s", addr_str.c_str(), strerror(errno));
goto error;
}
@@ -580,8 +580,8 @@ int grpc_udp_server_add_port(grpc_udp_server* s,
"Try to have multiple listeners on same port, but SO_REUSEPORT is "
"not supported. Only create 1 listener.");
}
- TString addr_str = grpc_sockaddr_to_string(addr, true);
- gpr_log(GPR_DEBUG, "add address: %s to server", addr_str.c_str());
+ TString addr_str = grpc_sockaddr_to_string(addr, true);
+ gpr_log(GPR_DEBUG, "add address: %s to server", addr_str.c_str());
int allocated_port1 = -1;
int allocated_port2 = -1;
@@ -701,29 +701,29 @@ int grpc_udp_server_get_fd(grpc_udp_server* s, unsigned port_index) {
return s->listeners[port_index].fd();
}
-void grpc_udp_server_start(grpc_udp_server* udp_server,
- const std::vector<grpc_pollset*>* pollsets,
- void* user_data) {
+void grpc_udp_server_start(grpc_udp_server* udp_server,
+ const std::vector<grpc_pollset*>* pollsets,
+ void* user_data) {
gpr_log(GPR_DEBUG, "grpc_udp_server_start");
- gpr_mu_lock(&udp_server->mu);
- GPR_ASSERT(udp_server->active_ports == 0);
- udp_server->pollsets = pollsets;
- udp_server->user_data = user_data;
+ gpr_mu_lock(&udp_server->mu);
+ GPR_ASSERT(udp_server->active_ports == 0);
+ udp_server->pollsets = pollsets;
+ udp_server->user_data = user_data;
- for (auto& listener : udp_server->listeners) {
- listener.StartListening(pollsets, udp_server->handler_factory);
+ for (auto& listener : udp_server->listeners) {
+ listener.StartListening(pollsets, udp_server->handler_factory);
}
- gpr_mu_unlock(&udp_server->mu);
+ gpr_mu_unlock(&udp_server->mu);
}
-void GrpcUdpListener::StartListening(const std::vector<grpc_pollset*>* pollsets,
+void GrpcUdpListener::StartListening(const std::vector<grpc_pollset*>* pollsets,
GrpcUdpHandlerFactory* handler_factory) {
gpr_mu_lock(&mutex_);
handler_factory_ = handler_factory;
udp_handler_ = handler_factory->CreateUdpHandler(emfd_, server_->user_data);
- for (grpc_pollset* pollset : *pollsets) {
- grpc_pollset_add_fd(pollset, emfd_);
+ for (grpc_pollset* pollset : *pollsets) {
+ grpc_pollset_add_fd(pollset, emfd_);
}
GRPC_CLOSURE_INIT(&read_closure_, on_read, this, grpc_schedule_on_exec_ctx);
grpc_fd_notify_on_read(emfd_, &read_closure_);
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/udp_server.h b/contrib/libs/grpc/src/core/lib/iomgr/udp_server.h
index aaca6c53c8..6cda332a5b 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/udp_server.h
+++ b/contrib/libs/grpc/src/core/lib/iomgr/udp_server.h
@@ -21,8 +21,8 @@
#include <grpc/support/port_platform.h>
-#include <vector>
-
+#include <vector>
+
#include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/resolve_address.h"
@@ -74,9 +74,9 @@ class GrpcUdpHandlerFactory {
grpc_udp_server* grpc_udp_server_create(const grpc_channel_args* args);
/* Start listening to bound ports. user_data is passed to callbacks. */
-void grpc_udp_server_start(grpc_udp_server* udp_server,
- const std::vector<grpc_pollset*>* pollsets,
- void* user_data);
+void grpc_udp_server_start(grpc_udp_server* udp_server,
+ const std::vector<grpc_pollset*>* pollsets,
+ void* user_data);
int grpc_udp_server_get_fd(grpc_udp_server* s, unsigned port_index);
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/unix_sockets_posix.cc b/contrib/libs/grpc/src/core/lib/iomgr/unix_sockets_posix.cc
index 8f02f7bd25..fd26673b38 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/unix_sockets_posix.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/unix_sockets_posix.cc
@@ -28,8 +28,8 @@
#include <sys/types.h>
#include <sys/un.h>
-#include "y_absl/strings/str_cat.h"
-
+#include "y_absl/strings/str_cat.h"
+
#include "src/core/lib/iomgr/unix_sockets_posix.h"
#include <grpc/support/alloc.h>
@@ -46,10 +46,10 @@ grpc_error* grpc_resolve_unix_domain_address(const char* name,
struct sockaddr_un* un;
if (strlen(name) >
GPR_ARRAY_SIZE(((struct sockaddr_un*)nullptr)->sun_path) - 1) {
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
- y_absl::StrCat("Path name should not have more than ",
- GPR_ARRAY_SIZE(un->sun_path) - 1, " characters")
- .c_str());
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
+ y_absl::StrCat("Path name should not have more than ",
+ GPR_ARRAY_SIZE(un->sun_path) - 1, " characters")
+ .c_str());
}
*addrs = static_cast<grpc_resolved_addresses*>(
gpr_malloc(sizeof(grpc_resolved_addresses)));
@@ -86,14 +86,14 @@ void grpc_unlink_if_unix_domain_socket(
}
}
-TString grpc_sockaddr_to_uri_unix_if_possible(
+TString grpc_sockaddr_to_uri_unix_if_possible(
const grpc_resolved_address* resolved_addr) {
const grpc_sockaddr* addr =
reinterpret_cast<const grpc_sockaddr*>(resolved_addr->addr);
if (addr->sa_family != AF_UNIX) {
- return "";
+ return "";
}
- return y_absl::StrCat("unix:", ((struct sockaddr_un*)addr)->sun_path);
+ return y_absl::StrCat("unix:", ((struct sockaddr_un*)addr)->sun_path);
}
#endif
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/unix_sockets_posix.h b/contrib/libs/grpc/src/core/lib/iomgr/unix_sockets_posix.h
index f5cbae30b6..962adde71c 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/unix_sockets_posix.h
+++ b/contrib/libs/grpc/src/core/lib/iomgr/unix_sockets_posix.h
@@ -21,8 +21,8 @@
#include <grpc/support/port_platform.h>
-#include <util/generic/string.h>
-
+#include <util/generic/string.h>
+
#include "src/core/lib/iomgr/port.h"
#include <grpc/support/string_util.h>
@@ -39,7 +39,7 @@ int grpc_is_unix_socket(const grpc_resolved_address* resolved_addr);
void grpc_unlink_if_unix_domain_socket(
const grpc_resolved_address* resolved_addr);
-TString grpc_sockaddr_to_uri_unix_if_possible(
+TString grpc_sockaddr_to_uri_unix_if_possible(
const grpc_resolved_address* resolved_addr);
#endif /* GRPC_CORE_LIB_IOMGR_UNIX_SOCKETS_POSIX_H */
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/unix_sockets_posix_noop.cc b/contrib/libs/grpc/src/core/lib/iomgr/unix_sockets_posix_noop.cc
index 2548c1349b..e391914ab5 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/unix_sockets_posix_noop.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/unix_sockets_posix_noop.cc
@@ -22,8 +22,8 @@
#ifndef GRPC_HAVE_UNIX_SOCKET
-#include <util/generic/string.h>
-
+#include <util/generic/string.h>
+
#include <grpc/support/log.h>
void grpc_create_socketpair_if_unix(int sv[2]) {
@@ -44,9 +44,9 @@ int grpc_is_unix_socket(const grpc_resolved_address* addr) { return false; }
void grpc_unlink_if_unix_domain_socket(const grpc_resolved_address* addr) {}
-TString grpc_sockaddr_to_uri_unix_if_possible(
- const grpc_resolved_address* addr) {
- return "";
+TString grpc_sockaddr_to_uri_unix_if_possible(
+ const grpc_resolved_address* addr) {
+ return "";
}
#endif
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/work_serializer.cc b/contrib/libs/grpc/src/core/lib/iomgr/work_serializer.cc
index f2d2e64bcf..db573e3b6f 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/work_serializer.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/work_serializer.cc
@@ -1,155 +1,155 @@
-/*
- *
- * Copyright 2019 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <grpc/support/port_platform.h>
-
-#include "src/core/lib/iomgr/work_serializer.h"
-
-namespace grpc_core {
-
-DebugOnlyTraceFlag grpc_work_serializer_trace(false, "work_serializer");
-
-struct CallbackWrapper {
- CallbackWrapper(std::function<void()> cb, const grpc_core::DebugLocation& loc)
- : callback(std::move(cb)), location(loc) {}
-
- MultiProducerSingleConsumerQueue::Node mpscq_node;
- const std::function<void()> callback;
- const DebugLocation location;
-};
-
-class WorkSerializer::WorkSerializerImpl : public Orphanable {
- public:
- void Run(std::function<void()> callback,
- const grpc_core::DebugLocation& location);
-
- void Orphan() override;
-
- private:
- void DrainQueue();
-
- // An initial size of 1 keeps track of whether the work serializer has been
- // orphaned.
- Atomic<size_t> size_{1};
- MultiProducerSingleConsumerQueue queue_;
-};
-
-void WorkSerializer::WorkSerializerImpl::Run(
- std::function<void()> callback, const grpc_core::DebugLocation& location) {
- if (GRPC_TRACE_FLAG_ENABLED(grpc_work_serializer_trace)) {
- gpr_log(GPR_INFO, "WorkSerializer::Run() %p Scheduling callback [%s:%d]",
- this, location.file(), location.line());
- }
- const size_t prev_size = size_.FetchAdd(1);
- // The work serializer should not have been orphaned.
- GPR_DEBUG_ASSERT(prev_size > 0);
- if (prev_size == 1) {
- // There is no other closure executing right now on this work serializer.
- // Execute this closure immediately.
- if (GRPC_TRACE_FLAG_ENABLED(grpc_work_serializer_trace)) {
- gpr_log(GPR_INFO, " Executing immediately");
- }
- callback();
- // Loan this thread to the work serializer thread and drain the queue.
- DrainQueue();
- } else {
- CallbackWrapper* cb_wrapper =
- new CallbackWrapper(std::move(callback), location);
- // There already are closures executing on this work serializer. Simply add
- // this closure to the queue.
- if (GRPC_TRACE_FLAG_ENABLED(grpc_work_serializer_trace)) {
- gpr_log(GPR_INFO, " Scheduling on queue : item %p", cb_wrapper);
- }
- queue_.Push(&cb_wrapper->mpscq_node);
- }
-}
-
-void WorkSerializer::WorkSerializerImpl::Orphan() {
- if (GRPC_TRACE_FLAG_ENABLED(grpc_work_serializer_trace)) {
- gpr_log(GPR_INFO, "WorkSerializer::Orphan() %p", this);
- }
- size_t prev_size = size_.FetchSub(1);
- if (prev_size == 1) {
- if (GRPC_TRACE_FLAG_ENABLED(grpc_work_serializer_trace)) {
- gpr_log(GPR_INFO, " Destroying");
- }
- delete this;
- }
-}
-
-// The thread that calls this loans itself to the work serializer so as to
-// execute all the scheduled callback. This is called from within
-// WorkSerializer::Run() after executing a callback immediately, and hence size_
-// is at least 1.
-void WorkSerializer::WorkSerializerImpl::DrainQueue() {
- while (true) {
- if (GRPC_TRACE_FLAG_ENABLED(grpc_work_serializer_trace)) {
- gpr_log(GPR_INFO, "WorkSerializer::DrainQueue() %p", this);
- }
- size_t prev_size = size_.FetchSub(1);
- GPR_DEBUG_ASSERT(prev_size >= 1);
- // It is possible that while draining the queue, one of the callbacks ended
- // up orphaning the work serializer. In that case, delete the object.
- if (prev_size == 1) {
- if (GRPC_TRACE_FLAG_ENABLED(grpc_work_serializer_trace)) {
- gpr_log(GPR_INFO, " Queue Drained. Destroying");
- }
- delete this;
- return;
- }
- if (prev_size == 2) {
- if (GRPC_TRACE_FLAG_ENABLED(grpc_work_serializer_trace)) {
- gpr_log(GPR_INFO, " Queue Drained");
- }
- return;
- }
- // There is at least one callback on the queue. Pop the callback from the
- // queue and execute it.
- CallbackWrapper* cb_wrapper = nullptr;
- bool empty_unused;
- while ((cb_wrapper = reinterpret_cast<CallbackWrapper*>(
- queue_.PopAndCheckEnd(&empty_unused))) == nullptr) {
- // This can happen either due to a race condition within the mpscq
- // implementation or because of a race with Run()
- if (GRPC_TRACE_FLAG_ENABLED(grpc_work_serializer_trace)) {
- gpr_log(GPR_INFO, " Queue returned nullptr, trying again");
- }
- }
- if (GRPC_TRACE_FLAG_ENABLED(grpc_work_serializer_trace)) {
- gpr_log(GPR_INFO, " Running item %p : callback scheduled at [%s:%d]",
- cb_wrapper, cb_wrapper->location.file(),
- cb_wrapper->location.line());
- }
- cb_wrapper->callback();
- delete cb_wrapper;
- }
-}
-
-// WorkSerializer
-
-WorkSerializer::WorkSerializer()
- : impl_(MakeOrphanable<WorkSerializerImpl>()) {}
-
-WorkSerializer::~WorkSerializer() {}
-
-void WorkSerializer::Run(std::function<void()> callback,
- const grpc_core::DebugLocation& location) {
- impl_->Run(std::move(callback), location);
-}
-
-} // namespace grpc_core
+/*
+ *
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <grpc/support/port_platform.h>
+
+#include "src/core/lib/iomgr/work_serializer.h"
+
+namespace grpc_core {
+
+DebugOnlyTraceFlag grpc_work_serializer_trace(false, "work_serializer");
+
+struct CallbackWrapper {
+ CallbackWrapper(std::function<void()> cb, const grpc_core::DebugLocation& loc)
+ : callback(std::move(cb)), location(loc) {}
+
+ MultiProducerSingleConsumerQueue::Node mpscq_node;
+ const std::function<void()> callback;
+ const DebugLocation location;
+};
+
+class WorkSerializer::WorkSerializerImpl : public Orphanable {
+ public:
+ void Run(std::function<void()> callback,
+ const grpc_core::DebugLocation& location);
+
+ void Orphan() override;
+
+ private:
+ void DrainQueue();
+
+ // An initial size of 1 keeps track of whether the work serializer has been
+ // orphaned.
+ Atomic<size_t> size_{1};
+ MultiProducerSingleConsumerQueue queue_;
+};
+
+void WorkSerializer::WorkSerializerImpl::Run(
+ std::function<void()> callback, const grpc_core::DebugLocation& location) {
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_work_serializer_trace)) {
+ gpr_log(GPR_INFO, "WorkSerializer::Run() %p Scheduling callback [%s:%d]",
+ this, location.file(), location.line());
+ }
+ const size_t prev_size = size_.FetchAdd(1);
+ // The work serializer should not have been orphaned.
+ GPR_DEBUG_ASSERT(prev_size > 0);
+ if (prev_size == 1) {
+ // There is no other closure executing right now on this work serializer.
+ // Execute this closure immediately.
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_work_serializer_trace)) {
+ gpr_log(GPR_INFO, " Executing immediately");
+ }
+ callback();
+ // Loan this thread to the work serializer thread and drain the queue.
+ DrainQueue();
+ } else {
+ CallbackWrapper* cb_wrapper =
+ new CallbackWrapper(std::move(callback), location);
+ // There already are closures executing on this work serializer. Simply add
+ // this closure to the queue.
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_work_serializer_trace)) {
+ gpr_log(GPR_INFO, " Scheduling on queue : item %p", cb_wrapper);
+ }
+ queue_.Push(&cb_wrapper->mpscq_node);
+ }
+}
+
+void WorkSerializer::WorkSerializerImpl::Orphan() {
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_work_serializer_trace)) {
+ gpr_log(GPR_INFO, "WorkSerializer::Orphan() %p", this);
+ }
+ size_t prev_size = size_.FetchSub(1);
+ if (prev_size == 1) {
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_work_serializer_trace)) {
+ gpr_log(GPR_INFO, " Destroying");
+ }
+ delete this;
+ }
+}
+
+// The thread that calls this loans itself to the work serializer so as to
+// execute all the scheduled callback. This is called from within
+// WorkSerializer::Run() after executing a callback immediately, and hence size_
+// is at least 1.
+void WorkSerializer::WorkSerializerImpl::DrainQueue() {
+ while (true) {
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_work_serializer_trace)) {
+ gpr_log(GPR_INFO, "WorkSerializer::DrainQueue() %p", this);
+ }
+ size_t prev_size = size_.FetchSub(1);
+ GPR_DEBUG_ASSERT(prev_size >= 1);
+ // It is possible that while draining the queue, one of the callbacks ended
+ // up orphaning the work serializer. In that case, delete the object.
+ if (prev_size == 1) {
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_work_serializer_trace)) {
+ gpr_log(GPR_INFO, " Queue Drained. Destroying");
+ }
+ delete this;
+ return;
+ }
+ if (prev_size == 2) {
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_work_serializer_trace)) {
+ gpr_log(GPR_INFO, " Queue Drained");
+ }
+ return;
+ }
+ // There is at least one callback on the queue. Pop the callback from the
+ // queue and execute it.
+ CallbackWrapper* cb_wrapper = nullptr;
+ bool empty_unused;
+ while ((cb_wrapper = reinterpret_cast<CallbackWrapper*>(
+ queue_.PopAndCheckEnd(&empty_unused))) == nullptr) {
+ // This can happen either due to a race condition within the mpscq
+ // implementation or because of a race with Run()
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_work_serializer_trace)) {
+ gpr_log(GPR_INFO, " Queue returned nullptr, trying again");
+ }
+ }
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_work_serializer_trace)) {
+ gpr_log(GPR_INFO, " Running item %p : callback scheduled at [%s:%d]",
+ cb_wrapper, cb_wrapper->location.file(),
+ cb_wrapper->location.line());
+ }
+ cb_wrapper->callback();
+ delete cb_wrapper;
+ }
+}
+
+// WorkSerializer
+
+WorkSerializer::WorkSerializer()
+ : impl_(MakeOrphanable<WorkSerializerImpl>()) {}
+
+WorkSerializer::~WorkSerializer() {}
+
+void WorkSerializer::Run(std::function<void()> callback,
+ const grpc_core::DebugLocation& location) {
+ impl_->Run(std::move(callback), location);
+}
+
+} // namespace grpc_core
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/work_serializer.h b/contrib/libs/grpc/src/core/lib/iomgr/work_serializer.h
index 77a1a383cc..53c80701a1 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/work_serializer.h
+++ b/contrib/libs/grpc/src/core/lib/iomgr/work_serializer.h
@@ -1,65 +1,65 @@
-/*
- *
- * Copyright 2019 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <grpc/support/port_platform.h>
-
-#include <functional>
-
-#include "src/core/lib/debug/trace.h"
-#include "src/core/lib/gprpp/atomic.h"
-#include "src/core/lib/gprpp/debug_location.h"
-#include "src/core/lib/gprpp/mpscq.h"
-#include "src/core/lib/gprpp/orphanable.h"
-#include "src/core/lib/gprpp/ref_counted.h"
-#include "src/core/lib/iomgr/exec_ctx.h"
-
-#ifndef GRPC_CORE_LIB_IOMGR_WORK_SERIALIZER_H
-#define GRPC_CORE_LIB_IOMGR_WORK_SERIALIZER_H
-
-namespace grpc_core {
-
-// WorkSerializer is a mechanism to schedule callbacks in a synchronized manner.
-// All callbacks scheduled on a WorkSerializer instance will be executed
-// serially in a borrowed thread. The API provides a FIFO guarantee to the
-// execution of callbacks scheduled on the thread.
-// When a thread calls Run() with a callback, the thread is considered borrowed.
-// The callback might run inline, or it might run asynchronously in a different
-// thread that is already inside of Run(). If the callback runs directly inline,
-// other callbacks from other threads might also be executed before Run()
-// returns. Since an arbitrary set of callbacks might be executed when Run() is
-// called, generally no locks should be held while calling Run().
-class WorkSerializer {
- public:
- WorkSerializer();
-
- ~WorkSerializer();
-
- // TODO(yashkt): Replace grpc_core::DebugLocation with y_absl::SourceLocation
- // once we can start using it directly.
- void Run(std::function<void()> callback,
- const grpc_core::DebugLocation& location);
-
- private:
- class WorkSerializerImpl;
-
- OrphanablePtr<WorkSerializerImpl> impl_;
-};
-
-} /* namespace grpc_core */
-
-#endif /* GRPC_CORE_LIB_IOMGR_WORK_SERIALIZER_H */
+/*
+ *
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <grpc/support/port_platform.h>
+
+#include <functional>
+
+#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/gprpp/atomic.h"
+#include "src/core/lib/gprpp/debug_location.h"
+#include "src/core/lib/gprpp/mpscq.h"
+#include "src/core/lib/gprpp/orphanable.h"
+#include "src/core/lib/gprpp/ref_counted.h"
+#include "src/core/lib/iomgr/exec_ctx.h"
+
+#ifndef GRPC_CORE_LIB_IOMGR_WORK_SERIALIZER_H
+#define GRPC_CORE_LIB_IOMGR_WORK_SERIALIZER_H
+
+namespace grpc_core {
+
+// WorkSerializer is a mechanism to schedule callbacks in a synchronized manner.
+// All callbacks scheduled on a WorkSerializer instance will be executed
+// serially in a borrowed thread. The API provides a FIFO guarantee to the
+// execution of callbacks scheduled on the thread.
+// When a thread calls Run() with a callback, the thread is considered borrowed.
+// The callback might run inline, or it might run asynchronously in a different
+// thread that is already inside of Run(). If the callback runs directly inline,
+// other callbacks from other threads might also be executed before Run()
+// returns. Since an arbitrary set of callbacks might be executed when Run() is
+// called, generally no locks should be held while calling Run().
+class WorkSerializer {
+ public:
+ WorkSerializer();
+
+ ~WorkSerializer();
+
+ // TODO(yashkt): Replace grpc_core::DebugLocation with y_absl::SourceLocation
+ // once we can start using it directly.
+ void Run(std::function<void()> callback,
+ const grpc_core::DebugLocation& location);
+
+ private:
+ class WorkSerializerImpl;
+
+ OrphanablePtr<WorkSerializerImpl> impl_;
+};
+
+} /* namespace grpc_core */
+
+#endif /* GRPC_CORE_LIB_IOMGR_WORK_SERIALIZER_H */
diff --git a/contrib/libs/grpc/src/core/lib/json/json.h b/contrib/libs/grpc/src/core/lib/json/json.h
index 82a3b0aa07..f426fbf1dd 100644
--- a/contrib/libs/grpc/src/core/lib/json/json.h
+++ b/contrib/libs/grpc/src/core/lib/json/json.h
@@ -23,219 +23,219 @@
#include <stdlib.h>
-#include <map>
-#include <util/generic/string.h>
-#include <util/string/cast.h>
-#include <vector>
-
-#include "y_absl/strings/string_view.h"
-
-#include "src/core/lib/iomgr/error.h"
-
-namespace grpc_core {
-
-// A JSON value, which can be any one of object, array, string,
-// number, true, false, or null.
-class Json {
- public:
- // TODO(roth): Currently, numbers are stored internally as strings,
- // which makes the API a bit cumbersome to use. When we have time,
- // consider whether there's a better alternative (e.g., maybe storing
- // each numeric type as the native C++ type and automatically converting
- // to string as needed).
- enum class Type {
- JSON_NULL,
- JSON_TRUE,
- JSON_FALSE,
- NUMBER,
- STRING,
- OBJECT,
- ARRAY
- };
-
- using Object = std::map<TString, Json>;
- using Array = std::vector<Json>;
-
- // Parses JSON string from json_str. On error, sets *error.
- static Json Parse(y_absl::string_view json_str, grpc_error** error);
-
- Json() = default;
-
- // Copyable.
- Json(const Json& other) { CopyFrom(other); }
- Json& operator=(const Json& other) {
- CopyFrom(other);
- return *this;
- }
-
- // Moveable.
- Json(Json&& other) { MoveFrom(std::move(other)); }
- Json& operator=(Json&& other) {
- MoveFrom(std::move(other));
- return *this;
- }
-
- // Construct from copying a string.
- // If is_number is true, the type will be NUMBER instead of STRING.
- Json(const TString& string, bool is_number = false)
- : type_(is_number ? Type::NUMBER : Type::STRING), string_value_(string) {}
- Json& operator=(const TString& string) {
- type_ = Type::STRING;
- string_value_ = string;
- return *this;
- }
-
- // Same thing for C-style strings, both const and mutable.
- Json(const char* string, bool is_number = false)
- : Json(TString(string), is_number) {}
- Json& operator=(const char* string) {
- *this = TString(string);
- return *this;
- }
- Json(char* string, bool is_number = false)
- : Json(TString(string), is_number) {}
- Json& operator=(char* string) {
- *this = TString(string);
- return *this;
- }
-
- // Construct by moving a string.
- Json(TString&& string)
- : type_(Type::STRING), string_value_(std::move(string)) {}
- Json& operator=(TString&& string) {
- type_ = Type::STRING;
- string_value_ = std::move(string);
- return *this;
- }
-
- // Construct from bool.
- Json(bool b) : type_(b ? Type::JSON_TRUE : Type::JSON_FALSE) {}
- Json& operator=(bool b) {
- type_ = b ? Type::JSON_TRUE : Type::JSON_FALSE;
- return *this;
- }
-
- // Construct from any numeric type.
- template <typename NumericType>
- Json(NumericType number)
- : type_(Type::NUMBER), string_value_(ToString(number)) {}
- template <typename NumericType>
- Json& operator=(NumericType number) {
- type_ = Type::NUMBER;
- string_value_ = ToString(number);
- return *this;
- }
-
- // Construct by copying object.
- Json(const Object& object) : type_(Type::OBJECT), object_value_(object) {}
- Json& operator=(const Object& object) {
- type_ = Type::OBJECT;
- object_value_ = object;
- return *this;
- }
-
- // Construct by moving object.
- Json(Object&& object)
- : type_(Type::OBJECT), object_value_(std::move(object)) {}
- Json& operator=(Object&& object) {
- type_ = Type::OBJECT;
- object_value_ = std::move(object);
- return *this;
- }
-
- // Construct by copying array.
- Json(const Array& array) : type_(Type::ARRAY), array_value_(array) {}
- Json& operator=(const Array& array) {
- type_ = Type::ARRAY;
- array_value_ = array;
- return *this;
- }
-
- // Construct by moving array.
- Json(Array&& array) : type_(Type::ARRAY), array_value_(std::move(array)) {}
- Json& operator=(Array&& array) {
- type_ = Type::ARRAY;
- array_value_ = std::move(array);
- return *this;
- }
-
- // Dumps JSON from value to string form.
- TString Dump(int indent = 0) const;
-
- // Accessor methods.
- Type type() const { return type_; }
- const TString& string_value() const { return string_value_; }
- TString* mutable_string_value() { return &string_value_; }
- const Object& object_value() const { return object_value_; }
- Object* mutable_object() { return &object_value_; }
- const Array& array_value() const { return array_value_; }
- Array* mutable_array() { return &array_value_; }
-
- bool operator==(const Json& other) const {
- if (type_ != other.type_) return false;
- switch (type_) {
- case Type::NUMBER:
- case Type::STRING:
- if (string_value_ != other.string_value_) return false;
- break;
- case Type::OBJECT:
- if (object_value_ != other.object_value_) return false;
- break;
- case Type::ARRAY:
- if (array_value_ != other.array_value_) return false;
- break;
- default:
- break;
- }
- return true;
- }
-
- bool operator!=(const Json& other) const { return !(*this == other); }
-
- private:
- void CopyFrom(const Json& other) {
- type_ = other.type_;
- switch (type_) {
- case Type::NUMBER:
- case Type::STRING:
- string_value_ = other.string_value_;
- break;
- case Type::OBJECT:
- object_value_ = other.object_value_;
- break;
- case Type::ARRAY:
- array_value_ = other.array_value_;
- break;
- default:
- break;
- }
- }
-
- void MoveFrom(Json&& other) {
- type_ = other.type_;
- other.type_ = Type::JSON_NULL;
- switch (type_) {
- case Type::NUMBER:
- case Type::STRING:
- string_value_ = std::move(other.string_value_);
- break;
- case Type::OBJECT:
- object_value_ = std::move(other.object_value_);
- break;
- case Type::ARRAY:
- array_value_ = std::move(other.array_value_);
- break;
- default:
- break;
- }
- }
-
- Type type_ = Type::JSON_NULL;
- TString string_value_;
- Object object_value_;
- Array array_value_;
-};
-
-} // namespace grpc_core
-
+#include <map>
+#include <util/generic/string.h>
+#include <util/string/cast.h>
+#include <vector>
+
+#include "y_absl/strings/string_view.h"
+
+#include "src/core/lib/iomgr/error.h"
+
+namespace grpc_core {
+
+// A JSON value, which can be any one of object, array, string,
+// number, true, false, or null.
+class Json {
+ public:
+ // TODO(roth): Currently, numbers are stored internally as strings,
+ // which makes the API a bit cumbersome to use. When we have time,
+ // consider whether there's a better alternative (e.g., maybe storing
+ // each numeric type as the native C++ type and automatically converting
+ // to string as needed).
+ enum class Type {
+ JSON_NULL,
+ JSON_TRUE,
+ JSON_FALSE,
+ NUMBER,
+ STRING,
+ OBJECT,
+ ARRAY
+ };
+
+ using Object = std::map<TString, Json>;
+ using Array = std::vector<Json>;
+
+ // Parses JSON string from json_str. On error, sets *error.
+ static Json Parse(y_absl::string_view json_str, grpc_error** error);
+
+ Json() = default;
+
+ // Copyable.
+ Json(const Json& other) { CopyFrom(other); }
+ Json& operator=(const Json& other) {
+ CopyFrom(other);
+ return *this;
+ }
+
+ // Moveable.
+ Json(Json&& other) { MoveFrom(std::move(other)); }
+ Json& operator=(Json&& other) {
+ MoveFrom(std::move(other));
+ return *this;
+ }
+
+ // Construct from copying a string.
+ // If is_number is true, the type will be NUMBER instead of STRING.
+ Json(const TString& string, bool is_number = false)
+ : type_(is_number ? Type::NUMBER : Type::STRING), string_value_(string) {}
+ Json& operator=(const TString& string) {
+ type_ = Type::STRING;
+ string_value_ = string;
+ return *this;
+ }
+
+ // Same thing for C-style strings, both const and mutable.
+ Json(const char* string, bool is_number = false)
+ : Json(TString(string), is_number) {}
+ Json& operator=(const char* string) {
+ *this = TString(string);
+ return *this;
+ }
+ Json(char* string, bool is_number = false)
+ : Json(TString(string), is_number) {}
+ Json& operator=(char* string) {
+ *this = TString(string);
+ return *this;
+ }
+
+ // Construct by moving a string.
+ Json(TString&& string)
+ : type_(Type::STRING), string_value_(std::move(string)) {}
+ Json& operator=(TString&& string) {
+ type_ = Type::STRING;
+ string_value_ = std::move(string);
+ return *this;
+ }
+
+ // Construct from bool.
+ Json(bool b) : type_(b ? Type::JSON_TRUE : Type::JSON_FALSE) {}
+ Json& operator=(bool b) {
+ type_ = b ? Type::JSON_TRUE : Type::JSON_FALSE;
+ return *this;
+ }
+
+ // Construct from any numeric type.
+ template <typename NumericType>
+ Json(NumericType number)
+ : type_(Type::NUMBER), string_value_(ToString(number)) {}
+ template <typename NumericType>
+ Json& operator=(NumericType number) {
+ type_ = Type::NUMBER;
+ string_value_ = ToString(number);
+ return *this;
+ }
+
+ // Construct by copying object.
+ Json(const Object& object) : type_(Type::OBJECT), object_value_(object) {}
+ Json& operator=(const Object& object) {
+ type_ = Type::OBJECT;
+ object_value_ = object;
+ return *this;
+ }
+
+ // Construct by moving object.
+ Json(Object&& object)
+ : type_(Type::OBJECT), object_value_(std::move(object)) {}
+ Json& operator=(Object&& object) {
+ type_ = Type::OBJECT;
+ object_value_ = std::move(object);
+ return *this;
+ }
+
+ // Construct by copying array.
+ Json(const Array& array) : type_(Type::ARRAY), array_value_(array) {}
+ Json& operator=(const Array& array) {
+ type_ = Type::ARRAY;
+ array_value_ = array;
+ return *this;
+ }
+
+ // Construct by moving array.
+ Json(Array&& array) : type_(Type::ARRAY), array_value_(std::move(array)) {}
+ Json& operator=(Array&& array) {
+ type_ = Type::ARRAY;
+ array_value_ = std::move(array);
+ return *this;
+ }
+
+ // Dumps JSON from value to string form.
+ TString Dump(int indent = 0) const;
+
+ // Accessor methods.
+ Type type() const { return type_; }
+ const TString& string_value() const { return string_value_; }
+ TString* mutable_string_value() { return &string_value_; }
+ const Object& object_value() const { return object_value_; }
+ Object* mutable_object() { return &object_value_; }
+ const Array& array_value() const { return array_value_; }
+ Array* mutable_array() { return &array_value_; }
+
+ bool operator==(const Json& other) const {
+ if (type_ != other.type_) return false;
+ switch (type_) {
+ case Type::NUMBER:
+ case Type::STRING:
+ if (string_value_ != other.string_value_) return false;
+ break;
+ case Type::OBJECT:
+ if (object_value_ != other.object_value_) return false;
+ break;
+ case Type::ARRAY:
+ if (array_value_ != other.array_value_) return false;
+ break;
+ default:
+ break;
+ }
+ return true;
+ }
+
+ bool operator!=(const Json& other) const { return !(*this == other); }
+
+ private:
+ void CopyFrom(const Json& other) {
+ type_ = other.type_;
+ switch (type_) {
+ case Type::NUMBER:
+ case Type::STRING:
+ string_value_ = other.string_value_;
+ break;
+ case Type::OBJECT:
+ object_value_ = other.object_value_;
+ break;
+ case Type::ARRAY:
+ array_value_ = other.array_value_;
+ break;
+ default:
+ break;
+ }
+ }
+
+ void MoveFrom(Json&& other) {
+ type_ = other.type_;
+ other.type_ = Type::JSON_NULL;
+ switch (type_) {
+ case Type::NUMBER:
+ case Type::STRING:
+ string_value_ = std::move(other.string_value_);
+ break;
+ case Type::OBJECT:
+ object_value_ = std::move(other.object_value_);
+ break;
+ case Type::ARRAY:
+ array_value_ = std::move(other.array_value_);
+ break;
+ default:
+ break;
+ }
+ }
+
+ Type type_ = Type::JSON_NULL;
+ TString string_value_;
+ Object object_value_;
+ Array array_value_;
+};
+
+} // namespace grpc_core
+
#endif /* GRPC_CORE_LIB_JSON_JSON_H */
diff --git a/contrib/libs/grpc/src/core/lib/json/json_reader.cc b/contrib/libs/grpc/src/core/lib/json/json_reader.cc
index f2dbe5844d..e251cb7882 100644
--- a/contrib/libs/grpc/src/core/lib/json/json_reader.cc
+++ b/contrib/libs/grpc/src/core/lib/json/json_reader.cc
@@ -20,267 +20,267 @@
#include <string.h>
-#include <util/generic/string.h>
-
-#include "y_absl/strings/str_cat.h"
-#include "y_absl/strings/str_format.h"
-
+#include <util/generic/string.h>
+
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_format.h"
+
#include <grpc/support/log.h>
-#include "src/core/lib/json/json.h"
-
-#define GRPC_JSON_MAX_DEPTH 255
-#define GRPC_JSON_MAX_ERRORS 16
-
-namespace grpc_core {
-
-namespace {
-
-class JsonReader {
- public:
- static grpc_error* Parse(y_absl::string_view input, Json* output);
-
- private:
- enum class Status {
- GRPC_JSON_DONE, /* The parser finished successfully. */
- GRPC_JSON_PARSE_ERROR, /* The parser found an error in the json stream. */
- GRPC_JSON_INTERNAL_ERROR /* The parser got an internal error. */
- };
-
- enum class State {
- GRPC_JSON_STATE_OBJECT_KEY_BEGIN,
- GRPC_JSON_STATE_OBJECT_KEY_STRING,
- GRPC_JSON_STATE_OBJECT_KEY_END,
- GRPC_JSON_STATE_VALUE_BEGIN,
- GRPC_JSON_STATE_VALUE_STRING,
- GRPC_JSON_STATE_STRING_ESCAPE,
- GRPC_JSON_STATE_STRING_ESCAPE_U1,
- GRPC_JSON_STATE_STRING_ESCAPE_U2,
- GRPC_JSON_STATE_STRING_ESCAPE_U3,
- GRPC_JSON_STATE_STRING_ESCAPE_U4,
- GRPC_JSON_STATE_VALUE_NUMBER,
- GRPC_JSON_STATE_VALUE_NUMBER_WITH_DECIMAL,
- GRPC_JSON_STATE_VALUE_NUMBER_ZERO,
- GRPC_JSON_STATE_VALUE_NUMBER_DOT,
- GRPC_JSON_STATE_VALUE_NUMBER_E,
- GRPC_JSON_STATE_VALUE_NUMBER_EPM,
- GRPC_JSON_STATE_VALUE_TRUE_R,
- GRPC_JSON_STATE_VALUE_TRUE_U,
- GRPC_JSON_STATE_VALUE_TRUE_E,
- GRPC_JSON_STATE_VALUE_FALSE_A,
- GRPC_JSON_STATE_VALUE_FALSE_L,
- GRPC_JSON_STATE_VALUE_FALSE_S,
- GRPC_JSON_STATE_VALUE_FALSE_E,
- GRPC_JSON_STATE_VALUE_NULL_U,
- GRPC_JSON_STATE_VALUE_NULL_L1,
- GRPC_JSON_STATE_VALUE_NULL_L2,
- GRPC_JSON_STATE_VALUE_END,
- GRPC_JSON_STATE_END
- };
-
- /* The first non-unicode value is 0x110000. But let's pick
- * a value high enough to start our error codes from. These
- * values are safe to return from the read_char function.
- */
- static constexpr uint32_t GRPC_JSON_READ_CHAR_EOF = 0x7ffffff0;
-
- explicit JsonReader(y_absl::string_view input)
- : original_input_(reinterpret_cast<const uint8_t*>(input.data())),
- input_(original_input_),
- remaining_input_(input.size()) {}
-
- Status Run();
- uint32_t ReadChar();
- bool IsComplete();
-
- size_t CurrentIndex() const { return input_ - original_input_ - 1; }
-
- void StringAddChar(uint32_t c);
- void StringAddUtf32(uint32_t c);
-
- Json* CreateAndLinkValue();
- bool StartContainer(Json::Type type);
- void EndContainer();
- void SetKey();
- void SetString();
- bool SetNumber();
- void SetTrue();
- void SetFalse();
- void SetNull();
-
- const uint8_t* original_input_;
- const uint8_t* input_;
- size_t remaining_input_;
-
- State state_ = State::GRPC_JSON_STATE_VALUE_BEGIN;
- bool escaped_string_was_key_ = false;
- bool container_just_begun_ = false;
- uint16_t unicode_char_ = 0;
- uint16_t unicode_high_surrogate_ = 0;
- std::vector<grpc_error*> errors_;
- bool truncated_errors_ = false;
-
- Json root_value_;
- std::vector<Json*> stack_;
-
- TString key_;
- TString string_;
-};
-
-void JsonReader::StringAddChar(uint32_t c) {
- string_.push_back(static_cast<uint8_t>(c));
+#include "src/core/lib/json/json.h"
+
+#define GRPC_JSON_MAX_DEPTH 255
+#define GRPC_JSON_MAX_ERRORS 16
+
+namespace grpc_core {
+
+namespace {
+
+class JsonReader {
+ public:
+ static grpc_error* Parse(y_absl::string_view input, Json* output);
+
+ private:
+ enum class Status {
+ GRPC_JSON_DONE, /* The parser finished successfully. */
+ GRPC_JSON_PARSE_ERROR, /* The parser found an error in the json stream. */
+ GRPC_JSON_INTERNAL_ERROR /* The parser got an internal error. */
+ };
+
+ enum class State {
+ GRPC_JSON_STATE_OBJECT_KEY_BEGIN,
+ GRPC_JSON_STATE_OBJECT_KEY_STRING,
+ GRPC_JSON_STATE_OBJECT_KEY_END,
+ GRPC_JSON_STATE_VALUE_BEGIN,
+ GRPC_JSON_STATE_VALUE_STRING,
+ GRPC_JSON_STATE_STRING_ESCAPE,
+ GRPC_JSON_STATE_STRING_ESCAPE_U1,
+ GRPC_JSON_STATE_STRING_ESCAPE_U2,
+ GRPC_JSON_STATE_STRING_ESCAPE_U3,
+ GRPC_JSON_STATE_STRING_ESCAPE_U4,
+ GRPC_JSON_STATE_VALUE_NUMBER,
+ GRPC_JSON_STATE_VALUE_NUMBER_WITH_DECIMAL,
+ GRPC_JSON_STATE_VALUE_NUMBER_ZERO,
+ GRPC_JSON_STATE_VALUE_NUMBER_DOT,
+ GRPC_JSON_STATE_VALUE_NUMBER_E,
+ GRPC_JSON_STATE_VALUE_NUMBER_EPM,
+ GRPC_JSON_STATE_VALUE_TRUE_R,
+ GRPC_JSON_STATE_VALUE_TRUE_U,
+ GRPC_JSON_STATE_VALUE_TRUE_E,
+ GRPC_JSON_STATE_VALUE_FALSE_A,
+ GRPC_JSON_STATE_VALUE_FALSE_L,
+ GRPC_JSON_STATE_VALUE_FALSE_S,
+ GRPC_JSON_STATE_VALUE_FALSE_E,
+ GRPC_JSON_STATE_VALUE_NULL_U,
+ GRPC_JSON_STATE_VALUE_NULL_L1,
+ GRPC_JSON_STATE_VALUE_NULL_L2,
+ GRPC_JSON_STATE_VALUE_END,
+ GRPC_JSON_STATE_END
+ };
+
+ /* The first non-unicode value is 0x110000. But let's pick
+ * a value high enough to start our error codes from. These
+ * values are safe to return from the read_char function.
+ */
+ static constexpr uint32_t GRPC_JSON_READ_CHAR_EOF = 0x7ffffff0;
+
+ explicit JsonReader(y_absl::string_view input)
+ : original_input_(reinterpret_cast<const uint8_t*>(input.data())),
+ input_(original_input_),
+ remaining_input_(input.size()) {}
+
+ Status Run();
+ uint32_t ReadChar();
+ bool IsComplete();
+
+ size_t CurrentIndex() const { return input_ - original_input_ - 1; }
+
+ void StringAddChar(uint32_t c);
+ void StringAddUtf32(uint32_t c);
+
+ Json* CreateAndLinkValue();
+ bool StartContainer(Json::Type type);
+ void EndContainer();
+ void SetKey();
+ void SetString();
+ bool SetNumber();
+ void SetTrue();
+ void SetFalse();
+ void SetNull();
+
+ const uint8_t* original_input_;
+ const uint8_t* input_;
+ size_t remaining_input_;
+
+ State state_ = State::GRPC_JSON_STATE_VALUE_BEGIN;
+ bool escaped_string_was_key_ = false;
+ bool container_just_begun_ = false;
+ uint16_t unicode_char_ = 0;
+ uint16_t unicode_high_surrogate_ = 0;
+ std::vector<grpc_error*> errors_;
+ bool truncated_errors_ = false;
+
+ Json root_value_;
+ std::vector<Json*> stack_;
+
+ TString key_;
+ TString string_;
+};
+
+void JsonReader::StringAddChar(uint32_t c) {
+ string_.push_back(static_cast<uint8_t>(c));
+}
+
+void JsonReader::StringAddUtf32(uint32_t c) {
+ if (c <= 0x7f) {
+ StringAddChar(c);
+ } else if (c <= 0x7ff) {
+ uint32_t b1 = 0xc0 | ((c >> 6) & 0x1f);
+ uint32_t b2 = 0x80 | (c & 0x3f);
+ StringAddChar(b1);
+ StringAddChar(b2);
+ } else if (c <= 0xffff) {
+ uint32_t b1 = 0xe0 | ((c >> 12) & 0x0f);
+ uint32_t b2 = 0x80 | ((c >> 6) & 0x3f);
+ uint32_t b3 = 0x80 | (c & 0x3f);
+ StringAddChar(b1);
+ StringAddChar(b2);
+ StringAddChar(b3);
+ } else if (c <= 0x1fffff) {
+ uint32_t b1 = 0xf0 | ((c >> 18) & 0x07);
+ uint32_t b2 = 0x80 | ((c >> 12) & 0x3f);
+ uint32_t b3 = 0x80 | ((c >> 6) & 0x3f);
+ uint32_t b4 = 0x80 | (c & 0x3f);
+ StringAddChar(b1);
+ StringAddChar(b2);
+ StringAddChar(b3);
+ StringAddChar(b4);
+ }
+}
+
+uint32_t JsonReader::ReadChar() {
+ if (remaining_input_ == 0) return GRPC_JSON_READ_CHAR_EOF;
+ const uint32_t r = *input_++;
+ --remaining_input_;
+ if (r == 0) {
+ remaining_input_ = 0;
+ return GRPC_JSON_READ_CHAR_EOF;
+ }
+ return r;
}
-void JsonReader::StringAddUtf32(uint32_t c) {
- if (c <= 0x7f) {
- StringAddChar(c);
- } else if (c <= 0x7ff) {
- uint32_t b1 = 0xc0 | ((c >> 6) & 0x1f);
- uint32_t b2 = 0x80 | (c & 0x3f);
- StringAddChar(b1);
- StringAddChar(b2);
- } else if (c <= 0xffff) {
- uint32_t b1 = 0xe0 | ((c >> 12) & 0x0f);
- uint32_t b2 = 0x80 | ((c >> 6) & 0x3f);
- uint32_t b3 = 0x80 | (c & 0x3f);
- StringAddChar(b1);
- StringAddChar(b2);
- StringAddChar(b3);
- } else if (c <= 0x1fffff) {
- uint32_t b1 = 0xf0 | ((c >> 18) & 0x07);
- uint32_t b2 = 0x80 | ((c >> 12) & 0x3f);
- uint32_t b3 = 0x80 | ((c >> 6) & 0x3f);
- uint32_t b4 = 0x80 | (c & 0x3f);
- StringAddChar(b1);
- StringAddChar(b2);
- StringAddChar(b3);
- StringAddChar(b4);
- }
+Json* JsonReader::CreateAndLinkValue() {
+ Json* value;
+ if (stack_.empty()) {
+ value = &root_value_;
+ } else {
+ Json* parent = stack_.back();
+ if (parent->type() == Json::Type::OBJECT) {
+ if (parent->object_value().find(key_) != parent->object_value().end()) {
+ if (errors_.size() == GRPC_JSON_MAX_ERRORS) {
+ truncated_errors_ = true;
+ } else {
+ errors_.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
+ y_absl::StrFormat("duplicate key \"%s\" at index %" PRIuPTR, key_,
+ CurrentIndex())
+ .c_str()));
+ }
+ }
+ value = &(*parent->mutable_object())[std::move(key_)];
+ } else {
+ GPR_ASSERT(parent->type() == Json::Type::ARRAY);
+ parent->mutable_array()->emplace_back();
+ value = &parent->mutable_array()->back();
+ }
+ }
+ return value;
}
-uint32_t JsonReader::ReadChar() {
- if (remaining_input_ == 0) return GRPC_JSON_READ_CHAR_EOF;
- const uint32_t r = *input_++;
- --remaining_input_;
- if (r == 0) {
- remaining_input_ = 0;
- return GRPC_JSON_READ_CHAR_EOF;
- }
- return r;
+bool JsonReader::StartContainer(Json::Type type) {
+ if (stack_.size() == GRPC_JSON_MAX_DEPTH) {
+ if (errors_.size() == GRPC_JSON_MAX_ERRORS) {
+ truncated_errors_ = true;
+ } else {
+ errors_.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
+ y_absl::StrFormat("exceeded max stack depth (%d) at index %" PRIuPTR,
+ GRPC_JSON_MAX_DEPTH, CurrentIndex())
+ .c_str()));
+ }
+ return false;
+ }
+ Json* value = CreateAndLinkValue();
+ if (type == Json::Type::OBJECT) {
+ *value = Json::Object();
+ } else {
+ GPR_ASSERT(type == Json::Type::ARRAY);
+ *value = Json::Array();
+ }
+ stack_.push_back(value);
+ return true;
}
-Json* JsonReader::CreateAndLinkValue() {
- Json* value;
- if (stack_.empty()) {
- value = &root_value_;
- } else {
- Json* parent = stack_.back();
- if (parent->type() == Json::Type::OBJECT) {
- if (parent->object_value().find(key_) != parent->object_value().end()) {
- if (errors_.size() == GRPC_JSON_MAX_ERRORS) {
- truncated_errors_ = true;
- } else {
- errors_.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
- y_absl::StrFormat("duplicate key \"%s\" at index %" PRIuPTR, key_,
- CurrentIndex())
- .c_str()));
- }
- }
- value = &(*parent->mutable_object())[std::move(key_)];
- } else {
- GPR_ASSERT(parent->type() == Json::Type::ARRAY);
- parent->mutable_array()->emplace_back();
- value = &parent->mutable_array()->back();
- }
- }
- return value;
-}
-
-bool JsonReader::StartContainer(Json::Type type) {
- if (stack_.size() == GRPC_JSON_MAX_DEPTH) {
- if (errors_.size() == GRPC_JSON_MAX_ERRORS) {
- truncated_errors_ = true;
- } else {
- errors_.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
- y_absl::StrFormat("exceeded max stack depth (%d) at index %" PRIuPTR,
- GRPC_JSON_MAX_DEPTH, CurrentIndex())
- .c_str()));
- }
- return false;
- }
- Json* value = CreateAndLinkValue();
- if (type == Json::Type::OBJECT) {
- *value = Json::Object();
- } else {
- GPR_ASSERT(type == Json::Type::ARRAY);
- *value = Json::Array();
- }
- stack_.push_back(value);
- return true;
-}
-
-void JsonReader::EndContainer() {
- GPR_ASSERT(!stack_.empty());
- stack_.pop_back();
+void JsonReader::EndContainer() {
+ GPR_ASSERT(!stack_.empty());
+ stack_.pop_back();
}
-void JsonReader::SetKey() {
- key_ = std::move(string_);
- string_.clear();
+void JsonReader::SetKey() {
+ key_ = std::move(string_);
+ string_.clear();
}
-void JsonReader::SetString() {
- Json* value = CreateAndLinkValue();
- *value = std::move(string_);
- string_.clear();
+void JsonReader::SetString() {
+ Json* value = CreateAndLinkValue();
+ *value = std::move(string_);
+ string_.clear();
}
-bool JsonReader::SetNumber() {
- Json* value = CreateAndLinkValue();
- *value = Json(string_, /*is_number=*/true);
- string_.clear();
- return true;
+bool JsonReader::SetNumber() {
+ Json* value = CreateAndLinkValue();
+ *value = Json(string_, /*is_number=*/true);
+ string_.clear();
+ return true;
}
-void JsonReader::SetTrue() {
- Json* value = CreateAndLinkValue();
- *value = true;
- string_.clear();
+void JsonReader::SetTrue() {
+ Json* value = CreateAndLinkValue();
+ *value = true;
+ string_.clear();
}
-void JsonReader::SetFalse() {
- Json* value = CreateAndLinkValue();
- *value = false;
- string_.clear();
+void JsonReader::SetFalse() {
+ Json* value = CreateAndLinkValue();
+ *value = false;
+ string_.clear();
}
-void JsonReader::SetNull() { CreateAndLinkValue(); }
+void JsonReader::SetNull() { CreateAndLinkValue(); }
-bool JsonReader::IsComplete() {
- return (stack_.empty() && (state_ == State::GRPC_JSON_STATE_END ||
- state_ == State::GRPC_JSON_STATE_VALUE_END));
+bool JsonReader::IsComplete() {
+ return (stack_.empty() && (state_ == State::GRPC_JSON_STATE_END ||
+ state_ == State::GRPC_JSON_STATE_VALUE_END));
}
-/* Call this function to start parsing the input. It will return the following:
- * . GRPC_JSON_DONE if the input got eof, and the parsing finished
- * successfully.
- * . GRPC_JSON_PARSE_ERROR if the input was somehow invalid.
- * . GRPC_JSON_INTERNAL_ERROR if the parser somehow ended into an invalid
- * internal state.
- */
-JsonReader::Status JsonReader::Run() {
- uint32_t c;
+/* Call this function to start parsing the input. It will return the following:
+ * . GRPC_JSON_DONE if the input got eof, and the parsing finished
+ * successfully.
+ * . GRPC_JSON_PARSE_ERROR if the input was somehow invalid.
+ * . GRPC_JSON_INTERNAL_ERROR if the parser somehow ended into an invalid
+ * internal state.
+ */
+JsonReader::Status JsonReader::Run() {
+ uint32_t c;
/* This state-machine is a strict implementation of ECMA-404 */
- while (true) {
- c = ReadChar();
+ while (true) {
+ c = ReadChar();
switch (c) {
- /* Let's process the error case first. */
+ /* Let's process the error case first. */
case GRPC_JSON_READ_CHAR_EOF:
- if (IsComplete()) {
- return Status::GRPC_JSON_DONE;
+ if (IsComplete()) {
+ return Status::GRPC_JSON_DONE;
} else {
- return Status::GRPC_JSON_PARSE_ERROR;
+ return Status::GRPC_JSON_PARSE_ERROR;
}
break;
@@ -289,33 +289,33 @@ JsonReader::Status JsonReader::Run() {
case '\t':
case '\n':
case '\r':
- switch (state_) {
- case State::GRPC_JSON_STATE_OBJECT_KEY_BEGIN:
- case State::GRPC_JSON_STATE_OBJECT_KEY_END:
- case State::GRPC_JSON_STATE_VALUE_BEGIN:
- case State::GRPC_JSON_STATE_VALUE_END:
- case State::GRPC_JSON_STATE_END:
- break;
-
- case State::GRPC_JSON_STATE_OBJECT_KEY_STRING:
- case State::GRPC_JSON_STATE_VALUE_STRING:
- if (c != ' ') return Status::GRPC_JSON_PARSE_ERROR;
- if (unicode_high_surrogate_ != 0) {
- return Status::GRPC_JSON_PARSE_ERROR;
- }
- StringAddChar(c);
+ switch (state_) {
+ case State::GRPC_JSON_STATE_OBJECT_KEY_BEGIN:
+ case State::GRPC_JSON_STATE_OBJECT_KEY_END:
+ case State::GRPC_JSON_STATE_VALUE_BEGIN:
+ case State::GRPC_JSON_STATE_VALUE_END:
+ case State::GRPC_JSON_STATE_END:
+ break;
+
+ case State::GRPC_JSON_STATE_OBJECT_KEY_STRING:
+ case State::GRPC_JSON_STATE_VALUE_STRING:
+ if (c != ' ') return Status::GRPC_JSON_PARSE_ERROR;
+ if (unicode_high_surrogate_ != 0) {
+ return Status::GRPC_JSON_PARSE_ERROR;
+ }
+ StringAddChar(c);
break;
- case State::GRPC_JSON_STATE_VALUE_NUMBER:
- case State::GRPC_JSON_STATE_VALUE_NUMBER_WITH_DECIMAL:
- case State::GRPC_JSON_STATE_VALUE_NUMBER_ZERO:
- case State::GRPC_JSON_STATE_VALUE_NUMBER_EPM:
- if (!SetNumber()) return Status::GRPC_JSON_PARSE_ERROR;
- state_ = State::GRPC_JSON_STATE_VALUE_END;
+ case State::GRPC_JSON_STATE_VALUE_NUMBER:
+ case State::GRPC_JSON_STATE_VALUE_NUMBER_WITH_DECIMAL:
+ case State::GRPC_JSON_STATE_VALUE_NUMBER_ZERO:
+ case State::GRPC_JSON_STATE_VALUE_NUMBER_EPM:
+ if (!SetNumber()) return Status::GRPC_JSON_PARSE_ERROR;
+ state_ = State::GRPC_JSON_STATE_VALUE_END;
break;
default:
- return Status::GRPC_JSON_PARSE_ERROR;
+ return Status::GRPC_JSON_PARSE_ERROR;
}
break;
@@ -323,171 +323,171 @@ JsonReader::Status JsonReader::Run() {
case ',':
case '}':
case ']':
- switch (state_) {
- case State::GRPC_JSON_STATE_OBJECT_KEY_STRING:
- case State::GRPC_JSON_STATE_VALUE_STRING:
- if (unicode_high_surrogate_ != 0) {
- return Status::GRPC_JSON_PARSE_ERROR;
+ switch (state_) {
+ case State::GRPC_JSON_STATE_OBJECT_KEY_STRING:
+ case State::GRPC_JSON_STATE_VALUE_STRING:
+ if (unicode_high_surrogate_ != 0) {
+ return Status::GRPC_JSON_PARSE_ERROR;
}
- StringAddChar(c);
- break;
-
- case State::GRPC_JSON_STATE_VALUE_NUMBER:
- case State::GRPC_JSON_STATE_VALUE_NUMBER_WITH_DECIMAL:
- case State::GRPC_JSON_STATE_VALUE_NUMBER_ZERO:
- case State::GRPC_JSON_STATE_VALUE_NUMBER_EPM:
- if (stack_.empty()) {
- return Status::GRPC_JSON_PARSE_ERROR;
- } else if (c == '}' &&
- stack_.back()->type() != Json::Type::OBJECT) {
- return Status::GRPC_JSON_PARSE_ERROR;
- return Status::GRPC_JSON_PARSE_ERROR;
- } else if (c == ']' && stack_.back()->type() != Json::Type::ARRAY) {
- return Status::GRPC_JSON_PARSE_ERROR;
+ StringAddChar(c);
+ break;
+
+ case State::GRPC_JSON_STATE_VALUE_NUMBER:
+ case State::GRPC_JSON_STATE_VALUE_NUMBER_WITH_DECIMAL:
+ case State::GRPC_JSON_STATE_VALUE_NUMBER_ZERO:
+ case State::GRPC_JSON_STATE_VALUE_NUMBER_EPM:
+ if (stack_.empty()) {
+ return Status::GRPC_JSON_PARSE_ERROR;
+ } else if (c == '}' &&
+ stack_.back()->type() != Json::Type::OBJECT) {
+ return Status::GRPC_JSON_PARSE_ERROR;
+ return Status::GRPC_JSON_PARSE_ERROR;
+ } else if (c == ']' && stack_.back()->type() != Json::Type::ARRAY) {
+ return Status::GRPC_JSON_PARSE_ERROR;
}
- if (!SetNumber()) return Status::GRPC_JSON_PARSE_ERROR;
- state_ = State::GRPC_JSON_STATE_VALUE_END;
+ if (!SetNumber()) return Status::GRPC_JSON_PARSE_ERROR;
+ state_ = State::GRPC_JSON_STATE_VALUE_END;
/* The missing break here is intentional. */
/* fallthrough */
- case State::GRPC_JSON_STATE_VALUE_END:
- case State::GRPC_JSON_STATE_OBJECT_KEY_BEGIN:
- case State::GRPC_JSON_STATE_VALUE_BEGIN:
+ case State::GRPC_JSON_STATE_VALUE_END:
+ case State::GRPC_JSON_STATE_OBJECT_KEY_BEGIN:
+ case State::GRPC_JSON_STATE_VALUE_BEGIN:
if (c == ',') {
- if (state_ != State::GRPC_JSON_STATE_VALUE_END) {
- return Status::GRPC_JSON_PARSE_ERROR;
+ if (state_ != State::GRPC_JSON_STATE_VALUE_END) {
+ return Status::GRPC_JSON_PARSE_ERROR;
}
- if (!stack_.empty() &&
- stack_.back()->type() == Json::Type::OBJECT) {
- state_ = State::GRPC_JSON_STATE_OBJECT_KEY_BEGIN;
- } else if (!stack_.empty() &&
- stack_.back()->type() == Json::Type::ARRAY) {
- state_ = State::GRPC_JSON_STATE_VALUE_BEGIN;
+ if (!stack_.empty() &&
+ stack_.back()->type() == Json::Type::OBJECT) {
+ state_ = State::GRPC_JSON_STATE_OBJECT_KEY_BEGIN;
+ } else if (!stack_.empty() &&
+ stack_.back()->type() == Json::Type::ARRAY) {
+ state_ = State::GRPC_JSON_STATE_VALUE_BEGIN;
} else {
- return Status::GRPC_JSON_PARSE_ERROR;
+ return Status::GRPC_JSON_PARSE_ERROR;
}
} else {
- if (stack_.empty()) {
- return Status::GRPC_JSON_PARSE_ERROR;
+ if (stack_.empty()) {
+ return Status::GRPC_JSON_PARSE_ERROR;
+ }
+ if (c == '}' && stack_.back()->type() != Json::Type::OBJECT) {
+ return Status::GRPC_JSON_PARSE_ERROR;
}
- if (c == '}' && stack_.back()->type() != Json::Type::OBJECT) {
- return Status::GRPC_JSON_PARSE_ERROR;
+ if (c == '}' &&
+ state_ == State::GRPC_JSON_STATE_OBJECT_KEY_BEGIN &&
+ !container_just_begun_) {
+ return Status::GRPC_JSON_PARSE_ERROR;
}
- if (c == '}' &&
- state_ == State::GRPC_JSON_STATE_OBJECT_KEY_BEGIN &&
- !container_just_begun_) {
- return Status::GRPC_JSON_PARSE_ERROR;
+ if (c == ']' && stack_.back()->type() != Json::Type::ARRAY) {
+ return Status::GRPC_JSON_PARSE_ERROR;
}
- if (c == ']' && stack_.back()->type() != Json::Type::ARRAY) {
- return Status::GRPC_JSON_PARSE_ERROR;
+ if (c == ']' && state_ == State::GRPC_JSON_STATE_VALUE_BEGIN &&
+ !container_just_begun_) {
+ return Status::GRPC_JSON_PARSE_ERROR;
+ }
+ state_ = State::GRPC_JSON_STATE_VALUE_END;
+ EndContainer();
+ if (stack_.empty()) {
+ state_ = State::GRPC_JSON_STATE_END;
}
- if (c == ']' && state_ == State::GRPC_JSON_STATE_VALUE_BEGIN &&
- !container_just_begun_) {
- return Status::GRPC_JSON_PARSE_ERROR;
- }
- state_ = State::GRPC_JSON_STATE_VALUE_END;
- EndContainer();
- if (stack_.empty()) {
- state_ = State::GRPC_JSON_STATE_END;
- }
}
break;
default:
- return Status::GRPC_JSON_PARSE_ERROR;
+ return Status::GRPC_JSON_PARSE_ERROR;
}
break;
/* In-string escaping. */
case '\\':
- switch (state_) {
- case State::GRPC_JSON_STATE_OBJECT_KEY_STRING:
- escaped_string_was_key_ = true;
- state_ = State::GRPC_JSON_STATE_STRING_ESCAPE;
+ switch (state_) {
+ case State::GRPC_JSON_STATE_OBJECT_KEY_STRING:
+ escaped_string_was_key_ = true;
+ state_ = State::GRPC_JSON_STATE_STRING_ESCAPE;
break;
- case State::GRPC_JSON_STATE_VALUE_STRING:
- escaped_string_was_key_ = false;
- state_ = State::GRPC_JSON_STATE_STRING_ESCAPE;
+ case State::GRPC_JSON_STATE_VALUE_STRING:
+ escaped_string_was_key_ = false;
+ state_ = State::GRPC_JSON_STATE_STRING_ESCAPE;
break;
/* This is the \\ case. */
- case State::GRPC_JSON_STATE_STRING_ESCAPE:
- if (unicode_high_surrogate_ != 0)
- return Status::GRPC_JSON_PARSE_ERROR;
- StringAddChar('\\');
- if (escaped_string_was_key_) {
- state_ = State::GRPC_JSON_STATE_OBJECT_KEY_STRING;
+ case State::GRPC_JSON_STATE_STRING_ESCAPE:
+ if (unicode_high_surrogate_ != 0)
+ return Status::GRPC_JSON_PARSE_ERROR;
+ StringAddChar('\\');
+ if (escaped_string_was_key_) {
+ state_ = State::GRPC_JSON_STATE_OBJECT_KEY_STRING;
} else {
- state_ = State::GRPC_JSON_STATE_VALUE_STRING;
+ state_ = State::GRPC_JSON_STATE_VALUE_STRING;
}
break;
default:
- return Status::GRPC_JSON_PARSE_ERROR;
+ return Status::GRPC_JSON_PARSE_ERROR;
}
break;
default:
- container_just_begun_ = false;
- switch (state_) {
- case State::GRPC_JSON_STATE_OBJECT_KEY_BEGIN:
- if (c != '"') return Status::GRPC_JSON_PARSE_ERROR;
- state_ = State::GRPC_JSON_STATE_OBJECT_KEY_STRING;
+ container_just_begun_ = false;
+ switch (state_) {
+ case State::GRPC_JSON_STATE_OBJECT_KEY_BEGIN:
+ if (c != '"') return Status::GRPC_JSON_PARSE_ERROR;
+ state_ = State::GRPC_JSON_STATE_OBJECT_KEY_STRING;
break;
- case State::GRPC_JSON_STATE_OBJECT_KEY_STRING:
- if (unicode_high_surrogate_ != 0) {
- return Status::GRPC_JSON_PARSE_ERROR;
+ case State::GRPC_JSON_STATE_OBJECT_KEY_STRING:
+ if (unicode_high_surrogate_ != 0) {
+ return Status::GRPC_JSON_PARSE_ERROR;
}
if (c == '"') {
- state_ = State::GRPC_JSON_STATE_OBJECT_KEY_END;
- SetKey();
+ state_ = State::GRPC_JSON_STATE_OBJECT_KEY_END;
+ SetKey();
} else {
- if (c < 32) return Status::GRPC_JSON_PARSE_ERROR;
- StringAddChar(c);
+ if (c < 32) return Status::GRPC_JSON_PARSE_ERROR;
+ StringAddChar(c);
}
break;
- case State::GRPC_JSON_STATE_VALUE_STRING:
- if (unicode_high_surrogate_ != 0) {
- return Status::GRPC_JSON_PARSE_ERROR;
+ case State::GRPC_JSON_STATE_VALUE_STRING:
+ if (unicode_high_surrogate_ != 0) {
+ return Status::GRPC_JSON_PARSE_ERROR;
}
if (c == '"') {
- state_ = State::GRPC_JSON_STATE_VALUE_END;
- SetString();
+ state_ = State::GRPC_JSON_STATE_VALUE_END;
+ SetString();
} else {
- if (c < 32) return Status::GRPC_JSON_PARSE_ERROR;
- StringAddChar(c);
+ if (c < 32) return Status::GRPC_JSON_PARSE_ERROR;
+ StringAddChar(c);
}
break;
- case State::GRPC_JSON_STATE_OBJECT_KEY_END:
- if (c != ':') return Status::GRPC_JSON_PARSE_ERROR;
- state_ = State::GRPC_JSON_STATE_VALUE_BEGIN;
+ case State::GRPC_JSON_STATE_OBJECT_KEY_END:
+ if (c != ':') return Status::GRPC_JSON_PARSE_ERROR;
+ state_ = State::GRPC_JSON_STATE_VALUE_BEGIN;
break;
- case State::GRPC_JSON_STATE_VALUE_BEGIN:
+ case State::GRPC_JSON_STATE_VALUE_BEGIN:
switch (c) {
case 't':
- state_ = State::GRPC_JSON_STATE_VALUE_TRUE_R;
+ state_ = State::GRPC_JSON_STATE_VALUE_TRUE_R;
break;
case 'f':
- state_ = State::GRPC_JSON_STATE_VALUE_FALSE_A;
+ state_ = State::GRPC_JSON_STATE_VALUE_FALSE_A;
break;
case 'n':
- state_ = State::GRPC_JSON_STATE_VALUE_NULL_U;
+ state_ = State::GRPC_JSON_STATE_VALUE_NULL_U;
break;
case '"':
- state_ = State::GRPC_JSON_STATE_VALUE_STRING;
+ state_ = State::GRPC_JSON_STATE_VALUE_STRING;
break;
case '0':
- StringAddChar(c);
- state_ = State::GRPC_JSON_STATE_VALUE_NUMBER_ZERO;
+ StringAddChar(c);
+ state_ = State::GRPC_JSON_STATE_VALUE_NUMBER_ZERO;
break;
case '1':
@@ -500,71 +500,71 @@ JsonReader::Status JsonReader::Run() {
case '8':
case '9':
case '-':
- StringAddChar(c);
- state_ = State::GRPC_JSON_STATE_VALUE_NUMBER;
+ StringAddChar(c);
+ state_ = State::GRPC_JSON_STATE_VALUE_NUMBER;
break;
case '{':
- container_just_begun_ = true;
- if (!StartContainer(Json::Type::OBJECT)) {
- return Status::GRPC_JSON_PARSE_ERROR;
- }
- state_ = State::GRPC_JSON_STATE_OBJECT_KEY_BEGIN;
+ container_just_begun_ = true;
+ if (!StartContainer(Json::Type::OBJECT)) {
+ return Status::GRPC_JSON_PARSE_ERROR;
+ }
+ state_ = State::GRPC_JSON_STATE_OBJECT_KEY_BEGIN;
break;
case '[':
- container_just_begun_ = true;
- if (!StartContainer(Json::Type::ARRAY)) {
- return Status::GRPC_JSON_PARSE_ERROR;
- }
+ container_just_begun_ = true;
+ if (!StartContainer(Json::Type::ARRAY)) {
+ return Status::GRPC_JSON_PARSE_ERROR;
+ }
break;
default:
- return Status::GRPC_JSON_PARSE_ERROR;
+ return Status::GRPC_JSON_PARSE_ERROR;
}
break;
- case State::GRPC_JSON_STATE_STRING_ESCAPE:
- if (escaped_string_was_key_) {
- state_ = State::GRPC_JSON_STATE_OBJECT_KEY_STRING;
+ case State::GRPC_JSON_STATE_STRING_ESCAPE:
+ if (escaped_string_was_key_) {
+ state_ = State::GRPC_JSON_STATE_OBJECT_KEY_STRING;
} else {
- state_ = State::GRPC_JSON_STATE_VALUE_STRING;
+ state_ = State::GRPC_JSON_STATE_VALUE_STRING;
}
- if (unicode_high_surrogate_ && c != 'u') {
- return Status::GRPC_JSON_PARSE_ERROR;
+ if (unicode_high_surrogate_ && c != 'u') {
+ return Status::GRPC_JSON_PARSE_ERROR;
}
switch (c) {
case '"':
case '/':
- StringAddChar(c);
+ StringAddChar(c);
break;
case 'b':
- StringAddChar('\b');
+ StringAddChar('\b');
break;
case 'f':
- StringAddChar('\f');
+ StringAddChar('\f');
break;
case 'n':
- StringAddChar('\n');
+ StringAddChar('\n');
break;
case 'r':
- StringAddChar('\r');
+ StringAddChar('\r');
break;
case 't':
- StringAddChar('\t');
+ StringAddChar('\t');
break;
case 'u':
- state_ = State::GRPC_JSON_STATE_STRING_ESCAPE_U1;
- unicode_char_ = 0;
+ state_ = State::GRPC_JSON_STATE_STRING_ESCAPE_U1;
+ unicode_char_ = 0;
break;
default:
- return Status::GRPC_JSON_PARSE_ERROR;
+ return Status::GRPC_JSON_PARSE_ERROR;
}
break;
- case State::GRPC_JSON_STATE_STRING_ESCAPE_U1:
- case State::GRPC_JSON_STATE_STRING_ESCAPE_U2:
- case State::GRPC_JSON_STATE_STRING_ESCAPE_U3:
- case State::GRPC_JSON_STATE_STRING_ESCAPE_U4:
+ case State::GRPC_JSON_STATE_STRING_ESCAPE_U1:
+ case State::GRPC_JSON_STATE_STRING_ESCAPE_U2:
+ case State::GRPC_JSON_STATE_STRING_ESCAPE_U3:
+ case State::GRPC_JSON_STATE_STRING_ESCAPE_U4:
if ((c >= '0') && (c <= '9')) {
c -= '0';
} else if ((c >= 'A') && (c <= 'F')) {
@@ -572,60 +572,60 @@ JsonReader::Status JsonReader::Run() {
} else if ((c >= 'a') && (c <= 'f')) {
c -= 'a' - 10;
} else {
- return Status::GRPC_JSON_PARSE_ERROR;
+ return Status::GRPC_JSON_PARSE_ERROR;
}
- unicode_char_ = static_cast<uint16_t>(unicode_char_ << 4);
- unicode_char_ = static_cast<uint16_t>(unicode_char_ | c);
+ unicode_char_ = static_cast<uint16_t>(unicode_char_ << 4);
+ unicode_char_ = static_cast<uint16_t>(unicode_char_ | c);
- switch (state_) {
- case State::GRPC_JSON_STATE_STRING_ESCAPE_U1:
- state_ = State::GRPC_JSON_STATE_STRING_ESCAPE_U2;
+ switch (state_) {
+ case State::GRPC_JSON_STATE_STRING_ESCAPE_U1:
+ state_ = State::GRPC_JSON_STATE_STRING_ESCAPE_U2;
break;
- case State::GRPC_JSON_STATE_STRING_ESCAPE_U2:
- state_ = State::GRPC_JSON_STATE_STRING_ESCAPE_U3;
+ case State::GRPC_JSON_STATE_STRING_ESCAPE_U2:
+ state_ = State::GRPC_JSON_STATE_STRING_ESCAPE_U3;
break;
- case State::GRPC_JSON_STATE_STRING_ESCAPE_U3:
- state_ = State::GRPC_JSON_STATE_STRING_ESCAPE_U4;
+ case State::GRPC_JSON_STATE_STRING_ESCAPE_U3:
+ state_ = State::GRPC_JSON_STATE_STRING_ESCAPE_U4;
break;
- case State::GRPC_JSON_STATE_STRING_ESCAPE_U4:
+ case State::GRPC_JSON_STATE_STRING_ESCAPE_U4:
/* See grpc_json_writer_escape_string to have a description
* of what's going on here.
*/
- if ((unicode_char_ & 0xfc00) == 0xd800) {
+ if ((unicode_char_ & 0xfc00) == 0xd800) {
/* high surrogate utf-16 */
- if (unicode_high_surrogate_ != 0)
- return Status::GRPC_JSON_PARSE_ERROR;
- unicode_high_surrogate_ = unicode_char_;
- } else if ((unicode_char_ & 0xfc00) == 0xdc00) {
+ if (unicode_high_surrogate_ != 0)
+ return Status::GRPC_JSON_PARSE_ERROR;
+ unicode_high_surrogate_ = unicode_char_;
+ } else if ((unicode_char_ & 0xfc00) == 0xdc00) {
/* low surrogate utf-16 */
uint32_t utf32;
- if (unicode_high_surrogate_ == 0)
- return Status::GRPC_JSON_PARSE_ERROR;
+ if (unicode_high_surrogate_ == 0)
+ return Status::GRPC_JSON_PARSE_ERROR;
utf32 = 0x10000;
utf32 += static_cast<uint32_t>(
- (unicode_high_surrogate_ - 0xd800) * 0x400);
- utf32 += static_cast<uint32_t>(unicode_char_ - 0xdc00);
- StringAddUtf32(utf32);
- unicode_high_surrogate_ = 0;
+ (unicode_high_surrogate_ - 0xd800) * 0x400);
+ utf32 += static_cast<uint32_t>(unicode_char_ - 0xdc00);
+ StringAddUtf32(utf32);
+ unicode_high_surrogate_ = 0;
} else {
/* anything else */
- if (unicode_high_surrogate_ != 0)
- return Status::GRPC_JSON_PARSE_ERROR;
- StringAddUtf32(unicode_char_);
+ if (unicode_high_surrogate_ != 0)
+ return Status::GRPC_JSON_PARSE_ERROR;
+ StringAddUtf32(unicode_char_);
}
- if (escaped_string_was_key_) {
- state_ = State::GRPC_JSON_STATE_OBJECT_KEY_STRING;
+ if (escaped_string_was_key_) {
+ state_ = State::GRPC_JSON_STATE_OBJECT_KEY_STRING;
} else {
- state_ = State::GRPC_JSON_STATE_VALUE_STRING;
+ state_ = State::GRPC_JSON_STATE_VALUE_STRING;
}
break;
default:
- GPR_UNREACHABLE_CODE(return Status::GRPC_JSON_INTERNAL_ERROR);
+ GPR_UNREACHABLE_CODE(return Status::GRPC_JSON_INTERNAL_ERROR);
}
break;
- case State::GRPC_JSON_STATE_VALUE_NUMBER:
- StringAddChar(c);
+ case State::GRPC_JSON_STATE_VALUE_NUMBER:
+ StringAddChar(c);
switch (c) {
case '0':
case '1':
@@ -640,18 +640,18 @@ JsonReader::Status JsonReader::Run() {
break;
case 'e':
case 'E':
- state_ = State::GRPC_JSON_STATE_VALUE_NUMBER_E;
+ state_ = State::GRPC_JSON_STATE_VALUE_NUMBER_E;
break;
case '.':
- state_ = State::GRPC_JSON_STATE_VALUE_NUMBER_DOT;
+ state_ = State::GRPC_JSON_STATE_VALUE_NUMBER_DOT;
break;
default:
- return Status::GRPC_JSON_PARSE_ERROR;
+ return Status::GRPC_JSON_PARSE_ERROR;
}
break;
- case State::GRPC_JSON_STATE_VALUE_NUMBER_WITH_DECIMAL:
- StringAddChar(c);
+ case State::GRPC_JSON_STATE_VALUE_NUMBER_WITH_DECIMAL:
+ StringAddChar(c);
switch (c) {
case '0':
case '1':
@@ -666,21 +666,21 @@ JsonReader::Status JsonReader::Run() {
break;
case 'e':
case 'E':
- state_ = State::GRPC_JSON_STATE_VALUE_NUMBER_E;
+ state_ = State::GRPC_JSON_STATE_VALUE_NUMBER_E;
break;
default:
- return Status::GRPC_JSON_PARSE_ERROR;
+ return Status::GRPC_JSON_PARSE_ERROR;
}
break;
- case State::GRPC_JSON_STATE_VALUE_NUMBER_ZERO:
- if (c != '.') return Status::GRPC_JSON_PARSE_ERROR;
- StringAddChar(c);
- state_ = State::GRPC_JSON_STATE_VALUE_NUMBER_DOT;
+ case State::GRPC_JSON_STATE_VALUE_NUMBER_ZERO:
+ if (c != '.') return Status::GRPC_JSON_PARSE_ERROR;
+ StringAddChar(c);
+ state_ = State::GRPC_JSON_STATE_VALUE_NUMBER_DOT;
break;
- case State::GRPC_JSON_STATE_VALUE_NUMBER_DOT:
- StringAddChar(c);
+ case State::GRPC_JSON_STATE_VALUE_NUMBER_DOT:
+ StringAddChar(c);
switch (c) {
case '0':
case '1':
@@ -692,15 +692,15 @@ JsonReader::Status JsonReader::Run() {
case '7':
case '8':
case '9':
- state_ = State::GRPC_JSON_STATE_VALUE_NUMBER_WITH_DECIMAL;
+ state_ = State::GRPC_JSON_STATE_VALUE_NUMBER_WITH_DECIMAL;
break;
default:
- return Status::GRPC_JSON_PARSE_ERROR;
+ return Status::GRPC_JSON_PARSE_ERROR;
}
break;
- case State::GRPC_JSON_STATE_VALUE_NUMBER_E:
- StringAddChar(c);
+ case State::GRPC_JSON_STATE_VALUE_NUMBER_E:
+ StringAddChar(c);
switch (c) {
case '0':
case '1':
@@ -714,15 +714,15 @@ JsonReader::Status JsonReader::Run() {
case '9':
case '+':
case '-':
- state_ = State::GRPC_JSON_STATE_VALUE_NUMBER_EPM;
+ state_ = State::GRPC_JSON_STATE_VALUE_NUMBER_EPM;
break;
default:
- return Status::GRPC_JSON_PARSE_ERROR;
+ return Status::GRPC_JSON_PARSE_ERROR;
}
break;
- case State::GRPC_JSON_STATE_VALUE_NUMBER_EPM:
- StringAddChar(c);
+ case State::GRPC_JSON_STATE_VALUE_NUMBER_EPM:
+ StringAddChar(c);
switch (c) {
case '0':
case '1':
@@ -736,119 +736,119 @@ JsonReader::Status JsonReader::Run() {
case '9':
break;
default:
- return Status::GRPC_JSON_PARSE_ERROR;
+ return Status::GRPC_JSON_PARSE_ERROR;
}
break;
- case State::GRPC_JSON_STATE_VALUE_TRUE_R:
- if (c != 'r') return Status::GRPC_JSON_PARSE_ERROR;
- state_ = State::GRPC_JSON_STATE_VALUE_TRUE_U;
+ case State::GRPC_JSON_STATE_VALUE_TRUE_R:
+ if (c != 'r') return Status::GRPC_JSON_PARSE_ERROR;
+ state_ = State::GRPC_JSON_STATE_VALUE_TRUE_U;
break;
- case State::GRPC_JSON_STATE_VALUE_TRUE_U:
- if (c != 'u') return Status::GRPC_JSON_PARSE_ERROR;
- state_ = State::GRPC_JSON_STATE_VALUE_TRUE_E;
+ case State::GRPC_JSON_STATE_VALUE_TRUE_U:
+ if (c != 'u') return Status::GRPC_JSON_PARSE_ERROR;
+ state_ = State::GRPC_JSON_STATE_VALUE_TRUE_E;
break;
- case State::GRPC_JSON_STATE_VALUE_TRUE_E:
- if (c != 'e') return Status::GRPC_JSON_PARSE_ERROR;
- SetTrue();
- state_ = State::GRPC_JSON_STATE_VALUE_END;
+ case State::GRPC_JSON_STATE_VALUE_TRUE_E:
+ if (c != 'e') return Status::GRPC_JSON_PARSE_ERROR;
+ SetTrue();
+ state_ = State::GRPC_JSON_STATE_VALUE_END;
break;
- case State::GRPC_JSON_STATE_VALUE_FALSE_A:
- if (c != 'a') return Status::GRPC_JSON_PARSE_ERROR;
- state_ = State::GRPC_JSON_STATE_VALUE_FALSE_L;
+ case State::GRPC_JSON_STATE_VALUE_FALSE_A:
+ if (c != 'a') return Status::GRPC_JSON_PARSE_ERROR;
+ state_ = State::GRPC_JSON_STATE_VALUE_FALSE_L;
break;
- case State::GRPC_JSON_STATE_VALUE_FALSE_L:
- if (c != 'l') return Status::GRPC_JSON_PARSE_ERROR;
- state_ = State::GRPC_JSON_STATE_VALUE_FALSE_S;
+ case State::GRPC_JSON_STATE_VALUE_FALSE_L:
+ if (c != 'l') return Status::GRPC_JSON_PARSE_ERROR;
+ state_ = State::GRPC_JSON_STATE_VALUE_FALSE_S;
break;
- case State::GRPC_JSON_STATE_VALUE_FALSE_S:
- if (c != 's') return Status::GRPC_JSON_PARSE_ERROR;
- state_ = State::GRPC_JSON_STATE_VALUE_FALSE_E;
+ case State::GRPC_JSON_STATE_VALUE_FALSE_S:
+ if (c != 's') return Status::GRPC_JSON_PARSE_ERROR;
+ state_ = State::GRPC_JSON_STATE_VALUE_FALSE_E;
break;
- case State::GRPC_JSON_STATE_VALUE_FALSE_E:
- if (c != 'e') return Status::GRPC_JSON_PARSE_ERROR;
- SetFalse();
- state_ = State::GRPC_JSON_STATE_VALUE_END;
+ case State::GRPC_JSON_STATE_VALUE_FALSE_E:
+ if (c != 'e') return Status::GRPC_JSON_PARSE_ERROR;
+ SetFalse();
+ state_ = State::GRPC_JSON_STATE_VALUE_END;
break;
- case State::GRPC_JSON_STATE_VALUE_NULL_U:
- if (c != 'u') return Status::GRPC_JSON_PARSE_ERROR;
- state_ = State::GRPC_JSON_STATE_VALUE_NULL_L1;
+ case State::GRPC_JSON_STATE_VALUE_NULL_U:
+ if (c != 'u') return Status::GRPC_JSON_PARSE_ERROR;
+ state_ = State::GRPC_JSON_STATE_VALUE_NULL_L1;
break;
- case State::GRPC_JSON_STATE_VALUE_NULL_L1:
- if (c != 'l') return Status::GRPC_JSON_PARSE_ERROR;
- state_ = State::GRPC_JSON_STATE_VALUE_NULL_L2;
+ case State::GRPC_JSON_STATE_VALUE_NULL_L1:
+ if (c != 'l') return Status::GRPC_JSON_PARSE_ERROR;
+ state_ = State::GRPC_JSON_STATE_VALUE_NULL_L2;
break;
- case State::GRPC_JSON_STATE_VALUE_NULL_L2:
- if (c != 'l') return Status::GRPC_JSON_PARSE_ERROR;
- SetNull();
- state_ = State::GRPC_JSON_STATE_VALUE_END;
+ case State::GRPC_JSON_STATE_VALUE_NULL_L2:
+ if (c != 'l') return Status::GRPC_JSON_PARSE_ERROR;
+ SetNull();
+ state_ = State::GRPC_JSON_STATE_VALUE_END;
break;
/* All of the VALUE_END cases are handled in the specialized case
* above. */
- case State::GRPC_JSON_STATE_VALUE_END:
+ case State::GRPC_JSON_STATE_VALUE_END:
switch (c) {
case ',':
case '}':
case ']':
- GPR_UNREACHABLE_CODE(return Status::GRPC_JSON_INTERNAL_ERROR);
+ GPR_UNREACHABLE_CODE(return Status::GRPC_JSON_INTERNAL_ERROR);
break;
default:
- return Status::GRPC_JSON_PARSE_ERROR;
+ return Status::GRPC_JSON_PARSE_ERROR;
}
break;
- case State::GRPC_JSON_STATE_END:
- return Status::GRPC_JSON_PARSE_ERROR;
+ case State::GRPC_JSON_STATE_END:
+ return Status::GRPC_JSON_PARSE_ERROR;
}
}
}
- GPR_UNREACHABLE_CODE(return Status::GRPC_JSON_INTERNAL_ERROR);
+ GPR_UNREACHABLE_CODE(return Status::GRPC_JSON_INTERNAL_ERROR);
+}
+
+grpc_error* JsonReader::Parse(y_absl::string_view input, Json* output) {
+ JsonReader reader(input);
+ Status status = reader.Run();
+ if (reader.truncated_errors_) {
+ reader.errors_.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "too many errors encountered during JSON parsing -- fix reported "
+ "errors and try again to see additional errors"));
+ }
+ if (status == Status::GRPC_JSON_INTERNAL_ERROR) {
+ reader.errors_.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
+ y_absl::StrCat("internal error in JSON parser at index ",
+ reader.CurrentIndex())
+ .c_str()));
+ } else if (status == Status::GRPC_JSON_PARSE_ERROR) {
+ reader.errors_.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
+ y_absl::StrCat("JSON parse error at index ", reader.CurrentIndex())
+ .c_str()));
+ }
+ if (!reader.errors_.empty()) {
+ return GRPC_ERROR_CREATE_FROM_VECTOR("JSON parsing failed",
+ &reader.errors_);
+ }
+ *output = std::move(reader.root_value_);
+ return GRPC_ERROR_NONE;
+}
+
+} // namespace
+
+Json Json::Parse(y_absl::string_view json_str, grpc_error** error) {
+ Json value;
+ *error = JsonReader::Parse(json_str, &value);
+ return value;
}
-
-grpc_error* JsonReader::Parse(y_absl::string_view input, Json* output) {
- JsonReader reader(input);
- Status status = reader.Run();
- if (reader.truncated_errors_) {
- reader.errors_.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "too many errors encountered during JSON parsing -- fix reported "
- "errors and try again to see additional errors"));
- }
- if (status == Status::GRPC_JSON_INTERNAL_ERROR) {
- reader.errors_.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
- y_absl::StrCat("internal error in JSON parser at index ",
- reader.CurrentIndex())
- .c_str()));
- } else if (status == Status::GRPC_JSON_PARSE_ERROR) {
- reader.errors_.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
- y_absl::StrCat("JSON parse error at index ", reader.CurrentIndex())
- .c_str()));
- }
- if (!reader.errors_.empty()) {
- return GRPC_ERROR_CREATE_FROM_VECTOR("JSON parsing failed",
- &reader.errors_);
- }
- *output = std::move(reader.root_value_);
- return GRPC_ERROR_NONE;
-}
-
-} // namespace
-
-Json Json::Parse(y_absl::string_view json_str, grpc_error** error) {
- Json value;
- *error = JsonReader::Parse(json_str, &value);
- return value;
-}
-
-} // namespace grpc_core
+
+} // namespace grpc_core
diff --git a/contrib/libs/grpc/src/core/lib/json/json_util.cc b/contrib/libs/grpc/src/core/lib/json/json_util.cc
index 44e0f4bd4e..1c90aeb5b4 100644
--- a/contrib/libs/grpc/src/core/lib/json/json_util.cc
+++ b/contrib/libs/grpc/src/core/lib/json/json_util.cc
@@ -1,58 +1,58 @@
-//
-//
-// Copyright 2020 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//
-
-#include <grpc/support/port_platform.h>
-
-#include "src/core/lib/json/json_util.h"
-
-#include <grpc/support/string_util.h>
-
-#include "src/core/lib/gpr/string.h"
-
-namespace grpc_core {
-
-bool ParseDurationFromJson(const Json& field, grpc_millis* duration) {
- if (field.type() != Json::Type::STRING) return false;
- size_t len = field.string_value().size();
- if (field.string_value()[len - 1] != 's') return false;
- grpc_core::UniquePtr<char> buf(gpr_strdup(field.string_value().c_str()));
- *(buf.get() + len - 1) = '\0'; // Remove trailing 's'.
- char* decimal_point = strchr(buf.get(), '.');
- int nanos = 0;
- if (decimal_point != nullptr) {
- *decimal_point = '\0';
- nanos = gpr_parse_nonnegative_int(decimal_point + 1);
- if (nanos == -1) {
- return false;
- }
- int num_digits = static_cast<int>(strlen(decimal_point + 1));
- if (num_digits > 9) { // We don't accept greater precision than nanos.
- return false;
- }
- for (int i = 0; i < (9 - num_digits); ++i) {
- nanos *= 10;
- }
- }
- int seconds =
- decimal_point == buf.get() ? 0 : gpr_parse_nonnegative_int(buf.get());
- if (seconds == -1) return false;
- *duration = seconds * GPR_MS_PER_SEC + nanos / GPR_NS_PER_MS;
- return true;
-}
-
-} // namespace grpc_core
+//
+//
+// Copyright 2020 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//
+
+#include <grpc/support/port_platform.h>
+
+#include "src/core/lib/json/json_util.h"
+
+#include <grpc/support/string_util.h>
+
+#include "src/core/lib/gpr/string.h"
+
+namespace grpc_core {
+
+bool ParseDurationFromJson(const Json& field, grpc_millis* duration) {
+ if (field.type() != Json::Type::STRING) return false;
+ size_t len = field.string_value().size();
+ if (field.string_value()[len - 1] != 's') return false;
+ grpc_core::UniquePtr<char> buf(gpr_strdup(field.string_value().c_str()));
+ *(buf.get() + len - 1) = '\0'; // Remove trailing 's'.
+ char* decimal_point = strchr(buf.get(), '.');
+ int nanos = 0;
+ if (decimal_point != nullptr) {
+ *decimal_point = '\0';
+ nanos = gpr_parse_nonnegative_int(decimal_point + 1);
+ if (nanos == -1) {
+ return false;
+ }
+ int num_digits = static_cast<int>(strlen(decimal_point + 1));
+ if (num_digits > 9) { // We don't accept greater precision than nanos.
+ return false;
+ }
+ for (int i = 0; i < (9 - num_digits); ++i) {
+ nanos *= 10;
+ }
+ }
+ int seconds =
+ decimal_point == buf.get() ? 0 : gpr_parse_nonnegative_int(buf.get());
+ if (seconds == -1) return false;
+ *duration = seconds * GPR_MS_PER_SEC + nanos / GPR_NS_PER_MS;
+ return true;
+}
+
+} // namespace grpc_core
diff --git a/contrib/libs/grpc/src/core/lib/json/json_util.h b/contrib/libs/grpc/src/core/lib/json/json_util.h
index cec3eb8ff5..071087f765 100644
--- a/contrib/libs/grpc/src/core/lib/json/json_util.h
+++ b/contrib/libs/grpc/src/core/lib/json/json_util.h
@@ -1,37 +1,37 @@
-//
-//
-// Copyright 2020 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//
-
-#ifndef GRPC_CORE_LIB_JSON_JSON_UTIL_H
-#define GRPC_CORE_LIB_JSON_JSON_UTIL_H
-
-#include <grpc/support/port_platform.h>
-
-#include "src/core/lib/iomgr/exec_ctx.h"
-#include "src/core/lib/json/json.h"
-
-namespace grpc_core {
-
-// Parses a JSON field of the form generated for a google.proto.Duration
-// proto message, as per:
-// https://developers.google.com/protocol-buffers/docs/proto3#json
-// Returns true on success, false otherwise.
-bool ParseDurationFromJson(const Json& field, grpc_millis* duration);
-
-} // namespace grpc_core
-
-#endif // GRPC_CORE_LIB_JSON_JSON_UTIL_H
+//
+//
+// Copyright 2020 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//
+
+#ifndef GRPC_CORE_LIB_JSON_JSON_UTIL_H
+#define GRPC_CORE_LIB_JSON_JSON_UTIL_H
+
+#include <grpc/support/port_platform.h>
+
+#include "src/core/lib/iomgr/exec_ctx.h"
+#include "src/core/lib/json/json.h"
+
+namespace grpc_core {
+
+// Parses a JSON field of the form generated for a google.proto.Duration
+// proto message, as per:
+// https://developers.google.com/protocol-buffers/docs/proto3#json
+// Returns true on success, false otherwise.
+bool ParseDurationFromJson(const Json& field, grpc_millis* duration);
+
+} // namespace grpc_core
+
+#endif // GRPC_CORE_LIB_JSON_JSON_UTIL_H
diff --git a/contrib/libs/grpc/src/core/lib/json/json_writer.cc b/contrib/libs/grpc/src/core/lib/json/json_writer.cc
index a6e02a5f94..f2043d55a0 100644
--- a/contrib/libs/grpc/src/core/lib/json/json_writer.cc
+++ b/contrib/libs/grpc/src/core/lib/json/json_writer.cc
@@ -18,155 +18,155 @@
#include <grpc/support/port_platform.h>
-#include <stdlib.h>
+#include <stdlib.h>
#include <string.h>
-#include "y_absl/strings/string_view.h"
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
+#include "y_absl/strings/string_view.h"
-#include "src/core/lib/json/json.h"
-
-namespace grpc_core {
-
-namespace {
-
-/* The idea of the writer is basically symmetrical of the reader. While the
- * reader emits various calls to your code, the writer takes basically the
- * same calls and emit json out of it. It doesn't try to make any check on
- * the order of the calls you do on it. Meaning you can theorically force
- * it to generate invalid json.
- *
- * Also, unlike the reader, the writer expects UTF-8 encoded input strings.
- * These strings will be UTF-8 validated, and any invalid character will
- * cut the conversion short, before any invalid UTF-8 sequence, thus forming
- * a valid UTF-8 string overall.
- */
-class JsonWriter {
- public:
- static TString Dump(const Json& value, int indent);
-
- private:
- explicit JsonWriter(int indent) : indent_(indent) {}
-
- void OutputCheck(size_t needed);
- void OutputChar(char c);
- void OutputString(const y_absl::string_view str);
- void OutputIndent();
- void ValueEnd();
- void EscapeUtf16(uint16_t utf16);
- void EscapeString(const TString& string);
- void ContainerBegins(Json::Type type);
- void ContainerEnds(Json::Type type);
- void ObjectKey(const TString& string);
- void ValueRaw(const TString& string);
- void ValueString(const TString& string);
-
- void DumpObject(const Json::Object& object);
- void DumpArray(const Json::Array& array);
- void DumpValue(const Json& value);
-
- int indent_;
- int depth_ = 0;
- bool container_empty_ = true;
- bool got_key_ = false;
- TString output_;
-};
-
-/* This function checks if there's enough space left in the output buffer,
- * and will enlarge it if necessary. We're only allocating chunks of 256
- * bytes at a time (or multiples thereof).
- */
-void JsonWriter::OutputCheck(size_t needed) {
- size_t free_space = output_.capacity() - output_.size();
- if (free_space >= needed) return;
- needed -= free_space;
- /* Round up by 256 bytes. */
- needed = (needed + 0xff) & ~0xffU;
- output_.reserve(output_.capacity() + needed);
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+
+#include "src/core/lib/json/json.h"
+
+namespace grpc_core {
+
+namespace {
+
+/* The idea of the writer is basically symmetrical of the reader. While the
+ * reader emits various calls to your code, the writer takes basically the
+ * same calls and emit json out of it. It doesn't try to make any check on
+ * the order of the calls you do on it. Meaning you can theorically force
+ * it to generate invalid json.
+ *
+ * Also, unlike the reader, the writer expects UTF-8 encoded input strings.
+ * These strings will be UTF-8 validated, and any invalid character will
+ * cut the conversion short, before any invalid UTF-8 sequence, thus forming
+ * a valid UTF-8 string overall.
+ */
+class JsonWriter {
+ public:
+ static TString Dump(const Json& value, int indent);
+
+ private:
+ explicit JsonWriter(int indent) : indent_(indent) {}
+
+ void OutputCheck(size_t needed);
+ void OutputChar(char c);
+ void OutputString(const y_absl::string_view str);
+ void OutputIndent();
+ void ValueEnd();
+ void EscapeUtf16(uint16_t utf16);
+ void EscapeString(const TString& string);
+ void ContainerBegins(Json::Type type);
+ void ContainerEnds(Json::Type type);
+ void ObjectKey(const TString& string);
+ void ValueRaw(const TString& string);
+ void ValueString(const TString& string);
+
+ void DumpObject(const Json::Object& object);
+ void DumpArray(const Json::Array& array);
+ void DumpValue(const Json& value);
+
+ int indent_;
+ int depth_ = 0;
+ bool container_empty_ = true;
+ bool got_key_ = false;
+ TString output_;
+};
+
+/* This function checks if there's enough space left in the output buffer,
+ * and will enlarge it if necessary. We're only allocating chunks of 256
+ * bytes at a time (or multiples thereof).
+ */
+void JsonWriter::OutputCheck(size_t needed) {
+ size_t free_space = output_.capacity() - output_.size();
+ if (free_space >= needed) return;
+ needed -= free_space;
+ /* Round up by 256 bytes. */
+ needed = (needed + 0xff) & ~0xffU;
+ output_.reserve(output_.capacity() + needed);
}
-void JsonWriter::OutputChar(char c) {
- OutputCheck(1);
- output_.push_back(c);
+void JsonWriter::OutputChar(char c) {
+ OutputCheck(1);
+ output_.push_back(c);
}
-void JsonWriter::OutputString(const y_absl::string_view str) {
- OutputCheck(str.size());
- output_.append(str.data(), str.size());
+void JsonWriter::OutputString(const y_absl::string_view str) {
+ OutputCheck(str.size());
+ output_.append(str.data(), str.size());
}
-void JsonWriter::OutputIndent() {
+void JsonWriter::OutputIndent() {
static const char spacesstr[] =
" "
" "
" "
" ";
- unsigned spaces = static_cast<unsigned>(depth_ * indent_);
- if (indent_ == 0) return;
- if (got_key_) {
- OutputChar(' ');
+ unsigned spaces = static_cast<unsigned>(depth_ * indent_);
+ if (indent_ == 0) return;
+ if (got_key_) {
+ OutputChar(' ');
return;
}
while (spaces >= (sizeof(spacesstr) - 1)) {
- OutputString(y_absl::string_view(spacesstr, sizeof(spacesstr) - 1));
+ OutputString(y_absl::string_view(spacesstr, sizeof(spacesstr) - 1));
spaces -= static_cast<unsigned>(sizeof(spacesstr) - 1);
}
if (spaces == 0) return;
- OutputString(
- y_absl::string_view(spacesstr + sizeof(spacesstr) - 1 - spaces, spaces));
+ OutputString(
+ y_absl::string_view(spacesstr + sizeof(spacesstr) - 1 - spaces, spaces));
}
-void JsonWriter::ValueEnd() {
- if (container_empty_) {
- container_empty_ = false;
- if (indent_ == 0 || depth_ == 0) return;
- OutputChar('\n');
+void JsonWriter::ValueEnd() {
+ if (container_empty_) {
+ container_empty_ = false;
+ if (indent_ == 0 || depth_ == 0) return;
+ OutputChar('\n');
} else {
- OutputChar(',');
- if (indent_ == 0) return;
- OutputChar('\n');
+ OutputChar(',');
+ if (indent_ == 0) return;
+ OutputChar('\n');
}
}
-void JsonWriter::EscapeUtf16(uint16_t utf16) {
+void JsonWriter::EscapeUtf16(uint16_t utf16) {
static const char hex[] = "0123456789abcdef";
- OutputString(y_absl::string_view("\\u", 2));
- OutputChar(hex[(utf16 >> 12) & 0x0f]);
- OutputChar(hex[(utf16 >> 8) & 0x0f]);
- OutputChar(hex[(utf16 >> 4) & 0x0f]);
- OutputChar(hex[(utf16)&0x0f]);
+ OutputString(y_absl::string_view("\\u", 2));
+ OutputChar(hex[(utf16 >> 12) & 0x0f]);
+ OutputChar(hex[(utf16 >> 8) & 0x0f]);
+ OutputChar(hex[(utf16 >> 4) & 0x0f]);
+ OutputChar(hex[(utf16)&0x0f]);
}
-void JsonWriter::EscapeString(const TString& string) {
- OutputChar('"');
- for (size_t idx = 0; idx < string.size(); ++idx) {
- uint8_t c = static_cast<uint8_t>(string[idx]);
+void JsonWriter::EscapeString(const TString& string) {
+ OutputChar('"');
+ for (size_t idx = 0; idx < string.size(); ++idx) {
+ uint8_t c = static_cast<uint8_t>(string[idx]);
if (c == 0) {
break;
- } else if (c >= 32 && c <= 126) {
- if (c == '\\' || c == '"') OutputChar('\\');
- OutputChar(static_cast<char>(c));
- } else if (c < 32 || c == 127) {
+ } else if (c >= 32 && c <= 126) {
+ if (c == '\\' || c == '"') OutputChar('\\');
+ OutputChar(static_cast<char>(c));
+ } else if (c < 32 || c == 127) {
switch (c) {
case '\b':
- OutputString(y_absl::string_view("\\b", 2));
+ OutputString(y_absl::string_view("\\b", 2));
break;
case '\f':
- OutputString(y_absl::string_view("\\f", 2));
+ OutputString(y_absl::string_view("\\f", 2));
break;
case '\n':
- OutputString(y_absl::string_view("\\n", 2));
+ OutputString(y_absl::string_view("\\n", 2));
break;
case '\r':
- OutputString(y_absl::string_view("\\r", 2));
+ OutputString(y_absl::string_view("\\r", 2));
break;
case '\t':
- OutputString(y_absl::string_view("\\t", 2));
+ OutputString(y_absl::string_view("\\t", 2));
break;
default:
- EscapeUtf16(c);
+ EscapeUtf16(c);
break;
}
} else {
@@ -188,13 +188,13 @@ void JsonWriter::EscapeString(const TString& string) {
}
for (i = 0; i < extra; i++) {
utf32 <<= 6;
- ++idx;
- /* Breaks out and bail if we hit the end of the string. */
- if (idx == string.size()) {
- valid = 0;
- break;
- }
- c = static_cast<uint8_t>(string[idx]);
+ ++idx;
+ /* Breaks out and bail if we hit the end of the string. */
+ if (idx == string.size()) {
+ valid = 0;
+ break;
+ }
+ c = static_cast<uint8_t>(string[idx]);
/* Breaks out and bail on any invalid UTF-8 sequence, including \0. */
if ((c & 0xc0) != 0x80) {
valid = 0;
@@ -227,111 +227,111 @@ void JsonWriter::EscapeString(const TString& string) {
* That range is exactly 20 bits.
*/
utf32 -= 0x10000;
- EscapeUtf16(static_cast<uint16_t>(0xd800 | (utf32 >> 10)));
- EscapeUtf16(static_cast<uint16_t>(0xdc00 | (utf32 & 0x3ff)));
+ EscapeUtf16(static_cast<uint16_t>(0xd800 | (utf32 >> 10)));
+ EscapeUtf16(static_cast<uint16_t>(0xdc00 | (utf32 & 0x3ff)));
} else {
- EscapeUtf16(static_cast<uint16_t>(utf32));
+ EscapeUtf16(static_cast<uint16_t>(utf32));
}
}
}
- OutputChar('"');
-}
+ OutputChar('"');
+}
+
+void JsonWriter::ContainerBegins(Json::Type type) {
+ if (!got_key_) ValueEnd();
+ OutputIndent();
+ OutputChar(type == Json::Type::OBJECT ? '{' : '[');
+ container_empty_ = true;
+ got_key_ = false;
+ depth_++;
+}
-void JsonWriter::ContainerBegins(Json::Type type) {
- if (!got_key_) ValueEnd();
- OutputIndent();
- OutputChar(type == Json::Type::OBJECT ? '{' : '[');
- container_empty_ = true;
- got_key_ = false;
- depth_++;
+void JsonWriter::ContainerEnds(Json::Type type) {
+ if (indent_ && !container_empty_) OutputChar('\n');
+ depth_--;
+ if (!container_empty_) OutputIndent();
+ OutputChar(type == Json::Type::OBJECT ? '}' : ']');
+ container_empty_ = false;
+ got_key_ = false;
}
-void JsonWriter::ContainerEnds(Json::Type type) {
- if (indent_ && !container_empty_) OutputChar('\n');
- depth_--;
- if (!container_empty_) OutputIndent();
- OutputChar(type == Json::Type::OBJECT ? '}' : ']');
- container_empty_ = false;
- got_key_ = false;
+void JsonWriter::ObjectKey(const TString& string) {
+ ValueEnd();
+ OutputIndent();
+ EscapeString(string);
+ OutputChar(':');
+ got_key_ = true;
}
-void JsonWriter::ObjectKey(const TString& string) {
- ValueEnd();
- OutputIndent();
- EscapeString(string);
- OutputChar(':');
- got_key_ = true;
+void JsonWriter::ValueRaw(const TString& string) {
+ if (!got_key_) ValueEnd();
+ OutputIndent();
+ OutputString(string);
+ got_key_ = false;
}
-void JsonWriter::ValueRaw(const TString& string) {
- if (!got_key_) ValueEnd();
- OutputIndent();
- OutputString(string);
- got_key_ = false;
+void JsonWriter::ValueString(const TString& string) {
+ if (!got_key_) ValueEnd();
+ OutputIndent();
+ EscapeString(string);
+ got_key_ = false;
}
-void JsonWriter::ValueString(const TString& string) {
- if (!got_key_) ValueEnd();
- OutputIndent();
- EscapeString(string);
- got_key_ = false;
+void JsonWriter::DumpObject(const Json::Object& object) {
+ ContainerBegins(Json::Type::OBJECT);
+ for (const auto& p : object) {
+ ObjectKey(p.first.data());
+ DumpValue(p.second);
+ }
+ ContainerEnds(Json::Type::OBJECT);
}
-void JsonWriter::DumpObject(const Json::Object& object) {
- ContainerBegins(Json::Type::OBJECT);
- for (const auto& p : object) {
- ObjectKey(p.first.data());
- DumpValue(p.second);
- }
- ContainerEnds(Json::Type::OBJECT);
+void JsonWriter::DumpArray(const Json::Array& array) {
+ ContainerBegins(Json::Type::ARRAY);
+ for (const auto& v : array) {
+ DumpValue(v);
+ }
+ ContainerEnds(Json::Type::ARRAY);
}
-void JsonWriter::DumpArray(const Json::Array& array) {
- ContainerBegins(Json::Type::ARRAY);
- for (const auto& v : array) {
- DumpValue(v);
- }
- ContainerEnds(Json::Type::ARRAY);
+void JsonWriter::DumpValue(const Json& value) {
+ switch (value.type()) {
+ case Json::Type::OBJECT:
+ DumpObject(value.object_value());
+ break;
+ case Json::Type::ARRAY:
+ DumpArray(value.array_value());
+ break;
+ case Json::Type::STRING:
+ ValueString(value.string_value());
+ break;
+ case Json::Type::NUMBER:
+ ValueRaw(value.string_value());
+ break;
+ case Json::Type::JSON_TRUE:
+ ValueRaw(TString("true", 4));
+ break;
+ case Json::Type::JSON_FALSE:
+ ValueRaw(TString("false", 5));
+ break;
+ case Json::Type::JSON_NULL:
+ ValueRaw(TString("null", 4));
+ break;
+ default:
+ GPR_UNREACHABLE_CODE(abort());
+ }
+}
+
+TString JsonWriter::Dump(const Json& value, int indent) {
+ JsonWriter writer(indent);
+ writer.DumpValue(value);
+ return std::move(writer.output_);
}
-
-void JsonWriter::DumpValue(const Json& value) {
- switch (value.type()) {
- case Json::Type::OBJECT:
- DumpObject(value.object_value());
- break;
- case Json::Type::ARRAY:
- DumpArray(value.array_value());
- break;
- case Json::Type::STRING:
- ValueString(value.string_value());
- break;
- case Json::Type::NUMBER:
- ValueRaw(value.string_value());
- break;
- case Json::Type::JSON_TRUE:
- ValueRaw(TString("true", 4));
- break;
- case Json::Type::JSON_FALSE:
- ValueRaw(TString("false", 5));
- break;
- case Json::Type::JSON_NULL:
- ValueRaw(TString("null", 4));
- break;
- default:
- GPR_UNREACHABLE_CODE(abort());
- }
-}
-
-TString JsonWriter::Dump(const Json& value, int indent) {
- JsonWriter writer(indent);
- writer.DumpValue(value);
- return std::move(writer.output_);
-}
-
-} // namespace
-
-TString Json::Dump(int indent) const {
- return JsonWriter::Dump(*this, indent);
-}
-
-} // namespace grpc_core
+
+} // namespace
+
+TString Json::Dump(int indent) const {
+ return JsonWriter::Dump(*this, indent);
+}
+
+} // namespace grpc_core
diff --git a/contrib/libs/grpc/src/core/lib/security/authorization/authorization_engine.cc b/contrib/libs/grpc/src/core/lib/security/authorization/authorization_engine.cc
index 776f0c8912..4a9386633b 100644
--- a/contrib/libs/grpc/src/core/lib/security/authorization/authorization_engine.cc
+++ b/contrib/libs/grpc/src/core/lib/security/authorization/authorization_engine.cc
@@ -1,177 +1,177 @@
-// Copyright 2020 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include <grpc/support/port_platform.h>
-
-#include "y_absl/memory/memory.h"
-
-#include "src/core/lib/security/authorization/authorization_engine.h"
-
-namespace grpc_core {
-
-namespace {
-
-// Symbols for traversing Envoy Attributes
-constexpr char kUrlPath[] = "url_path";
-constexpr char kHost[] = "host";
-constexpr char kMethod[] = "method";
-constexpr char kHeaders[] = "headers";
-constexpr char kSourceAddress[] = "source_address";
-constexpr char kSourcePort[] = "source_port";
-constexpr char kDestinationAddress[] = "destination_address";
-constexpr char kDestinationPort[] = "destination_port";
-constexpr char kSpiffeId[] = "spiffe_id";
-constexpr char kCertServerName[] = "cert_server_name";
-
-} // namespace
-
-std::unique_ptr<AuthorizationEngine>
-AuthorizationEngine::CreateAuthorizationEngine(
- const std::vector<envoy_config_rbac_v3_RBAC*>& rbac_policies) {
- if (rbac_policies.empty() || rbac_policies.size() > 2) {
- gpr_log(GPR_ERROR,
- "Invalid rbac policies vector. Must contain either one or two rbac "
- "policies.");
- return nullptr;
- } else if (rbac_policies.size() == 2 &&
- (envoy_config_rbac_v3_RBAC_action(rbac_policies[0]) != kDeny ||
- envoy_config_rbac_v3_RBAC_action(rbac_policies[1]) != kAllow)) {
- gpr_log(GPR_ERROR,
- "Invalid rbac policies vector. Must contain one deny \
- policy and one allow policy, in that order.");
- return nullptr;
- } else {
- return y_absl::make_unique<AuthorizationEngine>(rbac_policies);
- }
-}
-
-AuthorizationEngine::AuthorizationEngine(
- const std::vector<envoy_config_rbac_v3_RBAC*>& rbac_policies) {
- for (const auto& rbac_policy : rbac_policies) {
- // Extract array of policies and store their condition fields in either
- // allow_if_matched_ or deny_if_matched_, depending on the policy action.
- upb::Arena temp_arena;
- size_t policy_num = UPB_MAP_BEGIN;
- const envoy_config_rbac_v3_RBAC_PoliciesEntry* policy_entry;
- while ((policy_entry = envoy_config_rbac_v3_RBAC_policies_next(
- rbac_policy, &policy_num)) != nullptr) {
- const upb_strview policy_name_strview =
- envoy_config_rbac_v3_RBAC_PoliciesEntry_key(policy_entry);
- const TString policy_name(policy_name_strview.data,
- policy_name_strview.size);
- const envoy_config_rbac_v3_Policy* policy =
- envoy_config_rbac_v3_RBAC_PoliciesEntry_value(policy_entry);
- const google_api_expr_v1alpha1_Expr* condition =
- envoy_config_rbac_v3_Policy_condition(policy);
- // Parse condition to make a pointer tied to the lifetime of arena_.
- size_t serial_len;
- const char* serialized = google_api_expr_v1alpha1_Expr_serialize(
- condition, temp_arena.ptr(), &serial_len);
- const google_api_expr_v1alpha1_Expr* parsed_condition =
- google_api_expr_v1alpha1_Expr_parse(serialized, serial_len,
- arena_.ptr());
- if (envoy_config_rbac_v3_RBAC_action(rbac_policy) == kAllow) {
- allow_if_matched_.insert(std::make_pair(policy_name, parsed_condition));
- } else {
- deny_if_matched_.insert(std::make_pair(policy_name, parsed_condition));
- }
- }
- }
-}
-
-std::unique_ptr<mock_cel::Activation> AuthorizationEngine::CreateActivation(
- const EvaluateArgs& args) {
- std::unique_ptr<mock_cel::Activation> activation;
- for (const auto& elem : envoy_attributes_) {
- if (elem == kUrlPath) {
- y_absl::string_view url_path(args.GetPath());
- if (!url_path.empty()) {
- activation->InsertValue(kUrlPath,
- mock_cel::CelValue::CreateStringView(url_path));
- }
- } else if (elem == kHost) {
- y_absl::string_view host(args.GetHost());
- if (!host.empty()) {
- activation->InsertValue(kHost,
- mock_cel::CelValue::CreateStringView(host));
- }
- } else if (elem == kMethod) {
- y_absl::string_view method(args.GetMethod());
- if (!method.empty()) {
- activation->InsertValue(kMethod,
- mock_cel::CelValue::CreateStringView(method));
- }
- } else if (elem == kHeaders) {
- std::multimap<y_absl::string_view, y_absl::string_view> headers =
- args.GetHeaders();
- std::vector<std::pair<mock_cel::CelValue, mock_cel::CelValue>>
- header_items;
- for (const auto& header_key : header_keys_) {
- auto header_item = headers.find(header_key);
- if (header_item != headers.end()) {
- header_items.push_back(
- std::pair<mock_cel::CelValue, mock_cel::CelValue>(
- mock_cel::CelValue::CreateStringView(header_key),
- mock_cel::CelValue::CreateStringView(header_item->second)));
- }
- }
- headers_ = mock_cel::ContainerBackedMapImpl::Create(
- y_absl::Span<std::pair<mock_cel::CelValue, mock_cel::CelValue>>(
- header_items));
- activation->InsertValue(kHeaders,
- mock_cel::CelValue::CreateMap(headers_.get()));
- } else if (elem == kSourceAddress) {
- y_absl::string_view source_address(args.GetPeerAddress());
- if (!source_address.empty()) {
- activation->InsertValue(
- kSourceAddress,
- mock_cel::CelValue::CreateStringView(source_address));
- }
- } else if (elem == kSourcePort) {
- activation->InsertValue(
- kSourcePort, mock_cel::CelValue::CreateInt64(args.GetPeerPort()));
- } else if (elem == kDestinationAddress) {
- y_absl::string_view destination_address(args.GetLocalAddress());
- if (!destination_address.empty()) {
- activation->InsertValue(
- kDestinationAddress,
- mock_cel::CelValue::CreateStringView(destination_address));
- }
- } else if (elem == kDestinationPort) {
- activation->InsertValue(kDestinationPort, mock_cel::CelValue::CreateInt64(
- args.GetLocalPort()));
- } else if (elem == kSpiffeId) {
- y_absl::string_view spiffe_id(args.GetSpiffeId());
- if (!spiffe_id.empty()) {
- activation->InsertValue(
- kSpiffeId, mock_cel::CelValue::CreateStringView(spiffe_id));
- }
- } else if (elem == kCertServerName) {
- y_absl::string_view cert_server_name(args.GetCertServerName());
- if (!cert_server_name.empty()) {
- activation->InsertValue(
- kCertServerName,
- mock_cel::CelValue::CreateStringView(cert_server_name));
- }
- } else {
- gpr_log(GPR_ERROR,
- "Error: Authorization engine does not support evaluating "
- "attribute %s.",
- elem.c_str());
- }
- }
- return activation;
-}
-
-} // namespace grpc_core
+// Copyright 2020 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <grpc/support/port_platform.h>
+
+#include "y_absl/memory/memory.h"
+
+#include "src/core/lib/security/authorization/authorization_engine.h"
+
+namespace grpc_core {
+
+namespace {
+
+// Symbols for traversing Envoy Attributes
+constexpr char kUrlPath[] = "url_path";
+constexpr char kHost[] = "host";
+constexpr char kMethod[] = "method";
+constexpr char kHeaders[] = "headers";
+constexpr char kSourceAddress[] = "source_address";
+constexpr char kSourcePort[] = "source_port";
+constexpr char kDestinationAddress[] = "destination_address";
+constexpr char kDestinationPort[] = "destination_port";
+constexpr char kSpiffeId[] = "spiffe_id";
+constexpr char kCertServerName[] = "cert_server_name";
+
+} // namespace
+
+std::unique_ptr<AuthorizationEngine>
+AuthorizationEngine::CreateAuthorizationEngine(
+ const std::vector<envoy_config_rbac_v3_RBAC*>& rbac_policies) {
+ if (rbac_policies.empty() || rbac_policies.size() > 2) {
+ gpr_log(GPR_ERROR,
+ "Invalid rbac policies vector. Must contain either one or two rbac "
+ "policies.");
+ return nullptr;
+ } else if (rbac_policies.size() == 2 &&
+ (envoy_config_rbac_v3_RBAC_action(rbac_policies[0]) != kDeny ||
+ envoy_config_rbac_v3_RBAC_action(rbac_policies[1]) != kAllow)) {
+ gpr_log(GPR_ERROR,
+ "Invalid rbac policies vector. Must contain one deny \
+ policy and one allow policy, in that order.");
+ return nullptr;
+ } else {
+ return y_absl::make_unique<AuthorizationEngine>(rbac_policies);
+ }
+}
+
+AuthorizationEngine::AuthorizationEngine(
+ const std::vector<envoy_config_rbac_v3_RBAC*>& rbac_policies) {
+ for (const auto& rbac_policy : rbac_policies) {
+ // Extract array of policies and store their condition fields in either
+ // allow_if_matched_ or deny_if_matched_, depending on the policy action.
+ upb::Arena temp_arena;
+ size_t policy_num = UPB_MAP_BEGIN;
+ const envoy_config_rbac_v3_RBAC_PoliciesEntry* policy_entry;
+ while ((policy_entry = envoy_config_rbac_v3_RBAC_policies_next(
+ rbac_policy, &policy_num)) != nullptr) {
+ const upb_strview policy_name_strview =
+ envoy_config_rbac_v3_RBAC_PoliciesEntry_key(policy_entry);
+ const TString policy_name(policy_name_strview.data,
+ policy_name_strview.size);
+ const envoy_config_rbac_v3_Policy* policy =
+ envoy_config_rbac_v3_RBAC_PoliciesEntry_value(policy_entry);
+ const google_api_expr_v1alpha1_Expr* condition =
+ envoy_config_rbac_v3_Policy_condition(policy);
+ // Parse condition to make a pointer tied to the lifetime of arena_.
+ size_t serial_len;
+ const char* serialized = google_api_expr_v1alpha1_Expr_serialize(
+ condition, temp_arena.ptr(), &serial_len);
+ const google_api_expr_v1alpha1_Expr* parsed_condition =
+ google_api_expr_v1alpha1_Expr_parse(serialized, serial_len,
+ arena_.ptr());
+ if (envoy_config_rbac_v3_RBAC_action(rbac_policy) == kAllow) {
+ allow_if_matched_.insert(std::make_pair(policy_name, parsed_condition));
+ } else {
+ deny_if_matched_.insert(std::make_pair(policy_name, parsed_condition));
+ }
+ }
+ }
+}
+
+std::unique_ptr<mock_cel::Activation> AuthorizationEngine::CreateActivation(
+ const EvaluateArgs& args) {
+ std::unique_ptr<mock_cel::Activation> activation;
+ for (const auto& elem : envoy_attributes_) {
+ if (elem == kUrlPath) {
+ y_absl::string_view url_path(args.GetPath());
+ if (!url_path.empty()) {
+ activation->InsertValue(kUrlPath,
+ mock_cel::CelValue::CreateStringView(url_path));
+ }
+ } else if (elem == kHost) {
+ y_absl::string_view host(args.GetHost());
+ if (!host.empty()) {
+ activation->InsertValue(kHost,
+ mock_cel::CelValue::CreateStringView(host));
+ }
+ } else if (elem == kMethod) {
+ y_absl::string_view method(args.GetMethod());
+ if (!method.empty()) {
+ activation->InsertValue(kMethod,
+ mock_cel::CelValue::CreateStringView(method));
+ }
+ } else if (elem == kHeaders) {
+ std::multimap<y_absl::string_view, y_absl::string_view> headers =
+ args.GetHeaders();
+ std::vector<std::pair<mock_cel::CelValue, mock_cel::CelValue>>
+ header_items;
+ for (const auto& header_key : header_keys_) {
+ auto header_item = headers.find(header_key);
+ if (header_item != headers.end()) {
+ header_items.push_back(
+ std::pair<mock_cel::CelValue, mock_cel::CelValue>(
+ mock_cel::CelValue::CreateStringView(header_key),
+ mock_cel::CelValue::CreateStringView(header_item->second)));
+ }
+ }
+ headers_ = mock_cel::ContainerBackedMapImpl::Create(
+ y_absl::Span<std::pair<mock_cel::CelValue, mock_cel::CelValue>>(
+ header_items));
+ activation->InsertValue(kHeaders,
+ mock_cel::CelValue::CreateMap(headers_.get()));
+ } else if (elem == kSourceAddress) {
+ y_absl::string_view source_address(args.GetPeerAddress());
+ if (!source_address.empty()) {
+ activation->InsertValue(
+ kSourceAddress,
+ mock_cel::CelValue::CreateStringView(source_address));
+ }
+ } else if (elem == kSourcePort) {
+ activation->InsertValue(
+ kSourcePort, mock_cel::CelValue::CreateInt64(args.GetPeerPort()));
+ } else if (elem == kDestinationAddress) {
+ y_absl::string_view destination_address(args.GetLocalAddress());
+ if (!destination_address.empty()) {
+ activation->InsertValue(
+ kDestinationAddress,
+ mock_cel::CelValue::CreateStringView(destination_address));
+ }
+ } else if (elem == kDestinationPort) {
+ activation->InsertValue(kDestinationPort, mock_cel::CelValue::CreateInt64(
+ args.GetLocalPort()));
+ } else if (elem == kSpiffeId) {
+ y_absl::string_view spiffe_id(args.GetSpiffeId());
+ if (!spiffe_id.empty()) {
+ activation->InsertValue(
+ kSpiffeId, mock_cel::CelValue::CreateStringView(spiffe_id));
+ }
+ } else if (elem == kCertServerName) {
+ y_absl::string_view cert_server_name(args.GetCertServerName());
+ if (!cert_server_name.empty()) {
+ activation->InsertValue(
+ kCertServerName,
+ mock_cel::CelValue::CreateStringView(cert_server_name));
+ }
+ } else {
+ gpr_log(GPR_ERROR,
+ "Error: Authorization engine does not support evaluating "
+ "attribute %s.",
+ elem.c_str());
+ }
+ }
+ return activation;
+}
+
+} // namespace grpc_core
diff --git a/contrib/libs/grpc/src/core/lib/security/authorization/authorization_engine.h b/contrib/libs/grpc/src/core/lib/security/authorization/authorization_engine.h
index 38e3fb42e2..24cded28a3 100644
--- a/contrib/libs/grpc/src/core/lib/security/authorization/authorization_engine.h
+++ b/contrib/libs/grpc/src/core/lib/security/authorization/authorization_engine.h
@@ -1,84 +1,84 @@
-
-// Copyright 2020 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_AUTHORIZATION_ENGINE_H
-#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_AUTHORIZATION_ENGINE_H
-
-#include <grpc/support/port_platform.h>
-
-#include <grpc/support/log.h>
-#include <map>
-#include <memory>
-#include <util/generic/string.h>
-#include <vector>
-
-#include "y_absl/container/flat_hash_set.h"
-#include "envoy/config/rbac/v3/rbac.upb.h"
-#include "google/api/expr/v1alpha1/syntax.upb.h"
-#include "upb/upb.hpp"
-
-#include "src/core/lib/security/authorization/evaluate_args.h"
-#include "src/core/lib/security/authorization/mock_cel/activation.h"
-
-namespace grpc_core {
-
-// AuthorizationEngine makes an AuthorizationDecision to ALLOW or DENY the
-// current action based on the condition fields in provided RBAC policies.
-// The engine may be constructed with one or two policies. If two polcies,
-// the first policy is deny-if-matched and the second is allow-if-matched.
-// The engine returns UNDECIDED decision if it fails to find a match in any
-// policy. This engine ignores the principal and permission fields in RBAC
-// policies. It is the caller's responsibility to provide RBAC policies that
-// are compatible with this engine.
-//
-// Example:
-// AuthorizationEngine*
-// auth_engine = AuthorizationEngine::CreateAuthorizationEngine(rbac_policies);
-// auth_engine->Evaluate(evaluate_args); // returns authorization decision.
-class AuthorizationEngine {
- public:
- // rbac_policies must be a vector containing either a single policy of any
- // kind, or one deny policy and one allow policy, in that order.
- static std::unique_ptr<AuthorizationEngine> CreateAuthorizationEngine(
- const std::vector<envoy_config_rbac_v3_RBAC*>& rbac_policies);
-
- // Users should use the CreateAuthorizationEngine factory function
- // instead of calling the AuthorizationEngine constructor directly.
- explicit AuthorizationEngine(
- const std::vector<envoy_config_rbac_v3_RBAC*>& rbac_policies);
- // TODO(mywang@google.com): add an Evaluate member function.
-
- private:
- enum Action {
- kAllow,
- kDeny,
- };
-
- std::unique_ptr<mock_cel::Activation> CreateActivation(
- const EvaluateArgs& args);
-
- std::map<const TString, const google_api_expr_v1alpha1_Expr*>
- deny_if_matched_;
- std::map<const TString, const google_api_expr_v1alpha1_Expr*>
- allow_if_matched_;
- upb::Arena arena_;
- y_absl::flat_hash_set<TString> envoy_attributes_;
- y_absl::flat_hash_set<TString> header_keys_;
- std::unique_ptr<mock_cel::CelMap> headers_;
-};
-
-} // namespace grpc_core
-
-#endif /* GRPC_CORE_LIB_SECURITY_AUTHORIZATION_AUTHORIZATION_ENGINE_H */
+
+// Copyright 2020 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_AUTHORIZATION_ENGINE_H
+#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_AUTHORIZATION_ENGINE_H
+
+#include <grpc/support/port_platform.h>
+
+#include <grpc/support/log.h>
+#include <map>
+#include <memory>
+#include <util/generic/string.h>
+#include <vector>
+
+#include "y_absl/container/flat_hash_set.h"
+#include "envoy/config/rbac/v3/rbac.upb.h"
+#include "google/api/expr/v1alpha1/syntax.upb.h"
+#include "upb/upb.hpp"
+
+#include "src/core/lib/security/authorization/evaluate_args.h"
+#include "src/core/lib/security/authorization/mock_cel/activation.h"
+
+namespace grpc_core {
+
+// AuthorizationEngine makes an AuthorizationDecision to ALLOW or DENY the
+// current action based on the condition fields in provided RBAC policies.
+// The engine may be constructed with one or two policies. If two polcies,
+// the first policy is deny-if-matched and the second is allow-if-matched.
+// The engine returns UNDECIDED decision if it fails to find a match in any
+// policy. This engine ignores the principal and permission fields in RBAC
+// policies. It is the caller's responsibility to provide RBAC policies that
+// are compatible with this engine.
+//
+// Example:
+// AuthorizationEngine*
+// auth_engine = AuthorizationEngine::CreateAuthorizationEngine(rbac_policies);
+// auth_engine->Evaluate(evaluate_args); // returns authorization decision.
+class AuthorizationEngine {
+ public:
+ // rbac_policies must be a vector containing either a single policy of any
+ // kind, or one deny policy and one allow policy, in that order.
+ static std::unique_ptr<AuthorizationEngine> CreateAuthorizationEngine(
+ const std::vector<envoy_config_rbac_v3_RBAC*>& rbac_policies);
+
+ // Users should use the CreateAuthorizationEngine factory function
+ // instead of calling the AuthorizationEngine constructor directly.
+ explicit AuthorizationEngine(
+ const std::vector<envoy_config_rbac_v3_RBAC*>& rbac_policies);
+ // TODO(mywang@google.com): add an Evaluate member function.
+
+ private:
+ enum Action {
+ kAllow,
+ kDeny,
+ };
+
+ std::unique_ptr<mock_cel::Activation> CreateActivation(
+ const EvaluateArgs& args);
+
+ std::map<const TString, const google_api_expr_v1alpha1_Expr*>
+ deny_if_matched_;
+ std::map<const TString, const google_api_expr_v1alpha1_Expr*>
+ allow_if_matched_;
+ upb::Arena arena_;
+ y_absl::flat_hash_set<TString> envoy_attributes_;
+ y_absl::flat_hash_set<TString> header_keys_;
+ std::unique_ptr<mock_cel::CelMap> headers_;
+};
+
+} // namespace grpc_core
+
+#endif /* GRPC_CORE_LIB_SECURITY_AUTHORIZATION_AUTHORIZATION_ENGINE_H */
diff --git a/contrib/libs/grpc/src/core/lib/security/authorization/evaluate_args.cc b/contrib/libs/grpc/src/core/lib/security/authorization/evaluate_args.cc
index 8f3e1ea6b3..48af382f12 100644
--- a/contrib/libs/grpc/src/core/lib/security/authorization/evaluate_args.cc
+++ b/contrib/libs/grpc/src/core/lib/security/authorization/evaluate_args.cc
@@ -1,153 +1,153 @@
-//
-//
-// Copyright 2020 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//
-
-#include <grpc/support/port_platform.h>
-
-#include "src/core/lib/security/authorization/evaluate_args.h"
-
-#include "src/core/lib/iomgr/parse_address.h"
-#include "src/core/lib/iomgr/resolve_address.h"
-#include "src/core/lib/iomgr/sockaddr_utils.h"
-#include "src/core/lib/slice/slice_utils.h"
-
-namespace grpc_core {
-
-y_absl::string_view EvaluateArgs::GetPath() const {
- y_absl::string_view path;
- if (metadata_ != nullptr && metadata_->idx.named.path != nullptr) {
- grpc_linked_mdelem* elem = metadata_->idx.named.path;
- const grpc_slice& val = GRPC_MDVALUE(elem->md);
- path = StringViewFromSlice(val);
- }
- return path;
-}
-
-y_absl::string_view EvaluateArgs::GetHost() const {
- y_absl::string_view host;
- if (metadata_ != nullptr && metadata_->idx.named.host != nullptr) {
- grpc_linked_mdelem* elem = metadata_->idx.named.host;
- const grpc_slice& val = GRPC_MDVALUE(elem->md);
- host = StringViewFromSlice(val);
- }
- return host;
-}
-
-y_absl::string_view EvaluateArgs::GetMethod() const {
- y_absl::string_view method;
- if (metadata_ != nullptr && metadata_->idx.named.method != nullptr) {
- grpc_linked_mdelem* elem = metadata_->idx.named.method;
- const grpc_slice& val = GRPC_MDVALUE(elem->md);
- method = StringViewFromSlice(val);
- }
- return method;
-}
-
-std::multimap<y_absl::string_view, y_absl::string_view> EvaluateArgs::GetHeaders()
- const {
- std::multimap<y_absl::string_view, y_absl::string_view> headers;
- if (metadata_ == nullptr) {
- return headers;
- }
- for (grpc_linked_mdelem* elem = metadata_->list.head; elem != nullptr;
- elem = elem->next) {
- const grpc_slice& key = GRPC_MDKEY(elem->md);
- const grpc_slice& val = GRPC_MDVALUE(elem->md);
- headers.emplace(StringViewFromSlice(key), StringViewFromSlice(val));
- }
- return headers;
-}
-
-y_absl::string_view EvaluateArgs::GetLocalAddress() const {
- y_absl::string_view addr = grpc_endpoint_get_local_address(endpoint_);
- size_t first_colon = addr.find(":");
- size_t last_colon = addr.rfind(":");
- if (first_colon == TString::npos || last_colon == TString::npos) {
- return "";
- } else {
- return addr.substr(first_colon + 1, last_colon - first_colon - 1);
- }
-}
-
-int EvaluateArgs::GetLocalPort() const {
- if (endpoint_ == nullptr) {
- return 0;
- }
- grpc_uri* uri = grpc_uri_parse(
- TString(grpc_endpoint_get_local_address(endpoint_)).c_str(), true);
- grpc_resolved_address resolved_addr;
- if (uri == nullptr || !grpc_parse_uri(uri, &resolved_addr)) {
- grpc_uri_destroy(uri);
- return 0;
- }
- grpc_uri_destroy(uri);
- return grpc_sockaddr_get_port(&resolved_addr);
-}
-
-y_absl::string_view EvaluateArgs::GetPeerAddress() const {
- y_absl::string_view addr = grpc_endpoint_get_peer(endpoint_);
- size_t first_colon = addr.find(":");
- size_t last_colon = addr.rfind(":");
- if (first_colon == TString::npos || last_colon == TString::npos) {
- return "";
- } else {
- return addr.substr(first_colon + 1, last_colon - first_colon - 1);
- }
-}
-
-int EvaluateArgs::GetPeerPort() const {
- if (endpoint_ == nullptr) {
- return 0;
- }
- grpc_uri* uri = grpc_uri_parse(
- TString(grpc_endpoint_get_peer(endpoint_)).c_str(), true);
- grpc_resolved_address resolved_addr;
- if (uri == nullptr || !grpc_parse_uri(uri, &resolved_addr)) {
- grpc_uri_destroy(uri);
- return 0;
- }
- grpc_uri_destroy(uri);
- return grpc_sockaddr_get_port(&resolved_addr);
-}
-
-y_absl::string_view EvaluateArgs::GetSpiffeId() const {
- if (auth_context_ == nullptr) {
- return "";
- }
- grpc_auth_property_iterator it = grpc_auth_context_find_properties_by_name(
- auth_context_, GRPC_PEER_SPIFFE_ID_PROPERTY_NAME);
- const grpc_auth_property* prop = grpc_auth_property_iterator_next(&it);
- if (prop == nullptr || grpc_auth_property_iterator_next(&it) != nullptr) {
- return "";
- }
- return y_absl::string_view(prop->value, prop->value_length);
-}
-
-y_absl::string_view EvaluateArgs::GetCertServerName() const {
- if (auth_context_ == nullptr) {
- return "";
- }
- grpc_auth_property_iterator it = grpc_auth_context_find_properties_by_name(
- auth_context_, GRPC_X509_CN_PROPERTY_NAME);
- const grpc_auth_property* prop = grpc_auth_property_iterator_next(&it);
- if (prop == nullptr || grpc_auth_property_iterator_next(&it) != nullptr) {
- return "";
- }
- return y_absl::string_view(prop->value, prop->value_length);
-}
-
-} // namespace grpc_core
+//
+//
+// Copyright 2020 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//
+
+#include <grpc/support/port_platform.h>
+
+#include "src/core/lib/security/authorization/evaluate_args.h"
+
+#include "src/core/lib/iomgr/parse_address.h"
+#include "src/core/lib/iomgr/resolve_address.h"
+#include "src/core/lib/iomgr/sockaddr_utils.h"
+#include "src/core/lib/slice/slice_utils.h"
+
+namespace grpc_core {
+
+y_absl::string_view EvaluateArgs::GetPath() const {
+ y_absl::string_view path;
+ if (metadata_ != nullptr && metadata_->idx.named.path != nullptr) {
+ grpc_linked_mdelem* elem = metadata_->idx.named.path;
+ const grpc_slice& val = GRPC_MDVALUE(elem->md);
+ path = StringViewFromSlice(val);
+ }
+ return path;
+}
+
+y_absl::string_view EvaluateArgs::GetHost() const {
+ y_absl::string_view host;
+ if (metadata_ != nullptr && metadata_->idx.named.host != nullptr) {
+ grpc_linked_mdelem* elem = metadata_->idx.named.host;
+ const grpc_slice& val = GRPC_MDVALUE(elem->md);
+ host = StringViewFromSlice(val);
+ }
+ return host;
+}
+
+y_absl::string_view EvaluateArgs::GetMethod() const {
+ y_absl::string_view method;
+ if (metadata_ != nullptr && metadata_->idx.named.method != nullptr) {
+ grpc_linked_mdelem* elem = metadata_->idx.named.method;
+ const grpc_slice& val = GRPC_MDVALUE(elem->md);
+ method = StringViewFromSlice(val);
+ }
+ return method;
+}
+
+std::multimap<y_absl::string_view, y_absl::string_view> EvaluateArgs::GetHeaders()
+ const {
+ std::multimap<y_absl::string_view, y_absl::string_view> headers;
+ if (metadata_ == nullptr) {
+ return headers;
+ }
+ for (grpc_linked_mdelem* elem = metadata_->list.head; elem != nullptr;
+ elem = elem->next) {
+ const grpc_slice& key = GRPC_MDKEY(elem->md);
+ const grpc_slice& val = GRPC_MDVALUE(elem->md);
+ headers.emplace(StringViewFromSlice(key), StringViewFromSlice(val));
+ }
+ return headers;
+}
+
+y_absl::string_view EvaluateArgs::GetLocalAddress() const {
+ y_absl::string_view addr = grpc_endpoint_get_local_address(endpoint_);
+ size_t first_colon = addr.find(":");
+ size_t last_colon = addr.rfind(":");
+ if (first_colon == TString::npos || last_colon == TString::npos) {
+ return "";
+ } else {
+ return addr.substr(first_colon + 1, last_colon - first_colon - 1);
+ }
+}
+
+int EvaluateArgs::GetLocalPort() const {
+ if (endpoint_ == nullptr) {
+ return 0;
+ }
+ grpc_uri* uri = grpc_uri_parse(
+ TString(grpc_endpoint_get_local_address(endpoint_)).c_str(), true);
+ grpc_resolved_address resolved_addr;
+ if (uri == nullptr || !grpc_parse_uri(uri, &resolved_addr)) {
+ grpc_uri_destroy(uri);
+ return 0;
+ }
+ grpc_uri_destroy(uri);
+ return grpc_sockaddr_get_port(&resolved_addr);
+}
+
+y_absl::string_view EvaluateArgs::GetPeerAddress() const {
+ y_absl::string_view addr = grpc_endpoint_get_peer(endpoint_);
+ size_t first_colon = addr.find(":");
+ size_t last_colon = addr.rfind(":");
+ if (first_colon == TString::npos || last_colon == TString::npos) {
+ return "";
+ } else {
+ return addr.substr(first_colon + 1, last_colon - first_colon - 1);
+ }
+}
+
+int EvaluateArgs::GetPeerPort() const {
+ if (endpoint_ == nullptr) {
+ return 0;
+ }
+ grpc_uri* uri = grpc_uri_parse(
+ TString(grpc_endpoint_get_peer(endpoint_)).c_str(), true);
+ grpc_resolved_address resolved_addr;
+ if (uri == nullptr || !grpc_parse_uri(uri, &resolved_addr)) {
+ grpc_uri_destroy(uri);
+ return 0;
+ }
+ grpc_uri_destroy(uri);
+ return grpc_sockaddr_get_port(&resolved_addr);
+}
+
+y_absl::string_view EvaluateArgs::GetSpiffeId() const {
+ if (auth_context_ == nullptr) {
+ return "";
+ }
+ grpc_auth_property_iterator it = grpc_auth_context_find_properties_by_name(
+ auth_context_, GRPC_PEER_SPIFFE_ID_PROPERTY_NAME);
+ const grpc_auth_property* prop = grpc_auth_property_iterator_next(&it);
+ if (prop == nullptr || grpc_auth_property_iterator_next(&it) != nullptr) {
+ return "";
+ }
+ return y_absl::string_view(prop->value, prop->value_length);
+}
+
+y_absl::string_view EvaluateArgs::GetCertServerName() const {
+ if (auth_context_ == nullptr) {
+ return "";
+ }
+ grpc_auth_property_iterator it = grpc_auth_context_find_properties_by_name(
+ auth_context_, GRPC_X509_CN_PROPERTY_NAME);
+ const grpc_auth_property* prop = grpc_auth_property_iterator_next(&it);
+ if (prop == nullptr || grpc_auth_property_iterator_next(&it) != nullptr) {
+ return "";
+ }
+ return y_absl::string_view(prop->value, prop->value_length);
+}
+
+} // namespace grpc_core
diff --git a/contrib/libs/grpc/src/core/lib/security/authorization/evaluate_args.h b/contrib/libs/grpc/src/core/lib/security/authorization/evaluate_args.h
index 9f72af4862..1409cdc6c3 100644
--- a/contrib/libs/grpc/src/core/lib/security/authorization/evaluate_args.h
+++ b/contrib/libs/grpc/src/core/lib/security/authorization/evaluate_args.h
@@ -1,59 +1,59 @@
-//
-//
-// Copyright 2020 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//
-
-#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_EVALUATE_ARGS_H
-#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_EVALUATE_ARGS_H
-
-#include <grpc/support/port_platform.h>
-
-#include <map>
-
-#include "src/core/lib/iomgr/endpoint.h"
-#include "src/core/lib/security/context/security_context.h"
-#include "src/core/lib/transport/metadata_batch.h"
-
-namespace grpc_core {
-
-class EvaluateArgs {
- public:
- EvaluateArgs(grpc_metadata_batch* metadata, grpc_auth_context* auth_context,
- grpc_endpoint* endpoint)
- : metadata_(metadata), auth_context_(auth_context), endpoint_(endpoint) {}
-
- y_absl::string_view GetPath() const;
- y_absl::string_view GetHost() const;
- y_absl::string_view GetMethod() const;
- std::multimap<y_absl::string_view, y_absl::string_view> GetHeaders() const;
- y_absl::string_view GetLocalAddress() const;
- int GetLocalPort() const;
- y_absl::string_view GetPeerAddress() const;
- int GetPeerPort() const;
- y_absl::string_view GetSpiffeId() const;
- y_absl::string_view GetCertServerName() const;
-
- // TODO: Add a getter function for source.principal
-
- private:
- grpc_metadata_batch* metadata_;
- grpc_auth_context* auth_context_;
- grpc_endpoint* endpoint_;
-};
-
-} // namespace grpc_core
-
-#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_EVALUATE_ARGS_H
+//
+//
+// Copyright 2020 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//
+
+#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_EVALUATE_ARGS_H
+#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_EVALUATE_ARGS_H
+
+#include <grpc/support/port_platform.h>
+
+#include <map>
+
+#include "src/core/lib/iomgr/endpoint.h"
+#include "src/core/lib/security/context/security_context.h"
+#include "src/core/lib/transport/metadata_batch.h"
+
+namespace grpc_core {
+
+class EvaluateArgs {
+ public:
+ EvaluateArgs(grpc_metadata_batch* metadata, grpc_auth_context* auth_context,
+ grpc_endpoint* endpoint)
+ : metadata_(metadata), auth_context_(auth_context), endpoint_(endpoint) {}
+
+ y_absl::string_view GetPath() const;
+ y_absl::string_view GetHost() const;
+ y_absl::string_view GetMethod() const;
+ std::multimap<y_absl::string_view, y_absl::string_view> GetHeaders() const;
+ y_absl::string_view GetLocalAddress() const;
+ int GetLocalPort() const;
+ y_absl::string_view GetPeerAddress() const;
+ int GetPeerPort() const;
+ y_absl::string_view GetSpiffeId() const;
+ y_absl::string_view GetCertServerName() const;
+
+ // TODO: Add a getter function for source.principal
+
+ private:
+ grpc_metadata_batch* metadata_;
+ grpc_auth_context* auth_context_;
+ grpc_endpoint* endpoint_;
+};
+
+} // namespace grpc_core
+
+#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_EVALUATE_ARGS_H
diff --git a/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/activation.h b/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/activation.h
index 8beccfd014..34520c761d 100644
--- a/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/activation.h
+++ b/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/activation.h
@@ -1,57 +1,57 @@
-// Copyright 2020 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_ACTIVATION_H
-#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_ACTIVATION_H
-
-#include <grpc/support/port_platform.h>
-
-#include "y_absl/strings/string_view.h"
-
-#include "src/core/lib/security/authorization/mock_cel/cel_value.h"
-
-namespace grpc_core {
-namespace mock_cel {
-
-// Base class for an activation. This is a temporary stub implementation of CEL
-// APIs. Once gRPC imports the CEL library, this class will be removed.
-class BaseActivation {
- public:
- BaseActivation() = default;
-
- // Non-copyable/non-assignable
- BaseActivation(const BaseActivation&) = delete;
- BaseActivation& operator=(const BaseActivation&) = delete;
-};
-
-// Instance of Activation class is used by evaluator.
-// It provides binding between references used in expressions
-// and actual values. This is a temporary stub implementation of CEL APIs.
-// Once gRPC imports the CEL library, this class will be removed.
-class Activation : public BaseActivation {
- public:
- Activation() = default;
-
- // Non-copyable/non-assignable
- Activation(const Activation&) = delete;
- Activation& operator=(const Activation&) = delete;
-
- // Insert value into Activation.
- void InsertValue(y_absl::string_view name, const CelValue& value) {}
-};
-
-} // namespace mock_cel
-} // namespace grpc_core
-
-#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_ACTIVATION_H
+// Copyright 2020 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_ACTIVATION_H
+#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_ACTIVATION_H
+
+#include <grpc/support/port_platform.h>
+
+#include "y_absl/strings/string_view.h"
+
+#include "src/core/lib/security/authorization/mock_cel/cel_value.h"
+
+namespace grpc_core {
+namespace mock_cel {
+
+// Base class for an activation. This is a temporary stub implementation of CEL
+// APIs. Once gRPC imports the CEL library, this class will be removed.
+class BaseActivation {
+ public:
+ BaseActivation() = default;
+
+ // Non-copyable/non-assignable
+ BaseActivation(const BaseActivation&) = delete;
+ BaseActivation& operator=(const BaseActivation&) = delete;
+};
+
+// Instance of Activation class is used by evaluator.
+// It provides binding between references used in expressions
+// and actual values. This is a temporary stub implementation of CEL APIs.
+// Once gRPC imports the CEL library, this class will be removed.
+class Activation : public BaseActivation {
+ public:
+ Activation() = default;
+
+ // Non-copyable/non-assignable
+ Activation(const Activation&) = delete;
+ Activation& operator=(const Activation&) = delete;
+
+ // Insert value into Activation.
+ void InsertValue(y_absl::string_view name, const CelValue& value) {}
+};
+
+} // namespace mock_cel
+} // namespace grpc_core
+
+#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_ACTIVATION_H
diff --git a/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h b/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h
index d97e2aaca7..9bacaeede7 100644
--- a/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h
+++ b/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h
@@ -1,42 +1,42 @@
-// Copyright 2020 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_EXPR_BUILDER_FACTORY_H
-#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_EXPR_BUILDER_FACTORY_H
-
-#include <grpc/support/port_platform.h>
-
-#include <memory>
-
-#include "src/core/lib/security/authorization/mock_cel/flat_expr_builder.h"
-
-namespace grpc_core {
-namespace mock_cel {
-
-// This is a temporary stub implementation of CEL APIs.
-// Once gRPC imports the CEL library, this file will be removed.
-
-struct InterpreterOptions {
- bool short_circuiting = true;
-};
-
-std::unique_ptr<CelExpressionBuilder> CreateCelExpressionBuilder(
- const InterpreterOptions& options) {
- return y_absl::make_unique<FlatExprBuilder>();
-}
-
-} // namespace mock_cel
-} // namespace grpc_core
-
-#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_EXPR_BUILDER_FACTORY_H \ No newline at end of file
+// Copyright 2020 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_EXPR_BUILDER_FACTORY_H
+#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_EXPR_BUILDER_FACTORY_H
+
+#include <grpc/support/port_platform.h>
+
+#include <memory>
+
+#include "src/core/lib/security/authorization/mock_cel/flat_expr_builder.h"
+
+namespace grpc_core {
+namespace mock_cel {
+
+// This is a temporary stub implementation of CEL APIs.
+// Once gRPC imports the CEL library, this file will be removed.
+
+struct InterpreterOptions {
+ bool short_circuiting = true;
+};
+
+std::unique_ptr<CelExpressionBuilder> CreateCelExpressionBuilder(
+ const InterpreterOptions& options) {
+ return y_absl::make_unique<FlatExprBuilder>();
+}
+
+} // namespace mock_cel
+} // namespace grpc_core
+
+#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_EXPR_BUILDER_FACTORY_H \ No newline at end of file
diff --git a/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/cel_expression.h b/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/cel_expression.h
index 7ed9d9e38b..4ee422e942 100644
--- a/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/cel_expression.h
+++ b/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/cel_expression.h
@@ -1,68 +1,68 @@
-// Copyright 2020 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_EXPRESSION_H
-#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_EXPRESSION_H
-
-#include <grpc/support/port_platform.h>
-
-#include <memory>
-#include <vector>
-
-#include "google/api/expr/v1alpha1/syntax.upb.h"
-#include "src/core/lib/security/authorization/mock_cel/activation.h"
-#include "src/core/lib/security/authorization/mock_cel/cel_value.h"
-#include "src/core/lib/security/authorization/mock_cel/statusor.h"
-
-namespace grpc_core {
-namespace mock_cel {
-
-// This is a temporary stub implementation of CEL APIs.
-// Once gRPC imports the CEL library, this file will be removed.
-
-// Base interface for expression evaluating objects.
-class CelExpression {
- public:
- virtual ~CelExpression() = default;
-
- // Evaluates expression and returns value.
- // activation contains bindings from parameter names to values
- virtual StatusOr<CelValue> Evaluate(
- const BaseActivation& activation) const = 0;
-};
-
-// Base class for Expression Builder implementations
-// Provides user with factory to register extension functions.
-// ExpressionBuilder MUST NOT be destroyed before CelExpression objects
-// it built.
-class CelExpressionBuilder {
- public:
- virtual ~CelExpressionBuilder() = default;
-
- // Creates CelExpression object from AST tree.
- // expr specifies root of AST tree
- virtual StatusOr<std::unique_ptr<CelExpression>> CreateExpression(
- const google_api_expr_v1alpha1_Expr* expr,
- const google_api_expr_v1alpha1_SourceInfo* source_info) const = 0;
-
- virtual StatusOr<std::unique_ptr<CelExpression>> CreateExpression(
- const google_api_expr_v1alpha1_Expr* expr,
- const google_api_expr_v1alpha1_SourceInfo* source_info,
- std::vector<y_absl::Status>* warnings) const = 0;
-};
-
-} // namespace mock_cel
-} // namespace grpc_core
-
-#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_EXPRESSION_H \ No newline at end of file
+// Copyright 2020 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_EXPRESSION_H
+#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_EXPRESSION_H
+
+#include <grpc/support/port_platform.h>
+
+#include <memory>
+#include <vector>
+
+#include "google/api/expr/v1alpha1/syntax.upb.h"
+#include "src/core/lib/security/authorization/mock_cel/activation.h"
+#include "src/core/lib/security/authorization/mock_cel/cel_value.h"
+#include "src/core/lib/security/authorization/mock_cel/statusor.h"
+
+namespace grpc_core {
+namespace mock_cel {
+
+// This is a temporary stub implementation of CEL APIs.
+// Once gRPC imports the CEL library, this file will be removed.
+
+// Base interface for expression evaluating objects.
+class CelExpression {
+ public:
+ virtual ~CelExpression() = default;
+
+ // Evaluates expression and returns value.
+ // activation contains bindings from parameter names to values
+ virtual StatusOr<CelValue> Evaluate(
+ const BaseActivation& activation) const = 0;
+};
+
+// Base class for Expression Builder implementations
+// Provides user with factory to register extension functions.
+// ExpressionBuilder MUST NOT be destroyed before CelExpression objects
+// it built.
+class CelExpressionBuilder {
+ public:
+ virtual ~CelExpressionBuilder() = default;
+
+ // Creates CelExpression object from AST tree.
+ // expr specifies root of AST tree
+ virtual StatusOr<std::unique_ptr<CelExpression>> CreateExpression(
+ const google_api_expr_v1alpha1_Expr* expr,
+ const google_api_expr_v1alpha1_SourceInfo* source_info) const = 0;
+
+ virtual StatusOr<std::unique_ptr<CelExpression>> CreateExpression(
+ const google_api_expr_v1alpha1_Expr* expr,
+ const google_api_expr_v1alpha1_SourceInfo* source_info,
+ std::vector<y_absl::Status>* warnings) const = 0;
+};
+
+} // namespace mock_cel
+} // namespace grpc_core
+
+#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_EXPRESSION_H \ No newline at end of file
diff --git a/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/cel_value.h b/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/cel_value.h
index 6aad178ade..d06b1fcec4 100644
--- a/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/cel_value.h
+++ b/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/cel_value.h
@@ -1,93 +1,93 @@
-// Copyright 2020 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_VALUE_H
-#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_VALUE_H
-
-// CelValue is a holder, capable of storing all kinds of data
-// supported by CEL.
-// CelValue defines explicitly typed/named getters/setters.
-// When storing pointers to objects, CelValue does not accept ownership
-// to them and does not control their lifecycle. Instead objects are expected
-// to be either external to expression evaluation, and controlled beyond the
-// scope or to be allocated and associated with some allocation/ownership
-// controller (Arena).
-// Usage examples:
-// (a) For primitive types:
-// CelValue value = CelValue::CreateInt64(1);
-// (b) For string:
-// TString* msg("test");
-// CelValue value = CelValue::CreateString(msg);
-
-#include <grpc/support/port_platform.h>
-
-#include "y_absl/strings/string_view.h"
-
-namespace grpc_core {
-namespace mock_cel {
-
-// Break cyclic depdendencies for container types.
-class CelMap {
- public:
- CelMap() = default;
-};
-
-// This is a temporary stub implementation of CEL APIs.
-// Once gRPC imports the CEL library, this class will be removed.
-class CelValue {
- public:
- // Default constructor.
- // Creates CelValue with null data type.
- CelValue() : CelValue(nullptr) {}
-
- // We will use factory methods instead of public constructors
- // The reason for this is the high risk of implicit type conversions
- // between bool/int/pointer types.
- // We rely on copy elision to avoid extra copying.
- static CelValue CreateNull() { return CelValue(nullptr); }
-
- static CelValue CreateInt64(int64_t value) { return CreateNull(); }
-
- static CelValue CreateUint64(uint64_t value) { return CreateNull(); }
-
- static CelValue CreateStringView(y_absl::string_view value) {
- return CreateNull();
- }
-
- static CelValue CreateString(const TString* str) { return CreateNull(); }
-
- static CelValue CreateMap(const CelMap* value) { return CreateNull(); }
-
- private:
- // Constructs CelValue wrapping value supplied as argument.
- // Value type T should be supported by specification of ValueHolder.
- template <class T>
- explicit CelValue(T value) {}
-};
-
-// CelMap implementation that uses STL map container as backing storage.
-class ContainerBackedMapImpl : public CelMap {
- public:
- ContainerBackedMapImpl() = default;
-
- static std::unique_ptr<CelMap> Create(
- y_absl::Span<std::pair<CelValue, CelValue>> key_values) {
- return y_absl::make_unique<ContainerBackedMapImpl>();
- }
-};
-
-} // namespace mock_cel
-} // namespace grpc_core
-
-#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_VALUE_H
+// Copyright 2020 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_VALUE_H
+#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_VALUE_H
+
+// CelValue is a holder, capable of storing all kinds of data
+// supported by CEL.
+// CelValue defines explicitly typed/named getters/setters.
+// When storing pointers to objects, CelValue does not accept ownership
+// to them and does not control their lifecycle. Instead objects are expected
+// to be either external to expression evaluation, and controlled beyond the
+// scope or to be allocated and associated with some allocation/ownership
+// controller (Arena).
+// Usage examples:
+// (a) For primitive types:
+// CelValue value = CelValue::CreateInt64(1);
+// (b) For string:
+// TString* msg("test");
+// CelValue value = CelValue::CreateString(msg);
+
+#include <grpc/support/port_platform.h>
+
+#include "y_absl/strings/string_view.h"
+
+namespace grpc_core {
+namespace mock_cel {
+
+// Break cyclic depdendencies for container types.
+class CelMap {
+ public:
+ CelMap() = default;
+};
+
+// This is a temporary stub implementation of CEL APIs.
+// Once gRPC imports the CEL library, this class will be removed.
+class CelValue {
+ public:
+ // Default constructor.
+ // Creates CelValue with null data type.
+ CelValue() : CelValue(nullptr) {}
+
+ // We will use factory methods instead of public constructors
+ // The reason for this is the high risk of implicit type conversions
+ // between bool/int/pointer types.
+ // We rely on copy elision to avoid extra copying.
+ static CelValue CreateNull() { return CelValue(nullptr); }
+
+ static CelValue CreateInt64(int64_t value) { return CreateNull(); }
+
+ static CelValue CreateUint64(uint64_t value) { return CreateNull(); }
+
+ static CelValue CreateStringView(y_absl::string_view value) {
+ return CreateNull();
+ }
+
+ static CelValue CreateString(const TString* str) { return CreateNull(); }
+
+ static CelValue CreateMap(const CelMap* value) { return CreateNull(); }
+
+ private:
+ // Constructs CelValue wrapping value supplied as argument.
+ // Value type T should be supported by specification of ValueHolder.
+ template <class T>
+ explicit CelValue(T value) {}
+};
+
+// CelMap implementation that uses STL map container as backing storage.
+class ContainerBackedMapImpl : public CelMap {
+ public:
+ ContainerBackedMapImpl() = default;
+
+ static std::unique_ptr<CelMap> Create(
+ y_absl::Span<std::pair<CelValue, CelValue>> key_values) {
+ return y_absl::make_unique<ContainerBackedMapImpl>();
+ }
+};
+
+} // namespace mock_cel
+} // namespace grpc_core
+
+#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_VALUE_H
diff --git a/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/evaluator_core.h b/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/evaluator_core.h
index d254747a6c..8362e10175 100644
--- a/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/evaluator_core.h
+++ b/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/evaluator_core.h
@@ -1,67 +1,67 @@
-// Copyright 2020 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_EVALUATOR_CORE_H
-#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_EVALUATOR_CORE_H
-
-#include <grpc/support/port_platform.h>
-
-#include <memory>
-#include <set>
-#include <vector>
-
-#include "google/api/expr/v1alpha1/syntax.upb.h"
-#include "src/core/lib/security/authorization/mock_cel/activation.h"
-#include "src/core/lib/security/authorization/mock_cel/cel_expression.h"
-#include "src/core/lib/security/authorization/mock_cel/cel_value.h"
-#include "src/core/lib/security/authorization/mock_cel/statusor.h"
-
-namespace grpc_core {
-namespace mock_cel {
-
-// This is a temporary stub implementation of CEL APIs.
-// Once gRPC imports the CEL library, this file will be removed.
-
-class ExpressionStep {
- public:
- virtual ~ExpressionStep() = default;
-};
-
-using ExecutionPath = std::vector<std::unique_ptr<const ExpressionStep>>;
-
-// Implementation of the CelExpression that utilizes flattening
-// of the expression tree.
-class CelExpressionFlatImpl : public CelExpression {
- // Constructs CelExpressionFlatImpl instance.
- // path is flat execution path that is based upon
- // flattened AST tree. Max iterations dictates the maximum number of
- // iterations in the comprehension expressions (use 0 to disable the upper
- // bound).
- public:
- CelExpressionFlatImpl(const google_api_expr_v1alpha1_Expr* root_expr,
- ExecutionPath path, int max_iterations,
- std::set<TString> iter_variable_names,
- bool enable_unknowns = false,
- bool enable_unknown_function_results = false) {}
-
- // Implementation of CelExpression evaluate method.
- StatusOr<CelValue> Evaluate(const BaseActivation& activation) const override {
- return CelValue::CreateNull();
- }
-};
-
-} // namespace mock_cel
-} // namespace grpc_core
-
-#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_EVALUATOR_CORE_H \ No newline at end of file
+// Copyright 2020 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_EVALUATOR_CORE_H
+#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_EVALUATOR_CORE_H
+
+#include <grpc/support/port_platform.h>
+
+#include <memory>
+#include <set>
+#include <vector>
+
+#include "google/api/expr/v1alpha1/syntax.upb.h"
+#include "src/core/lib/security/authorization/mock_cel/activation.h"
+#include "src/core/lib/security/authorization/mock_cel/cel_expression.h"
+#include "src/core/lib/security/authorization/mock_cel/cel_value.h"
+#include "src/core/lib/security/authorization/mock_cel/statusor.h"
+
+namespace grpc_core {
+namespace mock_cel {
+
+// This is a temporary stub implementation of CEL APIs.
+// Once gRPC imports the CEL library, this file will be removed.
+
+class ExpressionStep {
+ public:
+ virtual ~ExpressionStep() = default;
+};
+
+using ExecutionPath = std::vector<std::unique_ptr<const ExpressionStep>>;
+
+// Implementation of the CelExpression that utilizes flattening
+// of the expression tree.
+class CelExpressionFlatImpl : public CelExpression {
+ // Constructs CelExpressionFlatImpl instance.
+ // path is flat execution path that is based upon
+ // flattened AST tree. Max iterations dictates the maximum number of
+ // iterations in the comprehension expressions (use 0 to disable the upper
+ // bound).
+ public:
+ CelExpressionFlatImpl(const google_api_expr_v1alpha1_Expr* root_expr,
+ ExecutionPath path, int max_iterations,
+ std::set<TString> iter_variable_names,
+ bool enable_unknowns = false,
+ bool enable_unknown_function_results = false) {}
+
+ // Implementation of CelExpression evaluate method.
+ StatusOr<CelValue> Evaluate(const BaseActivation& activation) const override {
+ return CelValue::CreateNull();
+ }
+};
+
+} // namespace mock_cel
+} // namespace grpc_core
+
+#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_EVALUATOR_CORE_H \ No newline at end of file
diff --git a/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h b/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h
index 682ee7a07d..c734704186 100644
--- a/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h
+++ b/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h
@@ -1,56 +1,56 @@
-// Copyright 2020 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_FLAT_EXPR_BUILDER_H
-#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_FLAT_EXPR_BUILDER_H
-
-#include <grpc/support/port_platform.h>
-
-#include <memory>
-
-#include "src/core/lib/security/authorization/mock_cel/evaluator_core.h"
-
-namespace grpc_core {
-namespace mock_cel {
-
-// This is a temporary stub implementation of CEL APIs.
-// Once gRPC imports the CEL library, this file will be removed.
-
-// CelExpressionBuilder implementation.
-// Builds instances of CelExpressionFlatImpl.
-class FlatExprBuilder : public CelExpressionBuilder {
- public:
- FlatExprBuilder() = default;
-
- cel_base::StatusOr<std::unique_ptr<CelExpression>> CreateExpression(
- const google::api::expr::v1alpha1::Expr* expr,
- const google::api::expr::v1alpha1::SourceInfo* source_info)
- const override {
- ExecutionPath path;
- return y_absl::make_unique<CelExpressionFlatImpl>(nullptr, path, 0);
- }
-
- cel_base::StatusOr<std::unique_ptr<CelExpression>> CreateExpression(
- const google::api::expr::v1alpha1::Expr* expr,
- const google::api::expr::v1alpha1::SourceInfo* source_info,
- std::vector<y_absl::Status>* warnings) const override {
- ExecutionPath path;
- return y_absl::make_unique<CelExpressionFlatImpl>(nullptr, path, 0);
- }
-};
-
-} // namespace mock_cel
-} // namespace grpc_core
-
-#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_FLAT_EXPR_BUILDER_H
+// Copyright 2020 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_FLAT_EXPR_BUILDER_H
+#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_FLAT_EXPR_BUILDER_H
+
+#include <grpc/support/port_platform.h>
+
+#include <memory>
+
+#include "src/core/lib/security/authorization/mock_cel/evaluator_core.h"
+
+namespace grpc_core {
+namespace mock_cel {
+
+// This is a temporary stub implementation of CEL APIs.
+// Once gRPC imports the CEL library, this file will be removed.
+
+// CelExpressionBuilder implementation.
+// Builds instances of CelExpressionFlatImpl.
+class FlatExprBuilder : public CelExpressionBuilder {
+ public:
+ FlatExprBuilder() = default;
+
+ cel_base::StatusOr<std::unique_ptr<CelExpression>> CreateExpression(
+ const google::api::expr::v1alpha1::Expr* expr,
+ const google::api::expr::v1alpha1::SourceInfo* source_info)
+ const override {
+ ExecutionPath path;
+ return y_absl::make_unique<CelExpressionFlatImpl>(nullptr, path, 0);
+ }
+
+ cel_base::StatusOr<std::unique_ptr<CelExpression>> CreateExpression(
+ const google::api::expr::v1alpha1::Expr* expr,
+ const google::api::expr::v1alpha1::SourceInfo* source_info,
+ std::vector<y_absl::Status>* warnings) const override {
+ ExecutionPath path;
+ return y_absl::make_unique<CelExpressionFlatImpl>(nullptr, path, 0);
+ }
+};
+
+} // namespace mock_cel
+} // namespace grpc_core
+
+#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_FLAT_EXPR_BUILDER_H
diff --git a/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/statusor.h b/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/statusor.h
index 37931d0893..2002d814c9 100644
--- a/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/statusor.h
+++ b/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/statusor.h
@@ -1,50 +1,50 @@
-// Copyright 2020 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_STATUSOR_H
-#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_STATUSOR_H
-
-#include <grpc/support/port_platform.h>
-
-#include <memory>
-
-#include "y_absl/status/status.h"
-
-namespace grpc_core {
-namespace mock_cel {
-
-// This is a temporary stub implementation of CEL APIs.
-// Once gRPC imports the CEL library, this file will be removed.
-
-template <typename T>
-class ABSL_MUST_USE_RESULT StatusOr;
-
-template <typename T>
-class StatusOr {
- public:
- StatusOr() = default;
-
- StatusOr(const T& value) {}
-
- StatusOr(const y_absl::Status& status) {}
-
- StatusOr(y_absl::Status&& status) {}
-
- bool ok() const { return true; }
-};
-
-} // namespace mock_cel
-} // namespace grpc_core
-
-#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_STATUSOR_H \ No newline at end of file
+// Copyright 2020 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_STATUSOR_H
+#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_STATUSOR_H
+
+#include <grpc/support/port_platform.h>
+
+#include <memory>
+
+#include "y_absl/status/status.h"
+
+namespace grpc_core {
+namespace mock_cel {
+
+// This is a temporary stub implementation of CEL APIs.
+// Once gRPC imports the CEL library, this file will be removed.
+
+template <typename T>
+class ABSL_MUST_USE_RESULT StatusOr;
+
+template <typename T>
+class StatusOr {
+ public:
+ StatusOr() = default;
+
+ StatusOr(const T& value) {}
+
+ StatusOr(const y_absl::Status& status) {}
+
+ StatusOr(y_absl::Status&& status) {}
+
+ bool ok() const { return true; }
+};
+
+} // namespace mock_cel
+} // namespace grpc_core
+
+#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_STATUSOR_H \ No newline at end of file
diff --git a/contrib/libs/grpc/src/core/lib/security/certificate_provider.h b/contrib/libs/grpc/src/core/lib/security/certificate_provider.h
index edf50e023b..5a9cfee0b9 100644
--- a/contrib/libs/grpc/src/core/lib/security/certificate_provider.h
+++ b/contrib/libs/grpc/src/core/lib/security/certificate_provider.h
@@ -1,60 +1,60 @@
-//
-//
-// Copyright 2020 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//
-
-#ifndef GRPC_CORE_LIB_SECURITY_CERTIFICATE_PROVIDER_H
-#define GRPC_CORE_LIB_SECURITY_CERTIFICATE_PROVIDER_H
-
-#include <grpc/support/port_platform.h>
-
-#include "src/core/lib/gprpp/ref_counted.h"
-#include "src/core/lib/gprpp/ref_counted_ptr.h"
-#include "src/core/lib/iomgr/pollset_set.h"
-
-// TODO(yashkt): After https://github.com/grpc/grpc/pull/23572, remove this
-// forward declaration and include the header for the distributor instead.
-struct grpc_tls_certificate_distributor;
-
-// Interface for a grpc_tls_certificate_provider that handles the process to
-// fetch credentials and validation contexts. Implementations are free to rely
-// on local or remote sources to fetch the latest secrets, and free to share any
-// state among different instances as they deem fit.
-//
-// On creation, grpc_tls_certificate_provider creates a
-// grpc_tls_certificate_distributor object. When the credentials and validation
-// contexts become valid or changed, a grpc_tls_certificate_provider should
-// notify its distributor so as to propagate the update to the watchers.
-struct grpc_tls_certificate_provider
- : public grpc_core::RefCounted<grpc_tls_certificate_provider> {
- public:
- grpc_tls_certificate_provider()
- : interested_parties_(grpc_pollset_set_create()) {}
-
- virtual ~grpc_tls_certificate_provider() {
- grpc_pollset_set_destroy(interested_parties_);
- }
-
- grpc_pollset_set* interested_parties() const { return interested_parties_; }
-
- virtual grpc_core::RefCountedPtr<grpc_tls_certificate_distributor>
- distributor() const = 0;
-
- private:
- grpc_pollset_set* interested_parties_;
-};
-
-#endif // GRPC_CORE_LIB_SECURITY_CERTIFICATE_PROVIDER_H
+//
+//
+// Copyright 2020 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//
+
+#ifndef GRPC_CORE_LIB_SECURITY_CERTIFICATE_PROVIDER_H
+#define GRPC_CORE_LIB_SECURITY_CERTIFICATE_PROVIDER_H
+
+#include <grpc/support/port_platform.h>
+
+#include "src/core/lib/gprpp/ref_counted.h"
+#include "src/core/lib/gprpp/ref_counted_ptr.h"
+#include "src/core/lib/iomgr/pollset_set.h"
+
+// TODO(yashkt): After https://github.com/grpc/grpc/pull/23572, remove this
+// forward declaration and include the header for the distributor instead.
+struct grpc_tls_certificate_distributor;
+
+// Interface for a grpc_tls_certificate_provider that handles the process to
+// fetch credentials and validation contexts. Implementations are free to rely
+// on local or remote sources to fetch the latest secrets, and free to share any
+// state among different instances as they deem fit.
+//
+// On creation, grpc_tls_certificate_provider creates a
+// grpc_tls_certificate_distributor object. When the credentials and validation
+// contexts become valid or changed, a grpc_tls_certificate_provider should
+// notify its distributor so as to propagate the update to the watchers.
+struct grpc_tls_certificate_provider
+ : public grpc_core::RefCounted<grpc_tls_certificate_provider> {
+ public:
+ grpc_tls_certificate_provider()
+ : interested_parties_(grpc_pollset_set_create()) {}
+
+ virtual ~grpc_tls_certificate_provider() {
+ grpc_pollset_set_destroy(interested_parties_);
+ }
+
+ grpc_pollset_set* interested_parties() const { return interested_parties_; }
+
+ virtual grpc_core::RefCountedPtr<grpc_tls_certificate_distributor>
+ distributor() const = 0;
+
+ private:
+ grpc_pollset_set* interested_parties_;
+};
+
+#endif // GRPC_CORE_LIB_SECURITY_CERTIFICATE_PROVIDER_H
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/alts/check_gcp_environment.cc b/contrib/libs/grpc/src/core/lib/security/credentials/alts/check_gcp_environment.cc
index 9962bf4469..9c98d7a5f4 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/alts/check_gcp_environment.cc
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/alts/check_gcp_environment.cc
@@ -30,7 +30,7 @@
const size_t kBiosDataBufferSize = 256;
static char* trim(const char* src) {
- if (src == nullptr || *src == '\0') {
+ if (src == nullptr || *src == '\0') {
return nullptr;
}
char* des = nullptr;
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/composite/composite_credentials.cc b/contrib/libs/grpc/src/core/lib/security/credentials/composite/composite_credentials.cc
index a39a910e95..a6c82d4774 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/composite/composite_credentials.cc
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/composite/composite_credentials.cc
@@ -22,10 +22,10 @@
#include <cstring>
#include <new>
-#include <vector>
+#include <vector>
-#include "y_absl/strings/str_cat.h"
-#include "y_absl/strings/str_join.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_join.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/iomgr/polling_entity.h"
#include "src/core/lib/surface/api_trace.h"
@@ -119,15 +119,15 @@ void grpc_composite_call_credentials::cancel_get_request_metadata(
GRPC_ERROR_UNREF(error);
}
-TString grpc_composite_call_credentials::debug_string() {
- std::vector<TString> outputs;
- for (auto& inner_cred : inner_) {
- outputs.emplace_back(inner_cred->debug_string());
- }
- return y_absl::StrCat("CompositeCallCredentials{", y_absl::StrJoin(outputs, ","),
- "}");
-}
-
+TString grpc_composite_call_credentials::debug_string() {
+ std::vector<TString> outputs;
+ for (auto& inner_cred : inner_) {
+ outputs.emplace_back(inner_cred->debug_string());
+ }
+ return y_absl::StrCat("CompositeCallCredentials{", y_absl::StrJoin(outputs, ","),
+ "}");
+}
+
static size_t get_creds_array_size(const grpc_call_credentials* creds,
bool is_composite) {
return is_composite
@@ -163,13 +163,13 @@ grpc_composite_call_credentials::grpc_composite_call_credentials(
inner_.reserve(size);
push_to_inner(std::move(creds1), creds1_is_composite);
push_to_inner(std::move(creds2), creds2_is_composite);
- min_security_level_ = GRPC_SECURITY_NONE;
- for (size_t i = 0; i < inner_.size(); ++i) {
- if (static_cast<int>(min_security_level_) <
- static_cast<int>(inner_[i]->min_security_level())) {
- min_security_level_ = inner_[i]->min_security_level();
- }
- }
+ min_security_level_ = GRPC_SECURITY_NONE;
+ for (size_t i = 0; i < inner_.size(); ++i) {
+ if (static_cast<int>(min_security_level_) <
+ static_cast<int>(inner_[i]->min_security_level())) {
+ min_security_level_ = inner_[i]->min_security_level();
+ }
+ }
}
static grpc_core::RefCountedPtr<grpc_call_credentials>
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/composite/composite_credentials.h b/contrib/libs/grpc/src/core/lib/security/credentials/composite/composite_credentials.h
index 7e7a99bd7c..5bebb9bd5a 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/composite/composite_credentials.h
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/composite/composite_credentials.h
@@ -21,10 +21,10 @@
#include <grpc/support/port_platform.h>
-#include <util/generic/string.h>
-
-#include "y_absl/container/inlined_vector.h"
-
+#include <util/generic/string.h>
+
+#include "y_absl/container/inlined_vector.h"
+
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/security/credentials/credentials.h"
@@ -72,7 +72,7 @@ class grpc_composite_channel_credentials : public grpc_channel_credentials {
class grpc_composite_call_credentials : public grpc_call_credentials {
public:
using CallCredentialsList =
- y_absl::InlinedVector<grpc_core::RefCountedPtr<grpc_call_credentials>, 2>;
+ y_absl::InlinedVector<grpc_core::RefCountedPtr<grpc_call_credentials>, 2>;
grpc_composite_call_credentials(
grpc_core::RefCountedPtr<grpc_call_credentials> creds1,
@@ -88,17 +88,17 @@ class grpc_composite_call_credentials : public grpc_call_credentials {
void cancel_get_request_metadata(grpc_credentials_mdelem_array* md_array,
grpc_error* error) override;
- grpc_security_level min_security_level() const override {
- return min_security_level_;
- }
-
+ grpc_security_level min_security_level() const override {
+ return min_security_level_;
+ }
+
const CallCredentialsList& inner() const { return inner_; }
- TString debug_string() override;
+ TString debug_string() override;
private:
void push_to_inner(grpc_core::RefCountedPtr<grpc_call_credentials> creds,
bool is_composite);
- grpc_security_level min_security_level_;
+ grpc_security_level min_security_level_;
CallCredentialsList inner_;
};
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/credentials.h b/contrib/libs/grpc/src/core/lib/security/credentials/credentials.h
index d22d435add..15a85cbd0b 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/credentials.h
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/credentials.h
@@ -21,10 +21,10 @@
#include <grpc/support/port_platform.h>
-#include <string.h>
-
-#include <util/generic/string.h>
-
+#include <string.h>
+
+#include <util/generic/string.h>
+
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
#include <grpc/support/sync.h>
@@ -81,13 +81,13 @@ typedef enum {
/* --- Google utils --- */
/* It is the caller's responsibility to gpr_free the result if not NULL. */
-TString grpc_get_well_known_google_credentials_file_path(void);
+TString grpc_get_well_known_google_credentials_file_path(void);
/* Implementation function for the different platforms. */
-TString grpc_get_well_known_google_credentials_file_path_impl(void);
+TString grpc_get_well_known_google_credentials_file_path_impl(void);
/* Override for testing only. Not thread-safe */
-typedef TString (*grpc_well_known_credentials_path_getter)(void);
+typedef TString (*grpc_well_known_credentials_path_getter)(void);
void grpc_override_well_known_credentials_path_getter(
grpc_well_known_credentials_path_getter getter);
@@ -172,11 +172,11 @@ void grpc_credentials_mdelem_array_destroy(grpc_credentials_mdelem_array* list);
struct grpc_call_credentials
: public grpc_core::RefCounted<grpc_call_credentials> {
public:
- explicit grpc_call_credentials(
- const char* type,
- grpc_security_level min_security_level = GRPC_PRIVACY_AND_INTEGRITY)
- : type_(type), min_security_level_(min_security_level) {}
-
+ explicit grpc_call_credentials(
+ const char* type,
+ grpc_security_level min_security_level = GRPC_PRIVACY_AND_INTEGRITY)
+ : type_(type), min_security_level_(min_security_level) {}
+
virtual ~grpc_call_credentials() = default;
// Returns true if completed synchronously, in which case \a error will
@@ -195,19 +195,19 @@ struct grpc_call_credentials
virtual void cancel_get_request_metadata(
grpc_credentials_mdelem_array* md_array, grpc_error* error) = 0;
- virtual grpc_security_level min_security_level() const {
- return min_security_level_;
- }
-
- virtual TString debug_string() {
- return "grpc_call_credentials did not provide debug string";
- }
-
+ virtual grpc_security_level min_security_level() const {
+ return min_security_level_;
+ }
+
+ virtual TString debug_string() {
+ return "grpc_call_credentials did not provide debug string";
+ }
+
const char* type() const { return type_; }
private:
const char* type_;
- const grpc_security_level min_security_level_;
+ const grpc_security_level min_security_level_;
};
/* Metadata-only credentials with the specified key and value where
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/fake/fake_credentials.h b/contrib/libs/grpc/src/core/lib/security/credentials/fake/fake_credentials.h
index f3331121b0..27f3a28451 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/fake/fake_credentials.h
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/fake/fake_credentials.h
@@ -21,8 +21,8 @@
#include <grpc/support/port_platform.h>
-#include <string.h>
-
+#include <string.h>
+
#include "src/core/lib/security/credentials/credentials.h"
#define GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS \
@@ -61,8 +61,8 @@ class grpc_md_only_test_credentials : public grpc_call_credentials {
public:
grpc_md_only_test_credentials(const char* md_key, const char* md_value,
bool is_async)
- : grpc_call_credentials(GRPC_CALL_CREDENTIALS_TYPE_OAUTH2,
- GRPC_SECURITY_NONE),
+ : grpc_call_credentials(GRPC_CALL_CREDENTIALS_TYPE_OAUTH2,
+ GRPC_SECURITY_NONE),
md_(grpc_mdelem_from_slices(grpc_slice_from_copied_string(md_key),
grpc_slice_from_copied_string(md_value))),
is_async_(is_async) {}
@@ -77,8 +77,8 @@ class grpc_md_only_test_credentials : public grpc_call_credentials {
void cancel_get_request_metadata(grpc_credentials_mdelem_array* md_array,
grpc_error* error) override;
- TString debug_string() override { return "MD only Test Credentials"; };
-
+ TString debug_string() override { return "MD only Test Credentials"; };
+
private:
grpc_mdelem md_;
bool is_async_;
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/google_default/credentials_generic.cc b/contrib/libs/grpc/src/core/lib/security/credentials/google_default/credentials_generic.cc
index 7dd1a93541..e8b9bbdadc 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/google_default/credentials_generic.cc
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/google_default/credentials_generic.cc
@@ -20,24 +20,24 @@
#include "src/core/lib/security/credentials/google_default/google_default_credentials.h"
-#include <util/generic/string.h>
-
-#include "y_absl/strings/str_cat.h"
-
+#include <util/generic/string.h>
+
+#include "y_absl/strings/str_cat.h"
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/lib/gpr/env.h"
-TString grpc_get_well_known_google_credentials_file_path_impl(void) {
+TString grpc_get_well_known_google_credentials_file_path_impl(void) {
char* base = gpr_getenv(GRPC_GOOGLE_CREDENTIALS_PATH_ENV_VAR);
if (base == nullptr) {
gpr_log(GPR_ERROR, "Could not get " GRPC_GOOGLE_CREDENTIALS_PATH_ENV_VAR
" environment variable.");
- return "";
+ return "";
}
- TString result =
- y_absl::StrCat(base, "/", GRPC_GOOGLE_CREDENTIALS_PATH_SUFFIX);
+ TString result =
+ y_absl::StrCat(base, "/", GRPC_GOOGLE_CREDENTIALS_PATH_SUFFIX);
gpr_free(base);
return result;
}
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/google_default/google_default_credentials.cc b/contrib/libs/grpc/src/core/lib/security/credentials/google_default/google_default_credentials.cc
index 11949d1cde..8f3ca009a5 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/google_default/google_default_credentials.cc
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/google_default/google_default_credentials.cc
@@ -44,13 +44,13 @@
#include "src/core/lib/slice/slice_string_helpers.h"
#include "src/core/lib/surface/api_trace.h"
-using grpc_core::Json;
-
+using grpc_core::Json;
+
/* -- Constants. -- */
#define GRPC_COMPUTE_ENGINE_DETECTION_HOST "metadata.google.internal."
-#define GRPC_GOOGLE_CREDENTIAL_CREATION_ERROR \
- "Failed to create Google credentials"
+#define GRPC_GOOGLE_CREDENTIAL_CREATION_ERROR \
+ "Failed to create Google credentials"
/* -- Default credentials. -- */
@@ -90,7 +90,7 @@ grpc_google_default_channel_credentials::create_security_connector(
bool use_alts =
is_grpclb_load_balancer || is_backend_from_grpclb_load_balancer;
/* Return failure if ALTS is selected but not running on GCE. */
- if (use_alts && alts_creds_ == nullptr) {
+ if (use_alts && alts_creds_ == nullptr) {
gpr_log(GPR_ERROR, "ALTS is selected, but not running on GCE.");
return nullptr;
}
@@ -217,23 +217,23 @@ static int is_metadata_server_reachable() {
/* Takes ownership of creds_path if not NULL. */
static grpc_error* create_default_creds_from_path(
- const TString& creds_path,
- grpc_core::RefCountedPtr<grpc_call_credentials>* creds) {
+ const TString& creds_path,
+ grpc_core::RefCountedPtr<grpc_call_credentials>* creds) {
grpc_auth_json_key key;
grpc_auth_refresh_token token;
grpc_core::RefCountedPtr<grpc_call_credentials> result;
grpc_slice creds_data = grpc_empty_slice();
grpc_error* error = GRPC_ERROR_NONE;
- Json json;
- if (creds_path.empty()) {
+ Json json;
+ if (creds_path.empty()) {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("creds_path unset");
goto end;
}
- error = grpc_load_file(creds_path.c_str(), 0, &creds_data);
- if (error != GRPC_ERROR_NONE) goto end;
- json = Json::Parse(grpc_core::StringViewFromSlice(creds_data), &error);
- if (error != GRPC_ERROR_NONE) goto end;
- if (json.type() != Json::Type::OBJECT) {
+ error = grpc_load_file(creds_path.c_str(), 0, &creds_data);
+ if (error != GRPC_ERROR_NONE) goto end;
+ json = Json::Parse(grpc_core::StringViewFromSlice(creds_data), &error);
+ if (error != GRPC_ERROR_NONE) goto end;
+ if (json.type() != Json::Type::OBJECT) {
error = grpc_error_set_str(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed to parse JSON"),
GRPC_ERROR_STR_RAW_BYTES, grpc_slice_ref_internal(creds_data));
@@ -274,13 +274,13 @@ end:
return error;
}
-static void update_tenancy() {
+static void update_tenancy() {
gpr_once_init(&g_once, init_default_credentials);
- grpc_core::MutexLock lock(&g_state_mu);
+ grpc_core::MutexLock lock(&g_state_mu);
/* Try a platform-provided hint for GCE. */
if (!g_metadata_server_available) {
- g_metadata_server_available = g_gce_tenancy_checker();
+ g_metadata_server_available = g_gce_tenancy_checker();
}
/* TODO: Add a platform-provided hint for GAE. */
@@ -288,64 +288,64 @@ static void update_tenancy() {
if (!g_metadata_server_available) {
g_metadata_server_available = is_metadata_server_reachable();
}
-}
-
-static bool metadata_server_available() {
- grpc_core::MutexLock lock(&g_state_mu);
- return static_cast<bool>(g_metadata_server_available);
-}
-
-static grpc_core::RefCountedPtr<grpc_call_credentials> make_default_call_creds(
- grpc_error** error) {
- grpc_core::RefCountedPtr<grpc_call_credentials> call_creds;
- grpc_error* err;
-
- /* First, try the environment variable. */
- char* path_from_env = gpr_getenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR);
- if (path_from_env != nullptr) {
- err = create_default_creds_from_path(path_from_env, &call_creds);
- gpr_free(path_from_env);
- if (err == GRPC_ERROR_NONE) return call_creds;
- *error = grpc_error_add_child(*error, err);
- }
-
- /* Then the well-known file. */
- err = create_default_creds_from_path(
- grpc_get_well_known_google_credentials_file_path(), &call_creds);
- if (err == GRPC_ERROR_NONE) return call_creds;
- *error = grpc_error_add_child(*error, err);
-
- update_tenancy();
-
- if (metadata_server_available()) {
+}
+
+static bool metadata_server_available() {
+ grpc_core::MutexLock lock(&g_state_mu);
+ return static_cast<bool>(g_metadata_server_available);
+}
+
+static grpc_core::RefCountedPtr<grpc_call_credentials> make_default_call_creds(
+ grpc_error** error) {
+ grpc_core::RefCountedPtr<grpc_call_credentials> call_creds;
+ grpc_error* err;
+
+ /* First, try the environment variable. */
+ char* path_from_env = gpr_getenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR);
+ if (path_from_env != nullptr) {
+ err = create_default_creds_from_path(path_from_env, &call_creds);
+ gpr_free(path_from_env);
+ if (err == GRPC_ERROR_NONE) return call_creds;
+ *error = grpc_error_add_child(*error, err);
+ }
+
+ /* Then the well-known file. */
+ err = create_default_creds_from_path(
+ grpc_get_well_known_google_credentials_file_path(), &call_creds);
+ if (err == GRPC_ERROR_NONE) return call_creds;
+ *error = grpc_error_add_child(*error, err);
+
+ update_tenancy();
+
+ if (metadata_server_available()) {
call_creds = grpc_core::RefCountedPtr<grpc_call_credentials>(
grpc_google_compute_engine_credentials_create(nullptr));
if (call_creds == nullptr) {
- *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- GRPC_GOOGLE_CREDENTIAL_CREATION_ERROR);
- *error = grpc_error_add_child(
- *error, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "Failed to get credentials from network"));
+ *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ GRPC_GOOGLE_CREDENTIAL_CREATION_ERROR);
+ *error = grpc_error_add_child(
+ *error, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Failed to get credentials from network"));
}
}
- return call_creds;
-}
-
-grpc_channel_credentials* grpc_google_default_credentials_create(
- grpc_call_credentials* call_credentials) {
- grpc_channel_credentials* result = nullptr;
- grpc_core::RefCountedPtr<grpc_call_credentials> call_creds(call_credentials);
- grpc_error* error = nullptr;
- grpc_core::ExecCtx exec_ctx;
-
- GRPC_API_TRACE("grpc_google_default_credentials_create(%p)", 1,
- (call_credentials));
-
- if (call_creds == nullptr) {
- call_creds = make_default_call_creds(&error);
- }
-
+ return call_creds;
+}
+
+grpc_channel_credentials* grpc_google_default_credentials_create(
+ grpc_call_credentials* call_credentials) {
+ grpc_channel_credentials* result = nullptr;
+ grpc_core::RefCountedPtr<grpc_call_credentials> call_creds(call_credentials);
+ grpc_error* error = nullptr;
+ grpc_core::ExecCtx exec_ctx;
+
+ GRPC_API_TRACE("grpc_google_default_credentials_create(%p)", 1,
+ (call_credentials));
+
+ if (call_creds == nullptr) {
+ call_creds = make_default_call_creds(&error);
+ }
+
if (call_creds != nullptr) {
/* Create google default credentials. */
grpc_channel_credentials* ssl_creds =
@@ -358,8 +358,8 @@ grpc_channel_credentials* grpc_google_default_credentials_create(
grpc_alts_credentials_options_destroy(options);
auto creds =
grpc_core::MakeRefCounted<grpc_google_default_channel_credentials>(
- grpc_core::RefCountedPtr<grpc_channel_credentials>(alts_creds),
- grpc_core::RefCountedPtr<grpc_channel_credentials>(ssl_creds));
+ grpc_core::RefCountedPtr<grpc_channel_credentials>(alts_creds),
+ grpc_core::RefCountedPtr<grpc_channel_credentials>(ssl_creds));
result = grpc_composite_channel_credentials_create(
creds.get(), call_creds.get(), nullptr);
GPR_ASSERT(result != nullptr);
@@ -393,7 +393,7 @@ void grpc_flush_cached_google_default_credentials(void) {
static grpc_well_known_credentials_path_getter creds_path_getter = nullptr;
-TString grpc_get_well_known_google_credentials_file_path(void) {
+TString grpc_get_well_known_google_credentials_file_path(void) {
if (creds_path_getter != nullptr) return creds_path_getter();
return grpc_get_well_known_google_credentials_file_path_impl();
}
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/iam/iam_credentials.cc b/contrib/libs/grpc/src/core/lib/security/credentials/iam/iam_credentials.cc
index 086409028c..a03e4970b8 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/iam/iam_credentials.cc
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/iam/iam_credentials.cc
@@ -25,10 +25,10 @@
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
-#include "y_absl/strings/str_format.h"
-#include "src/core/lib/gprpp/ref_counted_ptr.h"
-#include "src/core/lib/surface/api_trace.h"
-
+#include "y_absl/strings/str_format.h"
+#include "src/core/lib/gprpp/ref_counted_ptr.h"
+#include "src/core/lib/surface/api_trace.h"
+
grpc_google_iam_credentials::~grpc_google_iam_credentials() {
grpc_credentials_mdelem_array_destroy(&md_array_);
}
@@ -48,10 +48,10 @@ void grpc_google_iam_credentials::cancel_get_request_metadata(
grpc_google_iam_credentials::grpc_google_iam_credentials(
const char* token, const char* authority_selector)
- : grpc_call_credentials(GRPC_CALL_CREDENTIALS_TYPE_IAM),
- debug_string_(y_absl::StrFormat(
- "GoogleIAMCredentials{Token:%s,AuthoritySelector:%s}",
- token != nullptr ? "present" : "absent", authority_selector)) {
+ : grpc_call_credentials(GRPC_CALL_CREDENTIALS_TYPE_IAM),
+ debug_string_(y_absl::StrFormat(
+ "GoogleIAMCredentials{Token:%s,AuthoritySelector:%s}",
+ token != nullptr ? "present" : "absent", authority_selector)) {
grpc_mdelem md = grpc_mdelem_from_slices(
grpc_slice_from_static_string(GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY),
grpc_slice_from_copied_string(token));
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/iam/iam_credentials.h b/contrib/libs/grpc/src/core/lib/security/credentials/iam/iam_credentials.h
index d0d0ee8a55..76b6acfa28 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/iam/iam_credentials.h
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/iam/iam_credentials.h
@@ -21,8 +21,8 @@
#include <grpc/support/port_platform.h>
-#include <util/generic/string.h>
-
+#include <util/generic/string.h>
+
#include "src/core/lib/security/credentials/credentials.h"
class grpc_google_iam_credentials : public grpc_call_credentials {
@@ -39,11 +39,11 @@ class grpc_google_iam_credentials : public grpc_call_credentials {
void cancel_get_request_metadata(grpc_credentials_mdelem_array* md_array,
grpc_error* error) override;
- TString debug_string() override { return debug_string_; }
+ TString debug_string() override { return debug_string_; }
private:
grpc_credentials_mdelem_array md_array_;
- const TString debug_string_;
+ const TString debug_string_;
};
#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_IAM_IAM_CREDENTIALS_H */
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/jwt/json_token.cc b/contrib/libs/grpc/src/core/lib/security/credentials/jwt/json_token.cc
index e09338c4b6..c0c5b52782 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/jwt/json_token.cc
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/jwt/json_token.cc
@@ -39,8 +39,8 @@ extern "C" {
#include <openssl/pem.h>
}
-using grpc_core::Json;
-
+using grpc_core::Json;
+
/* --- Constants. --- */
/* 1 hour max. */
@@ -67,7 +67,7 @@ int grpc_auth_json_key_is_valid(const grpc_auth_json_key* json_key) {
strcmp(json_key->type, GRPC_AUTH_JSON_TYPE_INVALID);
}
-grpc_auth_json_key grpc_auth_json_key_create_from_json(const Json& json) {
+grpc_auth_json_key grpc_auth_json_key_create_from_json(const Json& json) {
grpc_auth_json_key result;
BIO* bio = nullptr;
const char* prop_value;
@@ -76,7 +76,7 @@ grpc_auth_json_key grpc_auth_json_key_create_from_json(const Json& json) {
memset(&result, 0, sizeof(grpc_auth_json_key));
result.type = GRPC_AUTH_JSON_TYPE_INVALID;
- if (json.type() == Json::Type::JSON_NULL) {
+ if (json.type() == Json::Type::JSON_NULL) {
gpr_log(GPR_ERROR, "Invalid json.");
goto end;
}
@@ -124,10 +124,10 @@ end:
grpc_auth_json_key grpc_auth_json_key_create_from_string(
const char* json_string) {
- grpc_error* error = GRPC_ERROR_NONE;
- Json json = Json::Parse(json_string, &error);
- GRPC_LOG_IF_ERROR("JSON key parsing", error);
- return grpc_auth_json_key_create_from_json(json);
+ grpc_error* error = GRPC_ERROR_NONE;
+ Json json = Json::Parse(json_string, &error);
+ GRPC_LOG_IF_ERROR("JSON key parsing", error);
+ return grpc_auth_json_key_create_from_json(json);
}
void grpc_auth_json_key_destruct(grpc_auth_json_key* json_key) {
@@ -154,13 +154,13 @@ void grpc_auth_json_key_destruct(grpc_auth_json_key* json_key) {
/* --- jwt encoding and signature. --- */
static char* encoded_jwt_header(const char* key_id, const char* algorithm) {
- Json json = Json::Object{
- {"alg", algorithm},
- {"typ", GRPC_JWT_TYPE},
- {"kid", key_id},
- };
- TString json_str = json.Dump();
- return grpc_base64_encode(json_str.c_str(), json_str.size(), 1, 0);
+ Json json = Json::Object{
+ {"alg", algorithm},
+ {"typ", GRPC_JWT_TYPE},
+ {"kid", key_id},
+ };
+ TString json_str = json.Dump();
+ return grpc_base64_encode(json_str.c_str(), json_str.size(), 1, 0);
}
static char* encoded_jwt_claim(const grpc_auth_json_key* json_key,
@@ -173,22 +173,22 @@ static char* encoded_jwt_claim(const grpc_auth_json_key* json_key,
expiration = gpr_time_add(now, grpc_max_auth_token_lifetime());
}
- Json::Object object = {
- {"iss", json_key->client_email},
- {"aud", audience},
- {"iat", now.tv_sec},
- {"exp", expiration.tv_sec},
- };
+ Json::Object object = {
+ {"iss", json_key->client_email},
+ {"aud", audience},
+ {"iat", now.tv_sec},
+ {"exp", expiration.tv_sec},
+ };
if (scope != nullptr) {
- object["scope"] = scope;
+ object["scope"] = scope;
} else {
/* Unscoped JWTs need a sub field. */
- object["sub"] = json_key->client_email;
+ object["sub"] = json_key->client_email;
}
- Json json(object);
- TString json_str = json.Dump();
- return grpc_base64_encode(json_str.c_str(), json_str.size(), 1, 0);
+ Json json(object);
+ TString json_str = json.Dump();
+ return grpc_base64_encode(json_str.c_str(), json_str.size(), 1, 0);
}
static char* dot_concat_and_free_strings(char* str1, char* str2) {
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/jwt/json_token.h b/contrib/libs/grpc/src/core/lib/security/credentials/jwt/json_token.h
index ac393473a7..b9a41c6b2b 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/jwt/json_token.h
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/jwt/json_token.h
@@ -49,8 +49,8 @@ grpc_auth_json_key grpc_auth_json_key_create_from_string(
/* Creates a json_key object from parsed json. Returns an invalid object if a
parsing error has been encountered. */
-grpc_auth_json_key grpc_auth_json_key_create_from_json(
- const grpc_core::Json& json);
+grpc_auth_json_key grpc_auth_json_key_create_from_json(
+ const grpc_core::Json& json);
/* Destructs the object. */
void grpc_auth_json_key_destruct(grpc_auth_json_key* json_key);
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_credentials.cc b/contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_credentials.cc
index aec34cf109..d5555c3aa1 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_credentials.cc
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_credentials.cc
@@ -23,13 +23,13 @@
#include <inttypes.h>
#include <string.h>
-#include <util/generic/string.h>
-
-#include "y_absl/strings/str_cat.h"
-
+#include <util/generic/string.h>
+
+#include "y_absl/strings/str_cat.h"
+
#include "src/core/lib/gprpp/ref_counted.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
-#include "src/core/lib/slice/slice_internal.h"
+#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/surface/api_trace.h"
#include <grpc/support/alloc.h>
@@ -37,8 +37,8 @@
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
-using grpc_core::Json;
-
+using grpc_core::Json;
+
void grpc_service_account_jwt_access_credentials::reset_cache() {
GRPC_MDELEM_UNREF(cached_.jwt_md);
cached_.jwt_md = GRPC_MDNULL;
@@ -86,14 +86,14 @@ bool grpc_service_account_jwt_access_credentials::get_request_metadata(
jwt = grpc_jwt_encode_and_sign(&key_, context.service_url, jwt_lifetime_,
nullptr);
if (jwt != nullptr) {
- TString md_value = y_absl::StrCat("Bearer ", jwt);
+ TString md_value = y_absl::StrCat("Bearer ", jwt);
gpr_free(jwt);
cached_.jwt_expiration =
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), jwt_lifetime_);
cached_.service_url = gpr_strdup(context.service_url);
cached_.jwt_md = grpc_mdelem_from_slices(
grpc_slice_from_static_string(GRPC_AUTHORIZATION_METADATA_KEY),
- grpc_slice_from_cpp_string(std::move(md_value)));
+ grpc_slice_from_cpp_string(std::move(md_value)));
jwt_md = GRPC_MDELEM_REF(cached_.jwt_md);
}
gpr_mu_unlock(&cache_mu_);
@@ -141,14 +141,14 @@ grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
}
static char* redact_private_key(const char* json_key) {
- grpc_error* error = GRPC_ERROR_NONE;
- Json json = Json::Parse(json_key, &error);
- if (error != GRPC_ERROR_NONE || json.type() != Json::Type::OBJECT) {
- GRPC_ERROR_UNREF(error);
+ grpc_error* error = GRPC_ERROR_NONE;
+ Json json = Json::Parse(json_key, &error);
+ if (error != GRPC_ERROR_NONE || json.type() != Json::Type::OBJECT) {
+ GRPC_ERROR_UNREF(error);
return gpr_strdup("<Json failed to parse.>");
}
- (*json.mutable_object())["private_key"] = "<redacted>";
- return gpr_strdup(json.Dump(/*indent=*/2).c_str());
+ (*json.mutable_object())["private_key"] = "<redacted>";
+ return gpr_strdup(json.Dump(/*indent=*/2).c_str());
}
grpc_call_credentials* grpc_service_account_jwt_access_credentials_create(
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_credentials.h b/contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_credentials.h
index 949b1905c0..9b60deacb5 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_credentials.h
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_credentials.h
@@ -21,12 +21,12 @@
#include <grpc/support/port_platform.h>
-#include <util/generic/string.h>
-
-#include <grpc/support/time.h>
-
-#include "y_absl/strings/str_format.h"
-#include "y_absl/time/time.h"
+#include <util/generic/string.h>
+
+#include <grpc/support/time.h>
+
+#include "y_absl/strings/str_format.h"
+#include "y_absl/time/time.h"
#include "src/core/lib/security/credentials/credentials.h"
#include "src/core/lib/security/credentials/jwt/json_token.h"
@@ -49,12 +49,12 @@ class grpc_service_account_jwt_access_credentials
const gpr_timespec& jwt_lifetime() const { return jwt_lifetime_; }
const grpc_auth_json_key& key() const { return key_; }
- TString debug_string() override {
- return y_absl::StrFormat("JWTAccessCredentials{ExpirationTime:%s}",
- y_absl::FormatTime(y_absl::FromUnixMicros(
- gpr_timespec_to_micros(jwt_lifetime_))));
- };
-
+ TString debug_string() override {
+ return y_absl::StrFormat("JWTAccessCredentials{ExpirationTime:%s}",
+ y_absl::FormatTime(y_absl::FromUnixMicros(
+ gpr_timespec_to_micros(jwt_lifetime_))));
+ };
+
private:
void reset_cache();
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_verifier.cc b/contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_verifier.cc
index 32573ab98d..0c9e118826 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_verifier.cc
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_verifier.cc
@@ -35,15 +35,15 @@ extern "C" {
}
#include "src/core/lib/gpr/string.h"
-#include "src/core/lib/gprpp/manual_constructor.h"
+#include "src/core/lib/gprpp/manual_constructor.h"
#include "src/core/lib/http/httpcli.h"
#include "src/core/lib/iomgr/polling_entity.h"
#include "src/core/lib/slice/b64.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/tsi/ssl_types.h"
-using grpc_core::Json;
-
+using grpc_core::Json;
+
/* --- Utils. --- */
const char* grpc_jwt_verifier_status_to_string(
@@ -80,39 +80,39 @@ static const EVP_MD* evp_md_from_alg(const char* alg) {
}
}
-static Json parse_json_part_from_jwt(const char* str, size_t len) {
- grpc_slice slice = grpc_base64_decode_with_len(str, len, 1);
- if (GRPC_SLICE_IS_EMPTY(slice)) {
+static Json parse_json_part_from_jwt(const char* str, size_t len) {
+ grpc_slice slice = grpc_base64_decode_with_len(str, len, 1);
+ if (GRPC_SLICE_IS_EMPTY(slice)) {
gpr_log(GPR_ERROR, "Invalid base64.");
- return Json(); // JSON null
+ return Json(); // JSON null
}
- y_absl::string_view string = grpc_core::StringViewFromSlice(slice);
- grpc_error* error = GRPC_ERROR_NONE;
- Json json = Json::Parse(string, &error);
- if (error != GRPC_ERROR_NONE) {
- gpr_log(GPR_ERROR, "JSON parse error: %s", grpc_error_string(error));
- GRPC_ERROR_UNREF(error);
- json = Json(); // JSON null
+ y_absl::string_view string = grpc_core::StringViewFromSlice(slice);
+ grpc_error* error = GRPC_ERROR_NONE;
+ Json json = Json::Parse(string, &error);
+ if (error != GRPC_ERROR_NONE) {
+ gpr_log(GPR_ERROR, "JSON parse error: %s", grpc_error_string(error));
+ GRPC_ERROR_UNREF(error);
+ json = Json(); // JSON null
}
- grpc_slice_unref_internal(slice);
+ grpc_slice_unref_internal(slice);
return json;
}
-static const char* validate_string_field(const Json& json, const char* key) {
- if (json.type() != Json::Type::STRING) {
- gpr_log(GPR_ERROR, "Invalid %s field", key);
+static const char* validate_string_field(const Json& json, const char* key) {
+ if (json.type() != Json::Type::STRING) {
+ gpr_log(GPR_ERROR, "Invalid %s field", key);
return nullptr;
}
- return json.string_value().c_str();
+ return json.string_value().c_str();
}
-static gpr_timespec validate_time_field(const Json& json, const char* key) {
+static gpr_timespec validate_time_field(const Json& json, const char* key) {
gpr_timespec result = gpr_time_0(GPR_CLOCK_REALTIME);
- if (json.type() != Json::Type::NUMBER) {
- gpr_log(GPR_ERROR, "Invalid %s field", key);
+ if (json.type() != Json::Type::NUMBER) {
+ gpr_log(GPR_ERROR, "Invalid %s field", key);
return result;
}
- result.tv_sec = strtol(json.string_value().c_str(), nullptr, 10);
+ result.tv_sec = strtol(json.string_value().c_str(), nullptr, 10);
return result;
}
@@ -123,51 +123,51 @@ struct jose_header {
const char* kid;
const char* typ;
/* TODO(jboeuf): Add others as needed (jku, jwk, x5u, x5c and so on...). */
- grpc_core::ManualConstructor<Json> json;
+ grpc_core::ManualConstructor<Json> json;
};
static void jose_header_destroy(jose_header* h) {
- h->json.Destroy();
+ h->json.Destroy();
gpr_free(h);
}
-static jose_header* jose_header_from_json(Json json) {
- const char* alg_value;
- Json::Object::const_iterator it;
+static jose_header* jose_header_from_json(Json json) {
+ const char* alg_value;
+ Json::Object::const_iterator it;
jose_header* h = static_cast<jose_header*>(gpr_zalloc(sizeof(jose_header)));
- if (json.type() != Json::Type::OBJECT) {
- gpr_log(GPR_ERROR, "JSON value is not an object");
- goto error;
+ if (json.type() != Json::Type::OBJECT) {
+ gpr_log(GPR_ERROR, "JSON value is not an object");
+ goto error;
}
- // Check alg field.
- it = json.object_value().find("alg");
- if (it == json.object_value().end()) {
+ // Check alg field.
+ it = json.object_value().find("alg");
+ if (it == json.object_value().end()) {
gpr_log(GPR_ERROR, "Missing alg field.");
goto error;
}
- /* We only support RSA-1.5 signatures for now.
- Beware of this if we add HMAC support:
- https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries/
- */
- alg_value = it->second.string_value().c_str();
- if (it->second.type() != Json::Type::STRING || strncmp(alg_value, "RS", 2) ||
- evp_md_from_alg(alg_value) == nullptr) {
- gpr_log(GPR_ERROR, "Invalid alg field");
- goto error;
- }
- h->alg = alg_value;
- // Check typ field.
- it = json.object_value().find("typ");
- if (it != json.object_value().end()) {
- h->typ = validate_string_field(it->second, "typ");
- if (h->typ == nullptr) goto error;
- }
- // Check kid field.
- it = json.object_value().find("kid");
- if (it != json.object_value().end()) {
- h->kid = validate_string_field(it->second, "kid");
- if (h->kid == nullptr) goto error;
- }
- h->json.Init(std::move(json));
+ /* We only support RSA-1.5 signatures for now.
+ Beware of this if we add HMAC support:
+ https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries/
+ */
+ alg_value = it->second.string_value().c_str();
+ if (it->second.type() != Json::Type::STRING || strncmp(alg_value, "RS", 2) ||
+ evp_md_from_alg(alg_value) == nullptr) {
+ gpr_log(GPR_ERROR, "Invalid alg field");
+ goto error;
+ }
+ h->alg = alg_value;
+ // Check typ field.
+ it = json.object_value().find("typ");
+ if (it != json.object_value().end()) {
+ h->typ = validate_string_field(it->second, "typ");
+ if (h->typ == nullptr) goto error;
+ }
+ // Check kid field.
+ it = json.object_value().find("kid");
+ if (it != json.object_value().end()) {
+ h->kid = validate_string_field(it->second, "kid");
+ if (h->kid == nullptr) goto error;
+ }
+ h->json.Init(std::move(json));
return h;
error:
@@ -187,17 +187,17 @@ struct grpc_jwt_claims {
gpr_timespec exp;
gpr_timespec nbf;
- grpc_core::ManualConstructor<Json> json;
+ grpc_core::ManualConstructor<Json> json;
};
void grpc_jwt_claims_destroy(grpc_jwt_claims* claims) {
- claims->json.Destroy();
+ claims->json.Destroy();
gpr_free(claims);
}
-const Json* grpc_jwt_claims_json(const grpc_jwt_claims* claims) {
+const Json* grpc_jwt_claims_json(const grpc_jwt_claims* claims) {
if (claims == nullptr) return nullptr;
- return claims->json.get();
+ return claims->json.get();
}
const char* grpc_jwt_claims_subject(const grpc_jwt_claims* claims) {
@@ -235,43 +235,43 @@ gpr_timespec grpc_jwt_claims_not_before(const grpc_jwt_claims* claims) {
return claims->nbf;
}
-grpc_jwt_claims* grpc_jwt_claims_from_json(Json json) {
+grpc_jwt_claims* grpc_jwt_claims_from_json(Json json) {
grpc_jwt_claims* claims =
- static_cast<grpc_jwt_claims*>(gpr_zalloc(sizeof(grpc_jwt_claims)));
- claims->json.Init(std::move(json));
+ static_cast<grpc_jwt_claims*>(gpr_zalloc(sizeof(grpc_jwt_claims)));
+ claims->json.Init(std::move(json));
claims->iat = gpr_inf_past(GPR_CLOCK_REALTIME);
claims->nbf = gpr_inf_past(GPR_CLOCK_REALTIME);
claims->exp = gpr_inf_future(GPR_CLOCK_REALTIME);
/* Per the spec, all fields are optional. */
- for (const auto& p : claims->json->object_value()) {
- if (p.first == "sub") {
- claims->sub = validate_string_field(p.second, "sub");
+ for (const auto& p : claims->json->object_value()) {
+ if (p.first == "sub") {
+ claims->sub = validate_string_field(p.second, "sub");
if (claims->sub == nullptr) goto error;
- } else if (p.first == "iss") {
- claims->iss = validate_string_field(p.second, "iss");
+ } else if (p.first == "iss") {
+ claims->iss = validate_string_field(p.second, "iss");
if (claims->iss == nullptr) goto error;
- } else if (p.first == "aud") {
- claims->aud = validate_string_field(p.second, "aud");
+ } else if (p.first == "aud") {
+ claims->aud = validate_string_field(p.second, "aud");
if (claims->aud == nullptr) goto error;
- } else if (p.first == "jti") {
- claims->jti = validate_string_field(p.second, "jti");
+ } else if (p.first == "jti") {
+ claims->jti = validate_string_field(p.second, "jti");
if (claims->jti == nullptr) goto error;
- } else if (p.first == "iat") {
- claims->iat = validate_time_field(p.second, "iat");
- if (gpr_time_cmp(claims->iat, gpr_time_0(GPR_CLOCK_REALTIME)) == 0) {
+ } else if (p.first == "iat") {
+ claims->iat = validate_time_field(p.second, "iat");
+ if (gpr_time_cmp(claims->iat, gpr_time_0(GPR_CLOCK_REALTIME)) == 0) {
goto error;
- }
- } else if (p.first == "exp") {
- claims->exp = validate_time_field(p.second, "exp");
- if (gpr_time_cmp(claims->exp, gpr_time_0(GPR_CLOCK_REALTIME)) == 0) {
+ }
+ } else if (p.first == "exp") {
+ claims->exp = validate_time_field(p.second, "exp");
+ if (gpr_time_cmp(claims->exp, gpr_time_0(GPR_CLOCK_REALTIME)) == 0) {
goto error;
- }
- } else if (p.first == "nbf") {
- claims->nbf = validate_time_field(p.second, "nbf");
- if (gpr_time_cmp(claims->nbf, gpr_time_0(GPR_CLOCK_REALTIME)) == 0) {
+ }
+ } else if (p.first == "nbf") {
+ claims->nbf = validate_time_field(p.second, "nbf");
+ if (gpr_time_cmp(claims->nbf, gpr_time_0(GPR_CLOCK_REALTIME)) == 0) {
goto error;
- }
+ }
}
}
return claims;
@@ -334,7 +334,7 @@ typedef enum {
HTTP_RESPONSE_COUNT /* must be last */
} http_response_index;
-struct verifier_cb_ctx {
+struct verifier_cb_ctx {
grpc_jwt_verifier* verifier;
grpc_polling_entity pollent;
jose_header* header;
@@ -345,7 +345,7 @@ struct verifier_cb_ctx {
void* user_data;
grpc_jwt_verification_done_cb user_cb;
grpc_http_response responses[HTTP_RESPONSE_COUNT];
-};
+};
/* Takes ownership of the header, claims and signature. */
static verifier_cb_ctx* verifier_cb_ctx_create(
grpc_jwt_verifier* verifier, grpc_pollset* pollset, jose_header* header,
@@ -390,10 +390,10 @@ gpr_timespec grpc_jwt_verifier_clock_skew = {60, 0, GPR_TIMESPAN};
/* Max delay defaults to one minute. */
grpc_millis grpc_jwt_verifier_max_delay = 60 * GPR_MS_PER_SEC;
-struct email_key_mapping {
+struct email_key_mapping {
char* email_domain;
char* key_url_prefix;
-};
+};
struct grpc_jwt_verifier {
email_key_mapping* mappings;
size_t num_mappings; /* Should be very few, linear search ok. */
@@ -401,32 +401,32 @@ struct grpc_jwt_verifier {
grpc_httpcli_context http_ctx;
};
-static Json json_from_http(const grpc_httpcli_response* response) {
+static Json json_from_http(const grpc_httpcli_response* response) {
if (response == nullptr) {
gpr_log(GPR_ERROR, "HTTP response is NULL.");
- return Json(); // JSON null
+ return Json(); // JSON null
}
if (response->status != 200) {
gpr_log(GPR_ERROR, "Call to http server failed with error %d.",
response->status);
- return Json(); // JSON null
+ return Json(); // JSON null
}
- grpc_error* error = GRPC_ERROR_NONE;
- Json json = Json::Parse(
- y_absl::string_view(response->body, response->body_length), &error);
- if (error != GRPC_ERROR_NONE) {
+ grpc_error* error = GRPC_ERROR_NONE;
+ Json json = Json::Parse(
+ y_absl::string_view(response->body, response->body_length), &error);
+ if (error != GRPC_ERROR_NONE) {
gpr_log(GPR_ERROR, "Invalid JSON found in response.");
- return Json(); // JSON null
+ return Json(); // JSON null
}
return json;
}
-static const Json* find_property_by_name(const Json& json, const char* name) {
- auto it = json.object_value().find(name);
- if (it == json.object_value().end()) {
- return nullptr;
+static const Json* find_property_by_name(const Json& json, const char* name) {
+ auto it = json.object_value().find(name);
+ if (it == json.object_value().end()) {
+ return nullptr;
}
- return &it->second;
+ return &it->second;
}
static EVP_PKEY* extract_pkey_from_x509(const char* x509_str) {
@@ -497,15 +497,15 @@ static int RSA_set0_key(RSA* r, BIGNUM* n, BIGNUM* e, BIGNUM* d) {
}
#endif // OPENSSL_VERSION_NUMBER < 0x10100000L
-static EVP_PKEY* pkey_from_jwk(const Json& json, const char* kty) {
+static EVP_PKEY* pkey_from_jwk(const Json& json, const char* kty) {
RSA* rsa = nullptr;
EVP_PKEY* result = nullptr;
BIGNUM* tmp_n = nullptr;
BIGNUM* tmp_e = nullptr;
- Json::Object::const_iterator it;
+ Json::Object::const_iterator it;
- GPR_ASSERT(json.type() == Json::Type::OBJECT);
- GPR_ASSERT(kty != nullptr);
+ GPR_ASSERT(json.type() == Json::Type::OBJECT);
+ GPR_ASSERT(kty != nullptr);
if (strcmp(kty, "RSA") != 0) {
gpr_log(GPR_ERROR, "Unsupported key type %s.", kty);
goto end;
@@ -515,20 +515,20 @@ static EVP_PKEY* pkey_from_jwk(const Json& json, const char* kty) {
gpr_log(GPR_ERROR, "Could not create rsa key.");
goto end;
}
- it = json.object_value().find("n");
- if (it == json.object_value().end()) {
- gpr_log(GPR_ERROR, "Missing RSA public key field.");
- goto end;
+ it = json.object_value().find("n");
+ if (it == json.object_value().end()) {
+ gpr_log(GPR_ERROR, "Missing RSA public key field.");
+ goto end;
}
- tmp_n = bignum_from_base64(validate_string_field(it->second, "n"));
- if (tmp_n == nullptr) goto end;
- it = json.object_value().find("e");
- if (it == json.object_value().end()) {
+ tmp_n = bignum_from_base64(validate_string_field(it->second, "n"));
+ if (tmp_n == nullptr) goto end;
+ it = json.object_value().find("e");
+ if (it == json.object_value().end()) {
gpr_log(GPR_ERROR, "Missing RSA public key field.");
goto end;
}
- tmp_e = bignum_from_base64(validate_string_field(it->second, "e"));
- if (tmp_e == nullptr) goto end;
+ tmp_e = bignum_from_base64(validate_string_field(it->second, "e"));
+ if (tmp_e == nullptr) goto end;
if (!RSA_set0_key(rsa, tmp_n, tmp_e, nullptr)) {
gpr_log(GPR_ERROR, "Cannot set RSA key from inputs.");
goto end;
@@ -546,41 +546,41 @@ end:
return result;
}
-static EVP_PKEY* find_verification_key(const Json& json, const char* header_alg,
+static EVP_PKEY* find_verification_key(const Json& json, const char* header_alg,
const char* header_kid) {
/* Try to parse the json as a JWK set:
https://tools.ietf.org/html/rfc7517#section-5. */
- const Json* jwt_keys = find_property_by_name(json, "keys");
- if (jwt_keys == nullptr) {
+ const Json* jwt_keys = find_property_by_name(json, "keys");
+ if (jwt_keys == nullptr) {
/* Use the google proprietary format which is:
{ <kid1>: <x5091>, <kid2>: <x5092>, ... } */
- const Json* cur = find_property_by_name(json, header_kid);
+ const Json* cur = find_property_by_name(json, header_kid);
if (cur == nullptr) return nullptr;
- return extract_pkey_from_x509(cur->string_value().c_str());
+ return extract_pkey_from_x509(cur->string_value().c_str());
}
- if (jwt_keys->type() != Json::Type::ARRAY) {
+ if (jwt_keys->type() != Json::Type::ARRAY) {
gpr_log(GPR_ERROR,
"Unexpected value type of keys property in jwks key set.");
return nullptr;
}
/* Key format is specified in:
https://tools.ietf.org/html/rfc7518#section-6. */
- for (const Json& jkey : jwt_keys->array_value()) {
- if (jkey.type() != Json::Type::OBJECT) continue;
+ for (const Json& jkey : jwt_keys->array_value()) {
+ if (jkey.type() != Json::Type::OBJECT) continue;
const char* alg = nullptr;
- auto it = jkey.object_value().find("alg");
- if (it != jkey.object_value().end()) {
- alg = validate_string_field(it->second, "alg");
- }
+ auto it = jkey.object_value().find("alg");
+ if (it != jkey.object_value().end()) {
+ alg = validate_string_field(it->second, "alg");
+ }
const char* kid = nullptr;
- it = jkey.object_value().find("kid");
- if (it != jkey.object_value().end()) {
- kid = validate_string_field(it->second, "kid");
- }
+ it = jkey.object_value().find("kid");
+ if (it != jkey.object_value().end()) {
+ kid = validate_string_field(it->second, "kid");
+ }
const char* kty = nullptr;
- it = jkey.object_value().find("kty");
- if (it != jkey.object_value().end()) {
- kty = validate_string_field(it->second, "kty");
+ it = jkey.object_value().find("kty");
+ if (it != jkey.object_value().end()) {
+ kty = validate_string_field(it->second, "kty");
}
if (alg != nullptr && kid != nullptr && kty != nullptr &&
strcmp(kid, header_kid) == 0 && strcmp(alg, header_alg) == 0) {
@@ -628,12 +628,12 @@ end:
static void on_keys_retrieved(void* user_data, grpc_error* /*error*/) {
verifier_cb_ctx* ctx = static_cast<verifier_cb_ctx*>(user_data);
- Json json = json_from_http(&ctx->responses[HTTP_RESPONSE_KEYS]);
+ Json json = json_from_http(&ctx->responses[HTTP_RESPONSE_KEYS]);
EVP_PKEY* verification_key = nullptr;
grpc_jwt_verifier_status status = GRPC_JWT_VERIFIER_GENERIC_ERROR;
grpc_jwt_claims* claims = nullptr;
- if (json.type() == Json::Type::JSON_NULL) {
+ if (json.type() == Json::Type::JSON_NULL) {
status = GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR;
goto end;
}
@@ -668,20 +668,20 @@ end:
static void on_openid_config_retrieved(void* user_data, grpc_error* /*error*/) {
verifier_cb_ctx* ctx = static_cast<verifier_cb_ctx*>(user_data);
const grpc_http_response* response = &ctx->responses[HTTP_RESPONSE_OPENID];
- Json json = json_from_http(response);
+ Json json = json_from_http(response);
grpc_httpcli_request req;
const char* jwks_uri;
grpc_resource_quota* resource_quota = nullptr;
- const Json* cur;
+ const Json* cur;
/* TODO(jboeuf): Cache the jwks_uri in order to avoid this hop next time. */
- if (json.type() == Json::Type::JSON_NULL) goto error;
+ if (json.type() == Json::Type::JSON_NULL) goto error;
cur = find_property_by_name(json, "jwks_uri");
if (cur == nullptr) {
gpr_log(GPR_ERROR, "Could not find jwks_uri in openid config.");
goto error;
}
- jwks_uri = validate_string_field(*cur, "jwks_uri");
+ jwks_uri = validate_string_field(*cur, "jwks_uri");
if (jwks_uri == nullptr) goto error;
if (strstr(jwks_uri, "https://") != jwks_uri) {
gpr_log(GPR_ERROR, "Invalid non https jwks_uri: %s.", jwks_uri);
@@ -852,23 +852,23 @@ void grpc_jwt_verifier_verify(grpc_jwt_verifier* verifier,
grpc_slice signature;
size_t signed_jwt_len;
const char* cur = jwt;
- Json json;
+ Json json;
GPR_ASSERT(verifier != nullptr && jwt != nullptr && audience != nullptr &&
cb != nullptr);
dot = strchr(cur, '.');
if (dot == nullptr) goto error;
- json = parse_json_part_from_jwt(cur, static_cast<size_t>(dot - cur));
- if (json.type() == Json::Type::JSON_NULL) goto error;
- header = jose_header_from_json(std::move(json));
+ json = parse_json_part_from_jwt(cur, static_cast<size_t>(dot - cur));
+ if (json.type() == Json::Type::JSON_NULL) goto error;
+ header = jose_header_from_json(std::move(json));
if (header == nullptr) goto error;
cur = dot + 1;
dot = strchr(cur, '.');
if (dot == nullptr) goto error;
- json = parse_json_part_from_jwt(cur, static_cast<size_t>(dot - cur));
- if (json.type() == Json::Type::JSON_NULL) goto error;
- claims = grpc_jwt_claims_from_json(std::move(json));
+ json = parse_json_part_from_jwt(cur, static_cast<size_t>(dot - cur));
+ if (json.type() == Json::Type::JSON_NULL) goto error;
+ claims = grpc_jwt_claims_from_json(std::move(json));
if (claims == nullptr) goto error;
signed_jwt_len = static_cast<size_t>(dot - jwt);
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_verifier.h b/contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_verifier.h
index 4a799b1601..66ddbf2206 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_verifier.h
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_verifier.h
@@ -56,7 +56,7 @@ typedef struct grpc_jwt_claims grpc_jwt_claims;
void grpc_jwt_claims_destroy(grpc_jwt_claims* claims);
/* Returns the whole JSON tree of the claims. */
-const grpc_core::Json* grpc_jwt_claims_json(const grpc_jwt_claims* claims);
+const grpc_core::Json* grpc_jwt_claims_json(const grpc_jwt_claims* claims);
/* Access to registered claims in https://tools.ietf.org/html/rfc7519#page-9 */
const char* grpc_jwt_claims_subject(const grpc_jwt_claims* claims);
@@ -114,7 +114,7 @@ void grpc_jwt_verifier_verify(grpc_jwt_verifier* verifier,
/* --- TESTING ONLY exposed functions. --- */
-grpc_jwt_claims* grpc_jwt_claims_from_json(grpc_core::Json json);
+grpc_jwt_claims* grpc_jwt_claims_from_json(grpc_core::Json json);
grpc_jwt_verifier_status grpc_jwt_claims_check(const grpc_jwt_claims* claims,
const char* audience);
const char* grpc_jwt_issuer_email_domain(const char* issuer);
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc b/contrib/libs/grpc/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
index bd1204e5c6..552ee37cfc 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
@@ -23,11 +23,11 @@
#include <string.h>
-#include "y_absl/container/inlined_vector.h"
-#include "y_absl/strings/str_cat.h"
-#include "y_absl/strings/str_format.h"
-#include "y_absl/strings/str_join.h"
-
+#include "y_absl/container/inlined_vector.h"
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/str_join.h"
+
#include <grpc/grpc_security.h>
#include <grpc/impl/codegen/slice.h>
#include <grpc/slice.h>
@@ -44,8 +44,8 @@
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/uri/uri_parser.h"
-using grpc_core::Json;
-
+using grpc_core::Json;
+
//
// Auth Refresh Token.
//
@@ -57,7 +57,7 @@ int grpc_auth_refresh_token_is_valid(
}
grpc_auth_refresh_token grpc_auth_refresh_token_create_from_json(
- const Json& json) {
+ const Json& json) {
grpc_auth_refresh_token result;
const char* prop_value;
int success = 0;
@@ -65,7 +65,7 @@ grpc_auth_refresh_token grpc_auth_refresh_token_create_from_json(
memset(&result, 0, sizeof(grpc_auth_refresh_token));
result.type = GRPC_AUTH_JSON_TYPE_INVALID;
- if (json.type() != Json::Type::OBJECT) {
+ if (json.type() != Json::Type::OBJECT) {
gpr_log(GPR_ERROR, "Invalid json.");
goto end;
}
@@ -94,13 +94,13 @@ end:
grpc_auth_refresh_token grpc_auth_refresh_token_create_from_string(
const char* json_string) {
- grpc_error* error = GRPC_ERROR_NONE;
- Json json = Json::Parse(json_string, &error);
- if (error != GRPC_ERROR_NONE) {
- gpr_log(GPR_ERROR, "JSON parsing failed: %s", grpc_error_string(error));
- GRPC_ERROR_UNREF(error);
- }
- return grpc_auth_refresh_token_create_from_json(json);
+ grpc_error* error = GRPC_ERROR_NONE;
+ Json json = Json::Parse(json_string, &error);
+ if (error != GRPC_ERROR_NONE) {
+ gpr_log(GPR_ERROR, "JSON parsing failed: %s", grpc_error_string(error));
+ GRPC_ERROR_UNREF(error);
+ }
+ return grpc_auth_refresh_token_create_from_json(json);
}
void grpc_auth_refresh_token_destruct(grpc_auth_refresh_token* refresh_token) {
@@ -138,7 +138,7 @@ grpc_oauth2_token_fetcher_credentials_parse_server_response(
grpc_millis* token_lifetime) {
char* null_terminated_body = nullptr;
grpc_credentials_status status = GRPC_CREDENTIALS_OK;
- Json json;
+ Json json;
if (response == nullptr) {
gpr_log(GPR_ERROR, "Received NULL response.");
@@ -160,54 +160,54 @@ grpc_oauth2_token_fetcher_credentials_parse_server_response(
status = GRPC_CREDENTIALS_ERROR;
goto end;
} else {
- const char* access_token = nullptr;
- const char* token_type = nullptr;
- const char* expires_in = nullptr;
- Json::Object::const_iterator it;
- grpc_error* error = GRPC_ERROR_NONE;
- json = Json::Parse(null_terminated_body, &error);
- if (error != GRPC_ERROR_NONE) {
- gpr_log(GPR_ERROR, "Could not parse JSON from %s: %s",
- null_terminated_body, grpc_error_string(error));
- GRPC_ERROR_UNREF(error);
+ const char* access_token = nullptr;
+ const char* token_type = nullptr;
+ const char* expires_in = nullptr;
+ Json::Object::const_iterator it;
+ grpc_error* error = GRPC_ERROR_NONE;
+ json = Json::Parse(null_terminated_body, &error);
+ if (error != GRPC_ERROR_NONE) {
+ gpr_log(GPR_ERROR, "Could not parse JSON from %s: %s",
+ null_terminated_body, grpc_error_string(error));
+ GRPC_ERROR_UNREF(error);
status = GRPC_CREDENTIALS_ERROR;
goto end;
}
- if (json.type() != Json::Type::OBJECT) {
+ if (json.type() != Json::Type::OBJECT) {
gpr_log(GPR_ERROR, "Response should be a JSON object");
status = GRPC_CREDENTIALS_ERROR;
goto end;
}
- it = json.object_value().find("access_token");
- if (it == json.object_value().end() ||
- it->second.type() != Json::Type::STRING) {
+ it = json.object_value().find("access_token");
+ if (it == json.object_value().end() ||
+ it->second.type() != Json::Type::STRING) {
gpr_log(GPR_ERROR, "Missing or invalid access_token in JSON.");
status = GRPC_CREDENTIALS_ERROR;
goto end;
}
- access_token = it->second.string_value().c_str();
- it = json.object_value().find("token_type");
- if (it == json.object_value().end() ||
- it->second.type() != Json::Type::STRING) {
+ access_token = it->second.string_value().c_str();
+ it = json.object_value().find("token_type");
+ if (it == json.object_value().end() ||
+ it->second.type() != Json::Type::STRING) {
gpr_log(GPR_ERROR, "Missing or invalid token_type in JSON.");
status = GRPC_CREDENTIALS_ERROR;
goto end;
}
- token_type = it->second.string_value().c_str();
- it = json.object_value().find("expires_in");
- if (it == json.object_value().end() ||
- it->second.type() != Json::Type::NUMBER) {
+ token_type = it->second.string_value().c_str();
+ it = json.object_value().find("expires_in");
+ if (it == json.object_value().end() ||
+ it->second.type() != Json::Type::NUMBER) {
gpr_log(GPR_ERROR, "Missing or invalid expires_in in JSON.");
status = GRPC_CREDENTIALS_ERROR;
goto end;
}
- expires_in = it->second.string_value().c_str();
- *token_lifetime = strtol(expires_in, nullptr, 10) * GPR_MS_PER_SEC;
+ expires_in = it->second.string_value().c_str();
+ *token_lifetime = strtol(expires_in, nullptr, 10) * GPR_MS_PER_SEC;
if (!GRPC_MDISNULL(*token_md)) GRPC_MDELEM_UNREF(*token_md);
*token_md = grpc_mdelem_from_slices(
grpc_core::ExternallyManagedSlice(GRPC_AUTHORIZATION_METADATA_KEY),
- grpc_slice_from_cpp_string(
- y_absl::StrCat(token_type, " ", access_token)));
+ grpc_slice_from_cpp_string(
+ y_absl::StrCat(token_type, " ", access_token)));
status = GRPC_CREDENTIALS_OK;
}
@@ -216,7 +216,7 @@ end:
GRPC_MDELEM_UNREF(*token_md);
*token_md = GRPC_MDNULL;
}
- gpr_free(null_terminated_body);
+ gpr_free(null_terminated_body);
return status;
}
@@ -360,10 +360,10 @@ grpc_oauth2_token_fetcher_credentials::grpc_oauth2_token_fetcher_credentials()
grpc_httpcli_context_init(&httpcli_context_);
}
-TString grpc_oauth2_token_fetcher_credentials::debug_string() {
- return "OAuth2TokenFetcherCredentials";
-}
-
+TString grpc_oauth2_token_fetcher_credentials::debug_string() {
+ return "OAuth2TokenFetcherCredentials";
+}
+
//
// Google Compute Engine credentials.
//
@@ -402,12 +402,12 @@ class grpc_compute_engine_token_fetcher_credentials
grpc_resource_quota_unref_internal(resource_quota);
}
- TString debug_string() override {
- return y_absl::StrFormat(
- "GoogleComputeEngineTokenFetcherCredentials{%s}",
- grpc_oauth2_token_fetcher_credentials::debug_string());
- }
-
+ TString debug_string() override {
+ return y_absl::StrFormat(
+ "GoogleComputeEngineTokenFetcherCredentials{%s}",
+ grpc_oauth2_token_fetcher_credentials::debug_string());
+ }
+
private:
grpc_closure http_get_cb_closure_;
};
@@ -441,9 +441,9 @@ void grpc_google_refresh_token_credentials::fetch_oauth2(
const_cast<char*>("Content-Type"),
const_cast<char*>("application/x-www-form-urlencoded")};
grpc_httpcli_request request;
- TString body = y_absl::StrFormat(
- GRPC_REFRESH_TOKEN_POST_BODY_FORMAT_STRING, refresh_token_.client_id,
- refresh_token_.client_secret, refresh_token_.refresh_token);
+ TString body = y_absl::StrFormat(
+ GRPC_REFRESH_TOKEN_POST_BODY_FORMAT_STRING, refresh_token_.client_id,
+ refresh_token_.client_secret, refresh_token_.refresh_token);
memset(&request, 0, sizeof(grpc_httpcli_request));
request.host = (char*)GRPC_GOOGLE_OAUTH2_SERVICE_HOST;
request.http.path = (char*)GRPC_GOOGLE_OAUTH2_SERVICE_TOKEN_PATH;
@@ -455,8 +455,8 @@ void grpc_google_refresh_token_credentials::fetch_oauth2(
extreme memory pressure. */
grpc_resource_quota* resource_quota =
grpc_resource_quota_create("oauth2_credentials_refresh");
- grpc_httpcli_post(httpcli_context, pollent, resource_quota, &request,
- body.c_str(), body.size(), deadline,
+ grpc_httpcli_post(httpcli_context, pollent, resource_quota, &request,
+ body.c_str(), body.size(), deadline,
GRPC_CLOSURE_INIT(&http_post_cb_closure_, response_cb,
metadata_req, grpc_schedule_on_exec_ctx),
&metadata_req->response);
@@ -478,21 +478,21 @@ grpc_refresh_token_credentials_create_from_auth_refresh_token(
refresh_token);
}
-TString grpc_google_refresh_token_credentials::debug_string() {
- return y_absl::StrFormat("GoogleRefreshToken{ClientID:%s,%s}",
- refresh_token_.client_id,
- grpc_oauth2_token_fetcher_credentials::debug_string());
-}
-
-static TString create_loggable_refresh_token(
- grpc_auth_refresh_token* token) {
+TString grpc_google_refresh_token_credentials::debug_string() {
+ return y_absl::StrFormat("GoogleRefreshToken{ClientID:%s,%s}",
+ refresh_token_.client_id,
+ grpc_oauth2_token_fetcher_credentials::debug_string());
+}
+
+static TString create_loggable_refresh_token(
+ grpc_auth_refresh_token* token) {
if (strcmp(token->type, GRPC_AUTH_JSON_TYPE_INVALID) == 0) {
- return "<Invalid json token>";
+ return "<Invalid json token>";
}
- return y_absl::StrFormat(
- "{\n type: %s\n client_id: %s\n client_secret: "
- "<redacted>\n refresh_token: <redacted>\n}",
- token->type, token->client_id);
+ return y_absl::StrFormat(
+ "{\n type: %s\n client_id: %s\n client_secret: "
+ "<redacted>\n refresh_token: <redacted>\n}",
+ token->type, token->client_id);
}
grpc_call_credentials* grpc_google_refresh_token_credentials_create(
@@ -503,7 +503,7 @@ grpc_call_credentials* grpc_google_refresh_token_credentials_create(
gpr_log(GPR_INFO,
"grpc_refresh_token_credentials_create(json_refresh_token=%s, "
"reserved=%p)",
- create_loggable_refresh_token(&token).c_str(), reserved);
+ create_loggable_refresh_token(&token).c_str(), reserved);
}
GPR_ASSERT(reserved == nullptr);
return grpc_refresh_token_credentials_create_from_auth_refresh_token(token)
@@ -518,10 +518,10 @@ namespace grpc_core {
namespace {
-void MaybeAddToBody(const char* field_name, const char* field,
- std::vector<TString>* body) {
+void MaybeAddToBody(const char* field_name, const char* field,
+ std::vector<TString>* body) {
if (field == nullptr || strlen(field) == 0) return;
- body->push_back(y_absl::StrFormat("&%s=%s", field_name, field));
+ body->push_back(y_absl::StrFormat("&%s=%s", field_name, field));
}
grpc_error* LoadTokenFile(const char* path, gpr_slice* token) {
@@ -551,13 +551,13 @@ class StsTokenFetcherCredentials
~StsTokenFetcherCredentials() override { grpc_uri_destroy(sts_url_); }
- TString debug_string() override {
- return y_absl::StrFormat(
- "StsTokenFetcherCredentials{Path:%s,Authority:%s,%s}", sts_url_->path,
- sts_url_->authority,
- grpc_oauth2_token_fetcher_credentials::debug_string());
- }
-
+ TString debug_string() override {
+ return y_absl::StrFormat(
+ "StsTokenFetcherCredentials{Path:%s,Authority:%s,%s}", sts_url_->path,
+ sts_url_->authority,
+ grpc_oauth2_token_fetcher_credentials::debug_string());
+ }
+
private:
void fetch_oauth2(grpc_credentials_metadata_request* metadata_req,
grpc_httpcli_context* http_context,
@@ -601,17 +601,17 @@ class StsTokenFetcherCredentials
grpc_error* FillBody(char** body, size_t* body_length) {
*body = nullptr;
- std::vector<TString> body_parts;
+ std::vector<TString> body_parts;
grpc_slice subject_token = grpc_empty_slice();
grpc_slice actor_token = grpc_empty_slice();
grpc_error* err = GRPC_ERROR_NONE;
- auto cleanup = [&body, &body_length, &body_parts, &subject_token,
+ auto cleanup = [&body, &body_length, &body_parts, &subject_token,
&actor_token, &err]() {
if (err == GRPC_ERROR_NONE) {
- TString body_str = y_absl::StrJoin(body_parts, "");
- *body = gpr_strdup(body_str.c_str());
- *body_length = body_str.size();
+ TString body_str = y_absl::StrJoin(body_parts, "");
+ *body = gpr_strdup(body_str.c_str());
+ *body_length = body_str.size();
}
grpc_slice_unref_internal(subject_token);
grpc_slice_unref_internal(actor_token);
@@ -620,23 +620,23 @@ class StsTokenFetcherCredentials
err = LoadTokenFile(subject_token_path_.get(), &subject_token);
if (err != GRPC_ERROR_NONE) return cleanup();
- body_parts.push_back(y_absl::StrFormat(
- GRPC_STS_POST_MINIMAL_BODY_FORMAT_STRING,
+ body_parts.push_back(y_absl::StrFormat(
+ GRPC_STS_POST_MINIMAL_BODY_FORMAT_STRING,
reinterpret_cast<const char*>(GRPC_SLICE_START_PTR(subject_token)),
- subject_token_type_.get()));
- MaybeAddToBody("resource", resource_.get(), &body_parts);
- MaybeAddToBody("audience", audience_.get(), &body_parts);
- MaybeAddToBody("scope", scope_.get(), &body_parts);
- MaybeAddToBody("requested_token_type", requested_token_type_.get(),
- &body_parts);
- if ((actor_token_path_ != nullptr) && *actor_token_path_ != '\0') {
+ subject_token_type_.get()));
+ MaybeAddToBody("resource", resource_.get(), &body_parts);
+ MaybeAddToBody("audience", audience_.get(), &body_parts);
+ MaybeAddToBody("scope", scope_.get(), &body_parts);
+ MaybeAddToBody("requested_token_type", requested_token_type_.get(),
+ &body_parts);
+ if ((actor_token_path_ != nullptr) && *actor_token_path_ != '\0') {
err = LoadTokenFile(actor_token_path_.get(), &actor_token);
if (err != GRPC_ERROR_NONE) return cleanup();
MaybeAddToBody(
- "actor_token",
- reinterpret_cast<const char*>(GRPC_SLICE_START_PTR(actor_token)),
- &body_parts);
- MaybeAddToBody("actor_token_type", actor_token_type_.get(), &body_parts);
+ "actor_token",
+ reinterpret_cast<const char*>(GRPC_SLICE_START_PTR(actor_token)),
+ &body_parts);
+ MaybeAddToBody("actor_token_type", actor_token_type_.get(), &body_parts);
}
return cleanup();
}
@@ -661,7 +661,7 @@ grpc_error* ValidateStsCredentialsOptions(
void operator()(grpc_uri* uri) { grpc_uri_destroy(uri); }
};
*sts_url_out = nullptr;
- y_absl::InlinedVector<grpc_error*, 3> error_list;
+ y_absl::InlinedVector<grpc_error*, 3> error_list;
std::unique_ptr<grpc_uri, GrpcUriDeleter> sts_url(
options->token_exchange_service_uri != nullptr
? grpc_uri_parse(options->token_exchange_service_uri, false)
@@ -741,15 +741,15 @@ grpc_access_token_credentials::grpc_access_token_credentials(
grpc_core::ExecCtx exec_ctx;
access_token_md_ = grpc_mdelem_from_slices(
grpc_core::ExternallyManagedSlice(GRPC_AUTHORIZATION_METADATA_KEY),
- grpc_slice_from_cpp_string(y_absl::StrCat("Bearer ", access_token)));
+ grpc_slice_from_cpp_string(y_absl::StrCat("Bearer ", access_token)));
+}
+
+TString grpc_access_token_credentials::debug_string() {
+ bool access_token_present = !GRPC_MDISNULL(access_token_md_);
+ return y_absl::StrFormat("AccessTokenCredentials{Token:%s}",
+ access_token_present ? "present" : "absent");
}
-TString grpc_access_token_credentials::debug_string() {
- bool access_token_present = !GRPC_MDISNULL(access_token_md_);
- return y_absl::StrFormat("AccessTokenCredentials{Token:%s}",
- access_token_present ? "present" : "absent");
-}
-
grpc_call_credentials* grpc_access_token_credentials_create(
const char* access_token, void* reserved) {
GRPC_API_TRACE(
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/oauth2/oauth2_credentials.h b/contrib/libs/grpc/src/core/lib/security/credentials/oauth2/oauth2_credentials.h
index 96f7479c5e..fd886405cf 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/oauth2/oauth2_credentials.h
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/oauth2/oauth2_credentials.h
@@ -21,8 +21,8 @@
#include <grpc/support/port_platform.h>
-#include <util/generic/string.h>
-
+#include <util/generic/string.h>
+
#include <grpc/grpc_security.h>
#include "src/core/lib/json/json.h"
#include "src/core/lib/security/credentials/credentials.h"
@@ -52,7 +52,7 @@ grpc_auth_refresh_token grpc_auth_refresh_token_create_from_string(
/// Creates a refresh token object from parsed json. Returns an invalid object
/// if a parsing error has been encountered.
grpc_auth_refresh_token grpc_auth_refresh_token_create_from_json(
- const grpc_core::Json& json);
+ const grpc_core::Json& json);
/// Destructs the object.
void grpc_auth_refresh_token_destruct(grpc_auth_refresh_token* refresh_token);
@@ -85,7 +85,7 @@ class grpc_oauth2_token_fetcher_credentials : public grpc_call_credentials {
void on_http_response(grpc_credentials_metadata_request* r,
grpc_error* error);
- TString debug_string() override;
+ TString debug_string() override;
protected:
virtual void fetch_oauth2(grpc_credentials_metadata_request* req,
@@ -114,8 +114,8 @@ class grpc_google_refresh_token_credentials final
return refresh_token_;
}
- TString debug_string() override;
-
+ TString debug_string() override;
+
protected:
void fetch_oauth2(grpc_credentials_metadata_request* req,
grpc_httpcli_context* httpcli_context,
@@ -142,8 +142,8 @@ class grpc_access_token_credentials final : public grpc_call_credentials {
void cancel_get_request_metadata(grpc_credentials_mdelem_array* md_array,
grpc_error* error) override;
- TString debug_string() override;
-
+ TString debug_string() override;
+
private:
grpc_mdelem access_token_md_;
};
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/plugin/plugin_credentials.cc b/contrib/libs/grpc/src/core/lib/security/credentials/plugin/plugin_credentials.cc
index 3c172053a2..40d8fec6e4 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/plugin/plugin_credentials.cc
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/plugin/plugin_credentials.cc
@@ -22,8 +22,8 @@
#include <string.h>
-#include "y_absl/strings/str_cat.h"
-
+#include "y_absl/strings/str_cat.h"
+
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@@ -43,19 +43,19 @@ grpc_plugin_credentials::~grpc_plugin_credentials() {
}
}
-TString grpc_plugin_credentials::debug_string() {
- char* debug_c_str = nullptr;
- if (plugin_.debug_string != nullptr) {
- debug_c_str = plugin_.debug_string(plugin_.state);
- }
- TString debug_str(
- debug_c_str != nullptr
- ? debug_c_str
- : "grpc_plugin_credentials did not provide a debug string");
- gpr_free(debug_c_str);
- return debug_str;
-}
-
+TString grpc_plugin_credentials::debug_string() {
+ char* debug_c_str = nullptr;
+ if (plugin_.debug_string != nullptr) {
+ debug_c_str = plugin_.debug_string(plugin_.state);
+ }
+ TString debug_str(
+ debug_c_str != nullptr
+ ? debug_c_str
+ : "grpc_plugin_credentials did not provide a debug string");
+ gpr_free(debug_c_str);
+ return debug_str;
+}
+
void grpc_plugin_credentials::pending_request_remove_locked(
pending_request* pending_request) {
if (pending_request->prev == nullptr) {
@@ -87,10 +87,10 @@ static grpc_error* process_plugin_result(
size_t num_md, grpc_status_code status, const char* error_details) {
grpc_error* error = GRPC_ERROR_NONE;
if (status != GRPC_STATUS_OK) {
- error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
- y_absl::StrCat("Getting metadata from plugin failed with error: ",
- error_details)
- .c_str());
+ error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
+ y_absl::StrCat("Getting metadata from plugin failed with error: ",
+ error_details)
+ .c_str());
} else {
bool seen_illegal_header = false;
for (size_t i = 0; i < num_md; ++i) {
@@ -253,17 +253,17 @@ void grpc_plugin_credentials::cancel_get_request_metadata(
}
grpc_plugin_credentials::grpc_plugin_credentials(
- grpc_metadata_credentials_plugin plugin,
- grpc_security_level min_security_level)
- : grpc_call_credentials(plugin.type, min_security_level), plugin_(plugin) {
+ grpc_metadata_credentials_plugin plugin,
+ grpc_security_level min_security_level)
+ : grpc_call_credentials(plugin.type, min_security_level), plugin_(plugin) {
gpr_mu_init(&mu_);
}
grpc_call_credentials* grpc_metadata_credentials_create_from_plugin(
- grpc_metadata_credentials_plugin plugin,
- grpc_security_level min_security_level, void* reserved) {
+ grpc_metadata_credentials_plugin plugin,
+ grpc_security_level min_security_level, void* reserved) {
GRPC_API_TRACE("grpc_metadata_credentials_create_from_plugin(reserved=%p)", 1,
(reserved));
GPR_ASSERT(reserved == nullptr);
- return new grpc_plugin_credentials(plugin, min_security_level);
+ return new grpc_plugin_credentials(plugin, min_security_level);
}
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/plugin/plugin_credentials.h b/contrib/libs/grpc/src/core/lib/security/credentials/plugin/plugin_credentials.h
index aaac8165f3..78bca05fb9 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/plugin/plugin_credentials.h
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/plugin/plugin_credentials.h
@@ -39,8 +39,8 @@ struct grpc_plugin_credentials final : public grpc_call_credentials {
struct pending_request* next;
};
- explicit grpc_plugin_credentials(grpc_metadata_credentials_plugin plugin,
- grpc_security_level min_security_level);
+ explicit grpc_plugin_credentials(grpc_metadata_credentials_plugin plugin,
+ grpc_security_level min_security_level);
~grpc_plugin_credentials() override;
bool get_request_metadata(grpc_polling_entity* pollent,
@@ -59,8 +59,8 @@ struct grpc_plugin_credentials final : public grpc_call_credentials {
// cancelled before completion.
void pending_request_complete(pending_request* r);
- TString debug_string() override;
-
+ TString debug_string() override;
+
private:
void pending_request_remove_locked(pending_request* pending_request);
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/ssl/ssl_credentials.cc b/contrib/libs/grpc/src/core/lib/security/credentials/ssl/ssl_credentials.cc
index 76edf780f4..3bb7790f5c 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/ssl/ssl_credentials.cc
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/ssl/ssl_credentials.cc
@@ -117,16 +117,16 @@ void grpc_ssl_credentials::build_config(
}
}
-void grpc_ssl_credentials::set_min_tls_version(
- grpc_tls_version min_tls_version) {
- config_.min_tls_version = min_tls_version;
-}
-
-void grpc_ssl_credentials::set_max_tls_version(
- grpc_tls_version max_tls_version) {
- config_.max_tls_version = max_tls_version;
-}
-
+void grpc_ssl_credentials::set_min_tls_version(
+ grpc_tls_version min_tls_version) {
+ config_.min_tls_version = min_tls_version;
+}
+
+void grpc_ssl_credentials::set_max_tls_version(
+ grpc_tls_version max_tls_version) {
+ config_.max_tls_version = max_tls_version;
+}
+
/* Deprecated in favor of grpc_ssl_credentials_create_ex. Will be removed
* once all of its call sites are migrated to grpc_ssl_credentials_create_ex. */
grpc_channel_credentials* grpc_ssl_credentials_create(
@@ -223,16 +223,16 @@ void grpc_ssl_server_credentials::build_config(
config_.num_key_cert_pairs = num_key_cert_pairs;
}
-void grpc_ssl_server_credentials::set_min_tls_version(
- grpc_tls_version min_tls_version) {
- config_.min_tls_version = min_tls_version;
-}
-
-void grpc_ssl_server_credentials::set_max_tls_version(
- grpc_tls_version max_tls_version) {
- config_.max_tls_version = max_tls_version;
-}
-
+void grpc_ssl_server_credentials::set_min_tls_version(
+ grpc_tls_version min_tls_version) {
+ config_.min_tls_version = min_tls_version;
+}
+
+void grpc_ssl_server_credentials::set_max_tls_version(
+ grpc_tls_version max_tls_version) {
+ config_.max_tls_version = max_tls_version;
+}
+
grpc_ssl_server_certificate_config* grpc_ssl_server_certificate_config_create(
const char* pem_root_certs,
const grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs,
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/ssl/ssl_credentials.h b/contrib/libs/grpc/src/core/lib/security/credentials/ssl/ssl_credentials.h
index f06aa0c575..4c90813f8d 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/ssl/ssl_credentials.h
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/ssl/ssl_credentials.h
@@ -38,11 +38,11 @@ class grpc_ssl_credentials : public grpc_channel_credentials {
const char* target, const grpc_channel_args* args,
grpc_channel_args** new_args) override;
- // TODO(mattstev): Plumb to wrapped languages. Until then, setting the TLS
- // version should be done for testing purposes only.
- void set_min_tls_version(grpc_tls_version min_tls_version);
- void set_max_tls_version(grpc_tls_version max_tls_version);
-
+ // TODO(mattstev): Plumb to wrapped languages. Until then, setting the TLS
+ // version should be done for testing purposes only.
+ void set_min_tls_version(grpc_tls_version min_tls_version);
+ void set_max_tls_version(grpc_tls_version max_tls_version);
+
private:
void build_config(const char* pem_root_certs,
grpc_ssl_pem_key_cert_pair* pem_key_cert_pair,
@@ -82,11 +82,11 @@ class grpc_ssl_server_credentials final : public grpc_server_credentials {
config);
}
- // TODO(mattstev): Plumb to wrapped languages. Until then, setting the TLS
- // version should be done for testing purposes only.
- void set_min_tls_version(grpc_tls_version min_tls_version);
- void set_max_tls_version(grpc_tls_version max_tls_version);
-
+ // TODO(mattstev): Plumb to wrapped languages. Until then, setting the TLS
+ // version should be done for testing purposes only.
+ void set_min_tls_version(grpc_tls_version min_tls_version);
+ void set_max_tls_version(grpc_tls_version max_tls_version);
+
const grpc_ssl_server_config& config() const { return config_; }
private:
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc b/contrib/libs/grpc/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc
index a03d040ebb..a925cf613e 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc
@@ -1,321 +1,321 @@
-//
-// Copyright 2020 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-#include <grpc/support/port_platform.h>
-
-#include "src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h"
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/string_util.h>
-#include <stdlib.h>
-#include <string.h>
-
-void grpc_tls_certificate_distributor::SetKeyMaterials(
- const TString& cert_name, y_absl::optional<TString> pem_root_certs,
- y_absl::optional<PemKeyCertPairList> pem_key_cert_pairs) {
- GPR_ASSERT(pem_root_certs.has_value() || pem_key_cert_pairs.has_value());
- grpc_core::MutexLock lock(&mu_);
- auto& cert_info = certificate_info_map_[cert_name];
- if (pem_root_certs.has_value()) {
- // Successful credential updates will clear any pre-existing error.
- cert_info.SetRootError(GRPC_ERROR_NONE);
- for (auto* watcher_ptr : cert_info.root_cert_watchers) {
- GPR_ASSERT(watcher_ptr != nullptr);
- const auto watcher_it = watchers_.find(watcher_ptr);
- GPR_ASSERT(watcher_it != watchers_.end());
- GPR_ASSERT(watcher_it->second.root_cert_name.has_value());
- y_absl::optional<PemKeyCertPairList> pem_key_cert_pairs_to_report;
- if (pem_key_cert_pairs.has_value() &&
- watcher_it->second.identity_cert_name == cert_name) {
- pem_key_cert_pairs_to_report = pem_key_cert_pairs;
- } else if (watcher_it->second.identity_cert_name.has_value()) {
- auto& identity_cert_info =
- certificate_info_map_[*watcher_it->second.identity_cert_name];
- pem_key_cert_pairs_to_report = identity_cert_info.pem_key_cert_pairs;
- }
- watcher_ptr->OnCertificatesChanged(
- pem_root_certs, std::move(pem_key_cert_pairs_to_report));
- }
- cert_info.pem_root_certs = std::move(*pem_root_certs);
- }
- if (pem_key_cert_pairs.has_value()) {
- // Successful credential updates will clear any pre-existing error.
- cert_info.SetIdentityError(GRPC_ERROR_NONE);
- for (const auto watcher_ptr : cert_info.identity_cert_watchers) {
- GPR_ASSERT(watcher_ptr != nullptr);
- const auto watcher_it = watchers_.find(watcher_ptr);
- GPR_ASSERT(watcher_it != watchers_.end());
- GPR_ASSERT(watcher_it->second.identity_cert_name.has_value());
- y_absl::optional<y_absl::string_view> pem_root_certs_to_report;
- if (pem_root_certs.has_value() &&
- watcher_it->second.root_cert_name == cert_name) {
- // In this case, We've already sent the credential updates at the time
- // when checking pem_root_certs, so we will skip here.
- continue;
- } else if (watcher_it->second.root_cert_name.has_value()) {
- auto& root_cert_info =
- certificate_info_map_[*watcher_it->second.root_cert_name];
- pem_root_certs_to_report = root_cert_info.pem_root_certs;
- }
- watcher_ptr->OnCertificatesChanged(pem_root_certs_to_report,
- pem_key_cert_pairs);
- }
- cert_info.pem_key_cert_pairs = std::move(*pem_key_cert_pairs);
- }
-}
-
-bool grpc_tls_certificate_distributor::HasRootCerts(
- const TString& root_cert_name) {
- grpc_core::MutexLock lock(&mu_);
- const auto it = certificate_info_map_.find(root_cert_name);
- return it != certificate_info_map_.end() &&
- !it->second.pem_root_certs.empty();
-};
-
-bool grpc_tls_certificate_distributor::HasKeyCertPairs(
- const TString& identity_cert_name) {
- grpc_core::MutexLock lock(&mu_);
- const auto it = certificate_info_map_.find(identity_cert_name);
- return it != certificate_info_map_.end() &&
- !it->second.pem_key_cert_pairs.empty();
-};
-
-void grpc_tls_certificate_distributor::SetErrorForCert(
- const TString& cert_name, y_absl::optional<grpc_error*> root_cert_error,
- y_absl::optional<grpc_error*> identity_cert_error) {
- GPR_ASSERT(root_cert_error.has_value() || identity_cert_error.has_value());
- grpc_core::MutexLock lock(&mu_);
- CertificateInfo& cert_info = certificate_info_map_[cert_name];
- if (root_cert_error.has_value()) {
- for (auto* watcher_ptr : cert_info.root_cert_watchers) {
- GPR_ASSERT(watcher_ptr != nullptr);
- const auto watcher_it = watchers_.find(watcher_ptr);
- GPR_ASSERT(watcher_it != watchers_.end());
- // identity_cert_error_to_report is the error of the identity cert this
- // watcher is watching, if there is any.
- grpc_error* identity_cert_error_to_report = GRPC_ERROR_NONE;
- if (identity_cert_error.has_value() &&
- watcher_it->second.identity_cert_name == cert_name) {
- identity_cert_error_to_report = *identity_cert_error;
- } else if (watcher_it->second.identity_cert_name.has_value()) {
- auto& identity_cert_info =
- certificate_info_map_[*watcher_it->second.identity_cert_name];
- identity_cert_error_to_report = identity_cert_info.identity_cert_error;
- }
- watcher_ptr->OnError(GRPC_ERROR_REF(*root_cert_error),
- GRPC_ERROR_REF(identity_cert_error_to_report));
- }
- cert_info.SetRootError(*root_cert_error);
- }
- if (identity_cert_error.has_value()) {
- for (auto* watcher_ptr : cert_info.identity_cert_watchers) {
- GPR_ASSERT(watcher_ptr != nullptr);
- const auto watcher_it = watchers_.find(watcher_ptr);
- GPR_ASSERT(watcher_it != watchers_.end());
- // root_cert_error_to_report is the error of the root cert this watcher is
- // watching, if there is any.
- grpc_error* root_cert_error_to_report = GRPC_ERROR_NONE;
- if (root_cert_error.has_value() &&
- watcher_it->second.root_cert_name == cert_name) {
- // In this case, We've already sent the error updates at the time when
- // checking root_cert_error, so we will skip here.
- continue;
- } else if (watcher_it->second.root_cert_name.has_value()) {
- auto& root_cert_info =
- certificate_info_map_[*watcher_it->second.root_cert_name];
- root_cert_error_to_report = root_cert_info.root_cert_error;
- }
- watcher_ptr->OnError(GRPC_ERROR_REF(root_cert_error_to_report),
- GRPC_ERROR_REF(*identity_cert_error));
- }
- cert_info.SetIdentityError(*identity_cert_error);
- }
-};
-
-void grpc_tls_certificate_distributor::SetError(grpc_error* error) {
- GPR_ASSERT(error != GRPC_ERROR_NONE);
- grpc_core::MutexLock lock(&mu_);
- for (const auto& watcher : watchers_) {
- const auto watcher_ptr = watcher.first;
- GPR_ASSERT(watcher_ptr != nullptr);
- const auto& watcher_info = watcher.second;
- watcher_ptr->OnError(
- watcher_info.root_cert_name.has_value() ? GRPC_ERROR_REF(error)
- : GRPC_ERROR_NONE,
- watcher_info.identity_cert_name.has_value() ? GRPC_ERROR_REF(error)
- : GRPC_ERROR_NONE);
- }
- for (auto& cert_info_entry : certificate_info_map_) {
- auto& cert_info = cert_info_entry.second;
- cert_info.SetRootError(GRPC_ERROR_REF(error));
- cert_info.SetIdentityError(GRPC_ERROR_REF(error));
- }
- GRPC_ERROR_UNREF(error);
-};
-
-void grpc_tls_certificate_distributor::WatchTlsCertificates(
- std::unique_ptr<TlsCertificatesWatcherInterface> watcher,
- y_absl::optional<TString> root_cert_name,
- y_absl::optional<TString> identity_cert_name) {
- bool start_watching_root_cert = false;
- bool already_watching_identity_for_root_cert = false;
- bool start_watching_identity_cert = false;
- bool already_watching_root_for_identity_cert = false;
- GPR_ASSERT(root_cert_name.has_value() || identity_cert_name.has_value());
- TlsCertificatesWatcherInterface* watcher_ptr = watcher.get();
- GPR_ASSERT(watcher_ptr != nullptr);
- // Update watchers_ and certificate_info_map_.
- {
- grpc_core::MutexLock lock(&mu_);
- const auto watcher_it = watchers_.find(watcher_ptr);
- // The caller needs to cancel the watcher first if it wants to re-register
- // the watcher.
- GPR_ASSERT(watcher_it == watchers_.end());
- watchers_[watcher_ptr] = {std::move(watcher), root_cert_name,
- identity_cert_name};
- y_absl::optional<y_absl::string_view> updated_root_certs;
- y_absl::optional<PemKeyCertPairList> updated_identity_pairs;
- grpc_error* root_error = GRPC_ERROR_NONE;
- grpc_error* identity_error = GRPC_ERROR_NONE;
- if (root_cert_name.has_value()) {
- CertificateInfo& cert_info = certificate_info_map_[*root_cert_name];
- start_watching_root_cert = cert_info.root_cert_watchers.empty();
- already_watching_identity_for_root_cert =
- !cert_info.identity_cert_watchers.empty();
- cert_info.root_cert_watchers.insert(watcher_ptr);
- root_error = GRPC_ERROR_REF(cert_info.root_cert_error);
- // Empty credentials will be treated as no updates.
- if (!cert_info.pem_root_certs.empty()) {
- updated_root_certs = cert_info.pem_root_certs;
- }
- }
- if (identity_cert_name.has_value()) {
- CertificateInfo& cert_info = certificate_info_map_[*identity_cert_name];
- start_watching_identity_cert = cert_info.identity_cert_watchers.empty();
- already_watching_root_for_identity_cert =
- !cert_info.root_cert_watchers.empty();
- cert_info.identity_cert_watchers.insert(watcher_ptr);
- identity_error = GRPC_ERROR_REF(cert_info.identity_cert_error);
- // Empty credentials will be treated as no updates.
- if (!cert_info.pem_key_cert_pairs.empty()) {
- updated_identity_pairs = cert_info.pem_key_cert_pairs;
- }
- }
- // Notify this watcher if the certs it is watching already had some
- // contents. Note that an *_cert_error in cert_info only indicates error
- // occurred while trying to fetch the latest cert, but the updated_*_certs
- // should always be valid. So we will send the updates regardless of
- // *_cert_error.
- if (updated_root_certs.has_value() || updated_identity_pairs.has_value()) {
- watcher_ptr->OnCertificatesChanged(updated_root_certs,
- std::move(updated_identity_pairs));
- }
- // Notify this watcher if the certs it is watching already had some errors.
- if (root_error != GRPC_ERROR_NONE || identity_error != GRPC_ERROR_NONE) {
- watcher_ptr->OnError(GRPC_ERROR_REF(root_error),
- GRPC_ERROR_REF(identity_error));
- }
- GRPC_ERROR_UNREF(root_error);
- GRPC_ERROR_UNREF(identity_error);
- }
- // Invoke watch status callback if needed.
- {
- grpc_core::MutexLock lock(&callback_mu_);
- if (watch_status_callback_ != nullptr) {
- if (root_cert_name == identity_cert_name &&
- (start_watching_root_cert || start_watching_identity_cert)) {
- watch_status_callback_(*root_cert_name, start_watching_root_cert,
- start_watching_identity_cert);
- } else {
- if (start_watching_root_cert) {
- watch_status_callback_(*root_cert_name, true,
- already_watching_identity_for_root_cert);
- }
- if (start_watching_identity_cert) {
- watch_status_callback_(*identity_cert_name,
- already_watching_root_for_identity_cert, true);
- }
- }
- }
- }
-};
-
-void grpc_tls_certificate_distributor::CancelTlsCertificatesWatch(
- TlsCertificatesWatcherInterface* watcher) {
- y_absl::optional<TString> root_cert_name;
- y_absl::optional<TString> identity_cert_name;
- bool stop_watching_root_cert = false;
- bool already_watching_identity_for_root_cert = false;
- bool stop_watching_identity_cert = false;
- bool already_watching_root_for_identity_cert = false;
- // Update watchers_ and certificate_info_map_.
- {
- grpc_core::MutexLock lock(&mu_);
- auto it = watchers_.find(watcher);
- if (it == watchers_.end()) return;
- WatcherInfo& watcher_info = it->second;
- root_cert_name = std::move(watcher_info.root_cert_name);
- identity_cert_name = std::move(watcher_info.identity_cert_name);
- watchers_.erase(it);
- if (root_cert_name.has_value()) {
- auto it = certificate_info_map_.find(*root_cert_name);
- GPR_ASSERT(it != certificate_info_map_.end());
- CertificateInfo& cert_info = it->second;
- cert_info.root_cert_watchers.erase(watcher);
- stop_watching_root_cert = cert_info.root_cert_watchers.empty();
- already_watching_identity_for_root_cert =
- !cert_info.identity_cert_watchers.empty();
- if (stop_watching_root_cert && !already_watching_identity_for_root_cert) {
- certificate_info_map_.erase(it);
- }
- }
- if (identity_cert_name.has_value()) {
- auto it = certificate_info_map_.find(*identity_cert_name);
- GPR_ASSERT(it != certificate_info_map_.end());
- CertificateInfo& cert_info = it->second;
- cert_info.identity_cert_watchers.erase(watcher);
- stop_watching_identity_cert = cert_info.identity_cert_watchers.empty();
- already_watching_root_for_identity_cert =
- !cert_info.root_cert_watchers.empty();
- if (stop_watching_identity_cert &&
- !already_watching_root_for_identity_cert) {
- certificate_info_map_.erase(it);
- }
- }
- }
- // Invoke watch status callback if needed.
- {
- grpc_core::MutexLock lock(&callback_mu_);
- if (watch_status_callback_ != nullptr) {
- if (root_cert_name == identity_cert_name &&
- (stop_watching_root_cert || stop_watching_identity_cert)) {
- watch_status_callback_(*root_cert_name, !stop_watching_root_cert,
- !stop_watching_identity_cert);
- } else {
- if (stop_watching_root_cert) {
- watch_status_callback_(*root_cert_name, false,
- already_watching_identity_for_root_cert);
- }
- if (stop_watching_identity_cert) {
- watch_status_callback_(*identity_cert_name,
- already_watching_root_for_identity_cert,
- false);
- }
- }
- }
- }
-};
+//
+// Copyright 2020 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <grpc/support/port_platform.h>
+
+#include "src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h"
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+#include <stdlib.h>
+#include <string.h>
+
+void grpc_tls_certificate_distributor::SetKeyMaterials(
+ const TString& cert_name, y_absl::optional<TString> pem_root_certs,
+ y_absl::optional<PemKeyCertPairList> pem_key_cert_pairs) {
+ GPR_ASSERT(pem_root_certs.has_value() || pem_key_cert_pairs.has_value());
+ grpc_core::MutexLock lock(&mu_);
+ auto& cert_info = certificate_info_map_[cert_name];
+ if (pem_root_certs.has_value()) {
+ // Successful credential updates will clear any pre-existing error.
+ cert_info.SetRootError(GRPC_ERROR_NONE);
+ for (auto* watcher_ptr : cert_info.root_cert_watchers) {
+ GPR_ASSERT(watcher_ptr != nullptr);
+ const auto watcher_it = watchers_.find(watcher_ptr);
+ GPR_ASSERT(watcher_it != watchers_.end());
+ GPR_ASSERT(watcher_it->second.root_cert_name.has_value());
+ y_absl::optional<PemKeyCertPairList> pem_key_cert_pairs_to_report;
+ if (pem_key_cert_pairs.has_value() &&
+ watcher_it->second.identity_cert_name == cert_name) {
+ pem_key_cert_pairs_to_report = pem_key_cert_pairs;
+ } else if (watcher_it->second.identity_cert_name.has_value()) {
+ auto& identity_cert_info =
+ certificate_info_map_[*watcher_it->second.identity_cert_name];
+ pem_key_cert_pairs_to_report = identity_cert_info.pem_key_cert_pairs;
+ }
+ watcher_ptr->OnCertificatesChanged(
+ pem_root_certs, std::move(pem_key_cert_pairs_to_report));
+ }
+ cert_info.pem_root_certs = std::move(*pem_root_certs);
+ }
+ if (pem_key_cert_pairs.has_value()) {
+ // Successful credential updates will clear any pre-existing error.
+ cert_info.SetIdentityError(GRPC_ERROR_NONE);
+ for (const auto watcher_ptr : cert_info.identity_cert_watchers) {
+ GPR_ASSERT(watcher_ptr != nullptr);
+ const auto watcher_it = watchers_.find(watcher_ptr);
+ GPR_ASSERT(watcher_it != watchers_.end());
+ GPR_ASSERT(watcher_it->second.identity_cert_name.has_value());
+ y_absl::optional<y_absl::string_view> pem_root_certs_to_report;
+ if (pem_root_certs.has_value() &&
+ watcher_it->second.root_cert_name == cert_name) {
+ // In this case, We've already sent the credential updates at the time
+ // when checking pem_root_certs, so we will skip here.
+ continue;
+ } else if (watcher_it->second.root_cert_name.has_value()) {
+ auto& root_cert_info =
+ certificate_info_map_[*watcher_it->second.root_cert_name];
+ pem_root_certs_to_report = root_cert_info.pem_root_certs;
+ }
+ watcher_ptr->OnCertificatesChanged(pem_root_certs_to_report,
+ pem_key_cert_pairs);
+ }
+ cert_info.pem_key_cert_pairs = std::move(*pem_key_cert_pairs);
+ }
+}
+
+bool grpc_tls_certificate_distributor::HasRootCerts(
+ const TString& root_cert_name) {
+ grpc_core::MutexLock lock(&mu_);
+ const auto it = certificate_info_map_.find(root_cert_name);
+ return it != certificate_info_map_.end() &&
+ !it->second.pem_root_certs.empty();
+};
+
+bool grpc_tls_certificate_distributor::HasKeyCertPairs(
+ const TString& identity_cert_name) {
+ grpc_core::MutexLock lock(&mu_);
+ const auto it = certificate_info_map_.find(identity_cert_name);
+ return it != certificate_info_map_.end() &&
+ !it->second.pem_key_cert_pairs.empty();
+};
+
+void grpc_tls_certificate_distributor::SetErrorForCert(
+ const TString& cert_name, y_absl::optional<grpc_error*> root_cert_error,
+ y_absl::optional<grpc_error*> identity_cert_error) {
+ GPR_ASSERT(root_cert_error.has_value() || identity_cert_error.has_value());
+ grpc_core::MutexLock lock(&mu_);
+ CertificateInfo& cert_info = certificate_info_map_[cert_name];
+ if (root_cert_error.has_value()) {
+ for (auto* watcher_ptr : cert_info.root_cert_watchers) {
+ GPR_ASSERT(watcher_ptr != nullptr);
+ const auto watcher_it = watchers_.find(watcher_ptr);
+ GPR_ASSERT(watcher_it != watchers_.end());
+ // identity_cert_error_to_report is the error of the identity cert this
+ // watcher is watching, if there is any.
+ grpc_error* identity_cert_error_to_report = GRPC_ERROR_NONE;
+ if (identity_cert_error.has_value() &&
+ watcher_it->second.identity_cert_name == cert_name) {
+ identity_cert_error_to_report = *identity_cert_error;
+ } else if (watcher_it->second.identity_cert_name.has_value()) {
+ auto& identity_cert_info =
+ certificate_info_map_[*watcher_it->second.identity_cert_name];
+ identity_cert_error_to_report = identity_cert_info.identity_cert_error;
+ }
+ watcher_ptr->OnError(GRPC_ERROR_REF(*root_cert_error),
+ GRPC_ERROR_REF(identity_cert_error_to_report));
+ }
+ cert_info.SetRootError(*root_cert_error);
+ }
+ if (identity_cert_error.has_value()) {
+ for (auto* watcher_ptr : cert_info.identity_cert_watchers) {
+ GPR_ASSERT(watcher_ptr != nullptr);
+ const auto watcher_it = watchers_.find(watcher_ptr);
+ GPR_ASSERT(watcher_it != watchers_.end());
+ // root_cert_error_to_report is the error of the root cert this watcher is
+ // watching, if there is any.
+ grpc_error* root_cert_error_to_report = GRPC_ERROR_NONE;
+ if (root_cert_error.has_value() &&
+ watcher_it->second.root_cert_name == cert_name) {
+ // In this case, We've already sent the error updates at the time when
+ // checking root_cert_error, so we will skip here.
+ continue;
+ } else if (watcher_it->second.root_cert_name.has_value()) {
+ auto& root_cert_info =
+ certificate_info_map_[*watcher_it->second.root_cert_name];
+ root_cert_error_to_report = root_cert_info.root_cert_error;
+ }
+ watcher_ptr->OnError(GRPC_ERROR_REF(root_cert_error_to_report),
+ GRPC_ERROR_REF(*identity_cert_error));
+ }
+ cert_info.SetIdentityError(*identity_cert_error);
+ }
+};
+
+void grpc_tls_certificate_distributor::SetError(grpc_error* error) {
+ GPR_ASSERT(error != GRPC_ERROR_NONE);
+ grpc_core::MutexLock lock(&mu_);
+ for (const auto& watcher : watchers_) {
+ const auto watcher_ptr = watcher.first;
+ GPR_ASSERT(watcher_ptr != nullptr);
+ const auto& watcher_info = watcher.second;
+ watcher_ptr->OnError(
+ watcher_info.root_cert_name.has_value() ? GRPC_ERROR_REF(error)
+ : GRPC_ERROR_NONE,
+ watcher_info.identity_cert_name.has_value() ? GRPC_ERROR_REF(error)
+ : GRPC_ERROR_NONE);
+ }
+ for (auto& cert_info_entry : certificate_info_map_) {
+ auto& cert_info = cert_info_entry.second;
+ cert_info.SetRootError(GRPC_ERROR_REF(error));
+ cert_info.SetIdentityError(GRPC_ERROR_REF(error));
+ }
+ GRPC_ERROR_UNREF(error);
+};
+
+void grpc_tls_certificate_distributor::WatchTlsCertificates(
+ std::unique_ptr<TlsCertificatesWatcherInterface> watcher,
+ y_absl::optional<TString> root_cert_name,
+ y_absl::optional<TString> identity_cert_name) {
+ bool start_watching_root_cert = false;
+ bool already_watching_identity_for_root_cert = false;
+ bool start_watching_identity_cert = false;
+ bool already_watching_root_for_identity_cert = false;
+ GPR_ASSERT(root_cert_name.has_value() || identity_cert_name.has_value());
+ TlsCertificatesWatcherInterface* watcher_ptr = watcher.get();
+ GPR_ASSERT(watcher_ptr != nullptr);
+ // Update watchers_ and certificate_info_map_.
+ {
+ grpc_core::MutexLock lock(&mu_);
+ const auto watcher_it = watchers_.find(watcher_ptr);
+ // The caller needs to cancel the watcher first if it wants to re-register
+ // the watcher.
+ GPR_ASSERT(watcher_it == watchers_.end());
+ watchers_[watcher_ptr] = {std::move(watcher), root_cert_name,
+ identity_cert_name};
+ y_absl::optional<y_absl::string_view> updated_root_certs;
+ y_absl::optional<PemKeyCertPairList> updated_identity_pairs;
+ grpc_error* root_error = GRPC_ERROR_NONE;
+ grpc_error* identity_error = GRPC_ERROR_NONE;
+ if (root_cert_name.has_value()) {
+ CertificateInfo& cert_info = certificate_info_map_[*root_cert_name];
+ start_watching_root_cert = cert_info.root_cert_watchers.empty();
+ already_watching_identity_for_root_cert =
+ !cert_info.identity_cert_watchers.empty();
+ cert_info.root_cert_watchers.insert(watcher_ptr);
+ root_error = GRPC_ERROR_REF(cert_info.root_cert_error);
+ // Empty credentials will be treated as no updates.
+ if (!cert_info.pem_root_certs.empty()) {
+ updated_root_certs = cert_info.pem_root_certs;
+ }
+ }
+ if (identity_cert_name.has_value()) {
+ CertificateInfo& cert_info = certificate_info_map_[*identity_cert_name];
+ start_watching_identity_cert = cert_info.identity_cert_watchers.empty();
+ already_watching_root_for_identity_cert =
+ !cert_info.root_cert_watchers.empty();
+ cert_info.identity_cert_watchers.insert(watcher_ptr);
+ identity_error = GRPC_ERROR_REF(cert_info.identity_cert_error);
+ // Empty credentials will be treated as no updates.
+ if (!cert_info.pem_key_cert_pairs.empty()) {
+ updated_identity_pairs = cert_info.pem_key_cert_pairs;
+ }
+ }
+ // Notify this watcher if the certs it is watching already had some
+ // contents. Note that an *_cert_error in cert_info only indicates error
+ // occurred while trying to fetch the latest cert, but the updated_*_certs
+ // should always be valid. So we will send the updates regardless of
+ // *_cert_error.
+ if (updated_root_certs.has_value() || updated_identity_pairs.has_value()) {
+ watcher_ptr->OnCertificatesChanged(updated_root_certs,
+ std::move(updated_identity_pairs));
+ }
+ // Notify this watcher if the certs it is watching already had some errors.
+ if (root_error != GRPC_ERROR_NONE || identity_error != GRPC_ERROR_NONE) {
+ watcher_ptr->OnError(GRPC_ERROR_REF(root_error),
+ GRPC_ERROR_REF(identity_error));
+ }
+ GRPC_ERROR_UNREF(root_error);
+ GRPC_ERROR_UNREF(identity_error);
+ }
+ // Invoke watch status callback if needed.
+ {
+ grpc_core::MutexLock lock(&callback_mu_);
+ if (watch_status_callback_ != nullptr) {
+ if (root_cert_name == identity_cert_name &&
+ (start_watching_root_cert || start_watching_identity_cert)) {
+ watch_status_callback_(*root_cert_name, start_watching_root_cert,
+ start_watching_identity_cert);
+ } else {
+ if (start_watching_root_cert) {
+ watch_status_callback_(*root_cert_name, true,
+ already_watching_identity_for_root_cert);
+ }
+ if (start_watching_identity_cert) {
+ watch_status_callback_(*identity_cert_name,
+ already_watching_root_for_identity_cert, true);
+ }
+ }
+ }
+ }
+};
+
+void grpc_tls_certificate_distributor::CancelTlsCertificatesWatch(
+ TlsCertificatesWatcherInterface* watcher) {
+ y_absl::optional<TString> root_cert_name;
+ y_absl::optional<TString> identity_cert_name;
+ bool stop_watching_root_cert = false;
+ bool already_watching_identity_for_root_cert = false;
+ bool stop_watching_identity_cert = false;
+ bool already_watching_root_for_identity_cert = false;
+ // Update watchers_ and certificate_info_map_.
+ {
+ grpc_core::MutexLock lock(&mu_);
+ auto it = watchers_.find(watcher);
+ if (it == watchers_.end()) return;
+ WatcherInfo& watcher_info = it->second;
+ root_cert_name = std::move(watcher_info.root_cert_name);
+ identity_cert_name = std::move(watcher_info.identity_cert_name);
+ watchers_.erase(it);
+ if (root_cert_name.has_value()) {
+ auto it = certificate_info_map_.find(*root_cert_name);
+ GPR_ASSERT(it != certificate_info_map_.end());
+ CertificateInfo& cert_info = it->second;
+ cert_info.root_cert_watchers.erase(watcher);
+ stop_watching_root_cert = cert_info.root_cert_watchers.empty();
+ already_watching_identity_for_root_cert =
+ !cert_info.identity_cert_watchers.empty();
+ if (stop_watching_root_cert && !already_watching_identity_for_root_cert) {
+ certificate_info_map_.erase(it);
+ }
+ }
+ if (identity_cert_name.has_value()) {
+ auto it = certificate_info_map_.find(*identity_cert_name);
+ GPR_ASSERT(it != certificate_info_map_.end());
+ CertificateInfo& cert_info = it->second;
+ cert_info.identity_cert_watchers.erase(watcher);
+ stop_watching_identity_cert = cert_info.identity_cert_watchers.empty();
+ already_watching_root_for_identity_cert =
+ !cert_info.root_cert_watchers.empty();
+ if (stop_watching_identity_cert &&
+ !already_watching_root_for_identity_cert) {
+ certificate_info_map_.erase(it);
+ }
+ }
+ }
+ // Invoke watch status callback if needed.
+ {
+ grpc_core::MutexLock lock(&callback_mu_);
+ if (watch_status_callback_ != nullptr) {
+ if (root_cert_name == identity_cert_name &&
+ (stop_watching_root_cert || stop_watching_identity_cert)) {
+ watch_status_callback_(*root_cert_name, !stop_watching_root_cert,
+ !stop_watching_identity_cert);
+ } else {
+ if (stop_watching_root_cert) {
+ watch_status_callback_(*root_cert_name, false,
+ already_watching_identity_for_root_cert);
+ }
+ if (stop_watching_identity_cert) {
+ watch_status_callback_(*identity_cert_name,
+ already_watching_root_for_identity_cert,
+ false);
+ }
+ }
+ }
+ }
+};
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h b/contrib/libs/grpc/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h
index 628db70815..15d76da420 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h
@@ -1,214 +1,214 @@
-//
-// Copyright 2020 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-#ifndef GRPC_CORE_LIB_SECURITY_CREDENTIALS_TLS_GRPC_TLS_CERTIFICATE_DISTRIBUTOR_H
-#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_TLS_GRPC_TLS_CERTIFICATE_DISTRIBUTOR_H
-
-#include <grpc/support/port_platform.h>
-
-#include <grpc/grpc_security.h>
-
-#include "y_absl/container/inlined_vector.h"
-#include "y_absl/types/optional.h"
-#include "src/core/lib/gprpp/ref_counted.h"
-#include "src/core/lib/security/security_connector/ssl_utils.h"
-
-// TLS certificate distributor.
-struct grpc_tls_certificate_distributor
- : public grpc_core::RefCounted<grpc_tls_certificate_distributor> {
- public:
- typedef y_absl::InlinedVector<grpc_core::PemKeyCertPair, 1> PemKeyCertPairList;
-
- // Interface for watching TLS certificates update.
- class TlsCertificatesWatcherInterface {
- public:
- virtual ~TlsCertificatesWatcherInterface() = default;
-
- // Handles the delivery of the updated root and identity certificates.
- // An y_absl::nullopt value indicates no corresponding contents for
- // root_certs or key_cert_pairs. Note that we will send updates of the
- // latest contents for both root and identity certificates, even when only
- // one side of it got updated.
- //
- // @param root_certs the contents of the reloaded root certs.
- // @param key_cert_pairs the contents of the reloaded identity key-cert
- // pairs.
- virtual void OnCertificatesChanged(
- y_absl::optional<y_absl::string_view> root_certs,
- y_absl::optional<PemKeyCertPairList> key_cert_pairs) = 0;
-
- // Handles an error that occurs while attempting to fetch certificate data.
- // Note that if a watcher sees an error, it simply means the Provider is
- // having problems renewing new data. If the watcher has previously received
- // several OnCertificatesChanged, all the data received from that function
- // is valid.
- // In that case, watcher might simply log the error. If the watcher hasn't
- // received any OnCertificatesChanged before the error occurs, no valid
- // data is available yet, and the watcher should either fail or "waiting"
- // for the valid data in a non-blocking way.
- //
- // @param root_cert_error the error occurred while reloading root
- // certificates.
- // @param identity_cert_error the error occurred while reloading identity
- // certificates.
- virtual void OnError(grpc_error* root_cert_error,
- grpc_error* identity_cert_error) = 0;
- };
-
- // Sets the key materials based on their certificate name. Note that we are
- // not doing any copies for pem_root_certs and pem_key_cert_pairs. For
- // pem_root_certs, the original string contents need to outlive the
- // distributor; for pem_key_cert_pairs, internally it is taking two
- // unique_ptr(s) to the credential string, so the ownership is actually
- // transferred.
- //
- // @param cert_name The name of the certificates being updated.
- // @param pem_root_certs The content of root certificates.
- // @param pem_key_cert_pairs The content of identity key-cert pairs.
- void SetKeyMaterials(const TString& cert_name,
- y_absl::optional<TString> pem_root_certs,
- y_absl::optional<PemKeyCertPairList> pem_key_cert_pairs);
-
- bool HasRootCerts(const TString& root_cert_name);
-
- bool HasKeyCertPairs(const TString& identity_cert_name);
-
- // Propagates the error that the caller (e.g. Producer) encounters to all the
- // watchers watching a particular certificate name.
- //
- // @param cert_name The watching cert name of the watchers that the caller
- // wants to notify when encountering error.
- // @param root_cert_error The error that the caller encounters when reloading
- // root certs.
- // @param identity_cert_error The error that the caller encounters when
- // reloading identity certs.
- void SetErrorForCert(const TString& cert_name,
- y_absl::optional<grpc_error*> root_cert_error,
- y_absl::optional<grpc_error*> identity_cert_error);
-
- // Propagates the error that the caller (e.g. Producer) encounters to all
- // watchers.
- //
- // @param error The error that the caller encounters.
- void SetError(grpc_error* error);
-
- // Sets the TLS certificate watch status callback function. The
- // grpc_tls_certificate_distributor will invoke this callback when a new
- // certificate name is watched by a newly registered watcher, or when a
- // certificate name is no longer watched by any watchers.
- // Note that when the callback shows a cert is no longer being watched, the
- // distributor will delete the corresponding certificate data from its cache,
- // and clear the corresponding error, if there is any. This means that if the
- // callback subsequently says the same cert is now being watched again, the
- // provider must re-provide the credentials or re-invoke the errors to the
- // distributor, to indicate a successful or failed reloading.
- // @param callback The callback function being set by the caller, e.g the
- // Producer. Note that this callback will be invoked for each certificate
- // name.
- //
- // For the parameters in the callback function:
- // string_value The name of the certificates being watched.
- // bool_value_1 If the root certificates with the specific name are being
- // watched. bool_value_2 If the identity certificates with the specific name
- // are being watched.
- void SetWatchStatusCallback(
- std::function<void(TString, bool, bool)> callback) {
- grpc_core::MutexLock lock(&mu_);
- watch_status_callback_ = callback;
- };
-
- // Registers a watcher. The caller may keep a raw pointer to the watcher,
- // which may be used only for cancellation. (Because the caller does not own
- // the watcher, the pointer must not be used for any other purpose.) At least
- // one of root_cert_name and identity_cert_name must be specified.
- //
- // @param watcher The watcher being registered.
- // @param root_cert_name The name of the root certificates that will be
- // watched. If set to y_absl::nullopt, the root certificates won't be watched.
- // @param identity_cert_name The name of the identity certificates that will
- // be watched. If set to y_absl::nullopt, the identity certificates won't be
- // watched.
- void WatchTlsCertificates(
- std::unique_ptr<TlsCertificatesWatcherInterface> watcher,
- y_absl::optional<TString> root_cert_name,
- y_absl::optional<TString> identity_cert_name);
-
- // Cancels a watcher.
- //
- // @param watcher The watcher being cancelled.
- void CancelTlsCertificatesWatch(TlsCertificatesWatcherInterface* watcher);
-
- private:
- // Contains the information about each watcher.
- struct WatcherInfo {
- std::unique_ptr<TlsCertificatesWatcherInterface> watcher;
- y_absl::optional<TString> root_cert_name;
- y_absl::optional<TString> identity_cert_name;
- };
- // CertificateInfo contains the credential contents and some additional
- // watcher information.
- // Note that having errors doesn't indicate the corresponding credentials are
- // invalid. For example, if root_cert_error != nullptr but pem_root_certs has
- // value, it simply means an error occurs while trying to fetch the latest
- // root certs, while pem_root_certs still contains the valid old data.
- struct CertificateInfo {
- // The contents of the root certificates.
- TString pem_root_certs;
- // The contents of the identity key-certificate pairs.
- PemKeyCertPairList pem_key_cert_pairs;
- // The root cert reloading error propagated by the caller.
- grpc_error* root_cert_error = GRPC_ERROR_NONE;
- // The identity cert reloading error propagated by the caller.
- grpc_error* identity_cert_error = GRPC_ERROR_NONE;
- // The set of watchers watching root certificates.
- // This is mainly used for quickly looking up the affected watchers while
- // performing a credential reloading.
- std::set<TlsCertificatesWatcherInterface*> root_cert_watchers;
- // The set of watchers watching identity certificates. This is mainly used
- // for quickly looking up the affected watchers while performing a
- // credential reloading.
- std::set<TlsCertificatesWatcherInterface*> identity_cert_watchers;
-
- ~CertificateInfo() {
- GRPC_ERROR_UNREF(root_cert_error);
- GRPC_ERROR_UNREF(identity_cert_error);
- }
- void SetRootError(grpc_error* error) {
- GRPC_ERROR_UNREF(root_cert_error);
- root_cert_error = error;
- }
- void SetIdentityError(grpc_error* error) {
- GRPC_ERROR_UNREF(identity_cert_error);
- identity_cert_error = error;
- }
- };
-
- grpc_core::Mutex mu_;
- // We need a dedicated mutex for watch_status_callback_ for allowing
- // callers(e.g. Producer) to directly set key materials in the callback
- // functions.
- grpc_core::Mutex callback_mu_;
- // Stores information about each watcher.
- std::map<TlsCertificatesWatcherInterface*, WatcherInfo> watchers_;
- // The callback to notify the caller, e.g. the Producer, that the watch status
- // is changed.
- std::function<void(TString, bool, bool)> watch_status_callback_;
- // Stores the names of each certificate, and their corresponding credential
- // contents as well as some additional watcher information.
- std::map<TString, CertificateInfo> certificate_info_map_;
-};
-
-#endif // GRPC_CORE_LIB_SECURITY_CREDENTIALS_TLS_GRPC_TLS_CERTIFICATE_DISTRIBUTOR_H
+//
+// Copyright 2020 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef GRPC_CORE_LIB_SECURITY_CREDENTIALS_TLS_GRPC_TLS_CERTIFICATE_DISTRIBUTOR_H
+#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_TLS_GRPC_TLS_CERTIFICATE_DISTRIBUTOR_H
+
+#include <grpc/support/port_platform.h>
+
+#include <grpc/grpc_security.h>
+
+#include "y_absl/container/inlined_vector.h"
+#include "y_absl/types/optional.h"
+#include "src/core/lib/gprpp/ref_counted.h"
+#include "src/core/lib/security/security_connector/ssl_utils.h"
+
+// TLS certificate distributor.
+struct grpc_tls_certificate_distributor
+ : public grpc_core::RefCounted<grpc_tls_certificate_distributor> {
+ public:
+ typedef y_absl::InlinedVector<grpc_core::PemKeyCertPair, 1> PemKeyCertPairList;
+
+ // Interface for watching TLS certificates update.
+ class TlsCertificatesWatcherInterface {
+ public:
+ virtual ~TlsCertificatesWatcherInterface() = default;
+
+ // Handles the delivery of the updated root and identity certificates.
+ // An y_absl::nullopt value indicates no corresponding contents for
+ // root_certs or key_cert_pairs. Note that we will send updates of the
+ // latest contents for both root and identity certificates, even when only
+ // one side of it got updated.
+ //
+ // @param root_certs the contents of the reloaded root certs.
+ // @param key_cert_pairs the contents of the reloaded identity key-cert
+ // pairs.
+ virtual void OnCertificatesChanged(
+ y_absl::optional<y_absl::string_view> root_certs,
+ y_absl::optional<PemKeyCertPairList> key_cert_pairs) = 0;
+
+ // Handles an error that occurs while attempting to fetch certificate data.
+ // Note that if a watcher sees an error, it simply means the Provider is
+ // having problems renewing new data. If the watcher has previously received
+ // several OnCertificatesChanged, all the data received from that function
+ // is valid.
+ // In that case, watcher might simply log the error. If the watcher hasn't
+ // received any OnCertificatesChanged before the error occurs, no valid
+ // data is available yet, and the watcher should either fail or "waiting"
+ // for the valid data in a non-blocking way.
+ //
+ // @param root_cert_error the error occurred while reloading root
+ // certificates.
+ // @param identity_cert_error the error occurred while reloading identity
+ // certificates.
+ virtual void OnError(grpc_error* root_cert_error,
+ grpc_error* identity_cert_error) = 0;
+ };
+
+ // Sets the key materials based on their certificate name. Note that we are
+ // not doing any copies for pem_root_certs and pem_key_cert_pairs. For
+ // pem_root_certs, the original string contents need to outlive the
+ // distributor; for pem_key_cert_pairs, internally it is taking two
+ // unique_ptr(s) to the credential string, so the ownership is actually
+ // transferred.
+ //
+ // @param cert_name The name of the certificates being updated.
+ // @param pem_root_certs The content of root certificates.
+ // @param pem_key_cert_pairs The content of identity key-cert pairs.
+ void SetKeyMaterials(const TString& cert_name,
+ y_absl::optional<TString> pem_root_certs,
+ y_absl::optional<PemKeyCertPairList> pem_key_cert_pairs);
+
+ bool HasRootCerts(const TString& root_cert_name);
+
+ bool HasKeyCertPairs(const TString& identity_cert_name);
+
+ // Propagates the error that the caller (e.g. Producer) encounters to all the
+ // watchers watching a particular certificate name.
+ //
+ // @param cert_name The watching cert name of the watchers that the caller
+ // wants to notify when encountering error.
+ // @param root_cert_error The error that the caller encounters when reloading
+ // root certs.
+ // @param identity_cert_error The error that the caller encounters when
+ // reloading identity certs.
+ void SetErrorForCert(const TString& cert_name,
+ y_absl::optional<grpc_error*> root_cert_error,
+ y_absl::optional<grpc_error*> identity_cert_error);
+
+ // Propagates the error that the caller (e.g. Producer) encounters to all
+ // watchers.
+ //
+ // @param error The error that the caller encounters.
+ void SetError(grpc_error* error);
+
+ // Sets the TLS certificate watch status callback function. The
+ // grpc_tls_certificate_distributor will invoke this callback when a new
+ // certificate name is watched by a newly registered watcher, or when a
+ // certificate name is no longer watched by any watchers.
+ // Note that when the callback shows a cert is no longer being watched, the
+ // distributor will delete the corresponding certificate data from its cache,
+ // and clear the corresponding error, if there is any. This means that if the
+ // callback subsequently says the same cert is now being watched again, the
+ // provider must re-provide the credentials or re-invoke the errors to the
+ // distributor, to indicate a successful or failed reloading.
+ // @param callback The callback function being set by the caller, e.g the
+ // Producer. Note that this callback will be invoked for each certificate
+ // name.
+ //
+ // For the parameters in the callback function:
+ // string_value The name of the certificates being watched.
+ // bool_value_1 If the root certificates with the specific name are being
+ // watched. bool_value_2 If the identity certificates with the specific name
+ // are being watched.
+ void SetWatchStatusCallback(
+ std::function<void(TString, bool, bool)> callback) {
+ grpc_core::MutexLock lock(&mu_);
+ watch_status_callback_ = callback;
+ };
+
+ // Registers a watcher. The caller may keep a raw pointer to the watcher,
+ // which may be used only for cancellation. (Because the caller does not own
+ // the watcher, the pointer must not be used for any other purpose.) At least
+ // one of root_cert_name and identity_cert_name must be specified.
+ //
+ // @param watcher The watcher being registered.
+ // @param root_cert_name The name of the root certificates that will be
+ // watched. If set to y_absl::nullopt, the root certificates won't be watched.
+ // @param identity_cert_name The name of the identity certificates that will
+ // be watched. If set to y_absl::nullopt, the identity certificates won't be
+ // watched.
+ void WatchTlsCertificates(
+ std::unique_ptr<TlsCertificatesWatcherInterface> watcher,
+ y_absl::optional<TString> root_cert_name,
+ y_absl::optional<TString> identity_cert_name);
+
+ // Cancels a watcher.
+ //
+ // @param watcher The watcher being cancelled.
+ void CancelTlsCertificatesWatch(TlsCertificatesWatcherInterface* watcher);
+
+ private:
+ // Contains the information about each watcher.
+ struct WatcherInfo {
+ std::unique_ptr<TlsCertificatesWatcherInterface> watcher;
+ y_absl::optional<TString> root_cert_name;
+ y_absl::optional<TString> identity_cert_name;
+ };
+ // CertificateInfo contains the credential contents and some additional
+ // watcher information.
+ // Note that having errors doesn't indicate the corresponding credentials are
+ // invalid. For example, if root_cert_error != nullptr but pem_root_certs has
+ // value, it simply means an error occurs while trying to fetch the latest
+ // root certs, while pem_root_certs still contains the valid old data.
+ struct CertificateInfo {
+ // The contents of the root certificates.
+ TString pem_root_certs;
+ // The contents of the identity key-certificate pairs.
+ PemKeyCertPairList pem_key_cert_pairs;
+ // The root cert reloading error propagated by the caller.
+ grpc_error* root_cert_error = GRPC_ERROR_NONE;
+ // The identity cert reloading error propagated by the caller.
+ grpc_error* identity_cert_error = GRPC_ERROR_NONE;
+ // The set of watchers watching root certificates.
+ // This is mainly used for quickly looking up the affected watchers while
+ // performing a credential reloading.
+ std::set<TlsCertificatesWatcherInterface*> root_cert_watchers;
+ // The set of watchers watching identity certificates. This is mainly used
+ // for quickly looking up the affected watchers while performing a
+ // credential reloading.
+ std::set<TlsCertificatesWatcherInterface*> identity_cert_watchers;
+
+ ~CertificateInfo() {
+ GRPC_ERROR_UNREF(root_cert_error);
+ GRPC_ERROR_UNREF(identity_cert_error);
+ }
+ void SetRootError(grpc_error* error) {
+ GRPC_ERROR_UNREF(root_cert_error);
+ root_cert_error = error;
+ }
+ void SetIdentityError(grpc_error* error) {
+ GRPC_ERROR_UNREF(identity_cert_error);
+ identity_cert_error = error;
+ }
+ };
+
+ grpc_core::Mutex mu_;
+ // We need a dedicated mutex for watch_status_callback_ for allowing
+ // callers(e.g. Producer) to directly set key materials in the callback
+ // functions.
+ grpc_core::Mutex callback_mu_;
+ // Stores information about each watcher.
+ std::map<TlsCertificatesWatcherInterface*, WatcherInfo> watchers_;
+ // The callback to notify the caller, e.g. the Producer, that the watch status
+ // is changed.
+ std::function<void(TString, bool, bool)> watch_status_callback_;
+ // Stores the names of each certificate, and their corresponding credential
+ // contents as well as some additional watcher information.
+ std::map<TString, CertificateInfo> certificate_info_map_;
+};
+
+#endif // GRPC_CORE_LIB_SECURITY_CREDENTIALS_TLS_GRPC_TLS_CERTIFICATE_DISTRIBUTOR_H
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc b/contrib/libs/grpc/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc
index 48581cf967..906a2f0209 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc
@@ -29,30 +29,30 @@
/** -- gRPC TLS key materials config API implementation. -- **/
void grpc_tls_key_materials_config::set_key_materials(
- const char* pem_root_certs,
- const grpc_ssl_pem_key_cert_pair** pem_key_cert_pairs,
- size_t num_key_cert_pairs) {
- this->set_pem_root_certs(pem_root_certs);
- grpc_tls_key_materials_config::PemKeyCertPairList cert_pair_list;
- for (size_t i = 0; i < num_key_cert_pairs; i++) {
- auto current_pair = static_cast<grpc_ssl_pem_key_cert_pair*>(
- gpr_zalloc(sizeof(grpc_ssl_pem_key_cert_pair)));
- current_pair->cert_chain = gpr_strdup(pem_key_cert_pairs[i]->cert_chain);
- current_pair->private_key = gpr_strdup(pem_key_cert_pairs[i]->private_key);
- cert_pair_list.emplace_back(grpc_core::PemKeyCertPair(current_pair));
- }
- pem_key_cert_pair_list_ = std::move(cert_pair_list);
-}
-
-void grpc_tls_key_materials_config::set_key_materials(
- const char* pem_root_certs,
- const PemKeyCertPairList& pem_key_cert_pair_list) {
- this->set_pem_root_certs(pem_root_certs);
- grpc_tls_key_materials_config::PemKeyCertPairList dup_list(
- pem_key_cert_pair_list);
- pem_key_cert_pair_list_ = std::move(dup_list);
-}
-
+ const char* pem_root_certs,
+ const grpc_ssl_pem_key_cert_pair** pem_key_cert_pairs,
+ size_t num_key_cert_pairs) {
+ this->set_pem_root_certs(pem_root_certs);
+ grpc_tls_key_materials_config::PemKeyCertPairList cert_pair_list;
+ for (size_t i = 0; i < num_key_cert_pairs; i++) {
+ auto current_pair = static_cast<grpc_ssl_pem_key_cert_pair*>(
+ gpr_zalloc(sizeof(grpc_ssl_pem_key_cert_pair)));
+ current_pair->cert_chain = gpr_strdup(pem_key_cert_pairs[i]->cert_chain);
+ current_pair->private_key = gpr_strdup(pem_key_cert_pairs[i]->private_key);
+ cert_pair_list.emplace_back(grpc_core::PemKeyCertPair(current_pair));
+ }
+ pem_key_cert_pair_list_ = std::move(cert_pair_list);
+}
+
+void grpc_tls_key_materials_config::set_key_materials(
+ const char* pem_root_certs,
+ const PemKeyCertPairList& pem_key_cert_pair_list) {
+ this->set_pem_root_certs(pem_root_certs);
+ grpc_tls_key_materials_config::PemKeyCertPairList dup_list(
+ pem_key_cert_pair_list);
+ pem_key_cert_pair_list_ = std::move(dup_list);
+}
+
/** -- gRPC TLS credential reload config API implementation. -- **/
grpc_tls_credential_reload_config::grpc_tls_credential_reload_config(
const void* config_user_data,
@@ -110,26 +110,26 @@ int grpc_tls_credentials_options_set_cert_request_type(
return 1;
}
-int grpc_tls_credentials_options_set_server_verification_option(
- grpc_tls_credentials_options* options,
- grpc_tls_server_verification_option server_verification_option) {
- if (options == nullptr) {
- gpr_log(GPR_ERROR,
- "Invalid nullptr arguments to "
- "grpc_tls_credentials_options_set_server_verification_option()");
- return 0;
- }
- if (server_verification_option != GRPC_TLS_SERVER_VERIFICATION &&
- options->server_authorization_check_config() == nullptr) {
- gpr_log(GPR_ERROR,
- "server_authorization_check_config needs to be specified when"
- "server_verification_option is not GRPC_TLS_SERVER_VERIFICATION");
- return 0;
- }
- options->set_server_verification_option(server_verification_option);
- return 1;
-}
-
+int grpc_tls_credentials_options_set_server_verification_option(
+ grpc_tls_credentials_options* options,
+ grpc_tls_server_verification_option server_verification_option) {
+ if (options == nullptr) {
+ gpr_log(GPR_ERROR,
+ "Invalid nullptr arguments to "
+ "grpc_tls_credentials_options_set_server_verification_option()");
+ return 0;
+ }
+ if (server_verification_option != GRPC_TLS_SERVER_VERIFICATION &&
+ options->server_authorization_check_config() == nullptr) {
+ gpr_log(GPR_ERROR,
+ "server_authorization_check_config needs to be specified when"
+ "server_verification_option is not GRPC_TLS_SERVER_VERIFICATION");
+ return 0;
+ }
+ options->set_server_verification_option(server_verification_option);
+ return 1;
+}
+
int grpc_tls_credentials_options_set_key_materials_config(
grpc_tls_credentials_options* options,
grpc_tls_key_materials_config* config) {
@@ -183,7 +183,7 @@ int grpc_tls_key_materials_config_set_key_materials(
"grpc_tls_key_materials_config_set_key_materials()");
return 0;
}
- config->set_key_materials(root_certs, key_cert_pairs, num);
+ config->set_key_materials(root_certs, key_cert_pairs, num);
return 1;
}
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h b/contrib/libs/grpc/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h
index 864f659e61..59411d4169 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h
@@ -23,29 +23,29 @@
#include <grpc/grpc_security.h>
-#include "y_absl/container/inlined_vector.h"
-
+#include "y_absl/container/inlined_vector.h"
+
#include "src/core/lib/gprpp/ref_counted.h"
#include "src/core/lib/security/security_connector/ssl_utils.h"
-struct grpc_tls_error_details
- : public grpc_core::RefCounted<grpc_tls_error_details> {
- public:
- grpc_tls_error_details() : error_details_("") {}
- void set_error_details(const char* err_details) {
- error_details_ = err_details;
- }
- const TString& error_details() { return error_details_; }
-
- private:
- TString error_details_;
-};
-
+struct grpc_tls_error_details
+ : public grpc_core::RefCounted<grpc_tls_error_details> {
+ public:
+ grpc_tls_error_details() : error_details_("") {}
+ void set_error_details(const char* err_details) {
+ error_details_ = err_details;
+ }
+ const TString& error_details() { return error_details_; }
+
+ private:
+ TString error_details_;
+};
+
/** TLS key materials config. **/
struct grpc_tls_key_materials_config
: public grpc_core::RefCounted<grpc_tls_key_materials_config> {
public:
- typedef y_absl::InlinedVector<grpc_core::PemKeyCertPair, 1> PemKeyCertPairList;
+ typedef y_absl::InlinedVector<grpc_core::PemKeyCertPair, 1> PemKeyCertPairList;
/** Getters for member fields. **/
const char* pem_root_certs() const { return pem_root_certs_.get(); }
@@ -55,28 +55,28 @@ struct grpc_tls_key_materials_config
int version() const { return version_; }
/** Setters for member fields. **/
- // TODO(ZhenLian): Remove this function
+ // TODO(ZhenLian): Remove this function
void set_pem_root_certs(grpc_core::UniquePtr<char> pem_root_certs) {
pem_root_certs_ = std::move(pem_root_certs);
}
- // The ownerships of |pem_root_certs| remain with the caller.
- void set_pem_root_certs(const char* pem_root_certs) {
- // make a copy of pem_root_certs.
- grpc_core::UniquePtr<char> pem_root_ptr(gpr_strdup(pem_root_certs));
- pem_root_certs_ = std::move(pem_root_ptr);
- }
+ // The ownerships of |pem_root_certs| remain with the caller.
+ void set_pem_root_certs(const char* pem_root_certs) {
+ // make a copy of pem_root_certs.
+ grpc_core::UniquePtr<char> pem_root_ptr(gpr_strdup(pem_root_certs));
+ pem_root_certs_ = std::move(pem_root_ptr);
+ }
void add_pem_key_cert_pair(grpc_core::PemKeyCertPair pem_key_cert_pair) {
pem_key_cert_pair_list_.push_back(pem_key_cert_pair);
}
- // The ownerships of |pem_root_certs| and |pem_key_cert_pairs| remain with the
- // caller.
- void set_key_materials(const char* pem_root_certs,
- const grpc_ssl_pem_key_cert_pair** pem_key_cert_pairs,
- size_t num_key_cert_pairs);
- // The ownerships of |pem_root_certs| and |pem_key_cert_pair_list| remain with
- // the caller.
- void set_key_materials(const char* pem_root_certs,
- const PemKeyCertPairList& pem_key_cert_pair_list);
+ // The ownerships of |pem_root_certs| and |pem_key_cert_pairs| remain with the
+ // caller.
+ void set_key_materials(const char* pem_root_certs,
+ const grpc_ssl_pem_key_cert_pair** pem_key_cert_pairs,
+ size_t num_key_cert_pairs);
+ // The ownerships of |pem_root_certs| and |pem_key_cert_pair_list| remain with
+ // the caller.
+ void set_key_materials(const char* pem_root_certs,
+ const PemKeyCertPairList& pem_key_cert_pair_list);
void set_version(int version) { version_ = version; }
private:
@@ -106,8 +106,8 @@ struct grpc_tls_credential_reload_config
gpr_log(GPR_ERROR, "schedule API is nullptr");
if (arg != nullptr) {
arg->status = GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_FAIL;
- arg->error_details->set_error_details(
- "schedule API in credential reload config is nullptr");
+ arg->error_details->set_error_details(
+ "schedule API in credential reload config is nullptr");
}
return 1;
}
@@ -121,8 +121,8 @@ struct grpc_tls_credential_reload_config
gpr_log(GPR_ERROR, "cancel API is nullptr.");
if (arg != nullptr) {
arg->status = GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_FAIL;
- arg->error_details->set_error_details(
- "cancel API in credential reload config is nullptr");
+ arg->error_details->set_error_details(
+ "cancel API in credential reload config is nullptr");
}
return;
}
@@ -182,7 +182,7 @@ struct grpc_tls_server_authorization_check_config
gpr_log(GPR_ERROR, "schedule API is nullptr");
if (arg != nullptr) {
arg->status = GRPC_STATUS_NOT_FOUND;
- arg->error_details->set_error_details(
+ arg->error_details->set_error_details(
"schedule API in server authorization check config is nullptr");
}
return 1;
@@ -198,7 +198,7 @@ struct grpc_tls_server_authorization_check_config
gpr_log(GPR_ERROR, "cancel API is nullptr.");
if (arg != nullptr) {
arg->status = GRPC_STATUS_NOT_FOUND;
- arg->error_details->set_error_details(
+ arg->error_details->set_error_details(
"schedule API in server authorization check config is nullptr");
}
return;
@@ -261,11 +261,11 @@ struct grpc_tls_credentials_options
grpc_ssl_client_certificate_request_type cert_request_type() const {
return cert_request_type_;
}
- grpc_tls_server_verification_option server_verification_option() const {
- return server_verification_option_;
- }
- grpc_tls_version min_tls_version() const { return min_tls_version_; }
- grpc_tls_version max_tls_version() const { return max_tls_version_; }
+ grpc_tls_server_verification_option server_verification_option() const {
+ return server_verification_option_;
+ }
+ grpc_tls_version min_tls_version() const { return min_tls_version_; }
+ grpc_tls_version max_tls_version() const { return max_tls_version_; }
grpc_tls_key_materials_config* key_materials_config() const {
return key_materials_config_.get();
}
@@ -282,16 +282,16 @@ struct grpc_tls_credentials_options
const grpc_ssl_client_certificate_request_type type) {
cert_request_type_ = type;
}
- void set_server_verification_option(
- const grpc_tls_server_verification_option server_verification_option) {
- server_verification_option_ = server_verification_option;
- }
- void set_min_tls_version(grpc_tls_version min_tls_version) {
- min_tls_version_ = min_tls_version;
- }
- void set_max_tls_version(grpc_tls_version max_tls_version) {
- max_tls_version_ = max_tls_version;
- }
+ void set_server_verification_option(
+ const grpc_tls_server_verification_option server_verification_option) {
+ server_verification_option_ = server_verification_option;
+ }
+ void set_min_tls_version(grpc_tls_version min_tls_version) {
+ min_tls_version_ = min_tls_version;
+ }
+ void set_max_tls_version(grpc_tls_version max_tls_version) {
+ max_tls_version_ = max_tls_version;
+ }
void set_key_materials_config(
grpc_core::RefCountedPtr<grpc_tls_key_materials_config> config) {
key_materials_config_ = std::move(config);
@@ -308,10 +308,10 @@ struct grpc_tls_credentials_options
private:
grpc_ssl_client_certificate_request_type cert_request_type_;
- grpc_tls_server_verification_option server_verification_option_ =
- GRPC_TLS_SERVER_VERIFICATION;
- grpc_tls_version min_tls_version_ = grpc_tls_version::TLS1_2;
- grpc_tls_version max_tls_version_ = grpc_tls_version::TLS1_3;
+ grpc_tls_server_verification_option server_verification_option_ =
+ GRPC_TLS_SERVER_VERIFICATION;
+ grpc_tls_version min_tls_version_ = grpc_tls_version::TLS1_2;
+ grpc_tls_version max_tls_version_ = grpc_tls_version::TLS1_3;
grpc_core::RefCountedPtr<grpc_tls_key_materials_config> key_materials_config_;
grpc_core::RefCountedPtr<grpc_tls_credential_reload_config>
credential_reload_config_;
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/tls/tls_credentials.cc b/contrib/libs/grpc/src/core/lib/security/credentials/tls/tls_credentials.cc
index 830c9b2985..701fd3b150 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/tls/tls_credentials.cc
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/tls/tls_credentials.cc
@@ -1,128 +1,128 @@
-/*
- *
- * Copyright 2018 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <grpc/support/port_platform.h>
-
-#include "src/core/lib/security/credentials/tls/tls_credentials.h"
-
-#include <cstring>
-
-#include <grpc/grpc.h>
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/string_util.h>
-
-#include "src/core/lib/channel/channel_args.h"
-#include "src/core/lib/security/security_connector/tls/tls_security_connector.h"
-
-#define GRPC_CREDENTIALS_TYPE_TLS "Tls"
-
-namespace {
-
-bool CredentialOptionSanityCheck(const grpc_tls_credentials_options* options,
- bool is_client) {
- if (options == nullptr) {
- gpr_log(GPR_ERROR, "TLS credentials options is nullptr.");
- return false;
- }
- if (options->key_materials_config() == nullptr &&
- options->credential_reload_config() == nullptr) {
- gpr_log(GPR_ERROR,
- "TLS credentials options must specify either key materials or "
- "credential reload config.");
- return false;
- }
- if (!is_client && options->server_authorization_check_config() != nullptr) {
- gpr_log(GPR_INFO,
- "Server's credentials options should not contain server "
- "authorization check config.");
- }
- return true;
-}
-
-} // namespace
-
-TlsCredentials::TlsCredentials(
- grpc_core::RefCountedPtr<grpc_tls_credentials_options> options)
- : grpc_channel_credentials(GRPC_CREDENTIALS_TYPE_TLS),
- options_(std::move(options)) {}
-
-TlsCredentials::~TlsCredentials() {}
-
-grpc_core::RefCountedPtr<grpc_channel_security_connector>
-TlsCredentials::create_security_connector(
- grpc_core::RefCountedPtr<grpc_call_credentials> call_creds,
- const char* target_name, const grpc_channel_args* args,
- grpc_channel_args** new_args) {
- const char* overridden_target_name = nullptr;
- tsi_ssl_session_cache* ssl_session_cache = nullptr;
- for (size_t i = 0; args != nullptr && i < args->num_args; i++) {
- grpc_arg* arg = &args->args[i];
- if (strcmp(arg->key, GRPC_SSL_TARGET_NAME_OVERRIDE_ARG) == 0 &&
- arg->type == GRPC_ARG_STRING) {
- overridden_target_name = arg->value.string;
- }
- if (strcmp(arg->key, GRPC_SSL_SESSION_CACHE_ARG) == 0 &&
- arg->type == GRPC_ARG_POINTER) {
- ssl_session_cache =
- static_cast<tsi_ssl_session_cache*>(arg->value.pointer.p);
- }
- }
- grpc_core::RefCountedPtr<grpc_channel_security_connector> sc =
- grpc_core::TlsChannelSecurityConnector::CreateTlsChannelSecurityConnector(
- this->Ref(), std::move(call_creds), target_name,
- overridden_target_name, ssl_session_cache);
- if (sc == nullptr) {
- return nullptr;
- }
- grpc_arg new_arg = grpc_channel_arg_string_create(
- (char*)GRPC_ARG_HTTP2_SCHEME, (char*)"https");
- *new_args = grpc_channel_args_copy_and_add(args, &new_arg, 1);
- return sc;
-}
-
-TlsServerCredentials::TlsServerCredentials(
- grpc_core::RefCountedPtr<grpc_tls_credentials_options> options)
- : grpc_server_credentials(GRPC_CREDENTIALS_TYPE_TLS),
- options_(std::move(options)) {}
-
-TlsServerCredentials::~TlsServerCredentials() {}
-
-grpc_core::RefCountedPtr<grpc_server_security_connector>
-TlsServerCredentials::create_security_connector() {
- return grpc_core::TlsServerSecurityConnector::
- CreateTlsServerSecurityConnector(this->Ref());
-}
-
-grpc_channel_credentials* grpc_tls_credentials_create(
- grpc_tls_credentials_options* options) {
- if (!CredentialOptionSanityCheck(options, true /* is_client */)) {
- return nullptr;
- }
- return new TlsCredentials(
- grpc_core::RefCountedPtr<grpc_tls_credentials_options>(options));
-}
-
-grpc_server_credentials* grpc_tls_server_credentials_create(
- grpc_tls_credentials_options* options) {
- if (!CredentialOptionSanityCheck(options, false /* is_client */)) {
- return nullptr;
- }
- return new TlsServerCredentials(
- grpc_core::RefCountedPtr<grpc_tls_credentials_options>(options));
-}
+/*
+ *
+ * Copyright 2018 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <grpc/support/port_platform.h>
+
+#include "src/core/lib/security/credentials/tls/tls_credentials.h"
+
+#include <cstring>
+
+#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+
+#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/security/security_connector/tls/tls_security_connector.h"
+
+#define GRPC_CREDENTIALS_TYPE_TLS "Tls"
+
+namespace {
+
+bool CredentialOptionSanityCheck(const grpc_tls_credentials_options* options,
+ bool is_client) {
+ if (options == nullptr) {
+ gpr_log(GPR_ERROR, "TLS credentials options is nullptr.");
+ return false;
+ }
+ if (options->key_materials_config() == nullptr &&
+ options->credential_reload_config() == nullptr) {
+ gpr_log(GPR_ERROR,
+ "TLS credentials options must specify either key materials or "
+ "credential reload config.");
+ return false;
+ }
+ if (!is_client && options->server_authorization_check_config() != nullptr) {
+ gpr_log(GPR_INFO,
+ "Server's credentials options should not contain server "
+ "authorization check config.");
+ }
+ return true;
+}
+
+} // namespace
+
+TlsCredentials::TlsCredentials(
+ grpc_core::RefCountedPtr<grpc_tls_credentials_options> options)
+ : grpc_channel_credentials(GRPC_CREDENTIALS_TYPE_TLS),
+ options_(std::move(options)) {}
+
+TlsCredentials::~TlsCredentials() {}
+
+grpc_core::RefCountedPtr<grpc_channel_security_connector>
+TlsCredentials::create_security_connector(
+ grpc_core::RefCountedPtr<grpc_call_credentials> call_creds,
+ const char* target_name, const grpc_channel_args* args,
+ grpc_channel_args** new_args) {
+ const char* overridden_target_name = nullptr;
+ tsi_ssl_session_cache* ssl_session_cache = nullptr;
+ for (size_t i = 0; args != nullptr && i < args->num_args; i++) {
+ grpc_arg* arg = &args->args[i];
+ if (strcmp(arg->key, GRPC_SSL_TARGET_NAME_OVERRIDE_ARG) == 0 &&
+ arg->type == GRPC_ARG_STRING) {
+ overridden_target_name = arg->value.string;
+ }
+ if (strcmp(arg->key, GRPC_SSL_SESSION_CACHE_ARG) == 0 &&
+ arg->type == GRPC_ARG_POINTER) {
+ ssl_session_cache =
+ static_cast<tsi_ssl_session_cache*>(arg->value.pointer.p);
+ }
+ }
+ grpc_core::RefCountedPtr<grpc_channel_security_connector> sc =
+ grpc_core::TlsChannelSecurityConnector::CreateTlsChannelSecurityConnector(
+ this->Ref(), std::move(call_creds), target_name,
+ overridden_target_name, ssl_session_cache);
+ if (sc == nullptr) {
+ return nullptr;
+ }
+ grpc_arg new_arg = grpc_channel_arg_string_create(
+ (char*)GRPC_ARG_HTTP2_SCHEME, (char*)"https");
+ *new_args = grpc_channel_args_copy_and_add(args, &new_arg, 1);
+ return sc;
+}
+
+TlsServerCredentials::TlsServerCredentials(
+ grpc_core::RefCountedPtr<grpc_tls_credentials_options> options)
+ : grpc_server_credentials(GRPC_CREDENTIALS_TYPE_TLS),
+ options_(std::move(options)) {}
+
+TlsServerCredentials::~TlsServerCredentials() {}
+
+grpc_core::RefCountedPtr<grpc_server_security_connector>
+TlsServerCredentials::create_security_connector() {
+ return grpc_core::TlsServerSecurityConnector::
+ CreateTlsServerSecurityConnector(this->Ref());
+}
+
+grpc_channel_credentials* grpc_tls_credentials_create(
+ grpc_tls_credentials_options* options) {
+ if (!CredentialOptionSanityCheck(options, true /* is_client */)) {
+ return nullptr;
+ }
+ return new TlsCredentials(
+ grpc_core::RefCountedPtr<grpc_tls_credentials_options>(options));
+}
+
+grpc_server_credentials* grpc_tls_server_credentials_create(
+ grpc_tls_credentials_options* options) {
+ if (!CredentialOptionSanityCheck(options, false /* is_client */)) {
+ return nullptr;
+ }
+ return new TlsServerCredentials(
+ grpc_core::RefCountedPtr<grpc_tls_credentials_options>(options));
+}
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/tls/tls_credentials.h b/contrib/libs/grpc/src/core/lib/security/credentials/tls/tls_credentials.h
index 27608a054b..388c71f6b7 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/tls/tls_credentials.h
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/tls/tls_credentials.h
@@ -1,62 +1,62 @@
-/*
- *
- * Copyright 2018 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef GRPC_CORE_LIB_SECURITY_CREDENTIALS_TLS_TLS_CREDENTIALS_H
-#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_TLS_TLS_CREDENTIALS_H
-
-#include <grpc/support/port_platform.h>
-
-#include <grpc/grpc_security.h>
-
-#include "src/core/lib/security/credentials/credentials.h"
-#include "src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h"
-
-class TlsCredentials final : public grpc_channel_credentials {
- public:
- explicit TlsCredentials(
- grpc_core::RefCountedPtr<grpc_tls_credentials_options> options);
- ~TlsCredentials() override;
-
- grpc_core::RefCountedPtr<grpc_channel_security_connector>
- create_security_connector(
- grpc_core::RefCountedPtr<grpc_call_credentials> call_creds,
- const char* target_name, const grpc_channel_args* args,
- grpc_channel_args** new_args) override;
-
- const grpc_tls_credentials_options& options() const { return *options_; }
-
- private:
- grpc_core::RefCountedPtr<grpc_tls_credentials_options> options_;
-};
-
-class TlsServerCredentials final : public grpc_server_credentials {
- public:
- explicit TlsServerCredentials(
- grpc_core::RefCountedPtr<grpc_tls_credentials_options> options);
- ~TlsServerCredentials() override;
-
- grpc_core::RefCountedPtr<grpc_server_security_connector>
- create_security_connector() override;
-
- const grpc_tls_credentials_options& options() const { return *options_; }
-
- private:
- grpc_core::RefCountedPtr<grpc_tls_credentials_options> options_;
-};
-
-#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_TLS_TLS_CREDENTIALS_H */
+/*
+ *
+ * Copyright 2018 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef GRPC_CORE_LIB_SECURITY_CREDENTIALS_TLS_TLS_CREDENTIALS_H
+#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_TLS_TLS_CREDENTIALS_H
+
+#include <grpc/support/port_platform.h>
+
+#include <grpc/grpc_security.h>
+
+#include "src/core/lib/security/credentials/credentials.h"
+#include "src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h"
+
+class TlsCredentials final : public grpc_channel_credentials {
+ public:
+ explicit TlsCredentials(
+ grpc_core::RefCountedPtr<grpc_tls_credentials_options> options);
+ ~TlsCredentials() override;
+
+ grpc_core::RefCountedPtr<grpc_channel_security_connector>
+ create_security_connector(
+ grpc_core::RefCountedPtr<grpc_call_credentials> call_creds,
+ const char* target_name, const grpc_channel_args* args,
+ grpc_channel_args** new_args) override;
+
+ const grpc_tls_credentials_options& options() const { return *options_; }
+
+ private:
+ grpc_core::RefCountedPtr<grpc_tls_credentials_options> options_;
+};
+
+class TlsServerCredentials final : public grpc_server_credentials {
+ public:
+ explicit TlsServerCredentials(
+ grpc_core::RefCountedPtr<grpc_tls_credentials_options> options);
+ ~TlsServerCredentials() override;
+
+ grpc_core::RefCountedPtr<grpc_server_security_connector>
+ create_security_connector() override;
+
+ const grpc_tls_credentials_options& options() const { return *options_; }
+
+ private:
+ grpc_core::RefCountedPtr<grpc_tls_credentials_options> options_;
+};
+
+#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_TLS_TLS_CREDENTIALS_H */
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/xds/xds_credentials.cc b/contrib/libs/grpc/src/core/lib/security/credentials/xds/xds_credentials.cc
index a34a584f4c..682d49badb 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/xds/xds_credentials.cc
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/xds/xds_credentials.cc
@@ -1,45 +1,45 @@
-//
-//
-// Copyright 2020 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//
-
-#include <grpc/support/port_platform.h>
-
-#include "src/core/lib/security/credentials/xds/xds_credentials.h"
-
-namespace grpc_core {
-
-constexpr const char XdsCredentials::kCredentialsTypeXds[];
-
-grpc_core::RefCountedPtr<grpc_channel_security_connector>
-XdsCredentials::create_security_connector(
- grpc_core::RefCountedPtr<grpc_call_credentials> call_creds,
- const char* target_name, const grpc_channel_args* args,
- grpc_channel_args** new_args) {
- /* TODO(yashkt) : To be filled */
- if (fallback_credentials_ != nullptr) {
- return fallback_credentials_->create_security_connector(
- std::move(call_creds), target_name, args, new_args);
- }
- return nullptr;
-}
-
-} // namespace grpc_core
-
-grpc_channel_credentials* grpc_xds_credentials_create(
- grpc_channel_credentials* fallback_credentials) {
- return new grpc_core::XdsCredentials(fallback_credentials->Ref());
-}
+//
+//
+// Copyright 2020 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//
+
+#include <grpc/support/port_platform.h>
+
+#include "src/core/lib/security/credentials/xds/xds_credentials.h"
+
+namespace grpc_core {
+
+constexpr const char XdsCredentials::kCredentialsTypeXds[];
+
+grpc_core::RefCountedPtr<grpc_channel_security_connector>
+XdsCredentials::create_security_connector(
+ grpc_core::RefCountedPtr<grpc_call_credentials> call_creds,
+ const char* target_name, const grpc_channel_args* args,
+ grpc_channel_args** new_args) {
+ /* TODO(yashkt) : To be filled */
+ if (fallback_credentials_ != nullptr) {
+ return fallback_credentials_->create_security_connector(
+ std::move(call_creds), target_name, args, new_args);
+ }
+ return nullptr;
+}
+
+} // namespace grpc_core
+
+grpc_channel_credentials* grpc_xds_credentials_create(
+ grpc_channel_credentials* fallback_credentials) {
+ return new grpc_core::XdsCredentials(fallback_credentials->Ref());
+}
diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/xds/xds_credentials.h b/contrib/libs/grpc/src/core/lib/security/credentials/xds/xds_credentials.h
index fc84d48afa..51576deebd 100644
--- a/contrib/libs/grpc/src/core/lib/security/credentials/xds/xds_credentials.h
+++ b/contrib/libs/grpc/src/core/lib/security/credentials/xds/xds_credentials.h
@@ -1,51 +1,51 @@
-//
-//
-// Copyright 2020 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//
-
-#ifndef GRPC_CORE_LIB_SECURITY_CREDENTIALS_XDS_XDS_CREDENTIALS_H
-#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_XDS_XDS_CREDENTIALS_H
-
-#include <grpc/support/port_platform.h>
-
-#include <grpc/grpc_security.h>
-
-#include "src/core/lib/security/credentials/credentials.h"
-
-namespace grpc_core {
-
-class XdsCredentials final : public grpc_channel_credentials {
- public:
- static constexpr const char kCredentialsTypeXds[] = "Xds";
-
- explicit XdsCredentials(
- grpc_core::RefCountedPtr<grpc_channel_credentials> fallback_credentials)
- : grpc_channel_credentials(kCredentialsTypeXds),
- fallback_credentials_(std::move(fallback_credentials)) {}
-
- grpc_core::RefCountedPtr<grpc_channel_security_connector>
- create_security_connector(
- grpc_core::RefCountedPtr<grpc_call_credentials> call_creds,
- const char* target_name, const grpc_channel_args* args,
- grpc_channel_args** new_args) override;
-
- private:
- grpc_core::RefCountedPtr<grpc_channel_credentials> fallback_credentials_;
-};
-
-} // namespace grpc_core
-
-#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_XDS_XDS_CREDENTIALS_H */
+//
+//
+// Copyright 2020 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//
+
+#ifndef GRPC_CORE_LIB_SECURITY_CREDENTIALS_XDS_XDS_CREDENTIALS_H
+#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_XDS_XDS_CREDENTIALS_H
+
+#include <grpc/support/port_platform.h>
+
+#include <grpc/grpc_security.h>
+
+#include "src/core/lib/security/credentials/credentials.h"
+
+namespace grpc_core {
+
+class XdsCredentials final : public grpc_channel_credentials {
+ public:
+ static constexpr const char kCredentialsTypeXds[] = "Xds";
+
+ explicit XdsCredentials(
+ grpc_core::RefCountedPtr<grpc_channel_credentials> fallback_credentials)
+ : grpc_channel_credentials(kCredentialsTypeXds),
+ fallback_credentials_(std::move(fallback_credentials)) {}
+
+ grpc_core::RefCountedPtr<grpc_channel_security_connector>
+ create_security_connector(
+ grpc_core::RefCountedPtr<grpc_call_credentials> call_creds,
+ const char* target_name, const grpc_channel_args* args,
+ grpc_channel_args** new_args) override;
+
+ private:
+ grpc_core::RefCountedPtr<grpc_channel_credentials> fallback_credentials_;
+};
+
+} // namespace grpc_core
+
+#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_XDS_XDS_CREDENTIALS_H */
diff --git a/contrib/libs/grpc/src/core/lib/security/security_connector/alts/alts_security_connector.cc b/contrib/libs/grpc/src/core/lib/security/security_connector/alts/alts_security_connector.cc
index 1902528bc6..d0b532ae18 100644
--- a/contrib/libs/grpc/src/core/lib/security/security_connector/alts/alts_security_connector.cc
+++ b/contrib/libs/grpc/src/core/lib/security/security_connector/alts/alts_security_connector.cc
@@ -82,17 +82,17 @@ class grpc_alts_channel_security_connector final
tsi_handshaker* handshaker = nullptr;
const grpc_alts_credentials* creds =
static_cast<const grpc_alts_credentials*>(channel_creds());
- size_t user_specified_max_frame_size = 0;
- const grpc_arg* arg =
- grpc_channel_args_find(args, GRPC_ARG_TSI_MAX_FRAME_SIZE);
- if (arg != nullptr && arg->type == GRPC_ARG_INTEGER) {
- user_specified_max_frame_size = grpc_channel_arg_get_integer(
- arg, {0, 0, std::numeric_limits<int>::max()});
- }
- GPR_ASSERT(alts_tsi_handshaker_create(
- creds->options(), target_name_,
- creds->handshaker_service_url(), true, interested_parties,
- &handshaker, user_specified_max_frame_size) == TSI_OK);
+ size_t user_specified_max_frame_size = 0;
+ const grpc_arg* arg =
+ grpc_channel_args_find(args, GRPC_ARG_TSI_MAX_FRAME_SIZE);
+ if (arg != nullptr && arg->type == GRPC_ARG_INTEGER) {
+ user_specified_max_frame_size = grpc_channel_arg_get_integer(
+ arg, {0, 0, std::numeric_limits<int>::max()});
+ }
+ GPR_ASSERT(alts_tsi_handshaker_create(
+ creds->options(), target_name_,
+ creds->handshaker_service_url(), true, interested_parties,
+ &handshaker, user_specified_max_frame_size) == TSI_OK);
handshake_manager->Add(
grpc_core::SecurityHandshakerCreate(handshaker, this, args));
}
@@ -111,7 +111,7 @@ class grpc_alts_channel_security_connector final
return strcmp(target_name_, other->target_name_);
}
- bool check_call_host(y_absl::string_view host,
+ bool check_call_host(y_absl::string_view host,
grpc_auth_context* /*auth_context*/,
grpc_closure* /*on_call_host_checked*/,
grpc_error** error) override {
@@ -147,17 +147,17 @@ class grpc_alts_server_security_connector final
tsi_handshaker* handshaker = nullptr;
const grpc_alts_server_credentials* creds =
static_cast<const grpc_alts_server_credentials*>(server_creds());
- size_t user_specified_max_frame_size = 0;
- const grpc_arg* arg =
- grpc_channel_args_find(args, GRPC_ARG_TSI_MAX_FRAME_SIZE);
- if (arg != nullptr && arg->type == GRPC_ARG_INTEGER) {
- user_specified_max_frame_size = grpc_channel_arg_get_integer(
- arg, {0, 0, std::numeric_limits<int>::max()});
- }
+ size_t user_specified_max_frame_size = 0;
+ const grpc_arg* arg =
+ grpc_channel_args_find(args, GRPC_ARG_TSI_MAX_FRAME_SIZE);
+ if (arg != nullptr && arg->type == GRPC_ARG_INTEGER) {
+ user_specified_max_frame_size = grpc_channel_arg_get_integer(
+ arg, {0, 0, std::numeric_limits<int>::max()});
+ }
GPR_ASSERT(alts_tsi_handshaker_create(
creds->options(), nullptr, creds->handshaker_service_url(),
- false, interested_parties, &handshaker,
- user_specified_max_frame_size) == TSI_OK);
+ false, interested_parties, &handshaker,
+ user_specified_max_frame_size) == TSI_OK);
handshake_manager->Add(
grpc_core::SecurityHandshakerCreate(handshaker, this, args));
}
@@ -193,13 +193,13 @@ grpc_alts_auth_context_from_tsi_peer(const tsi_peer* peer) {
gpr_log(GPR_ERROR, "Invalid or missing certificate type property.");
return nullptr;
}
- /* Check if security level exists. */
- const tsi_peer_property* security_level_prop =
- tsi_peer_get_property_by_name(peer, TSI_SECURITY_LEVEL_PEER_PROPERTY);
- if (security_level_prop == nullptr) {
- gpr_log(GPR_ERROR, "Missing security level property.");
- return nullptr;
- }
+ /* Check if security level exists. */
+ const tsi_peer_property* security_level_prop =
+ tsi_peer_get_property_by_name(peer, TSI_SECURITY_LEVEL_PEER_PROPERTY);
+ if (security_level_prop == nullptr) {
+ gpr_log(GPR_ERROR, "Missing security level property.");
+ return nullptr;
+ }
/* Validate RPC protocol versions. */
const tsi_peer_property* rpc_versions_prop =
tsi_peer_get_property_by_name(peer, TSI_ALTS_RPC_VERSIONS);
@@ -254,12 +254,12 @@ grpc_alts_auth_context_from_tsi_peer(const tsi_peer* peer) {
tsi_prop->value.data,
tsi_prop->value.length);
}
- /* Add security level to auth context. */
- if (strcmp(tsi_prop->name, TSI_SECURITY_LEVEL_PEER_PROPERTY) == 0) {
- grpc_auth_context_add_property(
- ctx.get(), GRPC_TRANSPORT_SECURITY_LEVEL_PROPERTY_NAME,
- tsi_prop->value.data, tsi_prop->value.length);
- }
+ /* Add security level to auth context. */
+ if (strcmp(tsi_prop->name, TSI_SECURITY_LEVEL_PEER_PROPERTY) == 0) {
+ grpc_auth_context_add_property(
+ ctx.get(), GRPC_TRANSPORT_SECURITY_LEVEL_PROPERTY_NAME,
+ tsi_prop->value.data, tsi_prop->value.length);
+ }
}
if (!grpc_auth_context_peer_is_authenticated(ctx.get())) {
gpr_log(GPR_ERROR, "Invalid unauthenticated peer.");
diff --git a/contrib/libs/grpc/src/core/lib/security/security_connector/fake/fake_security_connector.cc b/contrib/libs/grpc/src/core/lib/security/security_connector/fake/fake_security_connector.cc
index 6101c2d8e7..efbf6d231c 100644
--- a/contrib/libs/grpc/src/core/lib/security/security_connector/fake/fake_security_connector.cc
+++ b/contrib/libs/grpc/src/core/lib/security/security_connector/fake/fake_security_connector.cc
@@ -22,15 +22,15 @@
#include <stdbool.h>
-#include "y_absl/strings/str_cat.h"
-
+#include "y_absl/strings/str_cat.h"
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h"
#include "src/core/ext/transport/chttp2/alpn/alpn.h"
-#include "src/core/ext/xds/xds_channel_args.h"
+#include "src/core/ext/xds/xds_channel_args.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/handshaker.h"
#include "src/core/lib/gpr/string.h"
@@ -56,9 +56,9 @@ class grpc_fake_channel_security_connector final
target_(gpr_strdup(target)),
expected_targets_(
gpr_strdup(grpc_fake_transport_get_expected_targets(args))),
- is_lb_channel_(grpc_channel_args_find(
- args, GRPC_ARG_ADDRESS_IS_GRPCLB_LOAD_BALANCER) !=
- nullptr) {
+ is_lb_channel_(grpc_channel_args_find(
+ args, GRPC_ARG_ADDRESS_IS_GRPCLB_LOAD_BALANCER) !=
+ nullptr) {
const grpc_arg* target_name_override_arg =
grpc_channel_args_find(args, GRPC_SSL_TARGET_NAME_OVERRIDE_ARG);
if (target_name_override_arg != nullptr) {
@@ -102,20 +102,20 @@ class grpc_fake_channel_security_connector final
tsi_create_fake_handshaker(/*is_client=*/true), this, args));
}
- bool check_call_host(y_absl::string_view host,
+ bool check_call_host(y_absl::string_view host,
grpc_auth_context* /*auth_context*/,
grpc_closure* /*on_call_host_checked*/,
grpc_error** /*error*/) override {
- y_absl::string_view authority_hostname;
- y_absl::string_view authority_ignored_port;
- y_absl::string_view target_hostname;
- y_absl::string_view target_ignored_port;
+ y_absl::string_view authority_hostname;
+ y_absl::string_view authority_ignored_port;
+ y_absl::string_view target_hostname;
+ y_absl::string_view target_ignored_port;
grpc_core::SplitHostPort(host, &authority_hostname,
&authority_ignored_port);
grpc_core::SplitHostPort(target_, &target_hostname, &target_ignored_port);
if (target_name_override_ != nullptr) {
- y_absl::string_view fake_security_target_name_override_hostname;
- y_absl::string_view fake_security_target_name_override_ignored_port;
+ y_absl::string_view fake_security_target_name_override_hostname;
+ y_absl::string_view fake_security_target_name_override_ignored_port;
grpc_core::SplitHostPort(
target_name_override_, &fake_security_target_name_override_hostname,
&fake_security_target_name_override_ignored_port);
@@ -145,7 +145,7 @@ class grpc_fake_channel_security_connector final
char* target_name_override() const { return target_name_override_; }
private:
- bool fake_check_target(const char* target, const char* set_str) const {
+ bool fake_check_target(const char* target, const char* set_str) const {
GPR_ASSERT(target != nullptr);
char** set = nullptr;
size_t set_size = 0;
@@ -181,14 +181,14 @@ class grpc_fake_channel_security_connector final
expected_targets_);
goto done;
}
- if (!fake_check_target(target_, lbs_and_backends[1])) {
+ if (!fake_check_target(target_, lbs_and_backends[1])) {
gpr_log(GPR_ERROR, "LB target '%s' not found in expected set '%s'",
target_, lbs_and_backends[1]);
goto done;
}
success = true;
} else {
- if (!fake_check_target(target_, lbs_and_backends[0])) {
+ if (!fake_check_target(target_, lbs_and_backends[0])) {
gpr_log(GPR_ERROR, "Backend target '%s' not found in expected set '%s'",
target_, lbs_and_backends[0]);
goto done;
@@ -216,18 +216,18 @@ static void fake_check_peer(
const char* prop_name;
grpc_error* error = GRPC_ERROR_NONE;
*auth_context = nullptr;
- if (peer.property_count != 2) {
+ if (peer.property_count != 2) {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "Fake peers should only have 2 properties.");
+ "Fake peers should only have 2 properties.");
goto end;
}
prop_name = peer.properties[0].name;
if (prop_name == nullptr ||
strcmp(prop_name, TSI_CERTIFICATE_TYPE_PEER_PROPERTY)) {
- error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
- y_absl::StrCat("Unexpected property in fake peer: ",
- prop_name == nullptr ? "<EMPTY>" : prop_name)
- .c_str());
+ error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
+ y_absl::StrCat("Unexpected property in fake peer: ",
+ prop_name == nullptr ? "<EMPTY>" : prop_name)
+ .c_str());
goto end;
}
if (strncmp(peer.properties[0].value.data, TSI_FAKE_CERTIFICATE_TYPE,
@@ -236,29 +236,29 @@ static void fake_check_peer(
"Invalid value for cert type property.");
goto end;
}
- prop_name = peer.properties[1].name;
- if (prop_name == nullptr ||
- strcmp(prop_name, TSI_SECURITY_LEVEL_PEER_PROPERTY) != 0) {
- error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
- y_absl::StrCat("Unexpected property in fake peer: ",
- prop_name == nullptr ? "<EMPTY>" : prop_name)
- .c_str());
- goto end;
- }
- if (strncmp(peer.properties[1].value.data, TSI_FAKE_SECURITY_LEVEL,
- peer.properties[1].value.length) != 0) {
- error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "Invalid value for security level property.");
- goto end;
- }
-
+ prop_name = peer.properties[1].name;
+ if (prop_name == nullptr ||
+ strcmp(prop_name, TSI_SECURITY_LEVEL_PEER_PROPERTY) != 0) {
+ error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
+ y_absl::StrCat("Unexpected property in fake peer: ",
+ prop_name == nullptr ? "<EMPTY>" : prop_name)
+ .c_str());
+ goto end;
+ }
+ if (strncmp(peer.properties[1].value.data, TSI_FAKE_SECURITY_LEVEL,
+ peer.properties[1].value.length) != 0) {
+ error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Invalid value for security level property.");
+ goto end;
+ }
+
*auth_context = grpc_core::MakeRefCounted<grpc_auth_context>(nullptr);
grpc_auth_context_add_cstring_property(
auth_context->get(), GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME,
GRPC_FAKE_TRANSPORT_SECURITY_TYPE);
- grpc_auth_context_add_cstring_property(
- auth_context->get(), GRPC_TRANSPORT_SECURITY_LEVEL_PROPERTY_NAME,
- TSI_FAKE_SECURITY_LEVEL);
+ grpc_auth_context_add_cstring_property(
+ auth_context->get(), GRPC_TRANSPORT_SECURITY_LEVEL_PROPERTY_NAME,
+ TSI_FAKE_SECURITY_LEVEL);
end:
grpc_core::ExecCtx::Run(DEBUG_LOCATION, on_peer_checked, error);
tsi_peer_destruct(&peer);
diff --git a/contrib/libs/grpc/src/core/lib/security/security_connector/load_system_roots_fallback.cc b/contrib/libs/grpc/src/core/lib/security/security_connector/load_system_roots_fallback.cc
index c7e31c136d..f04d0ed225 100644
--- a/contrib/libs/grpc/src/core/lib/security/security_connector/load_system_roots_fallback.cc
+++ b/contrib/libs/grpc/src/core/lib/security/security_connector/load_system_roots_fallback.cc
@@ -21,7 +21,7 @@
#include <grpc/slice_buffer.h>
#include "src/core/lib/security/security_connector/load_system_roots.h"
-#if !defined(GPR_LINUX) && !defined(GPR_ANDROID)
+#if !defined(GPR_LINUX) && !defined(GPR_ANDROID)
namespace grpc_core {
@@ -29,4 +29,4 @@ grpc_slice LoadSystemRootCerts() { return grpc_empty_slice(); }
} // namespace grpc_core
-#endif /* !(GPR_LINUX || GPR_ANDROID) */
+#endif /* !(GPR_LINUX || GPR_ANDROID) */
diff --git a/contrib/libs/grpc/src/core/lib/security/security_connector/load_system_roots_linux.cc b/contrib/libs/grpc/src/core/lib/security/security_connector/load_system_roots_linux.cc
index 374ad04620..c0b6d5d727 100644
--- a/contrib/libs/grpc/src/core/lib/security/security_connector/load_system_roots_linux.cc
+++ b/contrib/libs/grpc/src/core/lib/security/security_connector/load_system_roots_linux.cc
@@ -21,7 +21,7 @@
#include <grpc/slice_buffer.h>
#include "src/core/lib/security/security_connector/load_system_roots_linux.h"
-#if defined(GPR_LINUX) || defined(GPR_ANDROID)
+#if defined(GPR_LINUX) || defined(GPR_ANDROID)
#include "src/core/lib/security/security_connector/load_system_roots.h"
@@ -34,8 +34,8 @@
#include <sys/types.h>
#include <unistd.h>
-#include "y_absl/container/inlined_vector.h"
-
+#include "y_absl/container/inlined_vector.h"
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
@@ -101,7 +101,7 @@ grpc_slice CreateRootCertsBundle(const char* certs_directory) {
char path[MAXPATHLEN];
off_t size;
};
- y_absl::InlinedVector<FileData, 2> roots_filenames;
+ y_absl::InlinedVector<FileData, 2> roots_filenames;
size_t total_bundle_size = 0;
struct dirent* directory_entry;
while ((directory_entry = readdir(ca_directory)) != nullptr) {
@@ -168,4 +168,4 @@ grpc_slice LoadSystemRootCerts() {
} // namespace grpc_core
-#endif /* GPR_LINUX || GPR_ANDROID */
+#endif /* GPR_LINUX || GPR_ANDROID */
diff --git a/contrib/libs/grpc/src/core/lib/security/security_connector/local/local_security_connector.cc b/contrib/libs/grpc/src/core/lib/security/security_connector/local/local_security_connector.cc
index 7df71b2d4d..8f622d4c22 100644
--- a/contrib/libs/grpc/src/core/lib/security/security_connector/local/local_security_connector.cc
+++ b/contrib/libs/grpc/src/core/lib/security/security_connector/local/local_security_connector.cc
@@ -46,8 +46,8 @@
namespace {
-grpc_core::RefCountedPtr<grpc_auth_context> local_auth_context_create(
- const tsi_peer* peer) {
+grpc_core::RefCountedPtr<grpc_auth_context> local_auth_context_create(
+ const tsi_peer* peer) {
/* Create auth context. */
grpc_core::RefCountedPtr<grpc_auth_context> ctx =
grpc_core::MakeRefCounted<grpc_auth_context>(nullptr);
@@ -56,17 +56,17 @@ grpc_core::RefCountedPtr<grpc_auth_context> local_auth_context_create(
GRPC_LOCAL_TRANSPORT_SECURITY_TYPE);
GPR_ASSERT(grpc_auth_context_set_peer_identity_property_name(
ctx.get(), GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME) == 1);
- GPR_ASSERT(peer->property_count == 1);
- const tsi_peer_property* prop = &peer->properties[0];
- GPR_ASSERT(prop != nullptr);
- GPR_ASSERT(strcmp(prop->name, TSI_SECURITY_LEVEL_PEER_PROPERTY) == 0);
- grpc_auth_context_add_property(ctx.get(),
- GRPC_TRANSPORT_SECURITY_LEVEL_PROPERTY_NAME,
- prop->value.data, prop->value.length);
+ GPR_ASSERT(peer->property_count == 1);
+ const tsi_peer_property* prop = &peer->properties[0];
+ GPR_ASSERT(prop != nullptr);
+ GPR_ASSERT(strcmp(prop->name, TSI_SECURITY_LEVEL_PEER_PROPERTY) == 0);
+ grpc_auth_context_add_property(ctx.get(),
+ GRPC_TRANSPORT_SECURITY_LEVEL_PROPERTY_NAME,
+ prop->value.data, prop->value.length);
return ctx;
}
-void local_check_peer(tsi_peer peer, grpc_endpoint* ep,
+void local_check_peer(tsi_peer peer, grpc_endpoint* ep,
grpc_core::RefCountedPtr<grpc_auth_context>* auth_context,
grpc_closure* on_peer_checked,
grpc_local_connect_type type) {
@@ -110,30 +110,30 @@ void local_check_peer(tsi_peer peer, grpc_endpoint* ep,
grpc_core::ExecCtx::Run(DEBUG_LOCATION, on_peer_checked, error);
return;
}
- // Add TSI_SECURITY_LEVEL_PEER_PROPERTY type peer property.
- size_t new_property_count = peer.property_count + 1;
- tsi_peer_property* new_properties = static_cast<tsi_peer_property*>(
- gpr_zalloc(sizeof(*new_properties) * new_property_count));
- for (size_t i = 0; i < peer.property_count; i++) {
- new_properties[i] = peer.properties[i];
- }
- if (peer.properties != nullptr) gpr_free(peer.properties);
- peer.properties = new_properties;
- // TODO(yihuazhang): Set security level of local TCP to TSI_SECURITY_NONE.
- const char* security_level =
- tsi_security_level_to_string(TSI_PRIVACY_AND_INTEGRITY);
- tsi_result result = tsi_construct_string_peer_property_from_cstring(
- TSI_SECURITY_LEVEL_PEER_PROPERTY, security_level,
- &peer.properties[peer.property_count]);
- if (result != TSI_OK) return;
- peer.property_count++;
+ // Add TSI_SECURITY_LEVEL_PEER_PROPERTY type peer property.
+ size_t new_property_count = peer.property_count + 1;
+ tsi_peer_property* new_properties = static_cast<tsi_peer_property*>(
+ gpr_zalloc(sizeof(*new_properties) * new_property_count));
+ for (size_t i = 0; i < peer.property_count; i++) {
+ new_properties[i] = peer.properties[i];
+ }
+ if (peer.properties != nullptr) gpr_free(peer.properties);
+ peer.properties = new_properties;
+ // TODO(yihuazhang): Set security level of local TCP to TSI_SECURITY_NONE.
+ const char* security_level =
+ tsi_security_level_to_string(TSI_PRIVACY_AND_INTEGRITY);
+ tsi_result result = tsi_construct_string_peer_property_from_cstring(
+ TSI_SECURITY_LEVEL_PEER_PROPERTY, security_level,
+ &peer.properties[peer.property_count]);
+ if (result != TSI_OK) return;
+ peer.property_count++;
/* Create an auth context which is necessary to pass the santiy check in
* {client, server}_auth_filter that verifies if the peer's auth context is
* obtained during handshakes. The auth context is only checked for its
* existence and not actually used.
*/
- *auth_context = local_auth_context_create(&peer);
- tsi_peer_destruct(&peer);
+ *auth_context = local_auth_context_create(&peer);
+ tsi_peer_destruct(&peer);
error = *auth_context != nullptr ? GRPC_ERROR_NONE
: GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Could not create local auth context");
@@ -177,11 +177,11 @@ class grpc_local_channel_security_connector final
grpc_closure* on_peer_checked) override {
grpc_local_credentials* creds =
reinterpret_cast<grpc_local_credentials*>(mutable_channel_creds());
- local_check_peer(peer, ep, auth_context, on_peer_checked,
+ local_check_peer(peer, ep, auth_context, on_peer_checked,
creds->connect_type());
}
- bool check_call_host(y_absl::string_view host,
+ bool check_call_host(y_absl::string_view host,
grpc_auth_context* /*auth_context*/,
grpc_closure* /*on_call_host_checked*/,
grpc_error** error) override {
@@ -226,7 +226,7 @@ class grpc_local_server_security_connector final
grpc_closure* on_peer_checked) override {
grpc_local_server_credentials* creds =
static_cast<grpc_local_server_credentials*>(mutable_server_creds());
- local_check_peer(peer, ep, auth_context, on_peer_checked,
+ local_check_peer(peer, ep, auth_context, on_peer_checked,
creds->connect_type());
}
diff --git a/contrib/libs/grpc/src/core/lib/security/security_connector/security_connector.cc b/contrib/libs/grpc/src/core/lib/security/security_connector/security_connector.cc
index 83e033f52f..0400ad6fb8 100644
--- a/contrib/libs/grpc/src/core/lib/security/security_connector/security_connector.cc
+++ b/contrib/libs/grpc/src/core/lib/security/security_connector/security_connector.cc
@@ -46,8 +46,8 @@ grpc_server_security_connector::grpc_server_security_connector(
: grpc_security_connector(url_scheme),
server_creds_(std::move(server_creds)) {}
-grpc_server_security_connector::~grpc_server_security_connector() = default;
-
+grpc_server_security_connector::~grpc_server_security_connector() = default;
+
grpc_channel_security_connector::grpc_channel_security_connector(
const char* url_scheme,
grpc_core::RefCountedPtr<grpc_channel_credentials> channel_creds,
diff --git a/contrib/libs/grpc/src/core/lib/security/security_connector/security_connector.h b/contrib/libs/grpc/src/core/lib/security/security_connector/security_connector.h
index b457b9f5a4..74d04600b2 100644
--- a/contrib/libs/grpc/src/core/lib/security/security_connector/security_connector.h
+++ b/contrib/libs/grpc/src/core/lib/security/security_connector/security_connector.h
@@ -98,7 +98,7 @@ class grpc_channel_security_connector : public grpc_security_connector {
/// Returns true if completed synchronously, in which case \a error will
/// be set to indicate the result. Otherwise, \a on_call_host_checked
/// will be invoked when complete.
- virtual bool check_call_host(y_absl::string_view host,
+ virtual bool check_call_host(y_absl::string_view host,
grpc_auth_context* auth_context,
grpc_closure* on_call_host_checked,
grpc_error** error) = 0;
@@ -151,7 +151,7 @@ class grpc_server_security_connector : public grpc_security_connector {
grpc_server_security_connector(
const char* url_scheme,
grpc_core::RefCountedPtr<grpc_server_credentials> server_creds);
- ~grpc_server_security_connector() override;
+ ~grpc_server_security_connector() override;
virtual void add_handshakers(const grpc_channel_args* args,
grpc_pollset_set* interested_parties,
diff --git a/contrib/libs/grpc/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc b/contrib/libs/grpc/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc
index 8b334b12dd..b5e78ddbbb 100644
--- a/contrib/libs/grpc/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc
+++ b/contrib/libs/grpc/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc
@@ -22,10 +22,10 @@
#include <stdbool.h>
-#include "y_absl/strings/str_cat.h"
-#include "y_absl/strings/str_format.h"
-#include "y_absl/strings/string_view.h"
-
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/string_view.h"
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@@ -34,7 +34,7 @@
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gprpp/host_port.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
-#include "src/core/lib/gprpp/sync.h"
+#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/security/context/security_context.h"
#include "src/core/lib/security/credentials/credentials.h"
#include "src/core/lib/security/credentials/ssl/ssl_credentials.h"
@@ -54,9 +54,9 @@ grpc_error* ssl_check_peer(
}
/* Check the peer name if specified. */
if (peer_name != nullptr && !grpc_ssl_host_matches_name(peer, peer_name)) {
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
- y_absl::StrCat("Peer name ", peer_name, " is not in peer certificate")
- .c_str());
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
+ y_absl::StrCat("Peer name ", peer_name, " is not in peer certificate")
+ .c_str());
}
*auth_context =
grpc_ssl_peer_to_auth_context(peer, GRPC_SSL_TRANSPORT_SECURITY_TYPE);
@@ -74,13 +74,13 @@ class grpc_ssl_channel_security_connector final
: grpc_channel_security_connector(GRPC_SSL_URL_SCHEME,
std::move(channel_creds),
std::move(request_metadata_creds)),
- overridden_target_name_(
- overridden_target_name == nullptr ? "" : overridden_target_name),
+ overridden_target_name_(
+ overridden_target_name == nullptr ? "" : overridden_target_name),
verify_options_(&config->verify_options) {
- y_absl::string_view host;
- y_absl::string_view port;
+ y_absl::string_view host;
+ y_absl::string_view port;
grpc_core::SplitHostPort(target_name, &host, &port);
- target_name_ = TString(host);
+ target_name_ = TString(host);
}
~grpc_ssl_channel_security_connector() override {
@@ -106,8 +106,8 @@ class grpc_ssl_channel_security_connector final
}
options.cipher_suites = grpc_get_ssl_cipher_suites();
options.session_cache = ssl_session_cache;
- options.min_tls_version = grpc_get_tsi_tls_version(config->min_tls_version);
- options.max_tls_version = grpc_get_tsi_tls_version(config->max_tls_version);
+ options.min_tls_version = grpc_get_tsi_tls_version(config->min_tls_version);
+ options.max_tls_version = grpc_get_tsi_tls_version(config->max_tls_version);
const tsi_result result =
tsi_create_ssl_client_handshaker_factory_with_options(
&options, &client_handshaker_factory_);
@@ -127,8 +127,8 @@ class grpc_ssl_channel_security_connector final
tsi_handshaker* tsi_hs = nullptr;
tsi_result result = tsi_ssl_client_handshaker_factory_create_handshaker(
client_handshaker_factory_,
- overridden_target_name_.empty() ? target_name_.c_str()
- : overridden_target_name_.c_str(),
+ overridden_target_name_.empty() ? target_name_.c_str()
+ : overridden_target_name_.c_str(),
&tsi_hs);
if (result != TSI_OK) {
gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.",
@@ -142,9 +142,9 @@ class grpc_ssl_channel_security_connector final
void check_peer(tsi_peer peer, grpc_endpoint* /*ep*/,
grpc_core::RefCountedPtr<grpc_auth_context>* auth_context,
grpc_closure* on_peer_checked) override {
- const char* target_name = overridden_target_name_.empty()
- ? target_name_.c_str()
- : overridden_target_name_.c_str();
+ const char* target_name = overridden_target_name_.empty()
+ ? target_name_.c_str()
+ : overridden_target_name_.c_str();
grpc_error* error = ssl_check_peer(target_name, &peer, auth_context);
if (error == GRPC_ERROR_NONE &&
verify_options_->verify_peer_callback != nullptr) {
@@ -162,10 +162,10 @@ class grpc_ssl_channel_security_connector final
verify_options_->verify_peer_callback_userdata);
gpr_free(peer_pem);
if (callback_status) {
- error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
- y_absl::StrFormat("Verify peer callback returned a failure (%d)",
- callback_status)
- .c_str());
+ error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
+ y_absl::StrFormat("Verify peer callback returned a failure (%d)",
+ callback_status)
+ .c_str());
}
}
}
@@ -178,17 +178,17 @@ class grpc_ssl_channel_security_connector final
reinterpret_cast<const grpc_ssl_channel_security_connector*>(other_sc);
int c = channel_security_connector_cmp(other);
if (c != 0) return c;
- c = target_name_.compare(other->target_name_);
+ c = target_name_.compare(other->target_name_);
if (c != 0) return c;
- return overridden_target_name_.compare(other->overridden_target_name_);
+ return overridden_target_name_.compare(other->overridden_target_name_);
}
- bool check_call_host(y_absl::string_view host, grpc_auth_context* auth_context,
+ bool check_call_host(y_absl::string_view host, grpc_auth_context* auth_context,
grpc_closure* /*on_call_host_checked*/,
grpc_error** error) override {
- return grpc_ssl_check_call_host(host, target_name_.c_str(),
- overridden_target_name_.c_str(),
- auth_context, error);
+ return grpc_ssl_check_call_host(host, target_name_.c_str(),
+ overridden_target_name_.c_str(),
+ auth_context, error);
}
void cancel_check_call_host(grpc_closure* /*on_call_host_checked*/,
@@ -198,8 +198,8 @@ class grpc_ssl_channel_security_connector final
private:
tsi_ssl_client_handshaker_factory* client_handshaker_factory_;
- TString target_name_;
- TString overridden_target_name_;
+ TString target_name_;
+ TString overridden_target_name_;
const verify_peer_options* verify_options_;
};
@@ -251,10 +251,10 @@ class grpc_ssl_server_security_connector
options.cipher_suites = grpc_get_ssl_cipher_suites();
options.alpn_protocols = alpn_protocol_strings;
options.num_alpn_protocols = static_cast<uint16_t>(num_alpn_protocols);
- options.min_tls_version = grpc_get_tsi_tls_version(
- server_credentials->config().min_tls_version);
- options.max_tls_version = grpc_get_tsi_tls_version(
- server_credentials->config().max_tls_version);
+ options.min_tls_version = grpc_get_tsi_tls_version(
+ server_credentials->config().min_tls_version);
+ options.max_tls_version = grpc_get_tsi_tls_version(
+ server_credentials->config().max_tls_version);
const tsi_result result =
tsi_create_ssl_server_handshaker_factory_with_options(
&options, &server_handshaker_factory_);
@@ -307,7 +307,7 @@ class grpc_ssl_server_security_connector
bool status;
if (!has_cert_config_fetcher()) return false;
- grpc_core::MutexLock lock(&mu_);
+ grpc_core::MutexLock lock(&mu_);
grpc_ssl_server_credentials* server_creds =
static_cast<grpc_ssl_server_credentials*>(this->mutable_server_creds());
grpc_ssl_certificate_config_reload_status cb_result =
@@ -387,7 +387,7 @@ class grpc_ssl_server_security_connector
server_handshaker_factory_ = new_factory;
}
- grpc_core::Mutex mu_;
+ grpc_core::Mutex mu_;
tsi_ssl_server_handshaker_factory* server_handshaker_factory_ = nullptr;
};
} // namespace
diff --git a/contrib/libs/grpc/src/core/lib/security/security_connector/ssl/ssl_security_connector.h b/contrib/libs/grpc/src/core/lib/security/security_connector/ssl/ssl_security_connector.h
index e8369afbea..04c32bb2a8 100644
--- a/contrib/libs/grpc/src/core/lib/security/security_connector/ssl/ssl_security_connector.h
+++ b/contrib/libs/grpc/src/core/lib/security/security_connector/ssl/ssl_security_connector.h
@@ -33,10 +33,10 @@ struct grpc_ssl_config {
tsi_ssl_pem_key_cert_pair* pem_key_cert_pair;
char* pem_root_certs;
verify_peer_options verify_options;
- grpc_tls_version min_tls_version = grpc_tls_version::TLS1_2;
- grpc_tls_version max_tls_version = grpc_tls_version::TLS1_3;
+ grpc_tls_version min_tls_version = grpc_tls_version::TLS1_2;
+ grpc_tls_version max_tls_version = grpc_tls_version::TLS1_3;
};
-
+
/* Creates an SSL channel_security_connector.
- request_metadata_creds is the credentials object which metadata
will be sent with each request. This parameter can be NULL.
@@ -65,8 +65,8 @@ struct grpc_ssl_server_config {
char* pem_root_certs = nullptr;
grpc_ssl_client_certificate_request_type client_certificate_request =
GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE;
- grpc_tls_version min_tls_version = grpc_tls_version::TLS1_2;
- grpc_tls_version max_tls_version = grpc_tls_version::TLS1_3;
+ grpc_tls_version min_tls_version = grpc_tls_version::TLS1_2;
+ grpc_tls_version max_tls_version = grpc_tls_version::TLS1_3;
};
/* Creates an SSL server_security_connector.
- config is the SSL config to be used for the SSL channel establishment.
diff --git a/contrib/libs/grpc/src/core/lib/security/security_connector/ssl_utils.cc b/contrib/libs/grpc/src/core/lib/security/security_connector/ssl_utils.cc
index 89caff5dd8..6c83968f8e 100644
--- a/contrib/libs/grpc/src/core/lib/security/security_connector/ssl_utils.cc
+++ b/contrib/libs/grpc/src/core/lib/security/security_connector/ssl_utils.cc
@@ -20,10 +20,10 @@
#include "src/core/lib/security/security_connector/ssl_utils.h"
-#include <vector>
-
-#include "y_absl/strings/str_cat.h"
-
+#include <vector>
+
+#include "y_absl/strings/str_cat.h"
+
#include <grpc/slice_buffer.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@@ -70,9 +70,9 @@ static const char* cipher_suites = nullptr;
// All cipher suites for default are compliant with HTTP2.
GPR_GLOBAL_CONFIG_DEFINE_STRING(
grpc_ssl_cipher_suites,
- "TLS_AES_128_GCM_SHA256:"
- "TLS_AES_256_GCM_SHA384:"
- "TLS_CHACHA20_POLY1305_SHA256:"
+ "TLS_AES_128_GCM_SHA256:"
+ "TLS_AES_256_GCM_SHA384:"
+ "TLS_CHACHA20_POLY1305_SHA256:"
"ECDHE-ECDSA-AES128-GCM-SHA256:"
"ECDHE-ECDSA-AES256-GCM-SHA384:"
"ECDHE-RSA-AES128-GCM-SHA256:"
@@ -92,30 +92,30 @@ const char* grpc_get_ssl_cipher_suites(void) {
return cipher_suites;
}
-grpc_security_level grpc_tsi_security_level_string_to_enum(
- const char* security_level) {
- if (strcmp(security_level, "TSI_INTEGRITY_ONLY") == 0) {
- return GRPC_INTEGRITY_ONLY;
- } else if (strcmp(security_level, "TSI_PRIVACY_AND_INTEGRITY") == 0) {
- return GRPC_PRIVACY_AND_INTEGRITY;
- }
- return GRPC_SECURITY_NONE;
-}
-
-const char* grpc_security_level_to_string(grpc_security_level security_level) {
- if (security_level == GRPC_PRIVACY_AND_INTEGRITY) {
- return "GRPC_PRIVACY_AND_INTEGRITY";
- } else if (security_level == GRPC_INTEGRITY_ONLY) {
- return "GRPC_INTEGRITY_ONLY";
- }
- return "GRPC_SECURITY_NONE";
-}
-
-bool grpc_check_security_level(grpc_security_level channel_level,
- grpc_security_level call_cred_level) {
- return static_cast<int>(channel_level) >= static_cast<int>(call_cred_level);
-}
-
+grpc_security_level grpc_tsi_security_level_string_to_enum(
+ const char* security_level) {
+ if (strcmp(security_level, "TSI_INTEGRITY_ONLY") == 0) {
+ return GRPC_INTEGRITY_ONLY;
+ } else if (strcmp(security_level, "TSI_PRIVACY_AND_INTEGRITY") == 0) {
+ return GRPC_PRIVACY_AND_INTEGRITY;
+ }
+ return GRPC_SECURITY_NONE;
+}
+
+const char* grpc_security_level_to_string(grpc_security_level security_level) {
+ if (security_level == GRPC_PRIVACY_AND_INTEGRITY) {
+ return "GRPC_PRIVACY_AND_INTEGRITY";
+ } else if (security_level == GRPC_INTEGRITY_ONLY) {
+ return "GRPC_INTEGRITY_ONLY";
+ }
+ return "GRPC_SECURITY_NONE";
+}
+
+bool grpc_check_security_level(grpc_security_level channel_level,
+ grpc_security_level call_cred_level) {
+ return static_cast<int>(channel_level) >= static_cast<int>(call_cred_level);
+}
+
tsi_client_certificate_request_type
grpc_get_tsi_client_certificate_request_type(
grpc_ssl_client_certificate_request_type grpc_request_type) {
@@ -140,18 +140,18 @@ grpc_get_tsi_client_certificate_request_type(
}
}
-tsi_tls_version grpc_get_tsi_tls_version(grpc_tls_version tls_version) {
- switch (tls_version) {
- case grpc_tls_version::TLS1_2:
- return tsi_tls_version::TSI_TLS1_2;
- case grpc_tls_version::TLS1_3:
- return tsi_tls_version::TSI_TLS1_3;
- default:
- gpr_log(GPR_INFO, "Falling back to TLS 1.2.");
- return tsi_tls_version::TSI_TLS1_2;
- }
-}
-
+tsi_tls_version grpc_get_tsi_tls_version(grpc_tls_version tls_version) {
+ switch (tls_version) {
+ case grpc_tls_version::TLS1_2:
+ return tsi_tls_version::TSI_TLS1_2;
+ case grpc_tls_version::TLS1_3:
+ return tsi_tls_version::TSI_TLS1_3;
+ default:
+ gpr_log(GPR_INFO, "Falling back to TLS 1.2.");
+ return tsi_tls_version::TSI_TLS1_2;
+ }
+}
+
grpc_error* grpc_ssl_check_alpn(const tsi_peer* peer) {
#if TSI_OPENSSL_ALPN_SUPPORT
/* Check the ALPN if ALPN is supported. */
@@ -169,28 +169,28 @@ grpc_error* grpc_ssl_check_alpn(const tsi_peer* peer) {
return GRPC_ERROR_NONE;
}
-grpc_error* grpc_ssl_check_peer_name(y_absl::string_view peer_name,
+grpc_error* grpc_ssl_check_peer_name(y_absl::string_view peer_name,
const tsi_peer* peer) {
/* Check the peer name if specified. */
if (!peer_name.empty() && !grpc_ssl_host_matches_name(peer, peer_name)) {
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
- y_absl::StrCat("Peer name ", peer_name, " is not in peer certificate")
- .c_str());
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
+ y_absl::StrCat("Peer name ", peer_name, " is not in peer certificate")
+ .c_str());
}
return GRPC_ERROR_NONE;
}
-bool grpc_ssl_check_call_host(y_absl::string_view host,
- y_absl::string_view target_name,
- y_absl::string_view overridden_target_name,
+bool grpc_ssl_check_call_host(y_absl::string_view host,
+ y_absl::string_view target_name,
+ y_absl::string_view overridden_target_name,
grpc_auth_context* auth_context,
grpc_error** error) {
grpc_security_status status = GRPC_SECURITY_ERROR;
tsi_peer peer = grpc_shallow_peer_from_ssl_auth_context(auth_context);
if (grpc_ssl_host_matches_name(&peer, host)) status = GRPC_SECURITY_OK;
- /* If the target name was overridden, then the original target_name was
- 'checked' transitively during the previous peer check at the end of the
- handshake. */
+ /* If the target name was overridden, then the original target_name was
+ 'checked' transitively during the previous peer check at the end of the
+ handshake. */
if (!overridden_target_name.empty() && host == target_name) {
status = GRPC_SECURITY_OK;
}
@@ -214,50 +214,50 @@ const char** grpc_fill_alpn_protocol_strings(size_t* num_alpn_protocols) {
}
int grpc_ssl_host_matches_name(const tsi_peer* peer,
- y_absl::string_view peer_name) {
- y_absl::string_view allocated_name;
- y_absl::string_view ignored_port;
+ y_absl::string_view peer_name) {
+ y_absl::string_view allocated_name;
+ y_absl::string_view ignored_port;
grpc_core::SplitHostPort(peer_name, &allocated_name, &ignored_port);
if (allocated_name.empty()) return 0;
// IPv6 zone-id should not be included in comparisons.
const size_t zone_id = allocated_name.find('%');
- if (zone_id != y_absl::string_view::npos) {
+ if (zone_id != y_absl::string_view::npos) {
allocated_name.remove_suffix(allocated_name.size() - zone_id);
}
return tsi_ssl_peer_matches_name(peer, allocated_name);
}
-int grpc_ssl_cmp_target_name(y_absl::string_view target_name,
- y_absl::string_view other_target_name,
- y_absl::string_view overridden_target_name,
- y_absl::string_view other_overridden_target_name) {
- int c = target_name.compare(other_target_name);
+int grpc_ssl_cmp_target_name(y_absl::string_view target_name,
+ y_absl::string_view other_target_name,
+ y_absl::string_view overridden_target_name,
+ y_absl::string_view other_overridden_target_name) {
+ int c = target_name.compare(other_target_name);
if (c != 0) return c;
- return overridden_target_name.compare(other_overridden_target_name);
-}
-
-static bool IsSpiffeId(y_absl::string_view uri) {
- // Return false without logging for a non-spiffe uri scheme.
- if (!y_absl::StartsWith(uri, "spiffe://")) {
- return false;
- };
- if (uri.size() > 2048) {
- gpr_log(GPR_INFO, "Invalid SPIFFE ID: ID longer than 2048 bytes.");
- return false;
- }
- std::vector<y_absl::string_view> splits = y_absl::StrSplit(uri, '/');
- if (splits.size() < 4 || splits[3] == "") {
- gpr_log(GPR_INFO, "Invalid SPIFFE ID: workload id is empty.");
- return false;
- }
- if (splits[2].size() > 255) {
- gpr_log(GPR_INFO, "Invalid SPIFFE ID: domain longer than 255 characters.");
- return false;
- }
- return true;
-}
-
+ return overridden_target_name.compare(other_overridden_target_name);
+}
+
+static bool IsSpiffeId(y_absl::string_view uri) {
+ // Return false without logging for a non-spiffe uri scheme.
+ if (!y_absl::StartsWith(uri, "spiffe://")) {
+ return false;
+ };
+ if (uri.size() > 2048) {
+ gpr_log(GPR_INFO, "Invalid SPIFFE ID: ID longer than 2048 bytes.");
+ return false;
+ }
+ std::vector<y_absl::string_view> splits = y_absl::StrSplit(uri, '/');
+ if (splits.size() < 4 || splits[3] == "") {
+ gpr_log(GPR_INFO, "Invalid SPIFFE ID: workload id is empty.");
+ return false;
+ }
+ if (splits[2].size() > 255) {
+ gpr_log(GPR_INFO, "Invalid SPIFFE ID: domain longer than 255 characters.");
+ return false;
+ }
+ return true;
+}
+
grpc_core::RefCountedPtr<grpc_auth_context> grpc_ssl_peer_to_auth_context(
const tsi_peer* peer, const char* transport_security_type) {
size_t i;
@@ -270,10 +270,10 @@ grpc_core::RefCountedPtr<grpc_auth_context> grpc_ssl_peer_to_auth_context(
grpc_auth_context_add_cstring_property(
ctx.get(), GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME,
transport_security_type);
- const char* spiffe_data = nullptr;
- size_t spiffe_length = 0;
- int uri_count = 0;
- bool has_spiffe_id = false;
+ const char* spiffe_data = nullptr;
+ size_t spiffe_length = 0;
+ int uri_count = 0;
+ bool has_spiffe_id = false;
for (i = 0; i < peer->property_count; i++) {
const tsi_peer_property* prop = &peer->properties[i];
if (prop->name == nullptr) continue;
@@ -293,44 +293,44 @@ grpc_core::RefCountedPtr<grpc_auth_context> grpc_ssl_peer_to_auth_context(
grpc_auth_context_add_property(ctx.get(),
GRPC_X509_PEM_CERT_PROPERTY_NAME,
prop->value.data, prop->value.length);
- } else if (strcmp(prop->name, TSI_X509_PEM_CERT_CHAIN_PROPERTY) == 0) {
- grpc_auth_context_add_property(ctx.get(),
- GRPC_X509_PEM_CERT_CHAIN_PROPERTY_NAME,
- prop->value.data, prop->value.length);
+ } else if (strcmp(prop->name, TSI_X509_PEM_CERT_CHAIN_PROPERTY) == 0) {
+ grpc_auth_context_add_property(ctx.get(),
+ GRPC_X509_PEM_CERT_CHAIN_PROPERTY_NAME,
+ prop->value.data, prop->value.length);
} else if (strcmp(prop->name, TSI_SSL_SESSION_REUSED_PEER_PROPERTY) == 0) {
grpc_auth_context_add_property(ctx.get(),
GRPC_SSL_SESSION_REUSED_PROPERTY,
prop->value.data, prop->value.length);
- } else if (strcmp(prop->name, TSI_SECURITY_LEVEL_PEER_PROPERTY) == 0) {
- grpc_auth_context_add_property(
- ctx.get(), GRPC_TRANSPORT_SECURITY_LEVEL_PROPERTY_NAME,
- prop->value.data, prop->value.length);
- } else if (strcmp(prop->name, TSI_X509_URI_PEER_PROPERTY) == 0) {
- uri_count++;
- y_absl::string_view spiffe_id(prop->value.data, prop->value.length);
- if (IsSpiffeId(spiffe_id)) {
- spiffe_data = prop->value.data;
- spiffe_length = prop->value.length;
- has_spiffe_id = true;
- }
+ } else if (strcmp(prop->name, TSI_SECURITY_LEVEL_PEER_PROPERTY) == 0) {
+ grpc_auth_context_add_property(
+ ctx.get(), GRPC_TRANSPORT_SECURITY_LEVEL_PROPERTY_NAME,
+ prop->value.data, prop->value.length);
+ } else if (strcmp(prop->name, TSI_X509_URI_PEER_PROPERTY) == 0) {
+ uri_count++;
+ y_absl::string_view spiffe_id(prop->value.data, prop->value.length);
+ if (IsSpiffeId(spiffe_id)) {
+ spiffe_data = prop->value.data;
+ spiffe_length = prop->value.length;
+ has_spiffe_id = true;
+ }
}
}
if (peer_identity_property_name != nullptr) {
GPR_ASSERT(grpc_auth_context_set_peer_identity_property_name(
ctx.get(), peer_identity_property_name) == 1);
}
- // A valid SPIFFE certificate can only have exact one URI SAN field.
- if (has_spiffe_id) {
- if (uri_count == 1) {
- GPR_ASSERT(spiffe_length > 0);
- GPR_ASSERT(spiffe_data != nullptr);
- grpc_auth_context_add_property(ctx.get(),
- GRPC_PEER_SPIFFE_ID_PROPERTY_NAME,
- spiffe_data, spiffe_length);
- } else {
- gpr_log(GPR_INFO, "Invalid SPIFFE ID: multiple URI SANs.");
- }
- }
+ // A valid SPIFFE certificate can only have exact one URI SAN field.
+ if (has_spiffe_id) {
+ if (uri_count == 1) {
+ GPR_ASSERT(spiffe_length > 0);
+ GPR_ASSERT(spiffe_data != nullptr);
+ grpc_auth_context_add_property(ctx.get(),
+ GRPC_PEER_SPIFFE_ID_PROPERTY_NAME,
+ spiffe_data, spiffe_length);
+ } else {
+ gpr_log(GPR_INFO, "Invalid SPIFFE ID: multiple URI SANs.");
+ }
+ }
return ctx;
}
@@ -368,17 +368,17 @@ tsi_peer grpc_shallow_peer_from_ssl_auth_context(
} else if (strcmp(prop->name, GRPC_X509_PEM_CERT_PROPERTY_NAME) == 0) {
add_shallow_auth_property_to_peer(&peer, prop,
TSI_X509_PEM_CERT_PROPERTY);
- } else if (strcmp(prop->name,
- GRPC_TRANSPORT_SECURITY_LEVEL_PROPERTY_NAME) == 0) {
- add_shallow_auth_property_to_peer(&peer, prop,
- TSI_SECURITY_LEVEL_PEER_PROPERTY);
- } else if (strcmp(prop->name, GRPC_X509_PEM_CERT_CHAIN_PROPERTY_NAME) ==
- 0) {
- add_shallow_auth_property_to_peer(&peer, prop,
- TSI_X509_PEM_CERT_CHAIN_PROPERTY);
- } else if (strcmp(prop->name, GRPC_PEER_SPIFFE_ID_PROPERTY_NAME) == 0) {
- add_shallow_auth_property_to_peer(&peer, prop,
- TSI_X509_URI_PEER_PROPERTY);
+ } else if (strcmp(prop->name,
+ GRPC_TRANSPORT_SECURITY_LEVEL_PROPERTY_NAME) == 0) {
+ add_shallow_auth_property_to_peer(&peer, prop,
+ TSI_SECURITY_LEVEL_PEER_PROPERTY);
+ } else if (strcmp(prop->name, GRPC_X509_PEM_CERT_CHAIN_PROPERTY_NAME) ==
+ 0) {
+ add_shallow_auth_property_to_peer(&peer, prop,
+ TSI_X509_PEM_CERT_CHAIN_PROPERTY);
+ } else if (strcmp(prop->name, GRPC_PEER_SPIFFE_ID_PROPERTY_NAME) == 0) {
+ add_shallow_auth_property_to_peer(&peer, prop,
+ TSI_X509_URI_PEER_PROPERTY);
}
}
}
@@ -391,8 +391,8 @@ void grpc_shallow_peer_destruct(tsi_peer* peer) {
grpc_security_status grpc_ssl_tsi_client_handshaker_factory_init(
tsi_ssl_pem_key_cert_pair* pem_key_cert_pair, const char* pem_root_certs,
- bool skip_server_certificate_verification, tsi_tls_version min_tls_version,
- tsi_tls_version max_tls_version, tsi_ssl_session_cache* ssl_session_cache,
+ bool skip_server_certificate_verification, tsi_tls_version min_tls_version,
+ tsi_tls_version max_tls_version, tsi_ssl_session_cache* ssl_session_cache,
tsi_ssl_client_handshaker_factory** handshaker_factory) {
const char* root_certs;
const tsi_ssl_root_certs_store* root_store;
@@ -422,10 +422,10 @@ grpc_security_status grpc_ssl_tsi_client_handshaker_factory_init(
}
options.cipher_suites = grpc_get_ssl_cipher_suites();
options.session_cache = ssl_session_cache;
- options.skip_server_certificate_verification =
- skip_server_certificate_verification;
- options.min_tls_version = min_tls_version;
- options.max_tls_version = max_tls_version;
+ options.skip_server_certificate_verification =
+ skip_server_certificate_verification;
+ options.min_tls_version = min_tls_version;
+ options.max_tls_version = max_tls_version;
const tsi_result result =
tsi_create_ssl_client_handshaker_factory_with_options(&options,
handshaker_factory);
@@ -442,7 +442,7 @@ grpc_security_status grpc_ssl_tsi_server_handshaker_factory_init(
tsi_ssl_pem_key_cert_pair* pem_key_cert_pairs, size_t num_key_cert_pairs,
const char* pem_root_certs,
grpc_ssl_client_certificate_request_type client_certificate_request,
- tsi_tls_version min_tls_version, tsi_tls_version max_tls_version,
+ tsi_tls_version min_tls_version, tsi_tls_version max_tls_version,
tsi_ssl_server_handshaker_factory** handshaker_factory) {
size_t num_alpn_protocols = 0;
const char** alpn_protocol_strings =
@@ -456,8 +456,8 @@ grpc_security_status grpc_ssl_tsi_server_handshaker_factory_init(
options.cipher_suites = grpc_get_ssl_cipher_suites();
options.alpn_protocols = alpn_protocol_strings;
options.num_alpn_protocols = static_cast<uint16_t>(num_alpn_protocols);
- options.min_tls_version = min_tls_version;
- options.max_tls_version = max_tls_version;
+ options.min_tls_version = min_tls_version;
+ options.max_tls_version = max_tls_version;
const tsi_result result =
tsi_create_ssl_server_handshaker_factory_with_options(&options,
handshaker_factory);
diff --git a/contrib/libs/grpc/src/core/lib/security/security_connector/ssl_utils.h b/contrib/libs/grpc/src/core/lib/security/security_connector/ssl_utils.h
index 769276c3fd..6141f8d9cb 100644
--- a/contrib/libs/grpc/src/core/lib/security/security_connector/ssl_utils.h
+++ b/contrib/libs/grpc/src/core/lib/security/security_connector/ssl_utils.h
@@ -23,9 +23,9 @@
#include <stdbool.h>
-#include "y_absl/strings/str_split.h"
-#include "y_absl/strings/string_view.h"
-
+#include "y_absl/strings/str_split.h"
+#include "y_absl/strings/string_view.h"
+
#include <grpc/grpc_security.h>
#include <grpc/slice_buffer.h>
@@ -47,17 +47,17 @@
grpc_error* grpc_ssl_check_alpn(const tsi_peer* peer);
/* Check peer name information returned from SSL handshakes. */
-grpc_error* grpc_ssl_check_peer_name(y_absl::string_view peer_name,
+grpc_error* grpc_ssl_check_peer_name(y_absl::string_view peer_name,
const tsi_peer* peer);
/* Compare targer_name information extracted from SSL security connectors. */
-int grpc_ssl_cmp_target_name(y_absl::string_view target_name,
- y_absl::string_view other_target_name,
- y_absl::string_view overridden_target_name,
- y_absl::string_view other_overridden_target_name);
+int grpc_ssl_cmp_target_name(y_absl::string_view target_name,
+ y_absl::string_view other_target_name,
+ y_absl::string_view overridden_target_name,
+ y_absl::string_view other_overridden_target_name);
/* Check the host that will be set for a call is acceptable.*/
-bool grpc_ssl_check_call_host(y_absl::string_view host,
- y_absl::string_view target_name,
- y_absl::string_view overridden_target_name,
+bool grpc_ssl_check_call_host(y_absl::string_view host,
+ y_absl::string_view target_name,
+ y_absl::string_view overridden_target_name,
grpc_auth_context* auth_context,
grpc_error** error);
/* Return HTTP2-compliant cipher suites that gRPC accepts by default. */
@@ -69,35 +69,35 @@ tsi_client_certificate_request_type
grpc_get_tsi_client_certificate_request_type(
grpc_ssl_client_certificate_request_type grpc_request_type);
-/* Map tsi_security_level string to grpc_security_level enum. */
-grpc_security_level grpc_tsi_security_level_string_to_enum(
- const char* security_level);
-
-/* Map grpc_tls_version to tsi_tls_version. */
-tsi_tls_version grpc_get_tsi_tls_version(grpc_tls_version tls_version);
-
-/* Map grpc_security_level enum to a string. */
-const char* grpc_security_level_to_string(grpc_security_level security_level);
-
-/* Check security level of channel and call credential.*/
-bool grpc_check_security_level(grpc_security_level channel_level,
- grpc_security_level call_cred_level);
-
+/* Map tsi_security_level string to grpc_security_level enum. */
+grpc_security_level grpc_tsi_security_level_string_to_enum(
+ const char* security_level);
+
+/* Map grpc_tls_version to tsi_tls_version. */
+tsi_tls_version grpc_get_tsi_tls_version(grpc_tls_version tls_version);
+
+/* Map grpc_security_level enum to a string. */
+const char* grpc_security_level_to_string(grpc_security_level security_level);
+
+/* Check security level of channel and call credential.*/
+bool grpc_check_security_level(grpc_security_level channel_level,
+ grpc_security_level call_cred_level);
+
/* Return an array of strings containing alpn protocols. */
const char** grpc_fill_alpn_protocol_strings(size_t* num_alpn_protocols);
/* Initialize TSI SSL server/client handshaker factory. */
grpc_security_status grpc_ssl_tsi_client_handshaker_factory_init(
tsi_ssl_pem_key_cert_pair* key_cert_pair, const char* pem_root_certs,
- bool skip_server_certificate_verification, tsi_tls_version min_tls_version,
- tsi_tls_version max_tls_version, tsi_ssl_session_cache* ssl_session_cache,
+ bool skip_server_certificate_verification, tsi_tls_version min_tls_version,
+ tsi_tls_version max_tls_version, tsi_ssl_session_cache* ssl_session_cache,
tsi_ssl_client_handshaker_factory** handshaker_factory);
grpc_security_status grpc_ssl_tsi_server_handshaker_factory_init(
tsi_ssl_pem_key_cert_pair* key_cert_pairs, size_t num_key_cert_pairs,
const char* pem_root_certs,
grpc_ssl_client_certificate_request_type client_certificate_request,
- tsi_tls_version min_tls_version, tsi_tls_version max_tls_version,
+ tsi_tls_version min_tls_version, tsi_tls_version max_tls_version,
tsi_ssl_server_handshaker_factory** handshaker_factory);
/* Exposed for testing only. */
@@ -107,7 +107,7 @@ tsi_peer grpc_shallow_peer_from_ssl_auth_context(
const grpc_auth_context* auth_context);
void grpc_shallow_peer_destruct(tsi_peer* peer);
int grpc_ssl_host_matches_name(const tsi_peer* peer,
- y_absl::string_view peer_name);
+ y_absl::string_view peer_name);
/* --- Default SSL Root Store. --- */
namespace grpc_core {
@@ -174,11 +174,11 @@ class PemKeyCertPair {
return *this;
}
- bool operator==(const PemKeyCertPair& other) const {
- return std::strcmp(this->private_key(), other.private_key()) == 0 &&
- std::strcmp(this->cert_chain(), other.cert_chain()) == 0;
- }
-
+ bool operator==(const PemKeyCertPair& other) const {
+ return std::strcmp(this->private_key(), other.private_key()) == 0 &&
+ std::strcmp(this->cert_chain(), other.cert_chain()) == 0;
+ }
+
char* private_key() const { return private_key_.get(); }
char* cert_chain() const { return cert_chain_.get(); }
diff --git a/contrib/libs/grpc/src/core/lib/security/security_connector/tls/tls_security_connector.cc b/contrib/libs/grpc/src/core/lib/security/security_connector/tls/tls_security_connector.cc
index e81c5d5fc0..4abcb75a08 100644
--- a/contrib/libs/grpc/src/core/lib/security/security_connector/tls/tls_security_connector.cc
+++ b/contrib/libs/grpc/src/core/lib/security/security_connector/tls/tls_security_connector.cc
@@ -1,606 +1,606 @@
-/*
- *
- * Copyright 2018 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <grpc/support/port_platform.h>
-
-#include "src/core/lib/security/security_connector/tls/tls_security_connector.h"
-
-#include <stdbool.h>
-#include <string.h>
-
-#include "y_absl/strings/str_cat.h"
-#include "y_absl/strings/string_view.h"
-
-#include <grpc/grpc.h>
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/string_util.h>
-
-#include "src/core/lib/gprpp/host_port.h"
-#include "src/core/lib/security/credentials/ssl/ssl_credentials.h"
-#include "src/core/lib/security/credentials/tls/tls_credentials.h"
-#include "src/core/lib/security/security_connector/ssl_utils.h"
-#include "src/core/lib/security/transport/security_handshaker.h"
-#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/transport/transport.h"
-#include "src/core/tsi/ssl_transport_security.h"
-#include "src/core/tsi/transport_security.h"
-
-namespace grpc_core {
-
-namespace {
-
-tsi_ssl_pem_key_cert_pair* ConvertToTsiPemKeyCertPair(
- const grpc_tls_key_materials_config::PemKeyCertPairList& cert_pair_list) {
- tsi_ssl_pem_key_cert_pair* tsi_pairs = nullptr;
- size_t num_key_cert_pairs = cert_pair_list.size();
- if (num_key_cert_pairs > 0) {
- GPR_ASSERT(cert_pair_list.data() != nullptr);
- tsi_pairs = static_cast<tsi_ssl_pem_key_cert_pair*>(
- gpr_zalloc(num_key_cert_pairs * sizeof(tsi_ssl_pem_key_cert_pair)));
- }
- for (size_t i = 0; i < num_key_cert_pairs; i++) {
- GPR_ASSERT(cert_pair_list[i].private_key() != nullptr);
- GPR_ASSERT(cert_pair_list[i].cert_chain() != nullptr);
- tsi_pairs[i].cert_chain = gpr_strdup(cert_pair_list[i].cert_chain());
- tsi_pairs[i].private_key = gpr_strdup(cert_pair_list[i].private_key());
- }
- return tsi_pairs;
-}
-
-} // namespace
-
-grpc_status_code TlsFetchKeyMaterials(
- const grpc_core::RefCountedPtr<grpc_tls_key_materials_config>&
- key_materials_config,
- const grpc_tls_credentials_options& options, bool is_server,
- grpc_ssl_certificate_config_reload_status* status) {
- GPR_ASSERT(key_materials_config != nullptr);
- GPR_ASSERT(status != nullptr);
- bool is_key_materials_empty =
- key_materials_config->pem_key_cert_pair_list().empty();
- grpc_tls_credential_reload_config* credential_reload_config =
- options.credential_reload_config();
- /** If there are no key materials and no credential reload config and the
- * caller is a server, then return an error. We do not require that a client
- * always provision certificates. **/
- if (credential_reload_config == nullptr && is_key_materials_empty &&
- is_server) {
- gpr_log(GPR_ERROR,
- "Either credential reload config or key materials should be "
- "provisioned.");
- return GRPC_STATUS_FAILED_PRECONDITION;
- }
- grpc_status_code reload_status = GRPC_STATUS_OK;
- /** Use |credential_reload_config| to update |key_materials_config|. **/
- if (credential_reload_config != nullptr) {
- grpc_tls_credential_reload_arg* arg = new grpc_tls_credential_reload_arg();
- arg->key_materials_config = key_materials_config.get();
- arg->error_details = new grpc_tls_error_details();
- int result = credential_reload_config->Schedule(arg);
- if (result) {
- /** Credential reloading is performed async. This is not yet supported.
- * **/
- gpr_log(GPR_ERROR, "Async credential reload is unsupported now.");
- *status = GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED;
- reload_status =
- is_key_materials_empty ? GRPC_STATUS_UNIMPLEMENTED : GRPC_STATUS_OK;
- } else {
- /** Credential reloading is performed sync. **/
- *status = arg->status;
- if (arg->status == GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED) {
- /* Key materials is not empty. */
- gpr_log(GPR_DEBUG, "Credential does not change after reload.");
- } else if (arg->status == GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_FAIL) {
- gpr_log(GPR_ERROR, "Credential reload failed with an error:");
- if (arg->error_details != nullptr) {
- gpr_log(GPR_ERROR, "%s", arg->error_details->error_details().c_str());
- }
- reload_status =
- is_key_materials_empty ? GRPC_STATUS_INTERNAL : GRPC_STATUS_OK;
- }
- }
- delete arg->error_details;
- /** If the credential reload config was constructed via a wrapped language,
- * then |arg->context| and |arg->destroy_context| will not be nullptr. In
- * this case, we must destroy |arg->context|, which stores the wrapped
- * language-version of the credential reload arg. **/
- if (arg->destroy_context != nullptr) {
- arg->destroy_context(arg->context);
- }
- delete arg;
- }
- return reload_status;
-}
-
-grpc_error* TlsCheckHostName(const char* peer_name, const tsi_peer* peer) {
- /* Check the peer name if specified. */
- if (peer_name != nullptr && !grpc_ssl_host_matches_name(peer, peer_name)) {
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
- y_absl::StrCat("Peer name ", peer_name, " is not in peer certificate")
- .c_str());
- }
- return GRPC_ERROR_NONE;
-}
-
-TlsChannelSecurityConnector::TlsChannelSecurityConnector(
- grpc_core::RefCountedPtr<grpc_channel_credentials> channel_creds,
- grpc_core::RefCountedPtr<grpc_call_credentials> request_metadata_creds,
- const char* target_name, const char* overridden_target_name)
- : grpc_channel_security_connector(GRPC_SSL_URL_SCHEME,
- std::move(channel_creds),
- std::move(request_metadata_creds)),
- overridden_target_name_(
- overridden_target_name == nullptr ? "" : overridden_target_name) {
- key_materials_config_ = grpc_tls_key_materials_config_create()->Ref();
- check_arg_ = ServerAuthorizationCheckArgCreate(this);
- y_absl::string_view host;
- y_absl::string_view port;
- grpc_core::SplitHostPort(target_name, &host, &port);
- target_name_ = TString(host);
-}
-
-TlsChannelSecurityConnector::~TlsChannelSecurityConnector() {
- if (client_handshaker_factory_ != nullptr) {
- tsi_ssl_client_handshaker_factory_unref(client_handshaker_factory_);
- }
- if (key_materials_config_.get() != nullptr) {
- key_materials_config_.get()->Unref();
- }
- ServerAuthorizationCheckArgDestroy(check_arg_);
-}
-
-void TlsChannelSecurityConnector::add_handshakers(
- const grpc_channel_args* args, grpc_pollset_set* /*interested_parties*/,
- grpc_core::HandshakeManager* handshake_mgr) {
- if (RefreshHandshakerFactory() != GRPC_SECURITY_OK) {
- gpr_log(GPR_ERROR, "Handshaker factory refresh failed.");
- return;
- }
- // Instantiate TSI handshaker.
- tsi_handshaker* tsi_hs = nullptr;
- tsi_result result = tsi_ssl_client_handshaker_factory_create_handshaker(
- client_handshaker_factory_,
- overridden_target_name_.empty() ? target_name_.c_str()
- : overridden_target_name_.c_str(),
- &tsi_hs);
- if (result != TSI_OK) {
- gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.",
- tsi_result_to_string(result));
- return;
- }
- // Create handshakers.
- handshake_mgr->Add(grpc_core::SecurityHandshakerCreate(tsi_hs, this, args));
-}
-
-void TlsChannelSecurityConnector::check_peer(
- tsi_peer peer, grpc_endpoint* /*ep*/,
- grpc_core::RefCountedPtr<grpc_auth_context>* auth_context,
- grpc_closure* on_peer_checked) {
- const char* target_name = overridden_target_name_.empty()
- ? target_name_.c_str()
- : overridden_target_name_.c_str();
- grpc_error* error = grpc_ssl_check_alpn(&peer);
- if (error != GRPC_ERROR_NONE) {
- grpc_core::ExecCtx::Run(DEBUG_LOCATION, on_peer_checked, error);
- tsi_peer_destruct(&peer);
- return;
- }
- *auth_context =
- grpc_ssl_peer_to_auth_context(&peer, GRPC_TLS_TRANSPORT_SECURITY_TYPE);
- const TlsCredentials* creds =
- static_cast<const TlsCredentials*>(channel_creds());
- if (creds->options().server_verification_option() ==
- GRPC_TLS_SERVER_VERIFICATION) {
- /* Do the default host name check if specifying the target name. */
- error = TlsCheckHostName(target_name, &peer);
- if (error != GRPC_ERROR_NONE) {
- grpc_core::ExecCtx::Run(DEBUG_LOCATION, on_peer_checked, error);
- tsi_peer_destruct(&peer);
- return;
- }
- }
- /* Do the custom server authorization check, if specified by the user. */
- const grpc_tls_server_authorization_check_config* config =
- creds->options().server_authorization_check_config();
- /* If server authorization config is not null, use it to perform
- * server authorization check. */
- if (config != nullptr) {
- const tsi_peer_property* p =
- tsi_peer_get_property_by_name(&peer, TSI_X509_PEM_CERT_PROPERTY);
- if (p == nullptr) {
- error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "Cannot check peer: missing pem cert property.");
- } else {
- char* peer_pem = static_cast<char*>(gpr_zalloc(p->value.length + 1));
- memcpy(peer_pem, p->value.data, p->value.length);
- GPR_ASSERT(check_arg_ != nullptr);
- check_arg_->peer_cert = check_arg_->peer_cert == nullptr
- ? gpr_strdup(peer_pem)
- : check_arg_->peer_cert;
- check_arg_->target_name = check_arg_->target_name == nullptr
- ? gpr_strdup(target_name)
- : check_arg_->target_name;
- on_peer_checked_ = on_peer_checked;
- gpr_free(peer_pem);
- const tsi_peer_property* chain = tsi_peer_get_property_by_name(
- &peer, TSI_X509_PEM_CERT_CHAIN_PROPERTY);
- if (chain != nullptr) {
- char* peer_pem_chain =
- static_cast<char*>(gpr_zalloc(chain->value.length + 1));
- memcpy(peer_pem_chain, chain->value.data, chain->value.length);
- check_arg_->peer_cert_full_chain =
- check_arg_->peer_cert_full_chain == nullptr
- ? gpr_strdup(peer_pem_chain)
- : check_arg_->peer_cert_full_chain;
- gpr_free(peer_pem_chain);
- }
- int callback_status = config->Schedule(check_arg_);
- /* Server authorization check is handled asynchronously. */
- if (callback_status) {
- tsi_peer_destruct(&peer);
- return;
- }
- /* Server authorization check is handled synchronously. */
- error = ProcessServerAuthorizationCheckResult(check_arg_);
- }
- }
- grpc_core::ExecCtx::Run(DEBUG_LOCATION, on_peer_checked, error);
- tsi_peer_destruct(&peer);
-}
-
-int TlsChannelSecurityConnector::cmp(
- const grpc_security_connector* other_sc) const {
- auto* other = reinterpret_cast<const TlsChannelSecurityConnector*>(other_sc);
- int c = channel_security_connector_cmp(other);
- if (c != 0) {
- return c;
- }
- return grpc_ssl_cmp_target_name(
- target_name_.c_str(), other->target_name_.c_str(),
- overridden_target_name_.c_str(), other->overridden_target_name_.c_str());
-}
-
-bool TlsChannelSecurityConnector::check_call_host(
- y_absl::string_view host, grpc_auth_context* auth_context,
- grpc_closure* /*on_call_host_checked*/, grpc_error** error) {
- return grpc_ssl_check_call_host(host, target_name_.c_str(),
- overridden_target_name_.c_str(), auth_context,
- error);
-}
-
-void TlsChannelSecurityConnector::cancel_check_call_host(
- grpc_closure* /*on_call_host_checked*/, grpc_error* error) {
- GRPC_ERROR_UNREF(error);
-}
-
-grpc_core::RefCountedPtr<grpc_channel_security_connector>
-TlsChannelSecurityConnector::CreateTlsChannelSecurityConnector(
- grpc_core::RefCountedPtr<grpc_channel_credentials> channel_creds,
- grpc_core::RefCountedPtr<grpc_call_credentials> request_metadata_creds,
- const char* target_name, const char* overridden_target_name,
- tsi_ssl_session_cache* ssl_session_cache) {
- if (channel_creds == nullptr) {
- gpr_log(GPR_ERROR,
- "channel_creds is nullptr in "
- "TlsChannelSecurityConnectorCreate()");
- return nullptr;
- }
- if (target_name == nullptr) {
- gpr_log(GPR_ERROR,
- "target_name is nullptr in "
- "TlsChannelSecurityConnectorCreate()");
- return nullptr;
- }
- grpc_core::RefCountedPtr<TlsChannelSecurityConnector> c =
- grpc_core::MakeRefCounted<TlsChannelSecurityConnector>(
- std::move(channel_creds), std::move(request_metadata_creds),
- target_name, overridden_target_name);
- if (c->InitializeHandshakerFactory(ssl_session_cache) != GRPC_SECURITY_OK) {
- gpr_log(GPR_ERROR, "Could not initialize client handshaker factory.");
- return nullptr;
- }
- return c;
-}
-
-grpc_security_status TlsChannelSecurityConnector::ReplaceHandshakerFactory(
- tsi_ssl_session_cache* ssl_session_cache) {
- const TlsCredentials* creds =
- static_cast<const TlsCredentials*>(channel_creds());
- bool skip_server_certificate_verification =
- creds->options().server_verification_option() ==
- GRPC_TLS_SKIP_ALL_SERVER_VERIFICATION;
- /* Free the client handshaker factory if exists. */
- if (client_handshaker_factory_) {
- tsi_ssl_client_handshaker_factory_unref(client_handshaker_factory_);
- }
- tsi_ssl_pem_key_cert_pair* pem_key_cert_pair = ConvertToTsiPemKeyCertPair(
- key_materials_config_->pem_key_cert_pair_list());
- grpc_security_status status = grpc_ssl_tsi_client_handshaker_factory_init(
- pem_key_cert_pair, key_materials_config_->pem_root_certs(),
- skip_server_certificate_verification,
- grpc_get_tsi_tls_version(creds->options().min_tls_version()),
- grpc_get_tsi_tls_version(creds->options().max_tls_version()),
- ssl_session_cache, &client_handshaker_factory_);
- /* Free memory. */
- grpc_tsi_ssl_pem_key_cert_pairs_destroy(pem_key_cert_pair, 1);
- return status;
-}
-
-grpc_security_status TlsChannelSecurityConnector::InitializeHandshakerFactory(
- tsi_ssl_session_cache* ssl_session_cache) {
- grpc_core::MutexLock lock(&mu_);
- const TlsCredentials* creds =
- static_cast<const TlsCredentials*>(channel_creds());
- grpc_tls_key_materials_config* key_materials_config =
- creds->options().key_materials_config();
- // key_materials_config_->set_key_materials will handle the copying of the key
- // materials users provided
- if (key_materials_config != nullptr) {
- key_materials_config_->set_key_materials(
- key_materials_config->pem_root_certs(),
- key_materials_config->pem_key_cert_pair_list());
- }
- grpc_ssl_certificate_config_reload_status reload_status =
- GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED;
- /** If |creds->options()| has a credential reload config, then the call to
- * |TlsFetchKeyMaterials| will use it to update the root cert and
- * pem-key-cert-pair list stored in |key_materials_config_|. **/
- if (TlsFetchKeyMaterials(key_materials_config_, creds->options(), false,
- &reload_status) != GRPC_STATUS_OK) {
- /* Raise an error if key materials are not populated. */
- return GRPC_SECURITY_ERROR;
- }
- return ReplaceHandshakerFactory(ssl_session_cache);
-}
-
-grpc_security_status TlsChannelSecurityConnector::RefreshHandshakerFactory() {
- grpc_core::MutexLock lock(&mu_);
- const TlsCredentials* creds =
- static_cast<const TlsCredentials*>(channel_creds());
- grpc_ssl_certificate_config_reload_status reload_status =
- GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED;
- /** If |creds->options()| has a credential reload config, then the call to
- * |TlsFetchKeyMaterials| will use it to update the root cert and
- * pem-key-cert-pair list stored in |key_materials_config_|. **/
- if (TlsFetchKeyMaterials(key_materials_config_, creds->options(), false,
- &reload_status) != GRPC_STATUS_OK) {
- return GRPC_SECURITY_ERROR;
- }
- if (reload_status != GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_NEW) {
- // Re-use existing handshaker factory.
- return GRPC_SECURITY_OK;
- } else {
- return ReplaceHandshakerFactory(nullptr);
- }
-}
-
-void TlsChannelSecurityConnector::ServerAuthorizationCheckDone(
- grpc_tls_server_authorization_check_arg* arg) {
- GPR_ASSERT(arg != nullptr);
- grpc_core::ExecCtx exec_ctx;
- grpc_error* error = ProcessServerAuthorizationCheckResult(arg);
- TlsChannelSecurityConnector* connector =
- static_cast<TlsChannelSecurityConnector*>(arg->cb_user_data);
- grpc_core::ExecCtx::Run(DEBUG_LOCATION, connector->on_peer_checked_, error);
-}
-
-grpc_error* TlsChannelSecurityConnector::ProcessServerAuthorizationCheckResult(
- grpc_tls_server_authorization_check_arg* arg) {
- grpc_error* error = GRPC_ERROR_NONE;
- /* Server authorization check is cancelled by caller. */
- if (arg->status == GRPC_STATUS_CANCELLED) {
- error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
- y_absl::StrCat("Server authorization check is cancelled by the caller "
- "with error: ",
- arg->error_details->error_details())
- .c_str());
- } else if (arg->status == GRPC_STATUS_OK) {
- /* Server authorization check completed successfully but returned check
- * failure. */
- if (!arg->success) {
- error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
- y_absl::StrCat("Server authorization check failed with error: ",
- arg->error_details->error_details())
- .c_str());
- }
- /* Server authorization check did not complete correctly. */
- } else {
- error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
- y_absl::StrCat(
- "Server authorization check did not finish correctly with error: ",
- arg->error_details->error_details())
- .c_str());
- }
- return error;
-}
-
-grpc_tls_server_authorization_check_arg*
-TlsChannelSecurityConnector::ServerAuthorizationCheckArgCreate(
- void* user_data) {
- grpc_tls_server_authorization_check_arg* arg =
- new grpc_tls_server_authorization_check_arg();
- arg->error_details = new grpc_tls_error_details();
- arg->cb = ServerAuthorizationCheckDone;
- arg->cb_user_data = user_data;
- arg->status = GRPC_STATUS_OK;
- return arg;
-}
-
-void TlsChannelSecurityConnector::ServerAuthorizationCheckArgDestroy(
- grpc_tls_server_authorization_check_arg* arg) {
- if (arg == nullptr) {
- return;
- }
- gpr_free((void*)arg->target_name);
- gpr_free((void*)arg->peer_cert);
- if (arg->peer_cert_full_chain) gpr_free((void*)arg->peer_cert_full_chain);
- delete arg->error_details;
- if (arg->destroy_context != nullptr) {
- arg->destroy_context(arg->context);
- }
- delete arg;
-}
-
-TlsServerSecurityConnector::TlsServerSecurityConnector(
- grpc_core::RefCountedPtr<grpc_server_credentials> server_creds)
- : grpc_server_security_connector(GRPC_SSL_URL_SCHEME,
- std::move(server_creds)) {
- key_materials_config_ = grpc_tls_key_materials_config_create()->Ref();
-}
-
-TlsServerSecurityConnector::~TlsServerSecurityConnector() {
- if (server_handshaker_factory_ != nullptr) {
- tsi_ssl_server_handshaker_factory_unref(server_handshaker_factory_);
- }
- if (key_materials_config_.get() != nullptr) {
- key_materials_config_.get()->Unref();
- }
-}
-
-void TlsServerSecurityConnector::add_handshakers(
- const grpc_channel_args* args, grpc_pollset_set* /*interested_parties*/,
- grpc_core::HandshakeManager* handshake_mgr) {
- /* Refresh handshaker factory if needed. */
- if (RefreshHandshakerFactory() != GRPC_SECURITY_OK) {
- gpr_log(GPR_ERROR, "Handshaker factory refresh failed.");
- return;
- }
- /* Create a TLS TSI handshaker for server. */
- tsi_handshaker* tsi_hs = nullptr;
- tsi_result result = tsi_ssl_server_handshaker_factory_create_handshaker(
- server_handshaker_factory_, &tsi_hs);
- if (result != TSI_OK) {
- gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.",
- tsi_result_to_string(result));
- return;
- }
- handshake_mgr->Add(grpc_core::SecurityHandshakerCreate(tsi_hs, this, args));
-}
-
-void TlsServerSecurityConnector::check_peer(
- tsi_peer peer, grpc_endpoint* /*ep*/,
- grpc_core::RefCountedPtr<grpc_auth_context>* auth_context,
- grpc_closure* on_peer_checked) {
- grpc_error* error = grpc_ssl_check_alpn(&peer);
- *auth_context =
- grpc_ssl_peer_to_auth_context(&peer, GRPC_TLS_TRANSPORT_SECURITY_TYPE);
- tsi_peer_destruct(&peer);
- grpc_core::ExecCtx::Run(DEBUG_LOCATION, on_peer_checked, error);
-}
-
-int TlsServerSecurityConnector::cmp(
- const grpc_security_connector* other) const {
- return server_security_connector_cmp(
- static_cast<const grpc_server_security_connector*>(other));
-}
-
-grpc_core::RefCountedPtr<grpc_server_security_connector>
-TlsServerSecurityConnector::CreateTlsServerSecurityConnector(
- grpc_core::RefCountedPtr<grpc_server_credentials> server_creds) {
- if (server_creds == nullptr) {
- gpr_log(GPR_ERROR,
- "server_creds is nullptr in "
- "TlsServerSecurityConnectorCreate()");
- return nullptr;
- }
- grpc_core::RefCountedPtr<TlsServerSecurityConnector> c =
- grpc_core::MakeRefCounted<TlsServerSecurityConnector>(
- std::move(server_creds));
- if (c->InitializeHandshakerFactory() != GRPC_SECURITY_OK) {
- gpr_log(GPR_ERROR, "Could not initialize server handshaker factory.");
- return nullptr;
- }
- return c;
-}
-
-grpc_security_status TlsServerSecurityConnector::ReplaceHandshakerFactory() {
- const TlsServerCredentials* creds =
- static_cast<const TlsServerCredentials*>(server_creds());
- /* Free the server handshaker factory if exists. */
- if (server_handshaker_factory_) {
- tsi_ssl_server_handshaker_factory_unref(server_handshaker_factory_);
- }
- GPR_ASSERT(!key_materials_config_->pem_key_cert_pair_list().empty());
- tsi_ssl_pem_key_cert_pair* pem_key_cert_pairs = ConvertToTsiPemKeyCertPair(
- key_materials_config_->pem_key_cert_pair_list());
- size_t num_key_cert_pairs =
- key_materials_config_->pem_key_cert_pair_list().size();
- grpc_security_status status = grpc_ssl_tsi_server_handshaker_factory_init(
- pem_key_cert_pairs, num_key_cert_pairs,
- key_materials_config_->pem_root_certs(),
- creds->options().cert_request_type(),
- grpc_get_tsi_tls_version(creds->options().min_tls_version()),
- grpc_get_tsi_tls_version(creds->options().max_tls_version()),
- &server_handshaker_factory_);
- /* Free memory. */
- grpc_tsi_ssl_pem_key_cert_pairs_destroy(pem_key_cert_pairs,
- num_key_cert_pairs);
- return status;
-}
-
-grpc_security_status TlsServerSecurityConnector::InitializeHandshakerFactory() {
- grpc_core::MutexLock lock(&mu_);
- const TlsServerCredentials* creds =
- static_cast<const TlsServerCredentials*>(server_creds());
- grpc_tls_key_materials_config* key_materials_config =
- creds->options().key_materials_config();
- if (key_materials_config != nullptr) {
- key_materials_config_->set_key_materials(
- key_materials_config->pem_root_certs(),
- key_materials_config->pem_key_cert_pair_list());
- }
- grpc_ssl_certificate_config_reload_status reload_status =
- GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED;
- /** If |creds->options()| has a credential reload config, then the call to
- * |TlsFetchKeyMaterials| will use it to update the root cert and
- * pem-key-cert-pair list stored in |key_materials_config_|. Otherwise, it
- * will return |GRPC_STATUS_OK| if |key_materials_config_| already has
- * credentials, and an error code if not. **/
- if (TlsFetchKeyMaterials(key_materials_config_, creds->options(), true,
- &reload_status) != GRPC_STATUS_OK) {
- /* Raise an error if key materials are not populated. */
- return GRPC_SECURITY_ERROR;
- }
- return ReplaceHandshakerFactory();
-}
-
-grpc_security_status TlsServerSecurityConnector::RefreshHandshakerFactory() {
- grpc_core::MutexLock lock(&mu_);
- const TlsServerCredentials* creds =
- static_cast<const TlsServerCredentials*>(server_creds());
- grpc_ssl_certificate_config_reload_status reload_status =
- GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED;
- /** If |creds->options()| has a credential reload config, then the call to
- * |TlsFetchKeyMaterials| will use it to update the root cert and
- * pem-key-cert-pair list stored in |key_materials_config_|. Otherwise, it
- * will return |GRPC_STATUS_OK| if |key_materials_config_| already has
- * credentials, and an error code if not. **/
- if (TlsFetchKeyMaterials(key_materials_config_, creds->options(), true,
- &reload_status) != GRPC_STATUS_OK) {
- return GRPC_SECURITY_ERROR;
- }
- if (reload_status != GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_NEW) {
- /* At this point, we should have key materials populated. */
- return GRPC_SECURITY_OK;
- } else {
- return ReplaceHandshakerFactory();
- }
-}
-
-} // namespace grpc_core
+/*
+ *
+ * Copyright 2018 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <grpc/support/port_platform.h>
+
+#include "src/core/lib/security/security_connector/tls/tls_security_connector.h"
+
+#include <stdbool.h>
+#include <string.h>
+
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/string_view.h"
+
+#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+
+#include "src/core/lib/gprpp/host_port.h"
+#include "src/core/lib/security/credentials/ssl/ssl_credentials.h"
+#include "src/core/lib/security/credentials/tls/tls_credentials.h"
+#include "src/core/lib/security/security_connector/ssl_utils.h"
+#include "src/core/lib/security/transport/security_handshaker.h"
+#include "src/core/lib/slice/slice_internal.h"
+#include "src/core/lib/transport/transport.h"
+#include "src/core/tsi/ssl_transport_security.h"
+#include "src/core/tsi/transport_security.h"
+
+namespace grpc_core {
+
+namespace {
+
+tsi_ssl_pem_key_cert_pair* ConvertToTsiPemKeyCertPair(
+ const grpc_tls_key_materials_config::PemKeyCertPairList& cert_pair_list) {
+ tsi_ssl_pem_key_cert_pair* tsi_pairs = nullptr;
+ size_t num_key_cert_pairs = cert_pair_list.size();
+ if (num_key_cert_pairs > 0) {
+ GPR_ASSERT(cert_pair_list.data() != nullptr);
+ tsi_pairs = static_cast<tsi_ssl_pem_key_cert_pair*>(
+ gpr_zalloc(num_key_cert_pairs * sizeof(tsi_ssl_pem_key_cert_pair)));
+ }
+ for (size_t i = 0; i < num_key_cert_pairs; i++) {
+ GPR_ASSERT(cert_pair_list[i].private_key() != nullptr);
+ GPR_ASSERT(cert_pair_list[i].cert_chain() != nullptr);
+ tsi_pairs[i].cert_chain = gpr_strdup(cert_pair_list[i].cert_chain());
+ tsi_pairs[i].private_key = gpr_strdup(cert_pair_list[i].private_key());
+ }
+ return tsi_pairs;
+}
+
+} // namespace
+
+grpc_status_code TlsFetchKeyMaterials(
+ const grpc_core::RefCountedPtr<grpc_tls_key_materials_config>&
+ key_materials_config,
+ const grpc_tls_credentials_options& options, bool is_server,
+ grpc_ssl_certificate_config_reload_status* status) {
+ GPR_ASSERT(key_materials_config != nullptr);
+ GPR_ASSERT(status != nullptr);
+ bool is_key_materials_empty =
+ key_materials_config->pem_key_cert_pair_list().empty();
+ grpc_tls_credential_reload_config* credential_reload_config =
+ options.credential_reload_config();
+ /** If there are no key materials and no credential reload config and the
+ * caller is a server, then return an error. We do not require that a client
+ * always provision certificates. **/
+ if (credential_reload_config == nullptr && is_key_materials_empty &&
+ is_server) {
+ gpr_log(GPR_ERROR,
+ "Either credential reload config or key materials should be "
+ "provisioned.");
+ return GRPC_STATUS_FAILED_PRECONDITION;
+ }
+ grpc_status_code reload_status = GRPC_STATUS_OK;
+ /** Use |credential_reload_config| to update |key_materials_config|. **/
+ if (credential_reload_config != nullptr) {
+ grpc_tls_credential_reload_arg* arg = new grpc_tls_credential_reload_arg();
+ arg->key_materials_config = key_materials_config.get();
+ arg->error_details = new grpc_tls_error_details();
+ int result = credential_reload_config->Schedule(arg);
+ if (result) {
+ /** Credential reloading is performed async. This is not yet supported.
+ * **/
+ gpr_log(GPR_ERROR, "Async credential reload is unsupported now.");
+ *status = GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED;
+ reload_status =
+ is_key_materials_empty ? GRPC_STATUS_UNIMPLEMENTED : GRPC_STATUS_OK;
+ } else {
+ /** Credential reloading is performed sync. **/
+ *status = arg->status;
+ if (arg->status == GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED) {
+ /* Key materials is not empty. */
+ gpr_log(GPR_DEBUG, "Credential does not change after reload.");
+ } else if (arg->status == GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_FAIL) {
+ gpr_log(GPR_ERROR, "Credential reload failed with an error:");
+ if (arg->error_details != nullptr) {
+ gpr_log(GPR_ERROR, "%s", arg->error_details->error_details().c_str());
+ }
+ reload_status =
+ is_key_materials_empty ? GRPC_STATUS_INTERNAL : GRPC_STATUS_OK;
+ }
+ }
+ delete arg->error_details;
+ /** If the credential reload config was constructed via a wrapped language,
+ * then |arg->context| and |arg->destroy_context| will not be nullptr. In
+ * this case, we must destroy |arg->context|, which stores the wrapped
+ * language-version of the credential reload arg. **/
+ if (arg->destroy_context != nullptr) {
+ arg->destroy_context(arg->context);
+ }
+ delete arg;
+ }
+ return reload_status;
+}
+
+grpc_error* TlsCheckHostName(const char* peer_name, const tsi_peer* peer) {
+ /* Check the peer name if specified. */
+ if (peer_name != nullptr && !grpc_ssl_host_matches_name(peer, peer_name)) {
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
+ y_absl::StrCat("Peer name ", peer_name, " is not in peer certificate")
+ .c_str());
+ }
+ return GRPC_ERROR_NONE;
+}
+
+TlsChannelSecurityConnector::TlsChannelSecurityConnector(
+ grpc_core::RefCountedPtr<grpc_channel_credentials> channel_creds,
+ grpc_core::RefCountedPtr<grpc_call_credentials> request_metadata_creds,
+ const char* target_name, const char* overridden_target_name)
+ : grpc_channel_security_connector(GRPC_SSL_URL_SCHEME,
+ std::move(channel_creds),
+ std::move(request_metadata_creds)),
+ overridden_target_name_(
+ overridden_target_name == nullptr ? "" : overridden_target_name) {
+ key_materials_config_ = grpc_tls_key_materials_config_create()->Ref();
+ check_arg_ = ServerAuthorizationCheckArgCreate(this);
+ y_absl::string_view host;
+ y_absl::string_view port;
+ grpc_core::SplitHostPort(target_name, &host, &port);
+ target_name_ = TString(host);
+}
+
+TlsChannelSecurityConnector::~TlsChannelSecurityConnector() {
+ if (client_handshaker_factory_ != nullptr) {
+ tsi_ssl_client_handshaker_factory_unref(client_handshaker_factory_);
+ }
+ if (key_materials_config_.get() != nullptr) {
+ key_materials_config_.get()->Unref();
+ }
+ ServerAuthorizationCheckArgDestroy(check_arg_);
+}
+
+void TlsChannelSecurityConnector::add_handshakers(
+ const grpc_channel_args* args, grpc_pollset_set* /*interested_parties*/,
+ grpc_core::HandshakeManager* handshake_mgr) {
+ if (RefreshHandshakerFactory() != GRPC_SECURITY_OK) {
+ gpr_log(GPR_ERROR, "Handshaker factory refresh failed.");
+ return;
+ }
+ // Instantiate TSI handshaker.
+ tsi_handshaker* tsi_hs = nullptr;
+ tsi_result result = tsi_ssl_client_handshaker_factory_create_handshaker(
+ client_handshaker_factory_,
+ overridden_target_name_.empty() ? target_name_.c_str()
+ : overridden_target_name_.c_str(),
+ &tsi_hs);
+ if (result != TSI_OK) {
+ gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.",
+ tsi_result_to_string(result));
+ return;
+ }
+ // Create handshakers.
+ handshake_mgr->Add(grpc_core::SecurityHandshakerCreate(tsi_hs, this, args));
+}
+
+void TlsChannelSecurityConnector::check_peer(
+ tsi_peer peer, grpc_endpoint* /*ep*/,
+ grpc_core::RefCountedPtr<grpc_auth_context>* auth_context,
+ grpc_closure* on_peer_checked) {
+ const char* target_name = overridden_target_name_.empty()
+ ? target_name_.c_str()
+ : overridden_target_name_.c_str();
+ grpc_error* error = grpc_ssl_check_alpn(&peer);
+ if (error != GRPC_ERROR_NONE) {
+ grpc_core::ExecCtx::Run(DEBUG_LOCATION, on_peer_checked, error);
+ tsi_peer_destruct(&peer);
+ return;
+ }
+ *auth_context =
+ grpc_ssl_peer_to_auth_context(&peer, GRPC_TLS_TRANSPORT_SECURITY_TYPE);
+ const TlsCredentials* creds =
+ static_cast<const TlsCredentials*>(channel_creds());
+ if (creds->options().server_verification_option() ==
+ GRPC_TLS_SERVER_VERIFICATION) {
+ /* Do the default host name check if specifying the target name. */
+ error = TlsCheckHostName(target_name, &peer);
+ if (error != GRPC_ERROR_NONE) {
+ grpc_core::ExecCtx::Run(DEBUG_LOCATION, on_peer_checked, error);
+ tsi_peer_destruct(&peer);
+ return;
+ }
+ }
+ /* Do the custom server authorization check, if specified by the user. */
+ const grpc_tls_server_authorization_check_config* config =
+ creds->options().server_authorization_check_config();
+ /* If server authorization config is not null, use it to perform
+ * server authorization check. */
+ if (config != nullptr) {
+ const tsi_peer_property* p =
+ tsi_peer_get_property_by_name(&peer, TSI_X509_PEM_CERT_PROPERTY);
+ if (p == nullptr) {
+ error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Cannot check peer: missing pem cert property.");
+ } else {
+ char* peer_pem = static_cast<char*>(gpr_zalloc(p->value.length + 1));
+ memcpy(peer_pem, p->value.data, p->value.length);
+ GPR_ASSERT(check_arg_ != nullptr);
+ check_arg_->peer_cert = check_arg_->peer_cert == nullptr
+ ? gpr_strdup(peer_pem)
+ : check_arg_->peer_cert;
+ check_arg_->target_name = check_arg_->target_name == nullptr
+ ? gpr_strdup(target_name)
+ : check_arg_->target_name;
+ on_peer_checked_ = on_peer_checked;
+ gpr_free(peer_pem);
+ const tsi_peer_property* chain = tsi_peer_get_property_by_name(
+ &peer, TSI_X509_PEM_CERT_CHAIN_PROPERTY);
+ if (chain != nullptr) {
+ char* peer_pem_chain =
+ static_cast<char*>(gpr_zalloc(chain->value.length + 1));
+ memcpy(peer_pem_chain, chain->value.data, chain->value.length);
+ check_arg_->peer_cert_full_chain =
+ check_arg_->peer_cert_full_chain == nullptr
+ ? gpr_strdup(peer_pem_chain)
+ : check_arg_->peer_cert_full_chain;
+ gpr_free(peer_pem_chain);
+ }
+ int callback_status = config->Schedule(check_arg_);
+ /* Server authorization check is handled asynchronously. */
+ if (callback_status) {
+ tsi_peer_destruct(&peer);
+ return;
+ }
+ /* Server authorization check is handled synchronously. */
+ error = ProcessServerAuthorizationCheckResult(check_arg_);
+ }
+ }
+ grpc_core::ExecCtx::Run(DEBUG_LOCATION, on_peer_checked, error);
+ tsi_peer_destruct(&peer);
+}
+
+int TlsChannelSecurityConnector::cmp(
+ const grpc_security_connector* other_sc) const {
+ auto* other = reinterpret_cast<const TlsChannelSecurityConnector*>(other_sc);
+ int c = channel_security_connector_cmp(other);
+ if (c != 0) {
+ return c;
+ }
+ return grpc_ssl_cmp_target_name(
+ target_name_.c_str(), other->target_name_.c_str(),
+ overridden_target_name_.c_str(), other->overridden_target_name_.c_str());
+}
+
+bool TlsChannelSecurityConnector::check_call_host(
+ y_absl::string_view host, grpc_auth_context* auth_context,
+ grpc_closure* /*on_call_host_checked*/, grpc_error** error) {
+ return grpc_ssl_check_call_host(host, target_name_.c_str(),
+ overridden_target_name_.c_str(), auth_context,
+ error);
+}
+
+void TlsChannelSecurityConnector::cancel_check_call_host(
+ grpc_closure* /*on_call_host_checked*/, grpc_error* error) {
+ GRPC_ERROR_UNREF(error);
+}
+
+grpc_core::RefCountedPtr<grpc_channel_security_connector>
+TlsChannelSecurityConnector::CreateTlsChannelSecurityConnector(
+ grpc_core::RefCountedPtr<grpc_channel_credentials> channel_creds,
+ grpc_core::RefCountedPtr<grpc_call_credentials> request_metadata_creds,
+ const char* target_name, const char* overridden_target_name,
+ tsi_ssl_session_cache* ssl_session_cache) {
+ if (channel_creds == nullptr) {
+ gpr_log(GPR_ERROR,
+ "channel_creds is nullptr in "
+ "TlsChannelSecurityConnectorCreate()");
+ return nullptr;
+ }
+ if (target_name == nullptr) {
+ gpr_log(GPR_ERROR,
+ "target_name is nullptr in "
+ "TlsChannelSecurityConnectorCreate()");
+ return nullptr;
+ }
+ grpc_core::RefCountedPtr<TlsChannelSecurityConnector> c =
+ grpc_core::MakeRefCounted<TlsChannelSecurityConnector>(
+ std::move(channel_creds), std::move(request_metadata_creds),
+ target_name, overridden_target_name);
+ if (c->InitializeHandshakerFactory(ssl_session_cache) != GRPC_SECURITY_OK) {
+ gpr_log(GPR_ERROR, "Could not initialize client handshaker factory.");
+ return nullptr;
+ }
+ return c;
+}
+
+grpc_security_status TlsChannelSecurityConnector::ReplaceHandshakerFactory(
+ tsi_ssl_session_cache* ssl_session_cache) {
+ const TlsCredentials* creds =
+ static_cast<const TlsCredentials*>(channel_creds());
+ bool skip_server_certificate_verification =
+ creds->options().server_verification_option() ==
+ GRPC_TLS_SKIP_ALL_SERVER_VERIFICATION;
+ /* Free the client handshaker factory if exists. */
+ if (client_handshaker_factory_) {
+ tsi_ssl_client_handshaker_factory_unref(client_handshaker_factory_);
+ }
+ tsi_ssl_pem_key_cert_pair* pem_key_cert_pair = ConvertToTsiPemKeyCertPair(
+ key_materials_config_->pem_key_cert_pair_list());
+ grpc_security_status status = grpc_ssl_tsi_client_handshaker_factory_init(
+ pem_key_cert_pair, key_materials_config_->pem_root_certs(),
+ skip_server_certificate_verification,
+ grpc_get_tsi_tls_version(creds->options().min_tls_version()),
+ grpc_get_tsi_tls_version(creds->options().max_tls_version()),
+ ssl_session_cache, &client_handshaker_factory_);
+ /* Free memory. */
+ grpc_tsi_ssl_pem_key_cert_pairs_destroy(pem_key_cert_pair, 1);
+ return status;
+}
+
+grpc_security_status TlsChannelSecurityConnector::InitializeHandshakerFactory(
+ tsi_ssl_session_cache* ssl_session_cache) {
+ grpc_core::MutexLock lock(&mu_);
+ const TlsCredentials* creds =
+ static_cast<const TlsCredentials*>(channel_creds());
+ grpc_tls_key_materials_config* key_materials_config =
+ creds->options().key_materials_config();
+ // key_materials_config_->set_key_materials will handle the copying of the key
+ // materials users provided
+ if (key_materials_config != nullptr) {
+ key_materials_config_->set_key_materials(
+ key_materials_config->pem_root_certs(),
+ key_materials_config->pem_key_cert_pair_list());
+ }
+ grpc_ssl_certificate_config_reload_status reload_status =
+ GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED;
+ /** If |creds->options()| has a credential reload config, then the call to
+ * |TlsFetchKeyMaterials| will use it to update the root cert and
+ * pem-key-cert-pair list stored in |key_materials_config_|. **/
+ if (TlsFetchKeyMaterials(key_materials_config_, creds->options(), false,
+ &reload_status) != GRPC_STATUS_OK) {
+ /* Raise an error if key materials are not populated. */
+ return GRPC_SECURITY_ERROR;
+ }
+ return ReplaceHandshakerFactory(ssl_session_cache);
+}
+
+grpc_security_status TlsChannelSecurityConnector::RefreshHandshakerFactory() {
+ grpc_core::MutexLock lock(&mu_);
+ const TlsCredentials* creds =
+ static_cast<const TlsCredentials*>(channel_creds());
+ grpc_ssl_certificate_config_reload_status reload_status =
+ GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED;
+ /** If |creds->options()| has a credential reload config, then the call to
+ * |TlsFetchKeyMaterials| will use it to update the root cert and
+ * pem-key-cert-pair list stored in |key_materials_config_|. **/
+ if (TlsFetchKeyMaterials(key_materials_config_, creds->options(), false,
+ &reload_status) != GRPC_STATUS_OK) {
+ return GRPC_SECURITY_ERROR;
+ }
+ if (reload_status != GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_NEW) {
+ // Re-use existing handshaker factory.
+ return GRPC_SECURITY_OK;
+ } else {
+ return ReplaceHandshakerFactory(nullptr);
+ }
+}
+
+void TlsChannelSecurityConnector::ServerAuthorizationCheckDone(
+ grpc_tls_server_authorization_check_arg* arg) {
+ GPR_ASSERT(arg != nullptr);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_error* error = ProcessServerAuthorizationCheckResult(arg);
+ TlsChannelSecurityConnector* connector =
+ static_cast<TlsChannelSecurityConnector*>(arg->cb_user_data);
+ grpc_core::ExecCtx::Run(DEBUG_LOCATION, connector->on_peer_checked_, error);
+}
+
+grpc_error* TlsChannelSecurityConnector::ProcessServerAuthorizationCheckResult(
+ grpc_tls_server_authorization_check_arg* arg) {
+ grpc_error* error = GRPC_ERROR_NONE;
+ /* Server authorization check is cancelled by caller. */
+ if (arg->status == GRPC_STATUS_CANCELLED) {
+ error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
+ y_absl::StrCat("Server authorization check is cancelled by the caller "
+ "with error: ",
+ arg->error_details->error_details())
+ .c_str());
+ } else if (arg->status == GRPC_STATUS_OK) {
+ /* Server authorization check completed successfully but returned check
+ * failure. */
+ if (!arg->success) {
+ error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
+ y_absl::StrCat("Server authorization check failed with error: ",
+ arg->error_details->error_details())
+ .c_str());
+ }
+ /* Server authorization check did not complete correctly. */
+ } else {
+ error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
+ y_absl::StrCat(
+ "Server authorization check did not finish correctly with error: ",
+ arg->error_details->error_details())
+ .c_str());
+ }
+ return error;
+}
+
+grpc_tls_server_authorization_check_arg*
+TlsChannelSecurityConnector::ServerAuthorizationCheckArgCreate(
+ void* user_data) {
+ grpc_tls_server_authorization_check_arg* arg =
+ new grpc_tls_server_authorization_check_arg();
+ arg->error_details = new grpc_tls_error_details();
+ arg->cb = ServerAuthorizationCheckDone;
+ arg->cb_user_data = user_data;
+ arg->status = GRPC_STATUS_OK;
+ return arg;
+}
+
+void TlsChannelSecurityConnector::ServerAuthorizationCheckArgDestroy(
+ grpc_tls_server_authorization_check_arg* arg) {
+ if (arg == nullptr) {
+ return;
+ }
+ gpr_free((void*)arg->target_name);
+ gpr_free((void*)arg->peer_cert);
+ if (arg->peer_cert_full_chain) gpr_free((void*)arg->peer_cert_full_chain);
+ delete arg->error_details;
+ if (arg->destroy_context != nullptr) {
+ arg->destroy_context(arg->context);
+ }
+ delete arg;
+}
+
+TlsServerSecurityConnector::TlsServerSecurityConnector(
+ grpc_core::RefCountedPtr<grpc_server_credentials> server_creds)
+ : grpc_server_security_connector(GRPC_SSL_URL_SCHEME,
+ std::move(server_creds)) {
+ key_materials_config_ = grpc_tls_key_materials_config_create()->Ref();
+}
+
+TlsServerSecurityConnector::~TlsServerSecurityConnector() {
+ if (server_handshaker_factory_ != nullptr) {
+ tsi_ssl_server_handshaker_factory_unref(server_handshaker_factory_);
+ }
+ if (key_materials_config_.get() != nullptr) {
+ key_materials_config_.get()->Unref();
+ }
+}
+
+void TlsServerSecurityConnector::add_handshakers(
+ const grpc_channel_args* args, grpc_pollset_set* /*interested_parties*/,
+ grpc_core::HandshakeManager* handshake_mgr) {
+ /* Refresh handshaker factory if needed. */
+ if (RefreshHandshakerFactory() != GRPC_SECURITY_OK) {
+ gpr_log(GPR_ERROR, "Handshaker factory refresh failed.");
+ return;
+ }
+ /* Create a TLS TSI handshaker for server. */
+ tsi_handshaker* tsi_hs = nullptr;
+ tsi_result result = tsi_ssl_server_handshaker_factory_create_handshaker(
+ server_handshaker_factory_, &tsi_hs);
+ if (result != TSI_OK) {
+ gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.",
+ tsi_result_to_string(result));
+ return;
+ }
+ handshake_mgr->Add(grpc_core::SecurityHandshakerCreate(tsi_hs, this, args));
+}
+
+void TlsServerSecurityConnector::check_peer(
+ tsi_peer peer, grpc_endpoint* /*ep*/,
+ grpc_core::RefCountedPtr<grpc_auth_context>* auth_context,
+ grpc_closure* on_peer_checked) {
+ grpc_error* error = grpc_ssl_check_alpn(&peer);
+ *auth_context =
+ grpc_ssl_peer_to_auth_context(&peer, GRPC_TLS_TRANSPORT_SECURITY_TYPE);
+ tsi_peer_destruct(&peer);
+ grpc_core::ExecCtx::Run(DEBUG_LOCATION, on_peer_checked, error);
+}
+
+int TlsServerSecurityConnector::cmp(
+ const grpc_security_connector* other) const {
+ return server_security_connector_cmp(
+ static_cast<const grpc_server_security_connector*>(other));
+}
+
+grpc_core::RefCountedPtr<grpc_server_security_connector>
+TlsServerSecurityConnector::CreateTlsServerSecurityConnector(
+ grpc_core::RefCountedPtr<grpc_server_credentials> server_creds) {
+ if (server_creds == nullptr) {
+ gpr_log(GPR_ERROR,
+ "server_creds is nullptr in "
+ "TlsServerSecurityConnectorCreate()");
+ return nullptr;
+ }
+ grpc_core::RefCountedPtr<TlsServerSecurityConnector> c =
+ grpc_core::MakeRefCounted<TlsServerSecurityConnector>(
+ std::move(server_creds));
+ if (c->InitializeHandshakerFactory() != GRPC_SECURITY_OK) {
+ gpr_log(GPR_ERROR, "Could not initialize server handshaker factory.");
+ return nullptr;
+ }
+ return c;
+}
+
+grpc_security_status TlsServerSecurityConnector::ReplaceHandshakerFactory() {
+ const TlsServerCredentials* creds =
+ static_cast<const TlsServerCredentials*>(server_creds());
+ /* Free the server handshaker factory if exists. */
+ if (server_handshaker_factory_) {
+ tsi_ssl_server_handshaker_factory_unref(server_handshaker_factory_);
+ }
+ GPR_ASSERT(!key_materials_config_->pem_key_cert_pair_list().empty());
+ tsi_ssl_pem_key_cert_pair* pem_key_cert_pairs = ConvertToTsiPemKeyCertPair(
+ key_materials_config_->pem_key_cert_pair_list());
+ size_t num_key_cert_pairs =
+ key_materials_config_->pem_key_cert_pair_list().size();
+ grpc_security_status status = grpc_ssl_tsi_server_handshaker_factory_init(
+ pem_key_cert_pairs, num_key_cert_pairs,
+ key_materials_config_->pem_root_certs(),
+ creds->options().cert_request_type(),
+ grpc_get_tsi_tls_version(creds->options().min_tls_version()),
+ grpc_get_tsi_tls_version(creds->options().max_tls_version()),
+ &server_handshaker_factory_);
+ /* Free memory. */
+ grpc_tsi_ssl_pem_key_cert_pairs_destroy(pem_key_cert_pairs,
+ num_key_cert_pairs);
+ return status;
+}
+
+grpc_security_status TlsServerSecurityConnector::InitializeHandshakerFactory() {
+ grpc_core::MutexLock lock(&mu_);
+ const TlsServerCredentials* creds =
+ static_cast<const TlsServerCredentials*>(server_creds());
+ grpc_tls_key_materials_config* key_materials_config =
+ creds->options().key_materials_config();
+ if (key_materials_config != nullptr) {
+ key_materials_config_->set_key_materials(
+ key_materials_config->pem_root_certs(),
+ key_materials_config->pem_key_cert_pair_list());
+ }
+ grpc_ssl_certificate_config_reload_status reload_status =
+ GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED;
+ /** If |creds->options()| has a credential reload config, then the call to
+ * |TlsFetchKeyMaterials| will use it to update the root cert and
+ * pem-key-cert-pair list stored in |key_materials_config_|. Otherwise, it
+ * will return |GRPC_STATUS_OK| if |key_materials_config_| already has
+ * credentials, and an error code if not. **/
+ if (TlsFetchKeyMaterials(key_materials_config_, creds->options(), true,
+ &reload_status) != GRPC_STATUS_OK) {
+ /* Raise an error if key materials are not populated. */
+ return GRPC_SECURITY_ERROR;
+ }
+ return ReplaceHandshakerFactory();
+}
+
+grpc_security_status TlsServerSecurityConnector::RefreshHandshakerFactory() {
+ grpc_core::MutexLock lock(&mu_);
+ const TlsServerCredentials* creds =
+ static_cast<const TlsServerCredentials*>(server_creds());
+ grpc_ssl_certificate_config_reload_status reload_status =
+ GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED;
+ /** If |creds->options()| has a credential reload config, then the call to
+ * |TlsFetchKeyMaterials| will use it to update the root cert and
+ * pem-key-cert-pair list stored in |key_materials_config_|. Otherwise, it
+ * will return |GRPC_STATUS_OK| if |key_materials_config_| already has
+ * credentials, and an error code if not. **/
+ if (TlsFetchKeyMaterials(key_materials_config_, creds->options(), true,
+ &reload_status) != GRPC_STATUS_OK) {
+ return GRPC_SECURITY_ERROR;
+ }
+ if (reload_status != GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_NEW) {
+ /* At this point, we should have key materials populated. */
+ return GRPC_SECURITY_OK;
+ } else {
+ return ReplaceHandshakerFactory();
+ }
+}
+
+} // namespace grpc_core
diff --git a/contrib/libs/grpc/src/core/lib/security/security_connector/tls/tls_security_connector.h b/contrib/libs/grpc/src/core/lib/security/security_connector/tls/tls_security_connector.h
index c7b438c84e..f50d916589 100644
--- a/contrib/libs/grpc/src/core/lib/security/security_connector/tls/tls_security_connector.h
+++ b/contrib/libs/grpc/src/core/lib/security/security_connector/tls/tls_security_connector.h
@@ -1,183 +1,183 @@
-/*
- *
- * Copyright 2018 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef GRPC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_TLS_TLS_SECURITY_CONNECTOR_H
-#define GRPC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_TLS_TLS_SECURITY_CONNECTOR_H
-
-#include <grpc/support/port_platform.h>
-
-#include "src/core/lib/gprpp/sync.h"
-#include "src/core/lib/security/context/security_context.h"
-#include "src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h"
-
-#define GRPC_TLS_TRANSPORT_SECURITY_TYPE "tls"
-
-namespace grpc_core {
-
-// TLS channel security connector.
-class TlsChannelSecurityConnector final
- : public grpc_channel_security_connector {
- public:
- // static factory method to create a TLS channel security connector.
- static grpc_core::RefCountedPtr<grpc_channel_security_connector>
- CreateTlsChannelSecurityConnector(
- grpc_core::RefCountedPtr<grpc_channel_credentials> channel_creds,
- grpc_core::RefCountedPtr<grpc_call_credentials> request_metadata_creds,
- const char* target_name, const char* overridden_target_name,
- tsi_ssl_session_cache* ssl_session_cache);
-
- TlsChannelSecurityConnector(
- grpc_core::RefCountedPtr<grpc_channel_credentials> channel_creds,
- grpc_core::RefCountedPtr<grpc_call_credentials> request_metadata_creds,
- const char* target_name, const char* overridden_target_name);
- ~TlsChannelSecurityConnector() override;
-
- void add_handshakers(const grpc_channel_args* args,
- grpc_pollset_set* interested_parties,
- grpc_core::HandshakeManager* handshake_mgr) override;
-
- void check_peer(tsi_peer peer, grpc_endpoint* ep,
- grpc_core::RefCountedPtr<grpc_auth_context>* auth_context,
- grpc_closure* on_peer_checked) override;
-
- int cmp(const grpc_security_connector* other_sc) const override;
-
- bool check_call_host(y_absl::string_view host, grpc_auth_context* auth_context,
- grpc_closure* on_call_host_checked,
- grpc_error** error) override;
-
- void cancel_check_call_host(grpc_closure* on_call_host_checked,
- grpc_error* error) override;
-
- private:
- // Initialize SSL TSI client handshaker factory.
- grpc_security_status InitializeHandshakerFactory(
- tsi_ssl_session_cache* ssl_session_cache);
-
- // A util function to create a new client handshaker factory to replace
- // the existing one if exists.
- grpc_security_status ReplaceHandshakerFactory(
- tsi_ssl_session_cache* ssl_session_cache);
-
- // gRPC-provided callback executed by application, which servers to bring the
- // control back to gRPC core.
- static void ServerAuthorizationCheckDone(
- grpc_tls_server_authorization_check_arg* arg);
-
- // A util function to process server authorization check result.
- static grpc_error* ProcessServerAuthorizationCheckResult(
- grpc_tls_server_authorization_check_arg* arg);
-
- // A util function to create a server authorization check arg instance.
- static grpc_tls_server_authorization_check_arg*
- ServerAuthorizationCheckArgCreate(void* user_data);
-
- // A util function to destroy a server authorization check arg instance.
- static void ServerAuthorizationCheckArgDestroy(
- grpc_tls_server_authorization_check_arg* arg);
-
- // A util function to refresh SSL TSI client handshaker factory with a valid
- // credential.
- grpc_security_status RefreshHandshakerFactory();
-
- grpc_core::Mutex mu_;
- grpc_closure* on_peer_checked_;
- TString target_name_;
- TString overridden_target_name_;
- tsi_ssl_client_handshaker_factory* client_handshaker_factory_ = nullptr;
- grpc_tls_server_authorization_check_arg* check_arg_;
- grpc_core::RefCountedPtr<grpc_tls_key_materials_config> key_materials_config_;
-};
-
-// TLS server security connector.
-class TlsServerSecurityConnector final : public grpc_server_security_connector {
- public:
- // static factory method to create a TLS server security connector.
- static grpc_core::RefCountedPtr<grpc_server_security_connector>
- CreateTlsServerSecurityConnector(
- grpc_core::RefCountedPtr<grpc_server_credentials> server_creds);
-
- explicit TlsServerSecurityConnector(
- grpc_core::RefCountedPtr<grpc_server_credentials> server_creds);
- ~TlsServerSecurityConnector() override;
-
- void add_handshakers(const grpc_channel_args* args,
- grpc_pollset_set* interested_parties,
- grpc_core::HandshakeManager* handshake_mgr) override;
-
- void check_peer(tsi_peer peer, grpc_endpoint* ep,
- grpc_core::RefCountedPtr<grpc_auth_context>* auth_context,
- grpc_closure* on_peer_checked) override;
-
- int cmp(const grpc_security_connector* other) const override;
-
- private:
- // Initialize SSL TSI server handshaker factory.
- grpc_security_status InitializeHandshakerFactory();
-
- // A util function to create a new server handshaker factory to replace the
- // existing once if exists.
- grpc_security_status ReplaceHandshakerFactory();
-
- // A util function to refresh SSL TSI server handshaker factory with a valid
- // credential.
- grpc_security_status RefreshHandshakerFactory();
-
- grpc_core::Mutex mu_;
- tsi_ssl_server_handshaker_factory* server_handshaker_factory_ = nullptr;
- grpc_core::RefCountedPtr<grpc_tls_key_materials_config> key_materials_config_;
-};
-
-// ---- Functions below are exposed for testing only -----------------------
-
-/** The |TlsFetchKeyMaterials| API ensures that |key_materials_config| has a
- * non-empty pem-key-cert pair list. This is done as follows:
- * - if |options| is equipped with a credential reload config, then this
- * methods uses credential reloading to populate |key_materials_config|, and
- * afterwards it populates |reload_status| with the status of this operation.
- * In particular, any data stored in |key_materials_config| is overwritten.
- * - if |options| has no credential reload config, then:
- * - if |key_materials_config| already has a non-empty pem-key-cert pair
- * list or is called by a client, then the method returns |GRPC_STATUS_OK|.
- * - if |key_materials_config| has an empty pem-key-cert pair list and is
- * called by a server, then the method return an error code.
- *
- * The arguments are detailed below:
- * - key_materials_config: a key materials config that will be populated by the
- * method on success; the caller should not pass in nullptr. Any data held by
- * the config will be overwritten.
- * - options: the TLS credentials options whose credential reloading config
- * will be used to populate |key_materials_config|.
- * - is_server: true denotes that this method is called by a server, and
- * false denotes that this method is called by a client.
- * - status: the status of the credential reloading after the method
- * returns; the caller should not pass in nullptr. **/
-grpc_status_code TlsFetchKeyMaterials(
- const grpc_core::RefCountedPtr<grpc_tls_key_materials_config>&
- key_materials_config,
- const grpc_tls_credentials_options& options, bool is_server,
- grpc_ssl_certificate_config_reload_status* status);
-
-// TlsCheckHostName checks if |peer_name| matches the identity information
-// contained in |peer|. This is AKA hostname check.
-grpc_error* TlsCheckHostName(const char* peer_name, const tsi_peer* peer);
-
-} // namespace grpc_core
-
-#endif /* GRPC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_TLS_TLS_SECURITY_CONNECTOR_H \
- */
+/*
+ *
+ * Copyright 2018 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef GRPC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_TLS_TLS_SECURITY_CONNECTOR_H
+#define GRPC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_TLS_TLS_SECURITY_CONNECTOR_H
+
+#include <grpc/support/port_platform.h>
+
+#include "src/core/lib/gprpp/sync.h"
+#include "src/core/lib/security/context/security_context.h"
+#include "src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h"
+
+#define GRPC_TLS_TRANSPORT_SECURITY_TYPE "tls"
+
+namespace grpc_core {
+
+// TLS channel security connector.
+class TlsChannelSecurityConnector final
+ : public grpc_channel_security_connector {
+ public:
+ // static factory method to create a TLS channel security connector.
+ static grpc_core::RefCountedPtr<grpc_channel_security_connector>
+ CreateTlsChannelSecurityConnector(
+ grpc_core::RefCountedPtr<grpc_channel_credentials> channel_creds,
+ grpc_core::RefCountedPtr<grpc_call_credentials> request_metadata_creds,
+ const char* target_name, const char* overridden_target_name,
+ tsi_ssl_session_cache* ssl_session_cache);
+
+ TlsChannelSecurityConnector(
+ grpc_core::RefCountedPtr<grpc_channel_credentials> channel_creds,
+ grpc_core::RefCountedPtr<grpc_call_credentials> request_metadata_creds,
+ const char* target_name, const char* overridden_target_name);
+ ~TlsChannelSecurityConnector() override;
+
+ void add_handshakers(const grpc_channel_args* args,
+ grpc_pollset_set* interested_parties,
+ grpc_core::HandshakeManager* handshake_mgr) override;
+
+ void check_peer(tsi_peer peer, grpc_endpoint* ep,
+ grpc_core::RefCountedPtr<grpc_auth_context>* auth_context,
+ grpc_closure* on_peer_checked) override;
+
+ int cmp(const grpc_security_connector* other_sc) const override;
+
+ bool check_call_host(y_absl::string_view host, grpc_auth_context* auth_context,
+ grpc_closure* on_call_host_checked,
+ grpc_error** error) override;
+
+ void cancel_check_call_host(grpc_closure* on_call_host_checked,
+ grpc_error* error) override;
+
+ private:
+ // Initialize SSL TSI client handshaker factory.
+ grpc_security_status InitializeHandshakerFactory(
+ tsi_ssl_session_cache* ssl_session_cache);
+
+ // A util function to create a new client handshaker factory to replace
+ // the existing one if exists.
+ grpc_security_status ReplaceHandshakerFactory(
+ tsi_ssl_session_cache* ssl_session_cache);
+
+ // gRPC-provided callback executed by application, which servers to bring the
+ // control back to gRPC core.
+ static void ServerAuthorizationCheckDone(
+ grpc_tls_server_authorization_check_arg* arg);
+
+ // A util function to process server authorization check result.
+ static grpc_error* ProcessServerAuthorizationCheckResult(
+ grpc_tls_server_authorization_check_arg* arg);
+
+ // A util function to create a server authorization check arg instance.
+ static grpc_tls_server_authorization_check_arg*
+ ServerAuthorizationCheckArgCreate(void* user_data);
+
+ // A util function to destroy a server authorization check arg instance.
+ static void ServerAuthorizationCheckArgDestroy(
+ grpc_tls_server_authorization_check_arg* arg);
+
+ // A util function to refresh SSL TSI client handshaker factory with a valid
+ // credential.
+ grpc_security_status RefreshHandshakerFactory();
+
+ grpc_core::Mutex mu_;
+ grpc_closure* on_peer_checked_;
+ TString target_name_;
+ TString overridden_target_name_;
+ tsi_ssl_client_handshaker_factory* client_handshaker_factory_ = nullptr;
+ grpc_tls_server_authorization_check_arg* check_arg_;
+ grpc_core::RefCountedPtr<grpc_tls_key_materials_config> key_materials_config_;
+};
+
+// TLS server security connector.
+class TlsServerSecurityConnector final : public grpc_server_security_connector {
+ public:
+ // static factory method to create a TLS server security connector.
+ static grpc_core::RefCountedPtr<grpc_server_security_connector>
+ CreateTlsServerSecurityConnector(
+ grpc_core::RefCountedPtr<grpc_server_credentials> server_creds);
+
+ explicit TlsServerSecurityConnector(
+ grpc_core::RefCountedPtr<grpc_server_credentials> server_creds);
+ ~TlsServerSecurityConnector() override;
+
+ void add_handshakers(const grpc_channel_args* args,
+ grpc_pollset_set* interested_parties,
+ grpc_core::HandshakeManager* handshake_mgr) override;
+
+ void check_peer(tsi_peer peer, grpc_endpoint* ep,
+ grpc_core::RefCountedPtr<grpc_auth_context>* auth_context,
+ grpc_closure* on_peer_checked) override;
+
+ int cmp(const grpc_security_connector* other) const override;
+
+ private:
+ // Initialize SSL TSI server handshaker factory.
+ grpc_security_status InitializeHandshakerFactory();
+
+ // A util function to create a new server handshaker factory to replace the
+ // existing once if exists.
+ grpc_security_status ReplaceHandshakerFactory();
+
+ // A util function to refresh SSL TSI server handshaker factory with a valid
+ // credential.
+ grpc_security_status RefreshHandshakerFactory();
+
+ grpc_core::Mutex mu_;
+ tsi_ssl_server_handshaker_factory* server_handshaker_factory_ = nullptr;
+ grpc_core::RefCountedPtr<grpc_tls_key_materials_config> key_materials_config_;
+};
+
+// ---- Functions below are exposed for testing only -----------------------
+
+/** The |TlsFetchKeyMaterials| API ensures that |key_materials_config| has a
+ * non-empty pem-key-cert pair list. This is done as follows:
+ * - if |options| is equipped with a credential reload config, then this
+ * methods uses credential reloading to populate |key_materials_config|, and
+ * afterwards it populates |reload_status| with the status of this operation.
+ * In particular, any data stored in |key_materials_config| is overwritten.
+ * - if |options| has no credential reload config, then:
+ * - if |key_materials_config| already has a non-empty pem-key-cert pair
+ * list or is called by a client, then the method returns |GRPC_STATUS_OK|.
+ * - if |key_materials_config| has an empty pem-key-cert pair list and is
+ * called by a server, then the method return an error code.
+ *
+ * The arguments are detailed below:
+ * - key_materials_config: a key materials config that will be populated by the
+ * method on success; the caller should not pass in nullptr. Any data held by
+ * the config will be overwritten.
+ * - options: the TLS credentials options whose credential reloading config
+ * will be used to populate |key_materials_config|.
+ * - is_server: true denotes that this method is called by a server, and
+ * false denotes that this method is called by a client.
+ * - status: the status of the credential reloading after the method
+ * returns; the caller should not pass in nullptr. **/
+grpc_status_code TlsFetchKeyMaterials(
+ const grpc_core::RefCountedPtr<grpc_tls_key_materials_config>&
+ key_materials_config,
+ const grpc_tls_credentials_options& options, bool is_server,
+ grpc_ssl_certificate_config_reload_status* status);
+
+// TlsCheckHostName checks if |peer_name| matches the identity information
+// contained in |peer|. This is AKA hostname check.
+grpc_error* TlsCheckHostName(const char* peer_name, const tsi_peer* peer);
+
+} // namespace grpc_core
+
+#endif /* GRPC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_TLS_TLS_SECURITY_CONNECTOR_H \
+ */
diff --git a/contrib/libs/grpc/src/core/lib/security/transport/client_auth_filter.cc b/contrib/libs/grpc/src/core/lib/security/transport/client_auth_filter.cc
index bf059cb203..b1a9d3f938 100644
--- a/contrib/libs/grpc/src/core/lib/security/transport/client_auth_filter.cc
+++ b/contrib/libs/grpc/src/core/lib/security/transport/client_auth_filter.cc
@@ -22,10 +22,10 @@
#include <string.h>
-#include <util/generic/string.h>
-
-#include "y_absl/strings/str_cat.h"
-
+#include <util/generic/string.h>
+
+#include "y_absl/strings/str_cat.h"
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
@@ -270,39 +270,39 @@ static void send_security_metadata(grpc_call_element* elem,
call_creds_has_md ? ctx->creds->Ref() : channel_call_creds->Ref();
}
- /* Check security level of call credential and channel, and do not send
- * metadata if the check fails. */
- grpc_auth_property_iterator it = grpc_auth_context_find_properties_by_name(
- chand->auth_context.get(), GRPC_TRANSPORT_SECURITY_LEVEL_PROPERTY_NAME);
- const grpc_auth_property* prop = grpc_auth_property_iterator_next(&it);
- if (prop == nullptr) {
- grpc_transport_stream_op_batch_finish_with_failure(
- batch,
- grpc_error_set_int(
- GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "Established channel does not have an auth property "
- "representing a security level."),
- GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAUTHENTICATED),
- calld->call_combiner);
- return;
- }
- grpc_security_level call_cred_security_level =
- calld->creds->min_security_level();
- int is_security_level_ok = grpc_check_security_level(
- grpc_tsi_security_level_string_to_enum(prop->value),
- call_cred_security_level);
- if (!is_security_level_ok) {
- grpc_transport_stream_op_batch_finish_with_failure(
- batch,
- grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "Established channel does not have a sufficient "
- "security level to transfer call credential."),
- GRPC_ERROR_INT_GRPC_STATUS,
- GRPC_STATUS_UNAUTHENTICATED),
- calld->call_combiner);
- return;
- }
-
+ /* Check security level of call credential and channel, and do not send
+ * metadata if the check fails. */
+ grpc_auth_property_iterator it = grpc_auth_context_find_properties_by_name(
+ chand->auth_context.get(), GRPC_TRANSPORT_SECURITY_LEVEL_PROPERTY_NAME);
+ const grpc_auth_property* prop = grpc_auth_property_iterator_next(&it);
+ if (prop == nullptr) {
+ grpc_transport_stream_op_batch_finish_with_failure(
+ batch,
+ grpc_error_set_int(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Established channel does not have an auth property "
+ "representing a security level."),
+ GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAUTHENTICATED),
+ calld->call_combiner);
+ return;
+ }
+ grpc_security_level call_cred_security_level =
+ calld->creds->min_security_level();
+ int is_security_level_ok = grpc_check_security_level(
+ grpc_tsi_security_level_string_to_enum(prop->value),
+ call_cred_security_level);
+ if (!is_security_level_ok) {
+ grpc_transport_stream_op_batch_finish_with_failure(
+ batch,
+ grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Established channel does not have a sufficient "
+ "security level to transfer call credential."),
+ GRPC_ERROR_INT_GRPC_STATUS,
+ GRPC_STATUS_UNAUTHENTICATED),
+ calld->call_combiner);
+ return;
+ }
+
grpc_auth_metadata_context_build(
chand->security_connector->url_scheme(), calld->host, calld->method,
chand->auth_context.get(), &calld->auth_md_context);
@@ -335,14 +335,14 @@ static void on_host_checked(void* arg, grpc_error* error) {
if (error == GRPC_ERROR_NONE) {
send_security_metadata(elem, batch);
} else {
- TString error_msg = y_absl::StrCat(
- "Invalid host ", grpc_core::StringViewFromSlice(calld->host),
- " set in :authority metadata.");
+ TString error_msg = y_absl::StrCat(
+ "Invalid host ", grpc_core::StringViewFromSlice(calld->host),
+ " set in :authority metadata.");
grpc_transport_stream_op_batch_finish_with_failure(
batch,
- grpc_error_set_int(
- GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_msg.c_str()),
- GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAUTHENTICATED),
+ grpc_error_set_int(
+ GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_msg.c_str()),
+ GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAUTHENTICATED),
calld->call_combiner);
}
GRPC_CALL_STACK_UNREF(calld->owning_call, "check_call_host");
@@ -380,7 +380,7 @@ static void client_auth_start_transport_stream_op_batch(
GRPC_CALL_STACK_REF(calld->owning_call, "check_call_host");
GRPC_CLOSURE_INIT(&calld->async_result_closure, on_host_checked, batch,
grpc_schedule_on_exec_ctx);
- y_absl::string_view call_host(grpc_core::StringViewFromSlice(calld->host));
+ y_absl::string_view call_host(grpc_core::StringViewFromSlice(calld->host));
grpc_error* error = GRPC_ERROR_NONE;
if (chand->security_connector->check_call_host(
call_host, chand->auth_context.get(),
diff --git a/contrib/libs/grpc/src/core/lib/security/transport/secure_endpoint.cc b/contrib/libs/grpc/src/core/lib/security/transport/secure_endpoint.cc
index 2a192185ce..e79184fac1 100644
--- a/contrib/libs/grpc/src/core/lib/security/transport/secure_endpoint.cc
+++ b/contrib/libs/grpc/src/core/lib/security/transport/secure_endpoint.cc
@@ -401,16 +401,16 @@ static void endpoint_delete_from_pollset_set(grpc_endpoint* secure_ep,
grpc_endpoint_delete_from_pollset_set(ep->wrapped_ep, pollset_set);
}
-static y_absl::string_view endpoint_get_peer(grpc_endpoint* secure_ep) {
+static y_absl::string_view endpoint_get_peer(grpc_endpoint* secure_ep) {
secure_endpoint* ep = reinterpret_cast<secure_endpoint*>(secure_ep);
return grpc_endpoint_get_peer(ep->wrapped_ep);
}
-static y_absl::string_view endpoint_get_local_address(grpc_endpoint* secure_ep) {
- secure_endpoint* ep = reinterpret_cast<secure_endpoint*>(secure_ep);
- return grpc_endpoint_get_local_address(ep->wrapped_ep);
-}
-
+static y_absl::string_view endpoint_get_local_address(grpc_endpoint* secure_ep) {
+ secure_endpoint* ep = reinterpret_cast<secure_endpoint*>(secure_ep);
+ return grpc_endpoint_get_local_address(ep->wrapped_ep);
+}
+
static int endpoint_get_fd(grpc_endpoint* secure_ep) {
secure_endpoint* ep = reinterpret_cast<secure_endpoint*>(secure_ep);
return grpc_endpoint_get_fd(ep->wrapped_ep);
@@ -436,7 +436,7 @@ static const grpc_endpoint_vtable vtable = {endpoint_read,
endpoint_destroy,
endpoint_get_resource_user,
endpoint_get_peer,
- endpoint_get_local_address,
+ endpoint_get_local_address,
endpoint_get_fd,
endpoint_can_track_err};
diff --git a/contrib/libs/grpc/src/core/lib/security/transport/security_handshaker.cc b/contrib/libs/grpc/src/core/lib/security/transport/security_handshaker.cc
index 9b3a320252..079b49c95a 100644
--- a/contrib/libs/grpc/src/core/lib/security/transport/security_handshaker.cc
+++ b/contrib/libs/grpc/src/core/lib/security/transport/security_handshaker.cc
@@ -559,10 +559,10 @@ RefCountedPtr<Handshaker> SecurityHandshakerCreate(
void SecurityRegisterHandshakerFactories() {
HandshakerRegistry::RegisterHandshakerFactory(
false /* at_start */, HANDSHAKER_CLIENT,
- y_absl::make_unique<ClientSecurityHandshakerFactory>());
+ y_absl::make_unique<ClientSecurityHandshakerFactory>());
HandshakerRegistry::RegisterHandshakerFactory(
false /* at_start */, HANDSHAKER_SERVER,
- y_absl::make_unique<ServerSecurityHandshakerFactory>());
+ y_absl::make_unique<ServerSecurityHandshakerFactory>());
}
} // namespace grpc_core
diff --git a/contrib/libs/grpc/src/core/lib/security/util/json_util.cc b/contrib/libs/grpc/src/core/lib/security/util/json_util.cc
index b4427b6769..70ed064841 100644
--- a/contrib/libs/grpc/src/core/lib/security/util/json_util.cc
+++ b/contrib/libs/grpc/src/core/lib/security/util/json_util.cc
@@ -20,46 +20,46 @@
#include <string.h>
-#include "y_absl/strings/str_cat.h"
-
+#include "y_absl/strings/str_cat.h"
+
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
-#include "src/core/lib/iomgr/error.h"
-#include "src/core/lib/security/util/json_util.h"
-
-const char* grpc_json_get_string_property(const grpc_core::Json& json,
+#include "src/core/lib/iomgr/error.h"
+#include "src/core/lib/security/util/json_util.h"
+
+const char* grpc_json_get_string_property(const grpc_core::Json& json,
const char* prop_name,
grpc_error** error) {
- if (json.type() != grpc_core::Json::Type::OBJECT) {
- if (error != nullptr) {
- *error =
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("JSON value is not an object");
+ if (json.type() != grpc_core::Json::Type::OBJECT) {
+ if (error != nullptr) {
+ *error =
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("JSON value is not an object");
+ }
+ return nullptr;
+ }
+ auto it = json.object_value().find(prop_name);
+ if (it == json.object_value().end()) {
+ if (error != nullptr) {
+ *error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
+ y_absl::StrCat("Property ", prop_name, " not found in JSON object.")
+ .c_str());
}
- return nullptr;
+ return nullptr;
}
- auto it = json.object_value().find(prop_name);
- if (it == json.object_value().end()) {
+ if (it->second.type() != grpc_core::Json::Type::STRING) {
if (error != nullptr) {
- *error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
- y_absl::StrCat("Property ", prop_name, " not found in JSON object.")
- .c_str());
+ *error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
+ y_absl::StrCat("Property ", prop_name,
+ " n JSON object is not a string.")
+ .c_str());
}
return nullptr;
}
- if (it->second.type() != grpc_core::Json::Type::STRING) {
- if (error != nullptr) {
- *error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
- y_absl::StrCat("Property ", prop_name,
- " n JSON object is not a string.")
- .c_str());
- }
- return nullptr;
- }
- return it->second.string_value().c_str();
+ return it->second.string_value().c_str();
}
-bool grpc_copy_json_string_property(const grpc_core::Json& json,
+bool grpc_copy_json_string_property(const grpc_core::Json& json,
const char* prop_name,
char** copied_value) {
grpc_error* error = GRPC_ERROR_NONE;
diff --git a/contrib/libs/grpc/src/core/lib/security/util/json_util.h b/contrib/libs/grpc/src/core/lib/security/util/json_util.h
index 95129b12bd..42f7005e00 100644
--- a/contrib/libs/grpc/src/core/lib/security/util/json_util.h
+++ b/contrib/libs/grpc/src/core/lib/security/util/json_util.h
@@ -32,13 +32,13 @@
#define GRPC_AUTH_JSON_TYPE_AUTHORIZED_USER "authorized_user"
// Gets a child property from a json node.
-const char* grpc_json_get_string_property(const grpc_core::Json& json,
+const char* grpc_json_get_string_property(const grpc_core::Json& json,
const char* prop_name,
grpc_error** error);
// Copies the value of the json child property specified by prop_name.
// Returns false if the property was not found.
-bool grpc_copy_json_string_property(const grpc_core::Json& json,
+bool grpc_copy_json_string_property(const grpc_core::Json& json,
const char* prop_name, char** copied_value);
#endif /* GRPC_CORE_LIB_SECURITY_UTIL_JSON_UTIL_H */
diff --git a/contrib/libs/grpc/src/core/lib/slice/slice.cc b/contrib/libs/grpc/src/core/lib/slice/slice.cc
index 2fbe1f8673..838cf4ba49 100644
--- a/contrib/libs/grpc/src/core/lib/slice/slice.cc
+++ b/contrib/libs/grpc/src/core/lib/slice/slice.cc
@@ -156,7 +156,7 @@ class NewWithLenSliceRefcount {
/** grpc_slice_from_moved_(string|buffer) ref count .*/
class MovedStringSliceRefCount {
public:
- explicit MovedStringSliceRefCount(grpc_core::UniquePtr<char>&& str)
+ explicit MovedStringSliceRefCount(grpc_core::UniquePtr<char>&& str)
: base_(grpc_slice_refcount::Type::REGULAR, &refs_, Destroy, this,
&base_),
str_(std::move(str)) {}
@@ -173,26 +173,26 @@ class MovedStringSliceRefCount {
grpc_core::UniquePtr<char> str_;
};
-// grpc_slice_from_cpp_string() ref count.
-class MovedCppStringSliceRefCount {
- public:
- explicit MovedCppStringSliceRefCount(TString&& str)
- : base_(grpc_slice_refcount::Type::REGULAR, &refs_, Destroy, this,
- &base_),
- str_(std::move(str)) {}
-
- grpc_slice_refcount* base_refcount() { return &base_; }
-
- private:
- static void Destroy(void* arg) {
- delete static_cast<MovedCppStringSliceRefCount*>(arg);
- }
-
- grpc_slice_refcount base_;
- grpc_core::RefCount refs_;
- TString str_;
-};
-
+// grpc_slice_from_cpp_string() ref count.
+class MovedCppStringSliceRefCount {
+ public:
+ explicit MovedCppStringSliceRefCount(TString&& str)
+ : base_(grpc_slice_refcount::Type::REGULAR, &refs_, Destroy, this,
+ &base_),
+ str_(std::move(str)) {}
+
+ grpc_slice_refcount* base_refcount() { return &base_; }
+
+ private:
+ static void Destroy(void* arg) {
+ delete static_cast<MovedCppStringSliceRefCount*>(arg);
+ }
+
+ grpc_slice_refcount base_;
+ grpc_core::RefCount refs_;
+ TString str_;
+};
+
} // namespace grpc_core
grpc_slice grpc_slice_new_with_len(void* p, size_t len,
@@ -252,23 +252,23 @@ grpc_slice grpc_slice_from_moved_string(grpc_core::UniquePtr<char> p) {
return grpc_slice_from_moved_buffer(std::move(p), len);
}
-grpc_slice grpc_slice_from_cpp_string(TString str) {
- grpc_slice slice;
- if (str.size() <= sizeof(slice.data.inlined.bytes)) {
- slice.refcount = nullptr;
- slice.data.inlined.length = str.size();
- memcpy(GRPC_SLICE_START_PTR(slice), str.data(), str.size());
- } else {
- slice.data.refcounted.bytes =
- reinterpret_cast<uint8_t*>(const_cast<char*>(str.data()));
- slice.data.refcounted.length = str.size();
- slice.refcount =
- (new grpc_core::MovedCppStringSliceRefCount(std::move(str)))
- ->base_refcount();
- }
- return slice;
-}
-
+grpc_slice grpc_slice_from_cpp_string(TString str) {
+ grpc_slice slice;
+ if (str.size() <= sizeof(slice.data.inlined.bytes)) {
+ slice.refcount = nullptr;
+ slice.data.inlined.length = str.size();
+ memcpy(GRPC_SLICE_START_PTR(slice), str.data(), str.size());
+ } else {
+ slice.data.refcounted.bytes =
+ reinterpret_cast<uint8_t*>(const_cast<char*>(str.data()));
+ slice.data.refcounted.length = str.size();
+ slice.refcount =
+ (new grpc_core::MovedCppStringSliceRefCount(std::move(str)))
+ ->base_refcount();
+ }
+ return slice;
+}
+
namespace {
class MallocRefCount {
diff --git a/contrib/libs/grpc/src/core/lib/slice/slice_internal.h b/contrib/libs/grpc/src/core/lib/slice/slice_internal.h
index 9738a712c1..8a17b6e72e 100644
--- a/contrib/libs/grpc/src/core/lib/slice/slice_internal.h
+++ b/contrib/libs/grpc/src/core/lib/slice/slice_internal.h
@@ -338,7 +338,7 @@ inline uint32_t grpc_slice_hash_internal(const grpc_slice& s) {
grpc_slice grpc_slice_from_moved_buffer(grpc_core::UniquePtr<char> p,
size_t len);
grpc_slice grpc_slice_from_moved_string(grpc_core::UniquePtr<char> p);
-grpc_slice grpc_slice_from_cpp_string(TString str);
+grpc_slice grpc_slice_from_cpp_string(TString str);
// Returns the memory used by this slice, not counting the slice structure
// itself. This means that inlined and slices from static strings will return
@@ -348,18 +348,18 @@ size_t grpc_slice_memory_usage(grpc_slice s);
grpc_core::UnmanagedMemorySlice grpc_slice_sub_no_ref(
const grpc_core::UnmanagedMemorySlice& source, size_t begin, size_t end);
-namespace grpc_core {
-
-struct SliceHash {
- std::size_t operator()(const grpc_slice& slice) const {
- return grpc_slice_hash_internal(slice);
- }
-};
-
-} // namespace grpc_core
-
-inline bool operator==(const grpc_slice& s1, const grpc_slice& s2) {
- return grpc_slice_eq(s1, s2);
-}
-
+namespace grpc_core {
+
+struct SliceHash {
+ std::size_t operator()(const grpc_slice& slice) const {
+ return grpc_slice_hash_internal(slice);
+ }
+};
+
+} // namespace grpc_core
+
+inline bool operator==(const grpc_slice& s1, const grpc_slice& s2) {
+ return grpc_slice_eq(s1, s2);
+}
+
#endif /* GRPC_CORE_LIB_SLICE_SLICE_INTERNAL_H */
diff --git a/contrib/libs/grpc/src/core/lib/slice/slice_utils.h b/contrib/libs/grpc/src/core/lib/slice/slice_utils.h
index 3636e38ccf..95cef73a4f 100644
--- a/contrib/libs/grpc/src/core/lib/slice/slice_utils.h
+++ b/contrib/libs/grpc/src/core/lib/slice/slice_utils.h
@@ -23,8 +23,8 @@
#include <cstring>
-#include "y_absl/strings/string_view.h"
-
+#include "y_absl/strings/string_view.h"
+
#include <grpc/slice.h>
#include "src/core/lib/gpr/murmur_hash.h"
@@ -188,13 +188,13 @@ struct InternedSlice : public ManagedMemorySlice {
explicit InternedSlice(InternedSliceRefcount* s);
};
-// Converts grpc_slice to y_absl::string_view.
-inline y_absl::string_view StringViewFromSlice(const grpc_slice& slice) {
- return y_absl::string_view(
- reinterpret_cast<const char*>(GRPC_SLICE_START_PTR(slice)),
- GRPC_SLICE_LENGTH(slice));
-}
-
+// Converts grpc_slice to y_absl::string_view.
+inline y_absl::string_view StringViewFromSlice(const grpc_slice& slice) {
+ return y_absl::string_view(
+ reinterpret_cast<const char*>(GRPC_SLICE_START_PTR(slice)),
+ GRPC_SLICE_LENGTH(slice));
+}
+
} // namespace grpc_core
#endif /* GRPC_CORE_LIB_SLICE_SLICE_UTILS_H */
diff --git a/contrib/libs/grpc/src/core/lib/surface/byte_buffer_reader.cc b/contrib/libs/grpc/src/core/lib/surface/byte_buffer_reader.cc
index 2f398be47e..3689c79455 100644
--- a/contrib/libs/grpc/src/core/lib/surface/byte_buffer_reader.cc
+++ b/contrib/libs/grpc/src/core/lib/surface/byte_buffer_reader.cc
@@ -35,7 +35,7 @@ int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader* reader,
reader->buffer_in = buffer;
switch (reader->buffer_in->type) {
case GRPC_BB_RAW:
- reader->buffer_out = reader->buffer_in;
+ reader->buffer_out = reader->buffer_in;
reader->current.index = 0;
break;
}
@@ -43,7 +43,7 @@ int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader* reader,
}
void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader* reader) {
- reader->buffer_out = nullptr;
+ reader->buffer_out = nullptr;
}
int grpc_byte_buffer_reader_peek(grpc_byte_buffer_reader* reader,
diff --git a/contrib/libs/grpc/src/core/lib/surface/call.cc b/contrib/libs/grpc/src/core/lib/surface/call.cc
index a2ef755ddf..fe4c774c52 100644
--- a/contrib/libs/grpc/src/core/lib/surface/call.cc
+++ b/contrib/libs/grpc/src/core/lib/surface/call.cc
@@ -24,11 +24,11 @@
#include <stdlib.h>
#include <string.h>
-#include <util/generic/string.h>
-
-#include "y_absl/strings/str_cat.h"
-#include "y_absl/strings/str_format.h"
-
+#include <util/generic/string.h>
+
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_format.h"
+
#include <grpc/compression.h>
#include <grpc/grpc.h>
#include <grpc/slice.h>
@@ -232,9 +232,9 @@ struct grpc_call {
grpc_closure receiving_initial_metadata_ready;
grpc_closure receiving_trailing_metadata_ready;
uint32_t test_only_last_message_flags = 0;
- // Status about operation of call
- bool sent_server_trailing_metadata = false;
- gpr_atm cancelled_with_error = 0;
+ // Status about operation of call
+ bool sent_server_trailing_metadata = false;
+ gpr_atm cancelled_with_error = 0;
grpc_closure release_call;
@@ -247,7 +247,7 @@ struct grpc_call {
struct {
int* cancelled;
// backpointer to owning server if this is a server side call.
- grpc_core::Server* core_server;
+ grpc_core::Server* core_server;
} server;
} final_op;
gpr_atm status_error = 0;
@@ -376,7 +376,7 @@ grpc_error* grpc_call_create(const grpc_call_create_args* args,
} else {
GRPC_STATS_INC_SERVER_CALLS_CREATED();
call->final_op.server.cancelled = nullptr;
- call->final_op.server.core_server = args->server;
+ call->final_op.server.core_server = args->server;
GPR_ASSERT(args->add_initial_metadata_count == 0);
call->send_extra_metadata_count = 0;
}
@@ -478,11 +478,11 @@ grpc_error* grpc_call_create(const grpc_call_create_args* args,
if (channelz_channel != nullptr) {
channelz_channel->RecordCallStarted();
}
- } else if (call->final_op.server.core_server != nullptr) {
- grpc_core::channelz::ServerNode* channelz_node =
- call->final_op.server.core_server->channelz_node();
- if (channelz_node != nullptr) {
- channelz_node->RecordCallStarted();
+ } else if (call->final_op.server.core_server != nullptr) {
+ grpc_core::channelz::ServerNode* channelz_node =
+ call->final_op.server.core_server->channelz_node();
+ if (channelz_node != nullptr) {
+ channelz_node->RecordCallStarted();
}
}
@@ -695,7 +695,7 @@ static void done_termination(void* arg, grpc_error* /*error*/) {
}
static void cancel_with_error(grpc_call* c, grpc_error* error) {
- if (!gpr_atm_rel_cas(&c->cancelled_with_error, 0, 1)) {
+ if (!gpr_atm_rel_cas(&c->cancelled_with_error, 0, 1)) {
GRPC_ERROR_UNREF(error);
return;
}
@@ -760,16 +760,16 @@ static void set_final_status(grpc_call* call, grpc_error* error) {
}
} else {
*call->final_op.server.cancelled =
- error != GRPC_ERROR_NONE || !call->sent_server_trailing_metadata;
- grpc_core::channelz::ServerNode* channelz_node =
- call->final_op.server.core_server->channelz_node();
- if (channelz_node != nullptr) {
- if (*call->final_op.server.cancelled ||
- reinterpret_cast<grpc_error*>(
- gpr_atm_acq_load(&call->status_error)) != GRPC_ERROR_NONE) {
- channelz_node->RecordCallFailed();
+ error != GRPC_ERROR_NONE || !call->sent_server_trailing_metadata;
+ grpc_core::channelz::ServerNode* channelz_node =
+ call->final_op.server.core_server->channelz_node();
+ if (channelz_node != nullptr) {
+ if (*call->final_op.server.cancelled ||
+ reinterpret_cast<grpc_error*>(
+ gpr_atm_acq_load(&call->status_error)) != GRPC_ERROR_NONE) {
+ channelz_node->RecordCallFailed();
} else {
- channelz_node->RecordCallSucceeded();
+ channelz_node->RecordCallSucceeded();
}
}
GRPC_ERROR_UNREF(error);
@@ -1059,10 +1059,10 @@ static void recv_trailing_filter(void* args, grpc_metadata_batch* b,
grpc_error* error = GRPC_ERROR_NONE;
if (status_code != GRPC_STATUS_OK) {
char* peer = grpc_call_get_peer(call);
- error = grpc_error_set_int(
- GRPC_ERROR_CREATE_FROM_COPIED_STRING(
- y_absl::StrCat("Error received from peer ", peer).c_str()),
- GRPC_ERROR_INT_GRPC_STATUS, static_cast<intptr_t>(status_code));
+ error = grpc_error_set_int(
+ GRPC_ERROR_CREATE_FROM_COPIED_STRING(
+ y_absl::StrCat("Error received from peer ", peer).c_str()),
+ GRPC_ERROR_INT_GRPC_STATUS, static_cast<intptr_t>(status_code));
gpr_free(peer);
}
if (b->idx.named.grpc_message != nullptr) {
@@ -1374,41 +1374,41 @@ static void receiving_stream_ready_in_call_combiner(void* bctlp,
static void GPR_ATTRIBUTE_NOINLINE
handle_both_stream_and_msg_compression_set(grpc_call* call) {
- TString error_msg = y_absl::StrFormat(
- "Incoming stream has both stream compression (%d) and message "
- "compression (%d).",
- call->incoming_stream_compression_algorithm,
- call->incoming_message_compression_algorithm);
- gpr_log(GPR_ERROR, "%s", error_msg.c_str());
- cancel_with_status(call, GRPC_STATUS_INTERNAL, error_msg.c_str());
+ TString error_msg = y_absl::StrFormat(
+ "Incoming stream has both stream compression (%d) and message "
+ "compression (%d).",
+ call->incoming_stream_compression_algorithm,
+ call->incoming_message_compression_algorithm);
+ gpr_log(GPR_ERROR, "%s", error_msg.c_str());
+ cancel_with_status(call, GRPC_STATUS_INTERNAL, error_msg.c_str());
}
static void GPR_ATTRIBUTE_NOINLINE
handle_error_parsing_compression_algorithm(grpc_call* call) {
- TString error_msg = y_absl::StrFormat(
- "Error in incoming message compression (%d) or stream "
- "compression (%d).",
- call->incoming_stream_compression_algorithm,
- call->incoming_message_compression_algorithm);
- cancel_with_status(call, GRPC_STATUS_INTERNAL, error_msg.c_str());
+ TString error_msg = y_absl::StrFormat(
+ "Error in incoming message compression (%d) or stream "
+ "compression (%d).",
+ call->incoming_stream_compression_algorithm,
+ call->incoming_message_compression_algorithm);
+ cancel_with_status(call, GRPC_STATUS_INTERNAL, error_msg.c_str());
}
static void GPR_ATTRIBUTE_NOINLINE handle_invalid_compression(
grpc_call* call, grpc_compression_algorithm compression_algorithm) {
- TString error_msg = y_absl::StrFormat(
- "Invalid compression algorithm value '%d'.", compression_algorithm);
- gpr_log(GPR_ERROR, "%s", error_msg.c_str());
- cancel_with_status(call, GRPC_STATUS_UNIMPLEMENTED, error_msg.c_str());
+ TString error_msg = y_absl::StrFormat(
+ "Invalid compression algorithm value '%d'.", compression_algorithm);
+ gpr_log(GPR_ERROR, "%s", error_msg.c_str());
+ cancel_with_status(call, GRPC_STATUS_UNIMPLEMENTED, error_msg.c_str());
}
static void GPR_ATTRIBUTE_NOINLINE handle_compression_algorithm_disabled(
grpc_call* call, grpc_compression_algorithm compression_algorithm) {
const char* algo_name = nullptr;
grpc_compression_algorithm_name(compression_algorithm, &algo_name);
- TString error_msg =
- y_absl::StrFormat("Compression algorithm '%s' is disabled.", algo_name);
- gpr_log(GPR_ERROR, "%s", error_msg.c_str());
- cancel_with_status(call, GRPC_STATUS_UNIMPLEMENTED, error_msg.c_str());
+ TString error_msg =
+ y_absl::StrFormat("Compression algorithm '%s' is disabled.", algo_name);
+ gpr_log(GPR_ERROR, "%s", error_msg.c_str());
+ cancel_with_status(call, GRPC_STATUS_UNIMPLEMENTED, error_msg.c_str());
}
static void GPR_ATTRIBUTE_NOINLINE handle_compression_algorithm_not_accepted(
@@ -1790,8 +1790,8 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
}
stream_op_payload->send_trailing_metadata.send_trailing_metadata =
&call->metadata_batch[0 /* is_receiving */][1 /* is_trailing */];
- stream_op_payload->send_trailing_metadata.sent =
- &call->sent_server_trailing_metadata;
+ stream_op_payload->send_trailing_metadata.sent =
+ &call->sent_server_trailing_metadata;
has_send_ops = true;
break;
}
diff --git a/contrib/libs/grpc/src/core/lib/surface/call.h b/contrib/libs/grpc/src/core/lib/surface/call.h
index b6ebd08e18..34d01db902 100644
--- a/contrib/libs/grpc/src/core/lib/surface/call.h
+++ b/contrib/libs/grpc/src/core/lib/surface/call.h
@@ -25,7 +25,7 @@
#include "src/core/lib/channel/context.h"
#include "src/core/lib/gprpp/arena.h"
#include "src/core/lib/surface/api_trace.h"
-#include "src/core/lib/surface/server.h"
+#include "src/core/lib/surface/server.h"
#include <grpc/grpc.h>
#include <grpc/impl/codegen/compression_types.h>
@@ -35,7 +35,7 @@ typedef void (*grpc_ioreq_completion_func)(grpc_call* call, int success,
typedef struct grpc_call_create_args {
grpc_channel* channel;
- grpc_core::Server* server;
+ grpc_core::Server* server;
grpc_call* parent;
uint32_t propagation_mask;
diff --git a/contrib/libs/grpc/src/core/lib/surface/call_log_batch.cc b/contrib/libs/grpc/src/core/lib/surface/call_log_batch.cc
index 5371ef4ad7..c4f78821ab 100644
--- a/contrib/libs/grpc/src/core/lib/surface/call_log_batch.cc
+++ b/contrib/libs/grpc/src/core/lib/surface/call_log_batch.cc
@@ -22,90 +22,90 @@
#include <inttypes.h>
-#include <vector>
-
-#include "y_absl/strings/str_format.h"
-#include "y_absl/strings/str_join.h"
-
+#include <vector>
+
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/str_join.h"
+
#include <grpc/support/alloc.h>
#include <grpc/support/string_util.h>
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-static void add_metadata(const grpc_metadata* md, size_t count,
- std::vector<TString>* b) {
+static void add_metadata(const grpc_metadata* md, size_t count,
+ std::vector<TString>* b) {
if (md == nullptr) {
- b->push_back("(nil)");
+ b->push_back("(nil)");
return;
}
- for (size_t i = 0; i < count; i++) {
- b->push_back("\nkey=");
- b->push_back(TString(grpc_core::StringViewFromSlice(md[i].key)));
- b->push_back(" value=");
- char* dump = grpc_dump_slice(md[i].value, GPR_DUMP_HEX | GPR_DUMP_ASCII);
- b->push_back(dump);
- gpr_free(dump);
+ for (size_t i = 0; i < count; i++) {
+ b->push_back("\nkey=");
+ b->push_back(TString(grpc_core::StringViewFromSlice(md[i].key)));
+ b->push_back(" value=");
+ char* dump = grpc_dump_slice(md[i].value, GPR_DUMP_HEX | GPR_DUMP_ASCII);
+ b->push_back(dump);
+ gpr_free(dump);
}
}
-static TString grpc_op_string(const grpc_op* op) {
- std::vector<TString> parts;
+static TString grpc_op_string(const grpc_op* op) {
+ std::vector<TString> parts;
switch (op->op) {
case GRPC_OP_SEND_INITIAL_METADATA:
- parts.push_back("SEND_INITIAL_METADATA");
- add_metadata(op->data.send_initial_metadata.metadata,
- op->data.send_initial_metadata.count, &parts);
+ parts.push_back("SEND_INITIAL_METADATA");
+ add_metadata(op->data.send_initial_metadata.metadata,
+ op->data.send_initial_metadata.count, &parts);
break;
case GRPC_OP_SEND_MESSAGE:
- parts.push_back(y_absl::StrFormat("SEND_MESSAGE ptr=%p",
- op->data.send_message.send_message));
+ parts.push_back(y_absl::StrFormat("SEND_MESSAGE ptr=%p",
+ op->data.send_message.send_message));
break;
case GRPC_OP_SEND_CLOSE_FROM_CLIENT:
- parts.push_back("SEND_CLOSE_FROM_CLIENT");
+ parts.push_back("SEND_CLOSE_FROM_CLIENT");
break;
case GRPC_OP_SEND_STATUS_FROM_SERVER:
- parts.push_back(
- y_absl::StrFormat("SEND_STATUS_FROM_SERVER status=%d details=",
- op->data.send_status_from_server.status));
+ parts.push_back(
+ y_absl::StrFormat("SEND_STATUS_FROM_SERVER status=%d details=",
+ op->data.send_status_from_server.status));
if (op->data.send_status_from_server.status_details != nullptr) {
- char* dump = grpc_dump_slice(
- *op->data.send_status_from_server.status_details, GPR_DUMP_ASCII);
- parts.push_back(dump);
- gpr_free(dump);
+ char* dump = grpc_dump_slice(
+ *op->data.send_status_from_server.status_details, GPR_DUMP_ASCII);
+ parts.push_back(dump);
+ gpr_free(dump);
} else {
- parts.push_back("(null)");
+ parts.push_back("(null)");
}
- add_metadata(op->data.send_status_from_server.trailing_metadata,
- op->data.send_status_from_server.trailing_metadata_count,
- &parts);
+ add_metadata(op->data.send_status_from_server.trailing_metadata,
+ op->data.send_status_from_server.trailing_metadata_count,
+ &parts);
break;
case GRPC_OP_RECV_INITIAL_METADATA:
- parts.push_back(y_absl::StrFormat(
- "RECV_INITIAL_METADATA ptr=%p",
- op->data.recv_initial_metadata.recv_initial_metadata));
+ parts.push_back(y_absl::StrFormat(
+ "RECV_INITIAL_METADATA ptr=%p",
+ op->data.recv_initial_metadata.recv_initial_metadata));
break;
case GRPC_OP_RECV_MESSAGE:
- parts.push_back(y_absl::StrFormat("RECV_MESSAGE ptr=%p",
- op->data.recv_message.recv_message));
+ parts.push_back(y_absl::StrFormat("RECV_MESSAGE ptr=%p",
+ op->data.recv_message.recv_message));
break;
case GRPC_OP_RECV_STATUS_ON_CLIENT:
- parts.push_back(y_absl::StrFormat(
- "RECV_STATUS_ON_CLIENT metadata=%p status=%p details=%p",
- op->data.recv_status_on_client.trailing_metadata,
- op->data.recv_status_on_client.status,
- op->data.recv_status_on_client.status_details));
+ parts.push_back(y_absl::StrFormat(
+ "RECV_STATUS_ON_CLIENT metadata=%p status=%p details=%p",
+ op->data.recv_status_on_client.trailing_metadata,
+ op->data.recv_status_on_client.status,
+ op->data.recv_status_on_client.status_details));
break;
case GRPC_OP_RECV_CLOSE_ON_SERVER:
- parts.push_back(y_absl::StrFormat("RECV_CLOSE_ON_SERVER cancelled=%p",
- op->data.recv_close_on_server.cancelled));
+ parts.push_back(y_absl::StrFormat("RECV_CLOSE_ON_SERVER cancelled=%p",
+ op->data.recv_close_on_server.cancelled));
}
- return y_absl::StrJoin(parts, "");
+ return y_absl::StrJoin(parts, "");
}
void grpc_call_log_batch(const char* file, int line, gpr_log_severity severity,
const grpc_op* ops, size_t nops) {
- for (size_t i = 0; i < nops; i++) {
- gpr_log(file, line, severity, "ops[%" PRIuPTR "]: %s", i,
- grpc_op_string(&ops[i]).c_str());
+ for (size_t i = 0; i < nops; i++) {
+ gpr_log(file, line, severity, "ops[%" PRIuPTR "]: %s", i,
+ grpc_op_string(&ops[i]).c_str());
}
}
diff --git a/contrib/libs/grpc/src/core/lib/surface/channel.cc b/contrib/libs/grpc/src/core/lib/surface/channel.cc
index 4d892b3e49..28df8e61ee 100644
--- a/contrib/libs/grpc/src/core/lib/surface/channel.cc
+++ b/contrib/libs/grpc/src/core/lib/surface/channel.cc
@@ -84,7 +84,7 @@ grpc_channel* grpc_channel_create_with_builder(
channel->target = target;
channel->resource_user = resource_user;
channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type);
- channel->registration_table.Init();
+ channel->registration_table.Init();
gpr_atm_no_barrier_store(
&channel->call_size_estimate,
@@ -183,30 +183,30 @@ void CreateChannelzNode(grpc_channel_stack_builder* builder) {
const grpc_channel_args* args =
grpc_channel_stack_builder_get_channel_arguments(builder);
// Check whether channelz is enabled.
- const bool channelz_enabled = grpc_channel_args_find_bool(
- args, GRPC_ARG_ENABLE_CHANNELZ, GRPC_ENABLE_CHANNELZ_DEFAULT);
+ const bool channelz_enabled = grpc_channel_args_find_bool(
+ args, GRPC_ARG_ENABLE_CHANNELZ, GRPC_ENABLE_CHANNELZ_DEFAULT);
if (!channelz_enabled) return;
// Get parameters needed to create the channelz node.
- const size_t channel_tracer_max_memory = grpc_channel_args_find_integer(
- args, GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE,
+ const size_t channel_tracer_max_memory = grpc_channel_args_find_integer(
+ args, GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE,
{GRPC_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE_DEFAULT, 0, INT_MAX});
- const bool is_internal_channel = grpc_channel_args_find_bool(
- args, GRPC_ARG_CHANNELZ_IS_INTERNAL_CHANNEL, false);
+ const bool is_internal_channel = grpc_channel_args_find_bool(
+ args, GRPC_ARG_CHANNELZ_IS_INTERNAL_CHANNEL, false);
// Create the channelz node.
const char* target = grpc_channel_stack_builder_get_target(builder);
grpc_core::RefCountedPtr<grpc_core::channelz::ChannelNode> channelz_node =
grpc_core::MakeRefCounted<grpc_core::channelz::ChannelNode>(
target != nullptr ? target : "", channel_tracer_max_memory,
- is_internal_channel);
+ is_internal_channel);
channelz_node->AddTraceEvent(
grpc_core::channelz::ChannelTrace::Severity::Info,
grpc_slice_from_static_string("Channel created"));
// Add channelz node to channel args.
- // We remove the is_internal_channel arg, since we no longer need it.
+ // We remove the is_internal_channel arg, since we no longer need it.
grpc_arg new_arg = grpc_channel_arg_pointer_create(
const_cast<char*>(GRPC_ARG_CHANNELZ_CHANNEL_NODE), channelz_node.get(),
&channelz_node_arg_vtable);
- const char* args_to_remove[] = {GRPC_ARG_CHANNELZ_IS_INTERNAL_CHANNEL};
+ const char* args_to_remove[] = {GRPC_ARG_CHANNELZ_IS_INTERNAL_CHANNEL};
grpc_channel_args* new_args = grpc_channel_args_copy_and_add_and_remove(
args, args_to_remove, GPR_ARRAY_SIZE(args_to_remove), &new_arg, 1);
grpc_channel_stack_builder_set_channel_arguments(builder, new_args);
@@ -317,7 +317,7 @@ char* grpc_channel_get_target(grpc_channel* channel) {
void grpc_channel_get_info(grpc_channel* channel,
const grpc_channel_info* channel_info) {
- grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
+ grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
grpc_channel_element* elem =
grpc_channel_stack_element(CHANNEL_STACK_FROM_CHANNEL(channel), 0);
@@ -325,7 +325,7 @@ void grpc_channel_get_info(grpc_channel* channel,
}
void grpc_channel_reset_connect_backoff(grpc_channel* channel) {
- grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
+ grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE("grpc_channel_reset_connect_backoff(channel=%p)", 1,
(channel));
@@ -376,7 +376,7 @@ grpc_call* grpc_channel_create_call(grpc_channel* channel,
grpc_slice method, const grpc_slice* host,
gpr_timespec deadline, void* reserved) {
GPR_ASSERT(!reserved);
- grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
+ grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
grpc_call* call = grpc_channel_create_call_internal(
channel, parent_call, propagation_mask, cq, nullptr,
@@ -401,74 +401,74 @@ grpc_call* grpc_channel_create_pollset_set_call(
deadline);
}
-namespace grpc_core {
-
-RegisteredCall::RegisteredCall(const char* method_arg, const char* host_arg)
- : method(method_arg != nullptr ? method_arg : ""),
- host(host_arg != nullptr ? host_arg : ""),
- path(grpc_mdelem_from_slices(
- GRPC_MDSTR_PATH, grpc_core::ExternallyManagedSlice(method.c_str()))),
- authority(!host.empty()
- ? grpc_mdelem_from_slices(
- GRPC_MDSTR_AUTHORITY,
- grpc_core::ExternallyManagedSlice(host.c_str()))
- : GRPC_MDNULL) {}
-
-// TODO(vjpai): Delete copy-constructor when allowed by all supported compilers.
-RegisteredCall::RegisteredCall(const RegisteredCall& other)
- : RegisteredCall(other.method.c_str(), other.host.c_str()) {}
-
-RegisteredCall::RegisteredCall(RegisteredCall&& other) noexcept
- : method(std::move(other.method)),
- host(std::move(other.host)),
- path(grpc_mdelem_from_slices(
- GRPC_MDSTR_PATH, grpc_core::ExternallyManagedSlice(method.c_str()))),
- authority(!host.empty()
- ? grpc_mdelem_from_slices(
- GRPC_MDSTR_AUTHORITY,
- grpc_core::ExternallyManagedSlice(host.c_str()))
- : GRPC_MDNULL) {
- GRPC_MDELEM_UNREF(other.path);
- GRPC_MDELEM_UNREF(other.authority);
- other.path = GRPC_MDNULL;
- other.authority = GRPC_MDNULL;
-}
-
-RegisteredCall::~RegisteredCall() {
- GRPC_MDELEM_UNREF(path);
- GRPC_MDELEM_UNREF(authority);
-}
-
-} // namespace grpc_core
-
+namespace grpc_core {
+
+RegisteredCall::RegisteredCall(const char* method_arg, const char* host_arg)
+ : method(method_arg != nullptr ? method_arg : ""),
+ host(host_arg != nullptr ? host_arg : ""),
+ path(grpc_mdelem_from_slices(
+ GRPC_MDSTR_PATH, grpc_core::ExternallyManagedSlice(method.c_str()))),
+ authority(!host.empty()
+ ? grpc_mdelem_from_slices(
+ GRPC_MDSTR_AUTHORITY,
+ grpc_core::ExternallyManagedSlice(host.c_str()))
+ : GRPC_MDNULL) {}
+
+// TODO(vjpai): Delete copy-constructor when allowed by all supported compilers.
+RegisteredCall::RegisteredCall(const RegisteredCall& other)
+ : RegisteredCall(other.method.c_str(), other.host.c_str()) {}
+
+RegisteredCall::RegisteredCall(RegisteredCall&& other) noexcept
+ : method(std::move(other.method)),
+ host(std::move(other.host)),
+ path(grpc_mdelem_from_slices(
+ GRPC_MDSTR_PATH, grpc_core::ExternallyManagedSlice(method.c_str()))),
+ authority(!host.empty()
+ ? grpc_mdelem_from_slices(
+ GRPC_MDSTR_AUTHORITY,
+ grpc_core::ExternallyManagedSlice(host.c_str()))
+ : GRPC_MDNULL) {
+ GRPC_MDELEM_UNREF(other.path);
+ GRPC_MDELEM_UNREF(other.authority);
+ other.path = GRPC_MDNULL;
+ other.authority = GRPC_MDNULL;
+}
+
+RegisteredCall::~RegisteredCall() {
+ GRPC_MDELEM_UNREF(path);
+ GRPC_MDELEM_UNREF(authority);
+}
+
+} // namespace grpc_core
+
void* grpc_channel_register_call(grpc_channel* channel, const char* method,
const char* host, void* reserved) {
GRPC_API_TRACE(
"grpc_channel_register_call(channel=%p, method=%s, host=%s, reserved=%p)",
4, (channel, method, host, reserved));
GPR_ASSERT(!reserved);
- grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
+ grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
- grpc_core::MutexLock lock(&channel->registration_table->mu);
- channel->registration_table->method_registration_attempts++;
- auto key = std::make_pair(TString(host != nullptr ? host : ""),
- TString(method != nullptr ? method : ""));
- auto rc_posn = channel->registration_table->map.find(key);
- if (rc_posn != channel->registration_table->map.end()) {
- return &rc_posn->second;
- }
- auto insertion_result = channel->registration_table->map.insert(
- {std::move(key), grpc_core::RegisteredCall(method, host)});
- return &insertion_result.first->second;
+ grpc_core::MutexLock lock(&channel->registration_table->mu);
+ channel->registration_table->method_registration_attempts++;
+ auto key = std::make_pair(TString(host != nullptr ? host : ""),
+ TString(method != nullptr ? method : ""));
+ auto rc_posn = channel->registration_table->map.find(key);
+ if (rc_posn != channel->registration_table->map.end()) {
+ return &rc_posn->second;
+ }
+ auto insertion_result = channel->registration_table->map.insert(
+ {std::move(key), grpc_core::RegisteredCall(method, host)});
+ return &insertion_result.first->second;
}
grpc_call* grpc_channel_create_registered_call(
grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask,
grpc_completion_queue* completion_queue, void* registered_call_handle,
gpr_timespec deadline, void* reserved) {
- grpc_core::RegisteredCall* rc =
- static_cast<grpc_core::RegisteredCall*>(registered_call_handle);
+ grpc_core::RegisteredCall* rc =
+ static_cast<grpc_core::RegisteredCall*>(registered_call_handle);
GRPC_API_TRACE(
"grpc_channel_create_registered_call("
"channel=%p, parent_call=%p, propagation_mask=%x, completion_queue=%p, "
@@ -481,7 +481,7 @@ grpc_call* grpc_channel_create_registered_call(
registered_call_handle, deadline.tv_sec, deadline.tv_nsec,
(int)deadline.clock_type, reserved));
GPR_ASSERT(!reserved);
- grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
+ grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
grpc_call* call = grpc_channel_create_call_internal(
channel, parent_call, propagation_mask, completion_queue, nullptr,
@@ -500,7 +500,7 @@ static void destroy_channel(void* arg, grpc_error* /*error*/) {
channel->channelz_node.reset();
}
grpc_channel_stack_destroy(CHANNEL_STACK_FROM_CHANNEL(channel));
- channel->registration_table.Destroy();
+ channel->registration_table.Destroy();
if (channel->resource_user != nullptr) {
grpc_resource_user_free(channel->resource_user,
GRPC_RESOURCE_QUOTA_CHANNEL_SIZE);
@@ -523,7 +523,7 @@ void grpc_channel_destroy_internal(grpc_channel* channel) {
}
void grpc_channel_destroy(grpc_channel* channel) {
- grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
+ grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
grpc_channel_destroy_internal(channel);
}
diff --git a/contrib/libs/grpc/src/core/lib/surface/channel.h b/contrib/libs/grpc/src/core/lib/surface/channel.h
index b9ead2c1eb..e49b9261f7 100644
--- a/contrib/libs/grpc/src/core/lib/surface/channel.h
+++ b/contrib/libs/grpc/src/core/lib/surface/channel.h
@@ -21,14 +21,14 @@
#include <grpc/support/port_platform.h>
-#include <map>
-
+#include <map>
+
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/channel/channel_stack_builder.h"
#include "src/core/lib/channel/channelz.h"
-#include "src/core/lib/gprpp/manual_constructor.h"
+#include "src/core/lib/gprpp/manual_constructor.h"
#include "src/core/lib/surface/channel_stack_type.h"
-#include "src/core/lib/transport/metadata.h"
+#include "src/core/lib/transport/metadata.h"
grpc_channel* grpc_channel_create(const char* target,
const grpc_channel_args* args,
@@ -66,40 +66,40 @@ grpc_core::channelz::ChannelNode* grpc_channel_get_channelz_node(
size_t grpc_channel_get_call_size_estimate(grpc_channel* channel);
void grpc_channel_update_call_size_estimate(grpc_channel* channel, size_t size);
-namespace grpc_core {
-
-struct RegisteredCall {
- // The method and host are kept as part of this struct just to manage their
- // lifetime since they must outlive the mdelem contents.
- TString method;
- TString host;
-
- grpc_mdelem path;
- grpc_mdelem authority;
-
- explicit RegisteredCall(const char* method_arg, const char* host_arg);
- // TODO(vjpai): delete copy constructor once all supported compilers allow
- // std::map value_type to be MoveConstructible.
- RegisteredCall(const RegisteredCall& other);
- RegisteredCall(RegisteredCall&& other) noexcept;
- RegisteredCall& operator=(const RegisteredCall&) = delete;
- RegisteredCall& operator=(RegisteredCall&&) = delete;
-
- ~RegisteredCall();
-};
-
-struct CallRegistrationTable {
- grpc_core::Mutex mu;
- // The map key should be owned strings rather than unowned char*'s to
- // guarantee that it outlives calls on the core channel (which may outlast the
- // C++ or other wrapped language Channel that registered these calls).
- std::map<std::pair<TString, TString>, RegisteredCall>
- map /* GUARDED_BY(mu) */;
- int method_registration_attempts /* GUARDED_BY(mu) */ = 0;
-};
-
-} // namespace grpc_core
-
+namespace grpc_core {
+
+struct RegisteredCall {
+ // The method and host are kept as part of this struct just to manage their
+ // lifetime since they must outlive the mdelem contents.
+ TString method;
+ TString host;
+
+ grpc_mdelem path;
+ grpc_mdelem authority;
+
+ explicit RegisteredCall(const char* method_arg, const char* host_arg);
+ // TODO(vjpai): delete copy constructor once all supported compilers allow
+ // std::map value_type to be MoveConstructible.
+ RegisteredCall(const RegisteredCall& other);
+ RegisteredCall(RegisteredCall&& other) noexcept;
+ RegisteredCall& operator=(const RegisteredCall&) = delete;
+ RegisteredCall& operator=(RegisteredCall&&) = delete;
+
+ ~RegisteredCall();
+};
+
+struct CallRegistrationTable {
+ grpc_core::Mutex mu;
+ // The map key should be owned strings rather than unowned char*'s to
+ // guarantee that it outlives calls on the core channel (which may outlast the
+ // C++ or other wrapped language Channel that registered these calls).
+ std::map<std::pair<TString, TString>, RegisteredCall>
+ map /* GUARDED_BY(mu) */;
+ int method_registration_attempts /* GUARDED_BY(mu) */ = 0;
+};
+
+} // namespace grpc_core
+
struct grpc_channel {
int is_client;
grpc_compression_options compression_options;
@@ -107,13 +107,13 @@ struct grpc_channel {
gpr_atm call_size_estimate;
grpc_resource_user* resource_user;
- // TODO(vjpai): Once the grpc_channel is allocated via new rather than malloc,
- // expand the members of the CallRegistrationTable directly into
- // the grpc_channel. For now it is kept separate so that all the
- // manual constructing can be done with a single call rather than
- // a separate manual construction for each field.
- grpc_core::ManualConstructor<grpc_core::CallRegistrationTable>
- registration_table;
+ // TODO(vjpai): Once the grpc_channel is allocated via new rather than malloc,
+ // expand the members of the CallRegistrationTable directly into
+ // the grpc_channel. For now it is kept separate so that all the
+ // manual constructing can be done with a single call rather than
+ // a separate manual construction for each field.
+ grpc_core::ManualConstructor<grpc_core::CallRegistrationTable>
+ registration_table;
grpc_core::RefCountedPtr<grpc_core::channelz::ChannelNode> channelz_node;
char* target;
@@ -161,13 +161,13 @@ inline void grpc_channel_internal_unref(grpc_channel* channel) {
grpc_channel_internal_unref(channel)
#endif
-// Return the channel's compression options.
+// Return the channel's compression options.
grpc_compression_options grpc_channel_compression_options(
const grpc_channel* channel);
-// Ping the channels peer (load balanced channels will select one sub-channel to
-// ping); if the channel is not connected, posts a failed.
-void grpc_channel_ping(grpc_channel* channel, grpc_completion_queue* cq,
- void* tag, void* reserved);
-
+// Ping the channels peer (load balanced channels will select one sub-channel to
+// ping); if the channel is not connected, posts a failed.
+void grpc_channel_ping(grpc_channel* channel, grpc_completion_queue* cq,
+ void* tag, void* reserved);
+
#endif /* GRPC_CORE_LIB_SURFACE_CHANNEL_H */
diff --git a/contrib/libs/grpc/src/core/lib/surface/completion_queue.cc b/contrib/libs/grpc/src/core/lib/surface/completion_queue.cc
index 49d2ff99bc..0f50906734 100644
--- a/contrib/libs/grpc/src/core/lib/surface/completion_queue.cc
+++ b/contrib/libs/grpc/src/core/lib/surface/completion_queue.cc
@@ -23,11 +23,11 @@
#include <stdio.h>
#include <string.h>
-#include <vector>
-
-#include "y_absl/strings/str_format.h"
-#include "y_absl/strings/str_join.h"
-
+#include <vector>
+
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/str_join.h"
+
#include <grpc/support/alloc.h>
#include <grpc/support/atm.h>
#include <grpc/support/log.h>
@@ -243,14 +243,14 @@ class CqEventQueue {
};
struct cq_next_data {
- ~cq_next_data() {
- GPR_ASSERT(queue.num_items() == 0);
-#ifndef NDEBUG
- if (pending_events.Load(grpc_core::MemoryOrder::ACQUIRE) != 0) {
- gpr_log(GPR_ERROR, "Destroying CQ without draining it fully.");
- }
-#endif
- }
+ ~cq_next_data() {
+ GPR_ASSERT(queue.num_items() == 0);
+#ifndef NDEBUG
+ if (pending_events.Load(grpc_core::MemoryOrder::ACQUIRE) != 0) {
+ gpr_log(GPR_ERROR, "Destroying CQ without draining it fully.");
+ }
+#endif
+ }
/** Completed events for completion-queues of type GRPC_CQ_NEXT */
CqEventQueue queue;
@@ -276,11 +276,11 @@ struct cq_pluck_data {
~cq_pluck_data() {
GPR_ASSERT(completed_head.next ==
reinterpret_cast<uintptr_t>(&completed_head));
-#ifndef NDEBUG
- if (pending_events.Load(grpc_core::MemoryOrder::ACQUIRE) != 0) {
- gpr_log(GPR_ERROR, "Destroying CQ without draining it fully.");
- }
-#endif
+#ifndef NDEBUG
+ if (pending_events.Load(grpc_core::MemoryOrder::ACQUIRE) != 0) {
+ gpr_log(GPR_ERROR, "Destroying CQ without draining it fully.");
+ }
+#endif
}
/** Completed events for completion-queues of type GRPC_CQ_PLUCK */
@@ -312,15 +312,15 @@ struct cq_callback_data {
cq_callback_data(
grpc_experimental_completion_queue_functor* shutdown_callback)
: shutdown_callback(shutdown_callback) {}
-
- ~cq_callback_data() {
-#ifndef NDEBUG
- if (pending_events.Load(grpc_core::MemoryOrder::ACQUIRE) != 0) {
- gpr_log(GPR_ERROR, "Destroying CQ without draining it fully.");
- }
-#endif
- }
-
+
+ ~cq_callback_data() {
+#ifndef NDEBUG
+ if (pending_events.Load(grpc_core::MemoryOrder::ACQUIRE) != 0) {
+ gpr_log(GPR_ERROR, "Destroying CQ without draining it fully.");
+ }
+#endif
+ }
+
/** No actual completed events queue, unlike other types */
/** Number of pending events (+1 if we're not shutdown).
@@ -428,14 +428,14 @@ static const cq_vtable g_cq_vtable[] = {
grpc_core::TraceFlag grpc_cq_pluck_trace(false, "queue_pluck");
-#define GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, event) \
- do { \
- if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace) && \
- (GRPC_TRACE_FLAG_ENABLED(grpc_cq_pluck_trace) || \
- (event)->type != GRPC_QUEUE_TIMEOUT)) { \
- gpr_log(GPR_INFO, "RETURN_EVENT[%p]: %s", cq, \
- grpc_event_string(event).c_str()); \
- } \
+#define GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, event) \
+ do { \
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace) && \
+ (GRPC_TRACE_FLAG_ENABLED(grpc_cq_pluck_trace) || \
+ (event)->type != GRPC_QUEUE_TIMEOUT)) { \
+ gpr_log(GPR_INFO, "RETURN_EVENT[%p]: %s", cq, \
+ grpc_event_string(event).c_str()); \
+ } \
} while (0)
static void on_pollset_shutdown_done(void* cq, grpc_error* error);
@@ -870,15 +870,15 @@ static void cq_end_op_for_callback(
cq_finish_shutdown_callback(cq);
}
- // If possible, schedule the callback onto an existing thread-local
- // ApplicationCallbackExecCtx, which is a work queue. This is possible for:
- // 1. The callback is internally-generated and there is an ACEC available
- // 2. The callback is marked inlineable and there is an ACEC available
- // 3. We are already running in a background poller thread (which always has
- // an ACEC available at the base of the stack).
+ // If possible, schedule the callback onto an existing thread-local
+ // ApplicationCallbackExecCtx, which is a work queue. This is possible for:
+ // 1. The callback is internally-generated and there is an ACEC available
+ // 2. The callback is marked inlineable and there is an ACEC available
+ // 3. We are already running in a background poller thread (which always has
+ // an ACEC available at the base of the stack).
auto* functor = static_cast<grpc_experimental_completion_queue_functor*>(tag);
- if (((internal || functor->inlineable) &&
- grpc_core::ApplicationCallbackExecCtx::Available()) ||
+ if (((internal || functor->inlineable) &&
+ grpc_core::ApplicationCallbackExecCtx::Available()) ||
grpc_iomgr_is_any_background_poller_thread()) {
grpc_core::ApplicationCallbackExecCtx::Enqueue(functor,
(error == GRPC_ERROR_NONE));
@@ -946,14 +946,14 @@ class ExecCtxNext : public grpc_core::ExecCtx {
#ifndef NDEBUG
static void dump_pending_tags(grpc_completion_queue* cq) {
if (!GRPC_TRACE_FLAG_ENABLED(grpc_trace_pending_tags)) return;
- std::vector<TString> parts;
- parts.push_back("PENDING TAGS:");
+ std::vector<TString> parts;
+ parts.push_back("PENDING TAGS:");
gpr_mu_lock(cq->mu);
for (size_t i = 0; i < cq->outstanding_tag_count; i++) {
- parts.push_back(y_absl::StrFormat(" %p", cq->outstanding_tags[i]));
+ parts.push_back(y_absl::StrFormat(" %p", cq->outstanding_tags[i]));
}
gpr_mu_unlock(cq->mu);
- gpr_log(GPR_DEBUG, "%s", y_absl::StrJoin(parts, "").c_str());
+ gpr_log(GPR_DEBUG, "%s", y_absl::StrJoin(parts, "").c_str());
}
#else
static void dump_pending_tags(grpc_completion_queue* /*cq*/) {}
diff --git a/contrib/libs/grpc/src/core/lib/surface/event_string.cc b/contrib/libs/grpc/src/core/lib/surface/event_string.cc
index 4af497bad2..d69aac6dee 100644
--- a/contrib/libs/grpc/src/core/lib/surface/event_string.cc
+++ b/contrib/libs/grpc/src/core/lib/surface/event_string.cc
@@ -22,40 +22,40 @@
#include <stdio.h>
-#include <vector>
-
-#include "y_absl/strings/str_format.h"
-#include "y_absl/strings/str_join.h"
-
+#include <vector>
+
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/str_join.h"
+
#include <grpc/byte_buffer.h>
#include <grpc/support/string_util.h>
#include "src/core/lib/gpr/string.h"
-static void addhdr(grpc_event* ev, std::vector<TString>* buf) {
- buf->push_back(y_absl::StrFormat("tag:%p", ev->tag));
+static void addhdr(grpc_event* ev, std::vector<TString>* buf) {
+ buf->push_back(y_absl::StrFormat("tag:%p", ev->tag));
}
static const char* errstr(int success) { return success ? "OK" : "ERROR"; }
-static void adderr(int success, std::vector<TString>* buf) {
- buf->push_back(y_absl::StrFormat(" %s", errstr(success)));
+static void adderr(int success, std::vector<TString>* buf) {
+ buf->push_back(y_absl::StrFormat(" %s", errstr(success)));
}
-TString grpc_event_string(grpc_event* ev) {
- if (ev == nullptr) return "null";
- std::vector<TString> out;
+TString grpc_event_string(grpc_event* ev) {
+ if (ev == nullptr) return "null";
+ std::vector<TString> out;
switch (ev->type) {
case GRPC_QUEUE_TIMEOUT:
- out.push_back("QUEUE_TIMEOUT");
+ out.push_back("QUEUE_TIMEOUT");
break;
case GRPC_QUEUE_SHUTDOWN:
- out.push_back("QUEUE_SHUTDOWN");
+ out.push_back("QUEUE_SHUTDOWN");
break;
case GRPC_OP_COMPLETE:
- out.push_back("OP_COMPLETE: ");
- addhdr(ev, &out);
- adderr(ev->success, &out);
+ out.push_back("OP_COMPLETE: ");
+ addhdr(ev, &out);
+ adderr(ev->success, &out);
break;
}
- return y_absl::StrJoin(out, "");
+ return y_absl::StrJoin(out, "");
}
diff --git a/contrib/libs/grpc/src/core/lib/surface/event_string.h b/contrib/libs/grpc/src/core/lib/surface/event_string.h
index 76a0f5152d..f4ad847b3c 100644
--- a/contrib/libs/grpc/src/core/lib/surface/event_string.h
+++ b/contrib/libs/grpc/src/core/lib/surface/event_string.h
@@ -21,11 +21,11 @@
#include <grpc/support/port_platform.h>
-#include <util/generic/string.h>
-
+#include <util/generic/string.h>
+
#include <grpc/grpc.h>
/* Returns a string describing an event. Must be later freed with gpr_free() */
-TString grpc_event_string(grpc_event* ev);
+TString grpc_event_string(grpc_event* ev);
#endif /* GRPC_CORE_LIB_SURFACE_EVENT_STRING_H */
diff --git a/contrib/libs/grpc/src/core/lib/surface/init.cc b/contrib/libs/grpc/src/core/lib/surface/init.cc
index 41342e84d0..7b79ba426b 100644
--- a/contrib/libs/grpc/src/core/lib/surface/init.cc
+++ b/contrib/libs/grpc/src/core/lib/surface/init.cc
@@ -18,8 +18,8 @@
#include <grpc/support/port_platform.h>
-#include "src/core/lib/surface/init.h"
-
+#include "src/core/lib/surface/init.h"
+
#include <limits.h>
#include <memory.h>
@@ -28,7 +28,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
-
+
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/channel/channelz_registry.h"
#include "src/core/lib/channel/connected_channel.h"
@@ -40,7 +40,7 @@
#include "src/core/lib/http/parser.h"
#include "src/core/lib/iomgr/call_combiner.h"
#include "src/core/lib/iomgr/combiner.h"
-#include "src/core/lib/iomgr/exec_ctx.h"
+#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/iomgr/iomgr.h"
#include "src/core/lib/iomgr/resource_quota.h"
@@ -105,7 +105,7 @@ static void register_builtin_channel_init() {
GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
append_filter, (void*)&grpc_lame_filter);
grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX, prepend_filter,
- (void*)&grpc_core::Server::kServerTopFilter);
+ (void*)&grpc_core::Server::kServerTopFilter);
}
typedef struct grpc_plugin {
@@ -214,29 +214,29 @@ void grpc_shutdown_internal(void* /*ignored*/) {
void grpc_shutdown(void) {
GRPC_API_TRACE("grpc_shutdown(void)", 0, ());
grpc_core::MutexLock lock(&g_init_mu);
-
+
if (--g_initializations == 0) {
- grpc_core::ApplicationCallbackExecCtx* acec =
- grpc_core::ApplicationCallbackExecCtx::Get();
- if (!grpc_iomgr_is_any_background_poller_thread() &&
- (acec == nullptr ||
- (acec->Flags() & GRPC_APP_CALLBACK_EXEC_CTX_FLAG_IS_INTERNAL_THREAD) ==
- 0)) {
- // just run clean-up when this is called on non-executor thread.
- gpr_log(GPR_DEBUG, "grpc_shutdown starts clean-up now");
- g_shutting_down = true;
- grpc_shutdown_internal_locked();
- } else {
- // spawn a detached thread to do the actual clean up in case we are
- // currently in an executor thread.
- gpr_log(GPR_DEBUG, "grpc_shutdown spawns clean-up thread");
- g_initializations++;
- g_shutting_down = true;
- grpc_core::Thread cleanup_thread(
- "grpc_shutdown", grpc_shutdown_internal, nullptr, nullptr,
- grpc_core::Thread::Options().set_joinable(false).set_tracked(false));
- cleanup_thread.Start();
- }
+ grpc_core::ApplicationCallbackExecCtx* acec =
+ grpc_core::ApplicationCallbackExecCtx::Get();
+ if (!grpc_iomgr_is_any_background_poller_thread() &&
+ (acec == nullptr ||
+ (acec->Flags() & GRPC_APP_CALLBACK_EXEC_CTX_FLAG_IS_INTERNAL_THREAD) ==
+ 0)) {
+ // just run clean-up when this is called on non-executor thread.
+ gpr_log(GPR_DEBUG, "grpc_shutdown starts clean-up now");
+ g_shutting_down = true;
+ grpc_shutdown_internal_locked();
+ } else {
+ // spawn a detached thread to do the actual clean up in case we are
+ // currently in an executor thread.
+ gpr_log(GPR_DEBUG, "grpc_shutdown spawns clean-up thread");
+ g_initializations++;
+ g_shutting_down = true;
+ grpc_core::Thread cleanup_thread(
+ "grpc_shutdown", grpc_shutdown_internal, nullptr, nullptr,
+ grpc_core::Thread::Options().set_joinable(false).set_tracked(false));
+ cleanup_thread.Start();
+ }
}
}
diff --git a/contrib/libs/grpc/src/core/lib/surface/init_secure.cc b/contrib/libs/grpc/src/core/lib/surface/init_secure.cc
index 4826f12132..428c5815c9 100644
--- a/contrib/libs/grpc/src/core/lib/surface/init_secure.cc
+++ b/contrib/libs/grpc/src/core/lib/surface/init_secure.cc
@@ -78,4 +78,4 @@ void grpc_register_security_filters(void) {
maybe_prepend_server_auth_filter, nullptr);
}
-void grpc_security_init() { grpc_core::SecurityRegisterHandshakerFactories(); }
+void grpc_security_init() { grpc_core::SecurityRegisterHandshakerFactories(); }
diff --git a/contrib/libs/grpc/src/core/lib/surface/server.cc b/contrib/libs/grpc/src/core/lib/surface/server.cc
index 4d5f1a56d5..0775c6ee4c 100644
--- a/contrib/libs/grpc/src/core/lib/surface/server.cc
+++ b/contrib/libs/grpc/src/core/lib/surface/server.cc
@@ -1,18 +1,18 @@
-//
-// Copyright 2015-2016 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+//
+// Copyright 2015-2016 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
#include <grpc/support/port_platform.h>
@@ -22,16 +22,16 @@
#include <stdlib.h>
#include <string.h>
-#include <algorithm>
-#include <atomic>
-#include <iterator>
-#include <list>
-#include <queue>
-#include <utility>
-#include <vector>
-
-#include "y_absl/types/optional.h"
-
+#include <algorithm>
+#include <atomic>
+#include <iterator>
+#include <list>
+#include <queue>
+#include <utility>
+#include <vector>
+
+#include "y_absl/types/optional.h"
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
@@ -54,1044 +54,1044 @@
#include "src/core/lib/transport/metadata.h"
#include "src/core/lib/transport/static_metadata.h"
-namespace grpc_core {
-
-TraceFlag grpc_server_channel_trace(false, "server_channel");
-
-//
-// Server::RequestedCall
-//
-
-struct Server::RequestedCall {
- enum class Type { BATCH_CALL, REGISTERED_CALL };
-
- RequestedCall(void* tag_arg, grpc_completion_queue* call_cq,
- grpc_call** call_arg, grpc_metadata_array* initial_md,
- grpc_call_details* details)
- : type(Type::BATCH_CALL),
- tag(tag_arg),
- cq_bound_to_call(call_cq),
- call(call_arg),
- initial_metadata(initial_md) {
- details->reserved = nullptr;
- data.batch.details = details;
- }
-
- RequestedCall(void* tag_arg, grpc_completion_queue* call_cq,
- grpc_call** call_arg, grpc_metadata_array* initial_md,
- RegisteredMethod* rm, gpr_timespec* deadline,
- grpc_byte_buffer** optional_payload)
- : type(Type::REGISTERED_CALL),
- tag(tag_arg),
- cq_bound_to_call(call_cq),
- call(call_arg),
- initial_metadata(initial_md) {
- data.registered.method = rm;
- data.registered.deadline = deadline;
- data.registered.optional_payload = optional_payload;
- }
-
- MultiProducerSingleConsumerQueue::Node mpscq_node;
- const Type type;
- void* const tag;
- grpc_completion_queue* const cq_bound_to_call;
- grpc_call** const call;
+namespace grpc_core {
+
+TraceFlag grpc_server_channel_trace(false, "server_channel");
+
+//
+// Server::RequestedCall
+//
+
+struct Server::RequestedCall {
+ enum class Type { BATCH_CALL, REGISTERED_CALL };
+
+ RequestedCall(void* tag_arg, grpc_completion_queue* call_cq,
+ grpc_call** call_arg, grpc_metadata_array* initial_md,
+ grpc_call_details* details)
+ : type(Type::BATCH_CALL),
+ tag(tag_arg),
+ cq_bound_to_call(call_cq),
+ call(call_arg),
+ initial_metadata(initial_md) {
+ details->reserved = nullptr;
+ data.batch.details = details;
+ }
+
+ RequestedCall(void* tag_arg, grpc_completion_queue* call_cq,
+ grpc_call** call_arg, grpc_metadata_array* initial_md,
+ RegisteredMethod* rm, gpr_timespec* deadline,
+ grpc_byte_buffer** optional_payload)
+ : type(Type::REGISTERED_CALL),
+ tag(tag_arg),
+ cq_bound_to_call(call_cq),
+ call(call_arg),
+ initial_metadata(initial_md) {
+ data.registered.method = rm;
+ data.registered.deadline = deadline;
+ data.registered.optional_payload = optional_payload;
+ }
+
+ MultiProducerSingleConsumerQueue::Node mpscq_node;
+ const Type type;
+ void* const tag;
+ grpc_completion_queue* const cq_bound_to_call;
+ grpc_call** const call;
grpc_cq_completion completion;
- grpc_metadata_array* const initial_metadata;
+ grpc_metadata_array* const initial_metadata;
union {
struct {
grpc_call_details* details;
} batch;
struct {
- RegisteredMethod* method;
+ RegisteredMethod* method;
gpr_timespec* deadline;
grpc_byte_buffer** optional_payload;
} registered;
} data;
};
-//
-// Server::RegisteredMethod
-//
-
-struct Server::RegisteredMethod {
- RegisteredMethod(
- const char* method_arg, const char* host_arg,
- grpc_server_register_method_payload_handling payload_handling_arg,
- uint32_t flags_arg)
- : method(method_arg == nullptr ? "" : method_arg),
- host(host_arg == nullptr ? "" : host_arg),
- payload_handling(payload_handling_arg),
- flags(flags_arg) {}
-
- ~RegisteredMethod() = default;
-
- const TString method;
- const TString host;
- const grpc_server_register_method_payload_handling payload_handling;
- const uint32_t flags;
- // One request matcher per method.
- std::unique_ptr<RequestMatcherInterface> matcher;
-};
-
-//
-// Server::RequestMatcherInterface
-//
-
-// RPCs that come in from the transport must be matched against RPC requests
-// from the application. An incoming request from the application can be matched
-// to an RPC that has already arrived or can be queued up for later use.
-// Likewise, an RPC coming in from the transport can either be matched to a
-// request that already arrived from the application or can be queued up for
-// later use (marked pending). If there is a match, the request's tag is posted
-// on the request's notification CQ.
-//
-// RequestMatcherInterface is the base class to provide this functionality.
-class Server::RequestMatcherInterface {
- public:
- virtual ~RequestMatcherInterface() {}
-
- // Unref the calls associated with any incoming RPCs in the pending queue (not
- // yet matched to an application-requested RPC).
- virtual void ZombifyPending() = 0;
-
- // Mark all application-requested RPCs failed if they have not been matched to
- // an incoming RPC. The error parameter indicates why the RPCs are being
- // failed (always server shutdown in all current implementations).
- virtual void KillRequests(grpc_error* error) = 0;
-
- // How many request queues are supported by this matcher. This is an abstract
- // concept that essentially maps to gRPC completion queues.
- virtual size_t request_queue_count() const = 0;
-
- // This function is invoked when the application requests a new RPC whose
- // information is in the call parameter. The request_queue_index marks the
- // queue onto which to place this RPC, and is typically associated with a gRPC
- // CQ. If there are pending RPCs waiting to be matched, publish one (match it
- // and notify the CQ).
- virtual void RequestCallWithPossiblePublish(size_t request_queue_index,
- RequestedCall* call) = 0;
-
- // This function is invoked on an incoming RPC, represented by the calld
- // object. The RequestMatcher will try to match it against an
- // application-requested RPC if possible or will place it in the pending queue
- // otherwise. To enable some measure of fairness between server CQs, the match
- // is done starting at the start_request_queue_index parameter in a cyclic
- // order rather than always starting at 0.
- virtual void MatchOrQueue(size_t start_request_queue_index,
- CallData* calld) = 0;
-
- // Returns the server associated with this request matcher
- virtual Server* server() const = 0;
-};
-
-// The RealRequestMatcher is an implementation of RequestMatcherInterface that
-// actually uses all the features of RequestMatcherInterface: expecting the
-// application to explicitly request RPCs and then matching those to incoming
-// RPCs, along with a slow path by which incoming RPCs are put on a locked
-// pending list if they aren't able to be matched to an application request.
-class Server::RealRequestMatcher : public RequestMatcherInterface {
- public:
- explicit RealRequestMatcher(Server* server)
- : server_(server), requests_per_cq_(server->cqs_.size()) {}
-
- ~RealRequestMatcher() override {
- for (LockedMultiProducerSingleConsumerQueue& queue : requests_per_cq_) {
- GPR_ASSERT(queue.Pop() == nullptr);
- }
- }
-
- void ZombifyPending() override {
- while (!pending_.empty()) {
- CallData* calld = pending_.front();
- calld->SetState(CallData::CallState::ZOMBIED);
- calld->KillZombie();
- pending_.pop();
- }
- }
-
- void KillRequests(grpc_error* error) override {
- for (size_t i = 0; i < requests_per_cq_.size(); i++) {
- RequestedCall* rc;
- while ((rc = reinterpret_cast<RequestedCall*>(
- requests_per_cq_[i].Pop())) != nullptr) {
- server_->FailCall(i, rc, GRPC_ERROR_REF(error));
- }
- }
- GRPC_ERROR_UNREF(error);
- }
-
- size_t request_queue_count() const override {
- return requests_per_cq_.size();
- }
-
- void RequestCallWithPossiblePublish(size_t request_queue_index,
- RequestedCall* call) override {
- if (requests_per_cq_[request_queue_index].Push(&call->mpscq_node)) {
- /* this was the first queued request: we need to lock and start
- matching calls */
- struct PendingCall {
- RequestedCall* rc = nullptr;
- CallData* calld;
- };
- auto pop_next_pending = [this, request_queue_index] {
- PendingCall pending_call;
- {
- MutexLock lock(&server_->mu_call_);
- if (!pending_.empty()) {
- pending_call.rc = reinterpret_cast<RequestedCall*>(
- requests_per_cq_[request_queue_index].Pop());
- if (pending_call.rc != nullptr) {
- pending_call.calld = pending_.front();
- pending_.pop();
- }
- }
- }
- return pending_call;
- };
- while (true) {
- PendingCall next_pending = pop_next_pending();
- if (next_pending.rc == nullptr) break;
- if (!next_pending.calld->MaybeActivate()) {
- // Zombied Call
- next_pending.calld->KillZombie();
- } else {
- next_pending.calld->Publish(request_queue_index, next_pending.rc);
- }
- }
+//
+// Server::RegisteredMethod
+//
+
+struct Server::RegisteredMethod {
+ RegisteredMethod(
+ const char* method_arg, const char* host_arg,
+ grpc_server_register_method_payload_handling payload_handling_arg,
+ uint32_t flags_arg)
+ : method(method_arg == nullptr ? "" : method_arg),
+ host(host_arg == nullptr ? "" : host_arg),
+ payload_handling(payload_handling_arg),
+ flags(flags_arg) {}
+
+ ~RegisteredMethod() = default;
+
+ const TString method;
+ const TString host;
+ const grpc_server_register_method_payload_handling payload_handling;
+ const uint32_t flags;
+ // One request matcher per method.
+ std::unique_ptr<RequestMatcherInterface> matcher;
+};
+
+//
+// Server::RequestMatcherInterface
+//
+
+// RPCs that come in from the transport must be matched against RPC requests
+// from the application. An incoming request from the application can be matched
+// to an RPC that has already arrived or can be queued up for later use.
+// Likewise, an RPC coming in from the transport can either be matched to a
+// request that already arrived from the application or can be queued up for
+// later use (marked pending). If there is a match, the request's tag is posted
+// on the request's notification CQ.
+//
+// RequestMatcherInterface is the base class to provide this functionality.
+class Server::RequestMatcherInterface {
+ public:
+ virtual ~RequestMatcherInterface() {}
+
+ // Unref the calls associated with any incoming RPCs in the pending queue (not
+ // yet matched to an application-requested RPC).
+ virtual void ZombifyPending() = 0;
+
+ // Mark all application-requested RPCs failed if they have not been matched to
+ // an incoming RPC. The error parameter indicates why the RPCs are being
+ // failed (always server shutdown in all current implementations).
+ virtual void KillRequests(grpc_error* error) = 0;
+
+ // How many request queues are supported by this matcher. This is an abstract
+ // concept that essentially maps to gRPC completion queues.
+ virtual size_t request_queue_count() const = 0;
+
+ // This function is invoked when the application requests a new RPC whose
+ // information is in the call parameter. The request_queue_index marks the
+ // queue onto which to place this RPC, and is typically associated with a gRPC
+ // CQ. If there are pending RPCs waiting to be matched, publish one (match it
+ // and notify the CQ).
+ virtual void RequestCallWithPossiblePublish(size_t request_queue_index,
+ RequestedCall* call) = 0;
+
+ // This function is invoked on an incoming RPC, represented by the calld
+ // object. The RequestMatcher will try to match it against an
+ // application-requested RPC if possible or will place it in the pending queue
+ // otherwise. To enable some measure of fairness between server CQs, the match
+ // is done starting at the start_request_queue_index parameter in a cyclic
+ // order rather than always starting at 0.
+ virtual void MatchOrQueue(size_t start_request_queue_index,
+ CallData* calld) = 0;
+
+ // Returns the server associated with this request matcher
+ virtual Server* server() const = 0;
+};
+
+// The RealRequestMatcher is an implementation of RequestMatcherInterface that
+// actually uses all the features of RequestMatcherInterface: expecting the
+// application to explicitly request RPCs and then matching those to incoming
+// RPCs, along with a slow path by which incoming RPCs are put on a locked
+// pending list if they aren't able to be matched to an application request.
+class Server::RealRequestMatcher : public RequestMatcherInterface {
+ public:
+ explicit RealRequestMatcher(Server* server)
+ : server_(server), requests_per_cq_(server->cqs_.size()) {}
+
+ ~RealRequestMatcher() override {
+ for (LockedMultiProducerSingleConsumerQueue& queue : requests_per_cq_) {
+ GPR_ASSERT(queue.Pop() == nullptr);
+ }
+ }
+
+ void ZombifyPending() override {
+ while (!pending_.empty()) {
+ CallData* calld = pending_.front();
+ calld->SetState(CallData::CallState::ZOMBIED);
+ calld->KillZombie();
+ pending_.pop();
+ }
+ }
+
+ void KillRequests(grpc_error* error) override {
+ for (size_t i = 0; i < requests_per_cq_.size(); i++) {
+ RequestedCall* rc;
+ while ((rc = reinterpret_cast<RequestedCall*>(
+ requests_per_cq_[i].Pop())) != nullptr) {
+ server_->FailCall(i, rc, GRPC_ERROR_REF(error));
+ }
+ }
+ GRPC_ERROR_UNREF(error);
+ }
+
+ size_t request_queue_count() const override {
+ return requests_per_cq_.size();
+ }
+
+ void RequestCallWithPossiblePublish(size_t request_queue_index,
+ RequestedCall* call) override {
+ if (requests_per_cq_[request_queue_index].Push(&call->mpscq_node)) {
+ /* this was the first queued request: we need to lock and start
+ matching calls */
+ struct PendingCall {
+ RequestedCall* rc = nullptr;
+ CallData* calld;
+ };
+ auto pop_next_pending = [this, request_queue_index] {
+ PendingCall pending_call;
+ {
+ MutexLock lock(&server_->mu_call_);
+ if (!pending_.empty()) {
+ pending_call.rc = reinterpret_cast<RequestedCall*>(
+ requests_per_cq_[request_queue_index].Pop());
+ if (pending_call.rc != nullptr) {
+ pending_call.calld = pending_.front();
+ pending_.pop();
+ }
+ }
+ }
+ return pending_call;
+ };
+ while (true) {
+ PendingCall next_pending = pop_next_pending();
+ if (next_pending.rc == nullptr) break;
+ if (!next_pending.calld->MaybeActivate()) {
+ // Zombied Call
+ next_pending.calld->KillZombie();
+ } else {
+ next_pending.calld->Publish(request_queue_index, next_pending.rc);
+ }
+ }
+ }
+ }
+
+ void MatchOrQueue(size_t start_request_queue_index,
+ CallData* calld) override {
+ for (size_t i = 0; i < requests_per_cq_.size(); i++) {
+ size_t cq_idx = (start_request_queue_index + i) % requests_per_cq_.size();
+ RequestedCall* rc =
+ reinterpret_cast<RequestedCall*>(requests_per_cq_[cq_idx].TryPop());
+ if (rc != nullptr) {
+ GRPC_STATS_INC_SERVER_CQS_CHECKED(i);
+ calld->SetState(CallData::CallState::ACTIVATED);
+ calld->Publish(cq_idx, rc);
+ return;
+ }
+ }
+ // No cq to take the request found; queue it on the slow list.
+ GRPC_STATS_INC_SERVER_SLOWPATH_REQUESTS_QUEUED();
+ // We need to ensure that all the queues are empty. We do this under
+ // the server mu_call_ lock to ensure that if something is added to
+ // an empty request queue, it will block until the call is actually
+ // added to the pending list.
+ RequestedCall* rc = nullptr;
+ size_t cq_idx = 0;
+ size_t loop_count;
+ {
+ MutexLock lock(&server_->mu_call_);
+ for (loop_count = 0; loop_count < requests_per_cq_.size(); loop_count++) {
+ cq_idx =
+ (start_request_queue_index + loop_count) % requests_per_cq_.size();
+ rc = reinterpret_cast<RequestedCall*>(requests_per_cq_[cq_idx].Pop());
+ if (rc != nullptr) {
+ break;
+ }
+ }
+ if (rc == nullptr) {
+ calld->SetState(CallData::CallState::PENDING);
+ pending_.push(calld);
+ return;
+ }
+ }
+ GRPC_STATS_INC_SERVER_CQS_CHECKED(loop_count + requests_per_cq_.size());
+ calld->SetState(CallData::CallState::ACTIVATED);
+ calld->Publish(cq_idx, rc);
+ }
+
+ Server* server() const override { return server_; }
+
+ private:
+ Server* const server_;
+ std::queue<CallData*> pending_;
+ std::vector<LockedMultiProducerSingleConsumerQueue> requests_per_cq_;
+};
+
+// AllocatingRequestMatchers don't allow the application to request an RPC in
+// advance or queue up any incoming RPC for later match. Instead, MatchOrQueue
+// will call out to an allocation function passed in at the construction of the
+// object. These request matchers are designed for the C++ callback API, so they
+// only support 1 completion queue (passed in at the constructor).
+class Server::AllocatingRequestMatcherBase : public RequestMatcherInterface {
+ public:
+ AllocatingRequestMatcherBase(Server* server, grpc_completion_queue* cq)
+ : server_(server), cq_(cq) {
+ size_t idx;
+ for (idx = 0; idx < server->cqs_.size(); idx++) {
+ if (server->cqs_[idx] == cq) {
+ break;
+ }
+ }
+ GPR_ASSERT(idx < server->cqs_.size());
+ cq_idx_ = idx;
+ }
+
+ void ZombifyPending() override {}
+
+ void KillRequests(grpc_error* error) override { GRPC_ERROR_UNREF(error); }
+
+ size_t request_queue_count() const override { return 0; }
+
+ void RequestCallWithPossiblePublish(size_t /*request_queue_index*/,
+ RequestedCall* /*call*/) final {
+ GPR_ASSERT(false);
+ }
+
+ Server* server() const override { return server_; }
+
+ // Supply the completion queue related to this request matcher
+ grpc_completion_queue* cq() const { return cq_; }
+
+ // Supply the completion queue's index relative to the server.
+ size_t cq_idx() const { return cq_idx_; }
+
+ private:
+ Server* const server_;
+ grpc_completion_queue* const cq_;
+ size_t cq_idx_;
+};
+
+// An allocating request matcher for non-registered methods (used for generic
+// API and unimplemented RPCs).
+class Server::AllocatingRequestMatcherBatch
+ : public AllocatingRequestMatcherBase {
+ public:
+ AllocatingRequestMatcherBatch(Server* server, grpc_completion_queue* cq,
+ std::function<BatchCallAllocation()> allocator)
+ : AllocatingRequestMatcherBase(server, cq),
+ allocator_(std::move(allocator)) {}
+
+ void MatchOrQueue(size_t /*start_request_queue_index*/,
+ CallData* calld) override {
+ BatchCallAllocation call_info = allocator_();
+ GPR_ASSERT(server()->ValidateServerRequest(
+ cq(), static_cast<void*>(call_info.tag), nullptr, nullptr) ==
+ GRPC_CALL_OK);
+ RequestedCall* rc = new RequestedCall(
+ static_cast<void*>(call_info.tag), cq(), call_info.call,
+ call_info.initial_metadata, call_info.details);
+ calld->SetState(CallData::CallState::ACTIVATED);
+ calld->Publish(cq_idx(), rc);
+ }
+
+ private:
+ std::function<BatchCallAllocation()> allocator_;
+};
+
+// An allocating request matcher for registered methods.
+class Server::AllocatingRequestMatcherRegistered
+ : public AllocatingRequestMatcherBase {
+ public:
+ AllocatingRequestMatcherRegistered(
+ Server* server, grpc_completion_queue* cq, RegisteredMethod* rm,
+ std::function<RegisteredCallAllocation()> allocator)
+ : AllocatingRequestMatcherBase(server, cq),
+ registered_method_(rm),
+ allocator_(std::move(allocator)) {}
+
+ void MatchOrQueue(size_t /*start_request_queue_index*/,
+ CallData* calld) override {
+ RegisteredCallAllocation call_info = allocator_();
+ GPR_ASSERT(
+ server()->ValidateServerRequest(cq(), static_cast<void*>(call_info.tag),
+ call_info.optional_payload,
+ registered_method_) == GRPC_CALL_OK);
+ RequestedCall* rc = new RequestedCall(
+ static_cast<void*>(call_info.tag), cq(), call_info.call,
+ call_info.initial_metadata, registered_method_, call_info.deadline,
+ call_info.optional_payload);
+ calld->SetState(CallData::CallState::ACTIVATED);
+ calld->Publish(cq_idx(), rc);
+ }
+
+ private:
+ RegisteredMethod* const registered_method_;
+ std::function<RegisteredCallAllocation()> allocator_;
+};
+
+//
+// ChannelBroadcaster
+//
+
+namespace {
+
+class ChannelBroadcaster {
+ public:
+ // This can have an empty constructor and destructor since we want to control
+ // when the actual setup and shutdown broadcast take place.
+
+ // Copies over the channels from the locked server.
+ void FillChannelsLocked(std::vector<grpc_channel*> channels) {
+ GPR_DEBUG_ASSERT(channels_.empty());
+ channels_ = std::move(channels);
+ }
+
+ // Broadcasts a shutdown on each channel.
+ void BroadcastShutdown(bool send_goaway, grpc_error* force_disconnect) {
+ for (grpc_channel* channel : channels_) {
+ SendShutdown(channel, send_goaway, GRPC_ERROR_REF(force_disconnect));
+ GRPC_CHANNEL_INTERNAL_UNREF(channel, "broadcast");
+ }
+ channels_.clear(); // just for safety against double broadcast
+ GRPC_ERROR_UNREF(force_disconnect);
+ }
+
+ private:
+ struct ShutdownCleanupArgs {
+ grpc_closure closure;
+ grpc_slice slice;
+ };
+
+ static void ShutdownCleanup(void* arg, grpc_error* /*error*/) {
+ ShutdownCleanupArgs* a = static_cast<ShutdownCleanupArgs*>(arg);
+ grpc_slice_unref_internal(a->slice);
+ delete a;
+ }
+
+ static void SendShutdown(grpc_channel* channel, bool send_goaway,
+ grpc_error* send_disconnect) {
+ ShutdownCleanupArgs* sc = new ShutdownCleanupArgs;
+ GRPC_CLOSURE_INIT(&sc->closure, ShutdownCleanup, sc,
+ grpc_schedule_on_exec_ctx);
+ grpc_transport_op* op = grpc_make_transport_op(&sc->closure);
+ grpc_channel_element* elem;
+ op->goaway_error =
+ send_goaway
+ ? grpc_error_set_int(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server shutdown"),
+ GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_OK)
+ : GRPC_ERROR_NONE;
+ op->set_accept_stream = true;
+ sc->slice = grpc_slice_from_copied_string("Server shutdown");
+ op->disconnect_with_error = send_disconnect;
+ elem =
+ grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0);
+ elem->filter->start_transport_op(elem, op);
+ }
+
+ std::vector<grpc_channel*> channels_;
+};
+
+} // namespace
+
+//
+// Server
+//
+
+const grpc_channel_filter Server::kServerTopFilter = {
+ Server::CallData::StartTransportStreamOpBatch,
+ grpc_channel_next_op,
+ sizeof(Server::CallData),
+ Server::CallData::InitCallElement,
+ grpc_call_stack_ignore_set_pollset_or_pollset_set,
+ Server::CallData::DestroyCallElement,
+ sizeof(Server::ChannelData),
+ Server::ChannelData::InitChannelElement,
+ Server::ChannelData::DestroyChannelElement,
+ grpc_channel_next_get_info,
+ "server",
+};
+
+namespace {
+
+grpc_resource_user* CreateDefaultResourceUser(const grpc_channel_args* args) {
+ if (args != nullptr) {
+ grpc_resource_quota* resource_quota =
+ grpc_resource_quota_from_channel_args(args, false /* create */);
+ if (resource_quota != nullptr) {
+ return grpc_resource_user_create(resource_quota, "default");
+ }
+ }
+ return nullptr;
+}
+
+RefCountedPtr<channelz::ServerNode> CreateChannelzNode(
+ Server* server, const grpc_channel_args* args) {
+ RefCountedPtr<channelz::ServerNode> channelz_node;
+ if (grpc_channel_args_find_bool(args, GRPC_ARG_ENABLE_CHANNELZ,
+ GRPC_ENABLE_CHANNELZ_DEFAULT)) {
+ size_t channel_tracer_max_memory = grpc_channel_args_find_integer(
+ args, GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE,
+ {GRPC_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE_DEFAULT, 0, INT_MAX});
+ channelz_node =
+ MakeRefCounted<channelz::ServerNode>(channel_tracer_max_memory);
+ channelz_node->AddTraceEvent(
+ channelz::ChannelTrace::Severity::Info,
+ grpc_slice_from_static_string("Server created"));
+ }
+ return channelz_node;
+}
+
+} // namespace
+
+Server::Server(const grpc_channel_args* args)
+ : channel_args_(grpc_channel_args_copy(args)),
+ default_resource_user_(CreateDefaultResourceUser(args)),
+ channelz_node_(CreateChannelzNode(this, args)) {}
+
+Server::~Server() {
+ grpc_channel_args_destroy(channel_args_);
+ for (size_t i = 0; i < cqs_.size(); i++) {
+ GRPC_CQ_INTERNAL_UNREF(cqs_[i], "server");
+ }
+}
+
+void Server::AddListener(OrphanablePtr<ListenerInterface> listener) {
+ channelz::ListenSocketNode* listen_socket_node =
+ listener->channelz_listen_socket_node();
+ if (listen_socket_node != nullptr && channelz_node_ != nullptr) {
+ channelz_node_->AddChildListenSocket(listen_socket_node->Ref());
+ }
+ listeners_.emplace_back(std::move(listener));
+}
+
+void Server::Start() {
+ started_ = true;
+ for (grpc_completion_queue* cq : cqs_) {
+ if (grpc_cq_can_listen(cq)) {
+ pollsets_.push_back(grpc_cq_pollset(cq));
+ }
+ }
+ if (unregistered_request_matcher_ == nullptr) {
+ unregistered_request_matcher_ = y_absl::make_unique<RealRequestMatcher>(this);
+ }
+ for (std::unique_ptr<RegisteredMethod>& rm : registered_methods_) {
+ if (rm->matcher == nullptr) {
+ rm->matcher = y_absl::make_unique<RealRequestMatcher>(this);
}
}
+ {
+ MutexLock lock(&mu_global_);
+ starting_ = true;
+ }
+ for (auto& listener : listeners_) {
+ listener.listener->Start(this, &pollsets_);
+ }
+ MutexLock lock(&mu_global_);
+ starting_ = false;
+ starting_cv_.Signal();
+}
- void MatchOrQueue(size_t start_request_queue_index,
- CallData* calld) override {
- for (size_t i = 0; i < requests_per_cq_.size(); i++) {
- size_t cq_idx = (start_request_queue_index + i) % requests_per_cq_.size();
- RequestedCall* rc =
- reinterpret_cast<RequestedCall*>(requests_per_cq_[cq_idx].TryPop());
- if (rc != nullptr) {
- GRPC_STATS_INC_SERVER_CQS_CHECKED(i);
- calld->SetState(CallData::CallState::ACTIVATED);
- calld->Publish(cq_idx, rc);
- return;
- }
- }
- // No cq to take the request found; queue it on the slow list.
- GRPC_STATS_INC_SERVER_SLOWPATH_REQUESTS_QUEUED();
- // We need to ensure that all the queues are empty. We do this under
- // the server mu_call_ lock to ensure that if something is added to
- // an empty request queue, it will block until the call is actually
- // added to the pending list.
- RequestedCall* rc = nullptr;
- size_t cq_idx = 0;
- size_t loop_count;
- {
- MutexLock lock(&server_->mu_call_);
- for (loop_count = 0; loop_count < requests_per_cq_.size(); loop_count++) {
- cq_idx =
- (start_request_queue_index + loop_count) % requests_per_cq_.size();
- rc = reinterpret_cast<RequestedCall*>(requests_per_cq_[cq_idx].Pop());
- if (rc != nullptr) {
- break;
- }
- }
- if (rc == nullptr) {
- calld->SetState(CallData::CallState::PENDING);
- pending_.push(calld);
- return;
- }
- }
- GRPC_STATS_INC_SERVER_CQS_CHECKED(loop_count + requests_per_cq_.size());
- calld->SetState(CallData::CallState::ACTIVATED);
- calld->Publish(cq_idx, rc);
- }
-
- Server* server() const override { return server_; }
-
- private:
- Server* const server_;
- std::queue<CallData*> pending_;
- std::vector<LockedMultiProducerSingleConsumerQueue> requests_per_cq_;
-};
-
-// AllocatingRequestMatchers don't allow the application to request an RPC in
-// advance or queue up any incoming RPC for later match. Instead, MatchOrQueue
-// will call out to an allocation function passed in at the construction of the
-// object. These request matchers are designed for the C++ callback API, so they
-// only support 1 completion queue (passed in at the constructor).
-class Server::AllocatingRequestMatcherBase : public RequestMatcherInterface {
- public:
- AllocatingRequestMatcherBase(Server* server, grpc_completion_queue* cq)
- : server_(server), cq_(cq) {
- size_t idx;
- for (idx = 0; idx < server->cqs_.size(); idx++) {
- if (server->cqs_[idx] == cq) {
- break;
- }
- }
- GPR_ASSERT(idx < server->cqs_.size());
- cq_idx_ = idx;
- }
-
- void ZombifyPending() override {}
-
- void KillRequests(grpc_error* error) override { GRPC_ERROR_UNREF(error); }
-
- size_t request_queue_count() const override { return 0; }
-
- void RequestCallWithPossiblePublish(size_t /*request_queue_index*/,
- RequestedCall* /*call*/) final {
- GPR_ASSERT(false);
- }
-
- Server* server() const override { return server_; }
-
- // Supply the completion queue related to this request matcher
- grpc_completion_queue* cq() const { return cq_; }
-
- // Supply the completion queue's index relative to the server.
- size_t cq_idx() const { return cq_idx_; }
-
- private:
- Server* const server_;
- grpc_completion_queue* const cq_;
- size_t cq_idx_;
-};
-
-// An allocating request matcher for non-registered methods (used for generic
-// API and unimplemented RPCs).
-class Server::AllocatingRequestMatcherBatch
- : public AllocatingRequestMatcherBase {
- public:
- AllocatingRequestMatcherBatch(Server* server, grpc_completion_queue* cq,
- std::function<BatchCallAllocation()> allocator)
- : AllocatingRequestMatcherBase(server, cq),
- allocator_(std::move(allocator)) {}
-
- void MatchOrQueue(size_t /*start_request_queue_index*/,
- CallData* calld) override {
- BatchCallAllocation call_info = allocator_();
- GPR_ASSERT(server()->ValidateServerRequest(
- cq(), static_cast<void*>(call_info.tag), nullptr, nullptr) ==
- GRPC_CALL_OK);
- RequestedCall* rc = new RequestedCall(
- static_cast<void*>(call_info.tag), cq(), call_info.call,
- call_info.initial_metadata, call_info.details);
- calld->SetState(CallData::CallState::ACTIVATED);
- calld->Publish(cq_idx(), rc);
- }
-
- private:
- std::function<BatchCallAllocation()> allocator_;
-};
-
-// An allocating request matcher for registered methods.
-class Server::AllocatingRequestMatcherRegistered
- : public AllocatingRequestMatcherBase {
- public:
- AllocatingRequestMatcherRegistered(
- Server* server, grpc_completion_queue* cq, RegisteredMethod* rm,
- std::function<RegisteredCallAllocation()> allocator)
- : AllocatingRequestMatcherBase(server, cq),
- registered_method_(rm),
- allocator_(std::move(allocator)) {}
-
- void MatchOrQueue(size_t /*start_request_queue_index*/,
- CallData* calld) override {
- RegisteredCallAllocation call_info = allocator_();
- GPR_ASSERT(
- server()->ValidateServerRequest(cq(), static_cast<void*>(call_info.tag),
- call_info.optional_payload,
- registered_method_) == GRPC_CALL_OK);
- RequestedCall* rc = new RequestedCall(
- static_cast<void*>(call_info.tag), cq(), call_info.call,
- call_info.initial_metadata, registered_method_, call_info.deadline,
- call_info.optional_payload);
- calld->SetState(CallData::CallState::ACTIVATED);
- calld->Publish(cq_idx(), rc);
- }
-
- private:
- RegisteredMethod* const registered_method_;
- std::function<RegisteredCallAllocation()> allocator_;
-};
-
-//
-// ChannelBroadcaster
-//
-
-namespace {
-
-class ChannelBroadcaster {
- public:
- // This can have an empty constructor and destructor since we want to control
- // when the actual setup and shutdown broadcast take place.
-
- // Copies over the channels from the locked server.
- void FillChannelsLocked(std::vector<grpc_channel*> channels) {
- GPR_DEBUG_ASSERT(channels_.empty());
- channels_ = std::move(channels);
- }
-
- // Broadcasts a shutdown on each channel.
- void BroadcastShutdown(bool send_goaway, grpc_error* force_disconnect) {
- for (grpc_channel* channel : channels_) {
- SendShutdown(channel, send_goaway, GRPC_ERROR_REF(force_disconnect));
- GRPC_CHANNEL_INTERNAL_UNREF(channel, "broadcast");
- }
- channels_.clear(); // just for safety against double broadcast
- GRPC_ERROR_UNREF(force_disconnect);
- }
-
- private:
- struct ShutdownCleanupArgs {
- grpc_closure closure;
- grpc_slice slice;
- };
-
- static void ShutdownCleanup(void* arg, grpc_error* /*error*/) {
- ShutdownCleanupArgs* a = static_cast<ShutdownCleanupArgs*>(arg);
- grpc_slice_unref_internal(a->slice);
- delete a;
- }
-
- static void SendShutdown(grpc_channel* channel, bool send_goaway,
- grpc_error* send_disconnect) {
- ShutdownCleanupArgs* sc = new ShutdownCleanupArgs;
- GRPC_CLOSURE_INIT(&sc->closure, ShutdownCleanup, sc,
- grpc_schedule_on_exec_ctx);
- grpc_transport_op* op = grpc_make_transport_op(&sc->closure);
- grpc_channel_element* elem;
- op->goaway_error =
- send_goaway
- ? grpc_error_set_int(
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server shutdown"),
- GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_OK)
- : GRPC_ERROR_NONE;
- op->set_accept_stream = true;
- sc->slice = grpc_slice_from_copied_string("Server shutdown");
- op->disconnect_with_error = send_disconnect;
- elem =
- grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0);
- elem->filter->start_transport_op(elem, op);
- }
-
- std::vector<grpc_channel*> channels_;
-};
-
-} // namespace
-
-//
-// Server
-//
-
-const grpc_channel_filter Server::kServerTopFilter = {
- Server::CallData::StartTransportStreamOpBatch,
- grpc_channel_next_op,
- sizeof(Server::CallData),
- Server::CallData::InitCallElement,
- grpc_call_stack_ignore_set_pollset_or_pollset_set,
- Server::CallData::DestroyCallElement,
- sizeof(Server::ChannelData),
- Server::ChannelData::InitChannelElement,
- Server::ChannelData::DestroyChannelElement,
- grpc_channel_next_get_info,
- "server",
-};
-
-namespace {
-
-grpc_resource_user* CreateDefaultResourceUser(const grpc_channel_args* args) {
- if (args != nullptr) {
- grpc_resource_quota* resource_quota =
- grpc_resource_quota_from_channel_args(args, false /* create */);
- if (resource_quota != nullptr) {
- return grpc_resource_user_create(resource_quota, "default");
- }
- }
- return nullptr;
+void Server::SetupTransport(
+ grpc_transport* transport, grpc_pollset* accepting_pollset,
+ const grpc_channel_args* args,
+ const RefCountedPtr<grpc_core::channelz::SocketNode>& socket_node,
+ grpc_resource_user* resource_user) {
+ // Create channel.
+ grpc_channel* channel = grpc_channel_create(
+ nullptr, args, GRPC_SERVER_CHANNEL, transport, resource_user);
+ ChannelData* chand = static_cast<ChannelData*>(
+ grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0)
+ ->channel_data);
+ // Set up CQs.
+ size_t cq_idx;
+ for (cq_idx = 0; cq_idx < cqs_.size(); cq_idx++) {
+ if (grpc_cq_pollset(cqs_[cq_idx]) == accepting_pollset) break;
+ }
+ if (cq_idx == cqs_.size()) {
+ // Completion queue not found. Pick a random one to publish new calls to.
+ cq_idx = static_cast<size_t>(rand()) % cqs_.size();
+ }
+ // Set up channelz node.
+ intptr_t channelz_socket_uuid = 0;
+ if (socket_node != nullptr) {
+ channelz_socket_uuid = socket_node->uuid();
+ channelz_node_->AddChildSocket(socket_node);
+ }
+ // Initialize chand.
+ chand->InitTransport(Ref(), channel, cq_idx, transport, channelz_socket_uuid);
}
-RefCountedPtr<channelz::ServerNode> CreateChannelzNode(
- Server* server, const grpc_channel_args* args) {
- RefCountedPtr<channelz::ServerNode> channelz_node;
- if (grpc_channel_args_find_bool(args, GRPC_ARG_ENABLE_CHANNELZ,
- GRPC_ENABLE_CHANNELZ_DEFAULT)) {
- size_t channel_tracer_max_memory = grpc_channel_args_find_integer(
- args, GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE,
- {GRPC_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE_DEFAULT, 0, INT_MAX});
- channelz_node =
- MakeRefCounted<channelz::ServerNode>(channel_tracer_max_memory);
- channelz_node->AddTraceEvent(
- channelz::ChannelTrace::Severity::Info,
- grpc_slice_from_static_string("Server created"));
- }
- return channelz_node;
+bool Server::HasOpenConnections() {
+ MutexLock lock(&mu_global_);
+ return !channels_.empty();
}
-} // namespace
-
-Server::Server(const grpc_channel_args* args)
- : channel_args_(grpc_channel_args_copy(args)),
- default_resource_user_(CreateDefaultResourceUser(args)),
- channelz_node_(CreateChannelzNode(this, args)) {}
-
-Server::~Server() {
- grpc_channel_args_destroy(channel_args_);
- for (size_t i = 0; i < cqs_.size(); i++) {
- GRPC_CQ_INTERNAL_UNREF(cqs_[i], "server");
- }
+void Server::SetRegisteredMethodAllocator(
+ grpc_completion_queue* cq, void* method_tag,
+ std::function<RegisteredCallAllocation()> allocator) {
+ RegisteredMethod* rm = static_cast<RegisteredMethod*>(method_tag);
+ rm->matcher = y_absl::make_unique<AllocatingRequestMatcherRegistered>(
+ this, cq, rm, std::move(allocator));
}
-void Server::AddListener(OrphanablePtr<ListenerInterface> listener) {
- channelz::ListenSocketNode* listen_socket_node =
- listener->channelz_listen_socket_node();
- if (listen_socket_node != nullptr && channelz_node_ != nullptr) {
- channelz_node_->AddChildListenSocket(listen_socket_node->Ref());
- }
- listeners_.emplace_back(std::move(listener));
+void Server::SetBatchMethodAllocator(
+ grpc_completion_queue* cq, std::function<BatchCallAllocation()> allocator) {
+ GPR_DEBUG_ASSERT(unregistered_request_matcher_ == nullptr);
+ unregistered_request_matcher_ =
+ y_absl::make_unique<AllocatingRequestMatcherBatch>(this, cq,
+ std::move(allocator));
}
-void Server::Start() {
- started_ = true;
- for (grpc_completion_queue* cq : cqs_) {
- if (grpc_cq_can_listen(cq)) {
- pollsets_.push_back(grpc_cq_pollset(cq));
- }
- }
- if (unregistered_request_matcher_ == nullptr) {
- unregistered_request_matcher_ = y_absl::make_unique<RealRequestMatcher>(this);
- }
- for (std::unique_ptr<RegisteredMethod>& rm : registered_methods_) {
- if (rm->matcher == nullptr) {
- rm->matcher = y_absl::make_unique<RealRequestMatcher>(this);
- }
- }
- {
- MutexLock lock(&mu_global_);
- starting_ = true;
- }
- for (auto& listener : listeners_) {
- listener.listener->Start(this, &pollsets_);
- }
- MutexLock lock(&mu_global_);
- starting_ = false;
- starting_cv_.Signal();
-}
-
-void Server::SetupTransport(
- grpc_transport* transport, grpc_pollset* accepting_pollset,
- const grpc_channel_args* args,
- const RefCountedPtr<grpc_core::channelz::SocketNode>& socket_node,
- grpc_resource_user* resource_user) {
- // Create channel.
- grpc_channel* channel = grpc_channel_create(
- nullptr, args, GRPC_SERVER_CHANNEL, transport, resource_user);
- ChannelData* chand = static_cast<ChannelData*>(
- grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0)
- ->channel_data);
- // Set up CQs.
- size_t cq_idx;
- for (cq_idx = 0; cq_idx < cqs_.size(); cq_idx++) {
- if (grpc_cq_pollset(cqs_[cq_idx]) == accepting_pollset) break;
- }
- if (cq_idx == cqs_.size()) {
- // Completion queue not found. Pick a random one to publish new calls to.
- cq_idx = static_cast<size_t>(rand()) % cqs_.size();
- }
- // Set up channelz node.
- intptr_t channelz_socket_uuid = 0;
- if (socket_node != nullptr) {
- channelz_socket_uuid = socket_node->uuid();
- channelz_node_->AddChildSocket(socket_node);
- }
- // Initialize chand.
- chand->InitTransport(Ref(), channel, cq_idx, transport, channelz_socket_uuid);
-}
-
-bool Server::HasOpenConnections() {
- MutexLock lock(&mu_global_);
- return !channels_.empty();
+void Server::RegisterCompletionQueue(grpc_completion_queue* cq) {
+ for (grpc_completion_queue* queue : cqs_) {
+ if (queue == cq) return;
+ }
+ GRPC_CQ_INTERNAL_REF(cq, "server");
+ cqs_.push_back(cq);
}
-void Server::SetRegisteredMethodAllocator(
- grpc_completion_queue* cq, void* method_tag,
- std::function<RegisteredCallAllocation()> allocator) {
- RegisteredMethod* rm = static_cast<RegisteredMethod*>(method_tag);
- rm->matcher = y_absl::make_unique<AllocatingRequestMatcherRegistered>(
- this, cq, rm, std::move(allocator));
+namespace {
+
+bool streq(const TString& a, const char* b) {
+ return (a.empty() && b == nullptr) ||
+ ((b != nullptr) && !strcmp(a.c_str(), b));
}
-void Server::SetBatchMethodAllocator(
- grpc_completion_queue* cq, std::function<BatchCallAllocation()> allocator) {
- GPR_DEBUG_ASSERT(unregistered_request_matcher_ == nullptr);
- unregistered_request_matcher_ =
- y_absl::make_unique<AllocatingRequestMatcherBatch>(this, cq,
- std::move(allocator));
-}
-
-void Server::RegisterCompletionQueue(grpc_completion_queue* cq) {
- for (grpc_completion_queue* queue : cqs_) {
- if (queue == cq) return;
- }
- GRPC_CQ_INTERNAL_REF(cq, "server");
- cqs_.push_back(cq);
-}
-
-namespace {
-
-bool streq(const TString& a, const char* b) {
- return (a.empty() && b == nullptr) ||
- ((b != nullptr) && !strcmp(a.c_str(), b));
+} // namespace
+
+Server::RegisteredMethod* Server::RegisterMethod(
+ const char* method, const char* host,
+ grpc_server_register_method_payload_handling payload_handling,
+ uint32_t flags) {
+ if (!method) {
+ gpr_log(GPR_ERROR,
+ "grpc_server_register_method method string cannot be NULL");
+ return nullptr;
+ }
+ for (std::unique_ptr<RegisteredMethod>& m : registered_methods_) {
+ if (streq(m->method, method) && streq(m->host, host)) {
+ gpr_log(GPR_ERROR, "duplicate registration for %s@%s", method,
+ host ? host : "*");
+ return nullptr;
+ }
+ }
+ if ((flags & ~GRPC_INITIAL_METADATA_USED_MASK) != 0) {
+ gpr_log(GPR_ERROR, "grpc_server_register_method invalid flags 0x%08x",
+ flags);
+ return nullptr;
+ }
+ registered_methods_.emplace_back(y_absl::make_unique<RegisteredMethod>(
+ method, host, payload_handling, flags));
+ return registered_methods_.back().get();
+}
+
+void Server::DoneRequestEvent(void* req, grpc_cq_completion* /*c*/) {
+ delete static_cast<RequestedCall*>(req);
}
-} // namespace
-
-Server::RegisteredMethod* Server::RegisterMethod(
- const char* method, const char* host,
- grpc_server_register_method_payload_handling payload_handling,
- uint32_t flags) {
- if (!method) {
- gpr_log(GPR_ERROR,
- "grpc_server_register_method method string cannot be NULL");
- return nullptr;
- }
- for (std::unique_ptr<RegisteredMethod>& m : registered_methods_) {
- if (streq(m->method, method) && streq(m->host, host)) {
- gpr_log(GPR_ERROR, "duplicate registration for %s@%s", method,
- host ? host : "*");
- return nullptr;
- }
- }
- if ((flags & ~GRPC_INITIAL_METADATA_USED_MASK) != 0) {
- gpr_log(GPR_ERROR, "grpc_server_register_method invalid flags 0x%08x",
- flags);
- return nullptr;
- }
- registered_methods_.emplace_back(y_absl::make_unique<RegisteredMethod>(
- method, host, payload_handling, flags));
- return registered_methods_.back().get();
-}
-
-void Server::DoneRequestEvent(void* req, grpc_cq_completion* /*c*/) {
- delete static_cast<RequestedCall*>(req);
+void Server::FailCall(size_t cq_idx, RequestedCall* rc, grpc_error* error) {
+ *rc->call = nullptr;
+ rc->initial_metadata->count = 0;
+ GPR_ASSERT(error != GRPC_ERROR_NONE);
+ grpc_cq_end_op(cqs_[cq_idx], rc->tag, error, DoneRequestEvent, rc,
+ &rc->completion);
}
-void Server::FailCall(size_t cq_idx, RequestedCall* rc, grpc_error* error) {
- *rc->call = nullptr;
- rc->initial_metadata->count = 0;
- GPR_ASSERT(error != GRPC_ERROR_NONE);
- grpc_cq_end_op(cqs_[cq_idx], rc->tag, error, DoneRequestEvent, rc,
- &rc->completion);
-}
-
-// Before calling MaybeFinishShutdown(), we must hold mu_global_ and not
-// hold mu_call_.
-void Server::MaybeFinishShutdown() {
- if (!shutdown_flag_.load(std::memory_order_acquire) || shutdown_published_) {
+// Before calling MaybeFinishShutdown(), we must hold mu_global_ and not
+// hold mu_call_.
+void Server::MaybeFinishShutdown() {
+ if (!shutdown_flag_.load(std::memory_order_acquire) || shutdown_published_) {
return;
}
- {
- MutexLock lock(&mu_call_);
- KillPendingWorkLocked(
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown"));
- }
- if (!channels_.empty() || listeners_destroyed_ < listeners_.size()) {
- if (gpr_time_cmp(gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME),
- last_shutdown_message_time_),
- gpr_time_from_seconds(1, GPR_TIMESPAN)) >= 0) {
- last_shutdown_message_time_ = gpr_now(GPR_CLOCK_REALTIME);
- gpr_log(GPR_DEBUG,
- "Waiting for %" PRIuPTR " channels and %" PRIuPTR "/%" PRIuPTR
- " listeners to be destroyed before shutting down server",
- channels_.size(), listeners_.size() - listeners_destroyed_,
- listeners_.size());
- }
- return;
- }
- shutdown_published_ = true;
- for (auto& shutdown_tag : shutdown_tags_) {
- Ref().release();
- grpc_cq_end_op(shutdown_tag.cq, shutdown_tag.tag, GRPC_ERROR_NONE,
- DoneShutdownEvent, this, &shutdown_tag.completion);
- }
-}
-
-void Server::KillPendingWorkLocked(grpc_error* error) {
- if (started_) {
- unregistered_request_matcher_->KillRequests(GRPC_ERROR_REF(error));
- unregistered_request_matcher_->ZombifyPending();
- for (std::unique_ptr<RegisteredMethod>& rm : registered_methods_) {
- rm->matcher->KillRequests(GRPC_ERROR_REF(error));
- rm->matcher->ZombifyPending();
+ {
+ MutexLock lock(&mu_call_);
+ KillPendingWorkLocked(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown"));
+ }
+ if (!channels_.empty() || listeners_destroyed_ < listeners_.size()) {
+ if (gpr_time_cmp(gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME),
+ last_shutdown_message_time_),
+ gpr_time_from_seconds(1, GPR_TIMESPAN)) >= 0) {
+ last_shutdown_message_time_ = gpr_now(GPR_CLOCK_REALTIME);
+ gpr_log(GPR_DEBUG,
+ "Waiting for %" PRIuPTR " channels and %" PRIuPTR "/%" PRIuPTR
+ " listeners to be destroyed before shutting down server",
+ channels_.size(), listeners_.size() - listeners_destroyed_,
+ listeners_.size());
+ }
+ return;
+ }
+ shutdown_published_ = true;
+ for (auto& shutdown_tag : shutdown_tags_) {
+ Ref().release();
+ grpc_cq_end_op(shutdown_tag.cq, shutdown_tag.tag, GRPC_ERROR_NONE,
+ DoneShutdownEvent, this, &shutdown_tag.completion);
+ }
+}
+
+void Server::KillPendingWorkLocked(grpc_error* error) {
+ if (started_) {
+ unregistered_request_matcher_->KillRequests(GRPC_ERROR_REF(error));
+ unregistered_request_matcher_->ZombifyPending();
+ for (std::unique_ptr<RegisteredMethod>& rm : registered_methods_) {
+ rm->matcher->KillRequests(GRPC_ERROR_REF(error));
+ rm->matcher->ZombifyPending();
}
}
- GRPC_ERROR_UNREF(error);
+ GRPC_ERROR_UNREF(error);
+}
+
+std::vector<grpc_channel*> Server::GetChannelsLocked() const {
+ std::vector<grpc_channel*> channels;
+ channels.reserve(channels_.size());
+ for (const ChannelData* chand : channels_) {
+ channels.push_back(chand->channel());
+ GRPC_CHANNEL_INTERNAL_REF(chand->channel(), "broadcast");
+ }
+ return channels;
}
-std::vector<grpc_channel*> Server::GetChannelsLocked() const {
- std::vector<grpc_channel*> channels;
- channels.reserve(channels_.size());
- for (const ChannelData* chand : channels_) {
- channels.push_back(chand->channel());
- GRPC_CHANNEL_INTERNAL_REF(chand->channel(), "broadcast");
- }
- return channels;
-}
-
-void Server::ListenerDestroyDone(void* arg, grpc_error* /*error*/) {
- Server* server = static_cast<Server*>(arg);
- MutexLock lock(&server->mu_global_);
- server->listeners_destroyed_++;
- server->MaybeFinishShutdown();
-}
-
-namespace {
-
-void DonePublishedShutdown(void* /*done_arg*/, grpc_cq_completion* storage) {
- delete storage;
-}
-
-} // namespace
-
-// - Kills all pending requests-for-incoming-RPC-calls (i.e., the requests made
-// via grpc_server_request_call() and grpc_server_request_registered_call()
-// will now be cancelled). See KillPendingWorkLocked().
-//
-// - Shuts down the listeners (i.e., the server will no longer listen on the
-// port for new incoming channels).
-//
-// - Iterates through all channels on the server and sends shutdown msg (see
-// ChannelBroadcaster::BroadcastShutdown() for details) to the clients via
-// the transport layer. The transport layer then guarantees the following:
-// -- Sends shutdown to the client (e.g., HTTP2 transport sends GOAWAY).
-// -- If the server has outstanding calls that are in the process, the
-// connection is NOT closed until the server is done with all those calls.
-// -- Once there are no more calls in progress, the channel is closed.
-void Server::ShutdownAndNotify(grpc_completion_queue* cq, void* tag) {
- ChannelBroadcaster broadcaster;
- {
- // Wait for startup to be finished. Locks mu_global.
- MutexLock lock(&mu_global_);
- starting_cv_.WaitUntil(&mu_global_, [this] { return !starting_; });
- // Stay locked, and gather up some stuff to do.
- GPR_ASSERT(grpc_cq_begin_op(cq, tag));
- if (shutdown_published_) {
- grpc_cq_end_op(cq, tag, GRPC_ERROR_NONE, DonePublishedShutdown, nullptr,
- new grpc_cq_completion);
+void Server::ListenerDestroyDone(void* arg, grpc_error* /*error*/) {
+ Server* server = static_cast<Server*>(arg);
+ MutexLock lock(&server->mu_global_);
+ server->listeners_destroyed_++;
+ server->MaybeFinishShutdown();
+}
+
+namespace {
+
+void DonePublishedShutdown(void* /*done_arg*/, grpc_cq_completion* storage) {
+ delete storage;
+}
+
+} // namespace
+
+// - Kills all pending requests-for-incoming-RPC-calls (i.e., the requests made
+// via grpc_server_request_call() and grpc_server_request_registered_call()
+// will now be cancelled). See KillPendingWorkLocked().
+//
+// - Shuts down the listeners (i.e., the server will no longer listen on the
+// port for new incoming channels).
+//
+// - Iterates through all channels on the server and sends shutdown msg (see
+// ChannelBroadcaster::BroadcastShutdown() for details) to the clients via
+// the transport layer. The transport layer then guarantees the following:
+// -- Sends shutdown to the client (e.g., HTTP2 transport sends GOAWAY).
+// -- If the server has outstanding calls that are in the process, the
+// connection is NOT closed until the server is done with all those calls.
+// -- Once there are no more calls in progress, the channel is closed.
+void Server::ShutdownAndNotify(grpc_completion_queue* cq, void* tag) {
+ ChannelBroadcaster broadcaster;
+ {
+ // Wait for startup to be finished. Locks mu_global.
+ MutexLock lock(&mu_global_);
+ starting_cv_.WaitUntil(&mu_global_, [this] { return !starting_; });
+ // Stay locked, and gather up some stuff to do.
+ GPR_ASSERT(grpc_cq_begin_op(cq, tag));
+ if (shutdown_published_) {
+ grpc_cq_end_op(cq, tag, GRPC_ERROR_NONE, DonePublishedShutdown, nullptr,
+ new grpc_cq_completion);
return;
}
- shutdown_tags_.emplace_back(tag, cq);
- if (shutdown_flag_.load(std::memory_order_acquire)) {
+ shutdown_tags_.emplace_back(tag, cq);
+ if (shutdown_flag_.load(std::memory_order_acquire)) {
return;
}
- last_shutdown_message_time_ = gpr_now(GPR_CLOCK_REALTIME);
- broadcaster.FillChannelsLocked(GetChannelsLocked());
- shutdown_flag_.store(true, std::memory_order_release);
- // Collect all unregistered then registered calls.
- {
- MutexLock lock(&mu_call_);
- KillPendingWorkLocked(
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown"));
- }
- MaybeFinishShutdown();
- }
- // Shutdown listeners.
- for (auto& listener : listeners_) {
- channelz::ListenSocketNode* channelz_listen_socket_node =
- listener.listener->channelz_listen_socket_node();
- if (channelz_node_ != nullptr && channelz_listen_socket_node != nullptr) {
- channelz_node_->RemoveChildListenSocket(
- channelz_listen_socket_node->uuid());
- }
- GRPC_CLOSURE_INIT(&listener.destroy_done, ListenerDestroyDone, this,
- grpc_schedule_on_exec_ctx);
- listener.listener->SetOnDestroyDone(&listener.destroy_done);
- listener.listener.reset();
- }
- broadcaster.BroadcastShutdown(/*send_goaway=*/true, GRPC_ERROR_NONE);
+ last_shutdown_message_time_ = gpr_now(GPR_CLOCK_REALTIME);
+ broadcaster.FillChannelsLocked(GetChannelsLocked());
+ shutdown_flag_.store(true, std::memory_order_release);
+ // Collect all unregistered then registered calls.
+ {
+ MutexLock lock(&mu_call_);
+ KillPendingWorkLocked(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown"));
+ }
+ MaybeFinishShutdown();
+ }
+ // Shutdown listeners.
+ for (auto& listener : listeners_) {
+ channelz::ListenSocketNode* channelz_listen_socket_node =
+ listener.listener->channelz_listen_socket_node();
+ if (channelz_node_ != nullptr && channelz_listen_socket_node != nullptr) {
+ channelz_node_->RemoveChildListenSocket(
+ channelz_listen_socket_node->uuid());
+ }
+ GRPC_CLOSURE_INIT(&listener.destroy_done, ListenerDestroyDone, this,
+ grpc_schedule_on_exec_ctx);
+ listener.listener->SetOnDestroyDone(&listener.destroy_done);
+ listener.listener.reset();
+ }
+ broadcaster.BroadcastShutdown(/*send_goaway=*/true, GRPC_ERROR_NONE);
}
-void Server::CancelAllCalls() {
- ChannelBroadcaster broadcaster;
- {
- MutexLock lock(&mu_global_);
- broadcaster.FillChannelsLocked(GetChannelsLocked());
+void Server::CancelAllCalls() {
+ ChannelBroadcaster broadcaster;
+ {
+ MutexLock lock(&mu_global_);
+ broadcaster.FillChannelsLocked(GetChannelsLocked());
}
- broadcaster.BroadcastShutdown(
- /*send_goaway=*/false,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Cancelling all calls"));
+ broadcaster.BroadcastShutdown(
+ /*send_goaway=*/false,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Cancelling all calls"));
}
-void Server::Orphan() {
- {
- MutexLock lock(&mu_global_);
- GPR_ASSERT(shutdown_flag_.load(std::memory_order_acquire) ||
- listeners_.empty());
- GPR_ASSERT(listeners_destroyed_ == listeners_.size());
- }
- if (default_resource_user_ != nullptr) {
- grpc_resource_quota_unref(grpc_resource_user_quota(default_resource_user_));
- grpc_resource_user_shutdown(default_resource_user_);
- grpc_resource_user_unref(default_resource_user_);
- }
- Unref();
+void Server::Orphan() {
+ {
+ MutexLock lock(&mu_global_);
+ GPR_ASSERT(shutdown_flag_.load(std::memory_order_acquire) ||
+ listeners_.empty());
+ GPR_ASSERT(listeners_destroyed_ == listeners_.size());
+ }
+ if (default_resource_user_ != nullptr) {
+ grpc_resource_quota_unref(grpc_resource_user_quota(default_resource_user_));
+ grpc_resource_user_shutdown(default_resource_user_);
+ grpc_resource_user_unref(default_resource_user_);
+ }
+ Unref();
}
-grpc_call_error Server::ValidateServerRequest(
- grpc_completion_queue* cq_for_notification, void* tag,
- grpc_byte_buffer** optional_payload, RegisteredMethod* rm) {
- if ((rm == nullptr && optional_payload != nullptr) ||
- ((rm != nullptr) && ((optional_payload == nullptr) !=
- (rm->payload_handling == GRPC_SRM_PAYLOAD_NONE)))) {
- return GRPC_CALL_ERROR_PAYLOAD_TYPE_MISMATCH;
- }
- if (grpc_cq_begin_op(cq_for_notification, tag) == false) {
- return GRPC_CALL_ERROR_COMPLETION_QUEUE_SHUTDOWN;
- }
- return GRPC_CALL_OK;
+grpc_call_error Server::ValidateServerRequest(
+ grpc_completion_queue* cq_for_notification, void* tag,
+ grpc_byte_buffer** optional_payload, RegisteredMethod* rm) {
+ if ((rm == nullptr && optional_payload != nullptr) ||
+ ((rm != nullptr) && ((optional_payload == nullptr) !=
+ (rm->payload_handling == GRPC_SRM_PAYLOAD_NONE)))) {
+ return GRPC_CALL_ERROR_PAYLOAD_TYPE_MISMATCH;
+ }
+ if (grpc_cq_begin_op(cq_for_notification, tag) == false) {
+ return GRPC_CALL_ERROR_COMPLETION_QUEUE_SHUTDOWN;
+ }
+ return GRPC_CALL_OK;
}
-grpc_call_error Server::ValidateServerRequestAndCq(
- size_t* cq_idx, grpc_completion_queue* cq_for_notification, void* tag,
- grpc_byte_buffer** optional_payload, RegisteredMethod* rm) {
- size_t idx;
- for (idx = 0; idx < cqs_.size(); idx++) {
- if (cqs_[idx] == cq_for_notification) {
- break;
+grpc_call_error Server::ValidateServerRequestAndCq(
+ size_t* cq_idx, grpc_completion_queue* cq_for_notification, void* tag,
+ grpc_byte_buffer** optional_payload, RegisteredMethod* rm) {
+ size_t idx;
+ for (idx = 0; idx < cqs_.size(); idx++) {
+ if (cqs_[idx] == cq_for_notification) {
+ break;
}
}
- if (idx == cqs_.size()) {
- return GRPC_CALL_ERROR_NOT_SERVER_COMPLETION_QUEUE;
- }
- grpc_call_error error =
- ValidateServerRequest(cq_for_notification, tag, optional_payload, rm);
- if (error != GRPC_CALL_OK) {
- return error;
- }
- *cq_idx = idx;
- return GRPC_CALL_OK;
+ if (idx == cqs_.size()) {
+ return GRPC_CALL_ERROR_NOT_SERVER_COMPLETION_QUEUE;
+ }
+ grpc_call_error error =
+ ValidateServerRequest(cq_for_notification, tag, optional_payload, rm);
+ if (error != GRPC_CALL_OK) {
+ return error;
+ }
+ *cq_idx = idx;
+ return GRPC_CALL_OK;
+}
+
+grpc_call_error Server::QueueRequestedCall(size_t cq_idx, RequestedCall* rc) {
+ if (shutdown_flag_.load(std::memory_order_acquire)) {
+ FailCall(cq_idx, rc,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown"));
+ return GRPC_CALL_OK;
+ }
+ RequestMatcherInterface* rm;
+ switch (rc->type) {
+ case RequestedCall::Type::BATCH_CALL:
+ rm = unregistered_request_matcher_.get();
+ break;
+ case RequestedCall::Type::REGISTERED_CALL:
+ rm = rc->data.registered.method->matcher.get();
+ break;
+ }
+ rm->RequestCallWithPossiblePublish(cq_idx, rc);
+ return GRPC_CALL_OK;
}
-grpc_call_error Server::QueueRequestedCall(size_t cq_idx, RequestedCall* rc) {
- if (shutdown_flag_.load(std::memory_order_acquire)) {
- FailCall(cq_idx, rc,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown"));
- return GRPC_CALL_OK;
- }
- RequestMatcherInterface* rm;
- switch (rc->type) {
- case RequestedCall::Type::BATCH_CALL:
- rm = unregistered_request_matcher_.get();
- break;
- case RequestedCall::Type::REGISTERED_CALL:
- rm = rc->data.registered.method->matcher.get();
- break;
- }
- rm->RequestCallWithPossiblePublish(cq_idx, rc);
- return GRPC_CALL_OK;
-}
-
-grpc_call_error Server::RequestCall(grpc_call** call,
- grpc_call_details* details,
- grpc_metadata_array* request_metadata,
- grpc_completion_queue* cq_bound_to_call,
- grpc_completion_queue* cq_for_notification,
- void* tag) {
- size_t cq_idx;
- grpc_call_error error = ValidateServerRequestAndCq(
- &cq_idx, cq_for_notification, tag, nullptr, nullptr);
- if (error != GRPC_CALL_OK) {
- return error;
- }
- RequestedCall* rc =
- new RequestedCall(tag, cq_bound_to_call, call, request_metadata, details);
- return QueueRequestedCall(cq_idx, rc);
-}
-
-grpc_call_error Server::RequestRegisteredCall(
- RegisteredMethod* rm, grpc_call** call, gpr_timespec* deadline,
- grpc_metadata_array* request_metadata, grpc_byte_buffer** optional_payload,
- grpc_completion_queue* cq_bound_to_call,
- grpc_completion_queue* cq_for_notification, void* tag_new) {
- size_t cq_idx;
- grpc_call_error error = ValidateServerRequestAndCq(
- &cq_idx, cq_for_notification, tag_new, optional_payload, rm);
- if (error != GRPC_CALL_OK) {
- return error;
- }
- RequestedCall* rc =
- new RequestedCall(tag_new, cq_bound_to_call, call, request_metadata, rm,
- deadline, optional_payload);
- return QueueRequestedCall(cq_idx, rc);
+grpc_call_error Server::RequestCall(grpc_call** call,
+ grpc_call_details* details,
+ grpc_metadata_array* request_metadata,
+ grpc_completion_queue* cq_bound_to_call,
+ grpc_completion_queue* cq_for_notification,
+ void* tag) {
+ size_t cq_idx;
+ grpc_call_error error = ValidateServerRequestAndCq(
+ &cq_idx, cq_for_notification, tag, nullptr, nullptr);
+ if (error != GRPC_CALL_OK) {
+ return error;
+ }
+ RequestedCall* rc =
+ new RequestedCall(tag, cq_bound_to_call, call, request_metadata, details);
+ return QueueRequestedCall(cq_idx, rc);
}
-//
-// Server::ChannelData::ConnectivityWatcher
-//
-
-class Server::ChannelData::ConnectivityWatcher
- : public AsyncConnectivityStateWatcherInterface {
- public:
- explicit ConnectivityWatcher(ChannelData* chand) : chand_(chand) {
- GRPC_CHANNEL_INTERNAL_REF(chand_->channel_, "connectivity");
- }
-
- ~ConnectivityWatcher() {
- GRPC_CHANNEL_INTERNAL_UNREF(chand_->channel_, "connectivity");
- }
-
- private:
- void OnConnectivityStateChange(grpc_connectivity_state new_state,
- const y_absl::Status& /*status*/) override {
- // Don't do anything until we are being shut down.
- if (new_state != GRPC_CHANNEL_SHUTDOWN) return;
- // Shut down channel.
- MutexLock lock(&chand_->server_->mu_global_);
- chand_->Destroy();
- }
-
- ChannelData* chand_;
-};
-
-//
-// Server::ChannelData
-//
-
-Server::ChannelData::~ChannelData() {
- if (registered_methods_ != nullptr) {
- for (const ChannelRegisteredMethod& crm : *registered_methods_) {
- grpc_slice_unref_internal(crm.method);
- GPR_DEBUG_ASSERT(crm.method.refcount == &kNoopRefcount ||
- crm.method.refcount == nullptr);
- if (crm.has_host) {
- grpc_slice_unref_internal(crm.host);
- GPR_DEBUG_ASSERT(crm.host.refcount == &kNoopRefcount ||
- crm.host.refcount == nullptr);
- }
- }
- registered_methods_.reset();
- }
- if (server_ != nullptr) {
- if (server_->channelz_node_ != nullptr && channelz_socket_uuid_ != 0) {
- server_->channelz_node_->RemoveChildSocket(channelz_socket_uuid_);
- }
- {
- MutexLock lock(&server_->mu_global_);
- if (list_position_.has_value()) {
- server_->channels_.erase(*list_position_);
- list_position_.reset();
- }
- server_->MaybeFinishShutdown();
- }
+grpc_call_error Server::RequestRegisteredCall(
+ RegisteredMethod* rm, grpc_call** call, gpr_timespec* deadline,
+ grpc_metadata_array* request_metadata, grpc_byte_buffer** optional_payload,
+ grpc_completion_queue* cq_bound_to_call,
+ grpc_completion_queue* cq_for_notification, void* tag_new) {
+ size_t cq_idx;
+ grpc_call_error error = ValidateServerRequestAndCq(
+ &cq_idx, cq_for_notification, tag_new, optional_payload, rm);
+ if (error != GRPC_CALL_OK) {
+ return error;
+ }
+ RequestedCall* rc =
+ new RequestedCall(tag_new, cq_bound_to_call, call, request_metadata, rm,
+ deadline, optional_payload);
+ return QueueRequestedCall(cq_idx, rc);
+}
+
+//
+// Server::ChannelData::ConnectivityWatcher
+//
+
+class Server::ChannelData::ConnectivityWatcher
+ : public AsyncConnectivityStateWatcherInterface {
+ public:
+ explicit ConnectivityWatcher(ChannelData* chand) : chand_(chand) {
+ GRPC_CHANNEL_INTERNAL_REF(chand_->channel_, "connectivity");
+ }
+
+ ~ConnectivityWatcher() {
+ GRPC_CHANNEL_INTERNAL_UNREF(chand_->channel_, "connectivity");
+ }
+
+ private:
+ void OnConnectivityStateChange(grpc_connectivity_state new_state,
+ const y_absl::Status& /*status*/) override {
+ // Don't do anything until we are being shut down.
+ if (new_state != GRPC_CHANNEL_SHUTDOWN) return;
+ // Shut down channel.
+ MutexLock lock(&chand_->server_->mu_global_);
+ chand_->Destroy();
+ }
+
+ ChannelData* chand_;
+};
+
+//
+// Server::ChannelData
+//
+
+Server::ChannelData::~ChannelData() {
+ if (registered_methods_ != nullptr) {
+ for (const ChannelRegisteredMethod& crm : *registered_methods_) {
+ grpc_slice_unref_internal(crm.method);
+ GPR_DEBUG_ASSERT(crm.method.refcount == &kNoopRefcount ||
+ crm.method.refcount == nullptr);
+ if (crm.has_host) {
+ grpc_slice_unref_internal(crm.host);
+ GPR_DEBUG_ASSERT(crm.host.refcount == &kNoopRefcount ||
+ crm.host.refcount == nullptr);
+ }
+ }
+ registered_methods_.reset();
+ }
+ if (server_ != nullptr) {
+ if (server_->channelz_node_ != nullptr && channelz_socket_uuid_ != 0) {
+ server_->channelz_node_->RemoveChildSocket(channelz_socket_uuid_);
+ }
+ {
+ MutexLock lock(&server_->mu_global_);
+ if (list_position_.has_value()) {
+ server_->channels_.erase(*list_position_);
+ list_position_.reset();
+ }
+ server_->MaybeFinishShutdown();
+ }
}
}
-void Server::ChannelData::InitTransport(RefCountedPtr<Server> server,
- grpc_channel* channel, size_t cq_idx,
- grpc_transport* transport,
- intptr_t channelz_socket_uuid) {
- server_ = std::move(server);
- channel_ = channel;
- cq_idx_ = cq_idx;
- channelz_socket_uuid_ = channelz_socket_uuid;
- // Build a lookup table phrased in terms of mdstr's in this channels context
- // to quickly find registered methods.
- size_t num_registered_methods = server_->registered_methods_.size();
- if (num_registered_methods > 0) {
- uint32_t max_probes = 0;
- size_t slots = 2 * num_registered_methods;
- registered_methods_.reset(new std::vector<ChannelRegisteredMethod>(slots));
- for (std::unique_ptr<RegisteredMethod>& rm : server_->registered_methods_) {
- ExternallyManagedSlice host;
- ExternallyManagedSlice method(rm->method.c_str());
- const bool has_host = !rm->host.empty();
- if (has_host) {
- host = ExternallyManagedSlice(rm->host.c_str());
- }
- uint32_t hash =
- GRPC_MDSTR_KV_HASH(has_host ? host.Hash() : 0, method.Hash());
- uint32_t probes = 0;
- for (probes = 0; (*registered_methods_)[(hash + probes) % slots]
- .server_registered_method != nullptr;
- probes++) {
- }
- if (probes > max_probes) max_probes = probes;
- ChannelRegisteredMethod* crm =
- &(*registered_methods_)[(hash + probes) % slots];
- crm->server_registered_method = rm.get();
- crm->flags = rm->flags;
- crm->has_host = has_host;
- if (has_host) {
- crm->host = host;
- }
- crm->method = method;
- }
- GPR_ASSERT(slots <= UINT32_MAX);
- registered_method_max_probes_ = max_probes;
- }
- // Publish channel.
- {
- MutexLock lock(&server_->mu_global_);
- server_->channels_.push_front(this);
- list_position_ = server_->channels_.begin();
- }
- // Start accept_stream transport op.
- grpc_transport_op* op = grpc_make_transport_op(nullptr);
- op->set_accept_stream = true;
- op->set_accept_stream_fn = AcceptStream;
- op->set_accept_stream_user_data = this;
- op->start_connectivity_watch = MakeOrphanable<ConnectivityWatcher>(this);
- if (server_->shutdown_flag_.load(std::memory_order_acquire)) {
- op->disconnect_with_error =
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server shutdown");
- }
- grpc_transport_perform_op(transport, op);
+void Server::ChannelData::InitTransport(RefCountedPtr<Server> server,
+ grpc_channel* channel, size_t cq_idx,
+ grpc_transport* transport,
+ intptr_t channelz_socket_uuid) {
+ server_ = std::move(server);
+ channel_ = channel;
+ cq_idx_ = cq_idx;
+ channelz_socket_uuid_ = channelz_socket_uuid;
+ // Build a lookup table phrased in terms of mdstr's in this channels context
+ // to quickly find registered methods.
+ size_t num_registered_methods = server_->registered_methods_.size();
+ if (num_registered_methods > 0) {
+ uint32_t max_probes = 0;
+ size_t slots = 2 * num_registered_methods;
+ registered_methods_.reset(new std::vector<ChannelRegisteredMethod>(slots));
+ for (std::unique_ptr<RegisteredMethod>& rm : server_->registered_methods_) {
+ ExternallyManagedSlice host;
+ ExternallyManagedSlice method(rm->method.c_str());
+ const bool has_host = !rm->host.empty();
+ if (has_host) {
+ host = ExternallyManagedSlice(rm->host.c_str());
+ }
+ uint32_t hash =
+ GRPC_MDSTR_KV_HASH(has_host ? host.Hash() : 0, method.Hash());
+ uint32_t probes = 0;
+ for (probes = 0; (*registered_methods_)[(hash + probes) % slots]
+ .server_registered_method != nullptr;
+ probes++) {
+ }
+ if (probes > max_probes) max_probes = probes;
+ ChannelRegisteredMethod* crm =
+ &(*registered_methods_)[(hash + probes) % slots];
+ crm->server_registered_method = rm.get();
+ crm->flags = rm->flags;
+ crm->has_host = has_host;
+ if (has_host) {
+ crm->host = host;
+ }
+ crm->method = method;
+ }
+ GPR_ASSERT(slots <= UINT32_MAX);
+ registered_method_max_probes_ = max_probes;
+ }
+ // Publish channel.
+ {
+ MutexLock lock(&server_->mu_global_);
+ server_->channels_.push_front(this);
+ list_position_ = server_->channels_.begin();
+ }
+ // Start accept_stream transport op.
+ grpc_transport_op* op = grpc_make_transport_op(nullptr);
+ op->set_accept_stream = true;
+ op->set_accept_stream_fn = AcceptStream;
+ op->set_accept_stream_user_data = this;
+ op->start_connectivity_watch = MakeOrphanable<ConnectivityWatcher>(this);
+ if (server_->shutdown_flag_.load(std::memory_order_acquire)) {
+ op->disconnect_with_error =
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server shutdown");
+ }
+ grpc_transport_perform_op(transport, op);
}
-Server::ChannelRegisteredMethod* Server::ChannelData::GetRegisteredMethod(
- const grpc_slice& host, const grpc_slice& path, bool is_idempotent) {
- if (registered_methods_ == nullptr) return nullptr;
- /* TODO(ctiller): unify these two searches */
- /* check for an exact match with host */
- uint32_t hash = GRPC_MDSTR_KV_HASH(grpc_slice_hash_internal(host),
- grpc_slice_hash_internal(path));
- for (size_t i = 0; i <= registered_method_max_probes_; i++) {
- ChannelRegisteredMethod* rm =
- &(*registered_methods_)[(hash + i) % registered_methods_->size()];
- if (rm->server_registered_method == nullptr) break;
- if (!rm->has_host) continue;
- if (rm->host != host) continue;
- if (rm->method != path) continue;
- if ((rm->flags & GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST) &&
- !is_idempotent) {
- continue;
+Server::ChannelRegisteredMethod* Server::ChannelData::GetRegisteredMethod(
+ const grpc_slice& host, const grpc_slice& path, bool is_idempotent) {
+ if (registered_methods_ == nullptr) return nullptr;
+ /* TODO(ctiller): unify these two searches */
+ /* check for an exact match with host */
+ uint32_t hash = GRPC_MDSTR_KV_HASH(grpc_slice_hash_internal(host),
+ grpc_slice_hash_internal(path));
+ for (size_t i = 0; i <= registered_method_max_probes_; i++) {
+ ChannelRegisteredMethod* rm =
+ &(*registered_methods_)[(hash + i) % registered_methods_->size()];
+ if (rm->server_registered_method == nullptr) break;
+ if (!rm->has_host) continue;
+ if (rm->host != host) continue;
+ if (rm->method != path) continue;
+ if ((rm->flags & GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST) &&
+ !is_idempotent) {
+ continue;
+ }
+ return rm;
+ }
+ /* check for a wildcard method definition (no host set) */
+ hash = GRPC_MDSTR_KV_HASH(0, grpc_slice_hash_internal(path));
+ for (size_t i = 0; i <= registered_method_max_probes_; i++) {
+ ChannelRegisteredMethod* rm =
+ &(*registered_methods_)[(hash + i) % registered_methods_->size()];
+ if (rm->server_registered_method == nullptr) break;
+ if (rm->has_host) continue;
+ if (rm->method != path) continue;
+ if ((rm->flags & GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST) &&
+ !is_idempotent) {
+ continue;
}
- return rm;
- }
- /* check for a wildcard method definition (no host set) */
- hash = GRPC_MDSTR_KV_HASH(0, grpc_slice_hash_internal(path));
- for (size_t i = 0; i <= registered_method_max_probes_; i++) {
- ChannelRegisteredMethod* rm =
- &(*registered_methods_)[(hash + i) % registered_methods_->size()];
- if (rm->server_registered_method == nullptr) break;
- if (rm->has_host) continue;
- if (rm->method != path) continue;
- if ((rm->flags & GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST) &&
- !is_idempotent) {
- continue;
- }
- return rm;
- }
- return nullptr;
+ return rm;
+ }
+ return nullptr;
}
-void Server::ChannelData::AcceptStream(void* arg, grpc_transport* /*transport*/,
- const void* transport_server_data) {
- auto* chand = static_cast<Server::ChannelData*>(arg);
+void Server::ChannelData::AcceptStream(void* arg, grpc_transport* /*transport*/,
+ const void* transport_server_data) {
+ auto* chand = static_cast<Server::ChannelData*>(arg);
/* create a call */
grpc_call_create_args args;
- args.channel = chand->channel_;
- args.server = chand->server_.get();
+ args.channel = chand->channel_;
+ args.server = chand->server_.get();
args.parent = nullptr;
args.propagation_mask = 0;
args.cq = nullptr;
@@ -1104,361 +1104,361 @@ void Server::ChannelData::AcceptStream(void* arg, grpc_transport* /*transport*/,
grpc_error* error = grpc_call_create(&args, &call);
grpc_call_element* elem =
grpc_call_stack_element(grpc_call_get_call_stack(call), 0);
- auto* calld = static_cast<Server::CallData*>(elem->call_data);
+ auto* calld = static_cast<Server::CallData*>(elem->call_data);
if (error != GRPC_ERROR_NONE) {
GRPC_ERROR_UNREF(error);
- calld->FailCallCreation();
+ calld->FailCallCreation();
return;
}
- calld->Start(elem);
+ calld->Start(elem);
}
-void Server::ChannelData::FinishDestroy(void* cd, grpc_error* /*error*/) {
- auto* chand = static_cast<Server::ChannelData*>(cd);
- Server* server = chand->server_.get();
- GRPC_CHANNEL_INTERNAL_UNREF(chand->channel_, "server");
- server->Unref();
+void Server::ChannelData::FinishDestroy(void* cd, grpc_error* /*error*/) {
+ auto* chand = static_cast<Server::ChannelData*>(cd);
+ Server* server = chand->server_.get();
+ GRPC_CHANNEL_INTERNAL_UNREF(chand->channel_, "server");
+ server->Unref();
}
-void Server::ChannelData::Destroy() {
- if (!list_position_.has_value()) return;
- GPR_ASSERT(server_ != nullptr);
- server_->channels_.erase(*list_position_);
- list_position_.reset();
- server_->Ref().release();
- server_->MaybeFinishShutdown();
- GRPC_CLOSURE_INIT(&finish_destroy_channel_closure_, FinishDestroy, this,
- grpc_schedule_on_exec_ctx);
- if (GRPC_TRACE_FLAG_ENABLED(grpc_server_channel_trace)) {
- gpr_log(GPR_INFO, "Disconnected client");
- }
- grpc_transport_op* op =
- grpc_make_transport_op(&finish_destroy_channel_closure_);
- op->set_accept_stream = true;
- grpc_channel_next_op(
- grpc_channel_stack_element(grpc_channel_get_channel_stack(channel_), 0),
- op);
+void Server::ChannelData::Destroy() {
+ if (!list_position_.has_value()) return;
+ GPR_ASSERT(server_ != nullptr);
+ server_->channels_.erase(*list_position_);
+ list_position_.reset();
+ server_->Ref().release();
+ server_->MaybeFinishShutdown();
+ GRPC_CLOSURE_INIT(&finish_destroy_channel_closure_, FinishDestroy, this,
+ grpc_schedule_on_exec_ctx);
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_server_channel_trace)) {
+ gpr_log(GPR_INFO, "Disconnected client");
+ }
+ grpc_transport_op* op =
+ grpc_make_transport_op(&finish_destroy_channel_closure_);
+ op->set_accept_stream = true;
+ grpc_channel_next_op(
+ grpc_channel_stack_element(grpc_channel_get_channel_stack(channel_), 0),
+ op);
}
-grpc_error* Server::ChannelData::InitChannelElement(
- grpc_channel_element* elem, grpc_channel_element_args* args) {
+grpc_error* Server::ChannelData::InitChannelElement(
+ grpc_channel_element* elem, grpc_channel_element_args* args) {
GPR_ASSERT(args->is_first);
GPR_ASSERT(!args->is_last);
- new (elem->channel_data) ChannelData();
+ new (elem->channel_data) ChannelData();
+ return GRPC_ERROR_NONE;
+}
+
+void Server::ChannelData::DestroyChannelElement(grpc_channel_element* elem) {
+ auto* chand = static_cast<ChannelData*>(elem->channel_data);
+ chand->~ChannelData();
+}
+
+//
+// Server::CallData
+//
+
+Server::CallData::CallData(grpc_call_element* elem,
+ const grpc_call_element_args& args,
+ RefCountedPtr<Server> server)
+ : server_(std::move(server)),
+ call_(grpc_call_from_top_element(elem)),
+ call_combiner_(args.call_combiner) {
+ GRPC_CLOSURE_INIT(&recv_initial_metadata_ready_, RecvInitialMetadataReady,
+ elem, grpc_schedule_on_exec_ctx);
+ GRPC_CLOSURE_INIT(&recv_trailing_metadata_ready_, RecvTrailingMetadataReady,
+ elem, grpc_schedule_on_exec_ctx);
+}
+
+Server::CallData::~CallData() {
+ GPR_ASSERT(state_.Load(MemoryOrder::RELAXED) != CallState::PENDING);
+ GRPC_ERROR_UNREF(recv_initial_metadata_error_);
+ if (host_.has_value()) {
+ grpc_slice_unref_internal(*host_);
+ }
+ if (path_.has_value()) {
+ grpc_slice_unref_internal(*path_);
+ }
+ grpc_metadata_array_destroy(&initial_metadata_);
+ grpc_byte_buffer_destroy(payload_);
+}
+
+void Server::CallData::SetState(CallState state) {
+ state_.Store(state, MemoryOrder::RELAXED);
+}
+
+bool Server::CallData::MaybeActivate() {
+ CallState expected = CallState::PENDING;
+ return state_.CompareExchangeStrong(&expected, CallState::ACTIVATED,
+ MemoryOrder::ACQ_REL,
+ MemoryOrder::RELAXED);
+}
+
+void Server::CallData::FailCallCreation() {
+ CallState expected_not_started = CallState::NOT_STARTED;
+ CallState expected_pending = CallState::PENDING;
+ if (state_.CompareExchangeStrong(&expected_not_started, CallState::ZOMBIED,
+ MemoryOrder::ACQ_REL,
+ MemoryOrder::ACQUIRE)) {
+ KillZombie();
+ } else if (state_.CompareExchangeStrong(&expected_pending, CallState::ZOMBIED,
+ MemoryOrder::ACQ_REL,
+ MemoryOrder::RELAXED)) {
+ // Zombied call will be destroyed when it's removed from the pending
+ // queue... later.
+ }
+}
+
+void Server::CallData::Start(grpc_call_element* elem) {
+ grpc_op op;
+ op.op = GRPC_OP_RECV_INITIAL_METADATA;
+ op.flags = 0;
+ op.reserved = nullptr;
+ op.data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_;
+ GRPC_CLOSURE_INIT(&recv_initial_metadata_batch_complete_,
+ RecvInitialMetadataBatchComplete, elem,
+ grpc_schedule_on_exec_ctx);
+ grpc_call_start_batch_and_execute(call_, &op, 1,
+ &recv_initial_metadata_batch_complete_);
+}
+
+void Server::CallData::Publish(size_t cq_idx, RequestedCall* rc) {
+ grpc_call_set_completion_queue(call_, rc->cq_bound_to_call);
+ *rc->call = call_;
+ cq_new_ = server_->cqs_[cq_idx];
+ GPR_SWAP(grpc_metadata_array, *rc->initial_metadata, initial_metadata_);
+ switch (rc->type) {
+ case RequestedCall::Type::BATCH_CALL:
+ GPR_ASSERT(host_.has_value());
+ GPR_ASSERT(path_.has_value());
+ rc->data.batch.details->host = grpc_slice_ref_internal(*host_);
+ rc->data.batch.details->method = grpc_slice_ref_internal(*path_);
+ rc->data.batch.details->deadline =
+ grpc_millis_to_timespec(deadline_, GPR_CLOCK_MONOTONIC);
+ rc->data.batch.details->flags = recv_initial_metadata_flags_;
+ break;
+ case RequestedCall::Type::REGISTERED_CALL:
+ *rc->data.registered.deadline =
+ grpc_millis_to_timespec(deadline_, GPR_CLOCK_MONOTONIC);
+ if (rc->data.registered.optional_payload != nullptr) {
+ *rc->data.registered.optional_payload = payload_;
+ payload_ = nullptr;
+ }
+ break;
+ default:
+ GPR_UNREACHABLE_CODE(return );
+ }
+ grpc_cq_end_op(cq_new_, rc->tag, GRPC_ERROR_NONE, Server::DoneRequestEvent,
+ rc, &rc->completion, true);
+}
+
+void Server::CallData::PublishNewRpc(void* arg, grpc_error* error) {
+ grpc_call_element* call_elem = static_cast<grpc_call_element*>(arg);
+ auto* calld = static_cast<Server::CallData*>(call_elem->call_data);
+ auto* chand = static_cast<Server::ChannelData*>(call_elem->channel_data);
+ RequestMatcherInterface* rm = calld->matcher_;
+ Server* server = rm->server();
+ if (error != GRPC_ERROR_NONE ||
+ server->shutdown_flag_.load(std::memory_order_acquire)) {
+ calld->state_.Store(CallState::ZOMBIED, MemoryOrder::RELAXED);
+ calld->KillZombie();
+ return;
+ }
+ rm->MatchOrQueue(chand->cq_idx(), calld);
+}
+
+namespace {
+
+void KillZombieClosure(void* call, grpc_error* /*error*/) {
+ grpc_call_unref(static_cast<grpc_call*>(call));
+}
+
+} // namespace
+
+void Server::CallData::KillZombie() {
+ GRPC_CLOSURE_INIT(&kill_zombie_closure_, KillZombieClosure, call_,
+ grpc_schedule_on_exec_ctx);
+ ExecCtx::Run(DEBUG_LOCATION, &kill_zombie_closure_, GRPC_ERROR_NONE);
+}
+
+void Server::CallData::StartNewRpc(grpc_call_element* elem) {
+ auto* chand = static_cast<ChannelData*>(elem->channel_data);
+ if (server_->shutdown_flag_.load(std::memory_order_acquire)) {
+ state_.Store(CallState::ZOMBIED, MemoryOrder::RELAXED);
+ KillZombie();
+ return;
+ }
+ // Find request matcher.
+ matcher_ = server_->unregistered_request_matcher_.get();
+ grpc_server_register_method_payload_handling payload_handling =
+ GRPC_SRM_PAYLOAD_NONE;
+ if (path_.has_value() && host_.has_value()) {
+ ChannelRegisteredMethod* rm =
+ chand->GetRegisteredMethod(*host_, *path_,
+ (recv_initial_metadata_flags_ &
+ GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST));
+ if (rm != nullptr) {
+ matcher_ = rm->server_registered_method->matcher.get();
+ payload_handling = rm->server_registered_method->payload_handling;
+ }
+ }
+ // Start recv_message op if needed.
+ switch (payload_handling) {
+ case GRPC_SRM_PAYLOAD_NONE:
+ PublishNewRpc(elem, GRPC_ERROR_NONE);
+ break;
+ case GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER: {
+ grpc_op op;
+ op.op = GRPC_OP_RECV_MESSAGE;
+ op.flags = 0;
+ op.reserved = nullptr;
+ op.data.recv_message.recv_message = &payload_;
+ GRPC_CLOSURE_INIT(&publish_, PublishNewRpc, elem,
+ grpc_schedule_on_exec_ctx);
+ grpc_call_start_batch_and_execute(call_, &op, 1, &publish_);
+ break;
+ }
+ }
+}
+
+void Server::CallData::RecvInitialMetadataBatchComplete(void* arg,
+ grpc_error* error) {
+ grpc_call_element* elem = static_cast<grpc_call_element*>(arg);
+ auto* calld = static_cast<Server::CallData*>(elem->call_data);
+ if (error != GRPC_ERROR_NONE) {
+ calld->FailCallCreation();
+ return;
+ }
+ calld->StartNewRpc(elem);
+}
+
+void Server::CallData::StartTransportStreamOpBatchImpl(
+ grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
+ if (batch->recv_initial_metadata) {
+ GPR_ASSERT(batch->payload->recv_initial_metadata.recv_flags == nullptr);
+ recv_initial_metadata_ =
+ batch->payload->recv_initial_metadata.recv_initial_metadata;
+ original_recv_initial_metadata_ready_ =
+ batch->payload->recv_initial_metadata.recv_initial_metadata_ready;
+ batch->payload->recv_initial_metadata.recv_initial_metadata_ready =
+ &recv_initial_metadata_ready_;
+ batch->payload->recv_initial_metadata.recv_flags =
+ &recv_initial_metadata_flags_;
+ }
+ if (batch->recv_trailing_metadata) {
+ original_recv_trailing_metadata_ready_ =
+ batch->payload->recv_trailing_metadata.recv_trailing_metadata_ready;
+ batch->payload->recv_trailing_metadata.recv_trailing_metadata_ready =
+ &recv_trailing_metadata_ready_;
+ }
+ grpc_call_next_op(elem, batch);
+}
+
+void Server::CallData::RecvInitialMetadataReady(void* ptr, grpc_error* error) {
+ grpc_call_element* elem = static_cast<grpc_call_element*>(ptr);
+ CallData* calld = static_cast<CallData*>(elem->call_data);
+ grpc_millis op_deadline;
+ if (error == GRPC_ERROR_NONE) {
+ GPR_DEBUG_ASSERT(calld->recv_initial_metadata_->idx.named.path != nullptr);
+ GPR_DEBUG_ASSERT(calld->recv_initial_metadata_->idx.named.authority !=
+ nullptr);
+ calld->path_.emplace(grpc_slice_ref_internal(
+ GRPC_MDVALUE(calld->recv_initial_metadata_->idx.named.path->md)));
+ calld->host_.emplace(grpc_slice_ref_internal(
+ GRPC_MDVALUE(calld->recv_initial_metadata_->idx.named.authority->md)));
+ grpc_metadata_batch_remove(calld->recv_initial_metadata_, GRPC_BATCH_PATH);
+ grpc_metadata_batch_remove(calld->recv_initial_metadata_,
+ GRPC_BATCH_AUTHORITY);
+ } else {
+ GRPC_ERROR_REF(error);
+ }
+ op_deadline = calld->recv_initial_metadata_->deadline;
+ if (op_deadline != GRPC_MILLIS_INF_FUTURE) {
+ calld->deadline_ = op_deadline;
+ }
+ if (calld->host_.has_value() && calld->path_.has_value()) {
+ /* do nothing */
+ } else {
+ /* Pass the error reference to calld->recv_initial_metadata_error */
+ grpc_error* src_error = error;
+ error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Missing :authority or :path", &src_error, 1);
+ GRPC_ERROR_UNREF(src_error);
+ calld->recv_initial_metadata_error_ = GRPC_ERROR_REF(error);
+ }
+ grpc_closure* closure = calld->original_recv_initial_metadata_ready_;
+ calld->original_recv_initial_metadata_ready_ = nullptr;
+ if (calld->seen_recv_trailing_metadata_ready_) {
+ GRPC_CALL_COMBINER_START(calld->call_combiner_,
+ &calld->recv_trailing_metadata_ready_,
+ calld->recv_trailing_metadata_error_,
+ "continue server recv_trailing_metadata_ready");
+ }
+ Closure::Run(DEBUG_LOCATION, closure, error);
+}
+
+void Server::CallData::RecvTrailingMetadataReady(void* user_data,
+ grpc_error* error) {
+ grpc_call_element* elem = static_cast<grpc_call_element*>(user_data);
+ CallData* calld = static_cast<CallData*>(elem->call_data);
+ if (calld->original_recv_initial_metadata_ready_ != nullptr) {
+ calld->recv_trailing_metadata_error_ = GRPC_ERROR_REF(error);
+ calld->seen_recv_trailing_metadata_ready_ = true;
+ GRPC_CLOSURE_INIT(&calld->recv_trailing_metadata_ready_,
+ RecvTrailingMetadataReady, elem,
+ grpc_schedule_on_exec_ctx);
+ GRPC_CALL_COMBINER_STOP(calld->call_combiner_,
+ "deferring server recv_trailing_metadata_ready "
+ "until after recv_initial_metadata_ready");
+ return;
+ }
+ error =
+ grpc_error_add_child(GRPC_ERROR_REF(error),
+ GRPC_ERROR_REF(calld->recv_initial_metadata_error_));
+ Closure::Run(DEBUG_LOCATION, calld->original_recv_trailing_metadata_ready_,
+ error);
+}
+
+grpc_error* Server::CallData::InitCallElement(
+ grpc_call_element* elem, const grpc_call_element_args* args) {
+ auto* chand = static_cast<ChannelData*>(elem->channel_data);
+ new (elem->call_data) Server::CallData(elem, *args, chand->server());
return GRPC_ERROR_NONE;
}
-void Server::ChannelData::DestroyChannelElement(grpc_channel_element* elem) {
- auto* chand = static_cast<ChannelData*>(elem->channel_data);
- chand->~ChannelData();
-}
-
-//
-// Server::CallData
-//
-
-Server::CallData::CallData(grpc_call_element* elem,
- const grpc_call_element_args& args,
- RefCountedPtr<Server> server)
- : server_(std::move(server)),
- call_(grpc_call_from_top_element(elem)),
- call_combiner_(args.call_combiner) {
- GRPC_CLOSURE_INIT(&recv_initial_metadata_ready_, RecvInitialMetadataReady,
- elem, grpc_schedule_on_exec_ctx);
- GRPC_CLOSURE_INIT(&recv_trailing_metadata_ready_, RecvTrailingMetadataReady,
- elem, grpc_schedule_on_exec_ctx);
-}
-
-Server::CallData::~CallData() {
- GPR_ASSERT(state_.Load(MemoryOrder::RELAXED) != CallState::PENDING);
- GRPC_ERROR_UNREF(recv_initial_metadata_error_);
- if (host_.has_value()) {
- grpc_slice_unref_internal(*host_);
- }
- if (path_.has_value()) {
- grpc_slice_unref_internal(*path_);
- }
- grpc_metadata_array_destroy(&initial_metadata_);
- grpc_byte_buffer_destroy(payload_);
+void Server::CallData::DestroyCallElement(
+ grpc_call_element* elem, const grpc_call_final_info* /*final_info*/,
+ grpc_closure* /*ignored*/) {
+ auto* calld = static_cast<CallData*>(elem->call_data);
+ calld->~CallData();
+}
+
+void Server::CallData::StartTransportStreamOpBatch(
+ grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
+ auto* calld = static_cast<CallData*>(elem->call_data);
+ calld->StartTransportStreamOpBatchImpl(elem, batch);
+}
+
+} // namespace grpc_core
+
+//
+// C-core API
+//
+
+grpc_server* grpc_server_create(const grpc_channel_args* args, void* reserved) {
+ grpc_core::ExecCtx exec_ctx;
+ GRPC_API_TRACE("grpc_server_create(%p, %p)", 2, (args, reserved));
+ grpc_server* c_server = new grpc_server;
+ c_server->core_server = grpc_core::MakeOrphanable<grpc_core::Server>(args);
+ return c_server;
}
-void Server::CallData::SetState(CallState state) {
- state_.Store(state, MemoryOrder::RELAXED);
-}
-
-bool Server::CallData::MaybeActivate() {
- CallState expected = CallState::PENDING;
- return state_.CompareExchangeStrong(&expected, CallState::ACTIVATED,
- MemoryOrder::ACQ_REL,
- MemoryOrder::RELAXED);
-}
-
-void Server::CallData::FailCallCreation() {
- CallState expected_not_started = CallState::NOT_STARTED;
- CallState expected_pending = CallState::PENDING;
- if (state_.CompareExchangeStrong(&expected_not_started, CallState::ZOMBIED,
- MemoryOrder::ACQ_REL,
- MemoryOrder::ACQUIRE)) {
- KillZombie();
- } else if (state_.CompareExchangeStrong(&expected_pending, CallState::ZOMBIED,
- MemoryOrder::ACQ_REL,
- MemoryOrder::RELAXED)) {
- // Zombied call will be destroyed when it's removed from the pending
- // queue... later.
- }
-}
-
-void Server::CallData::Start(grpc_call_element* elem) {
- grpc_op op;
- op.op = GRPC_OP_RECV_INITIAL_METADATA;
- op.flags = 0;
- op.reserved = nullptr;
- op.data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_;
- GRPC_CLOSURE_INIT(&recv_initial_metadata_batch_complete_,
- RecvInitialMetadataBatchComplete, elem,
- grpc_schedule_on_exec_ctx);
- grpc_call_start_batch_and_execute(call_, &op, 1,
- &recv_initial_metadata_batch_complete_);
-}
-
-void Server::CallData::Publish(size_t cq_idx, RequestedCall* rc) {
- grpc_call_set_completion_queue(call_, rc->cq_bound_to_call);
- *rc->call = call_;
- cq_new_ = server_->cqs_[cq_idx];
- GPR_SWAP(grpc_metadata_array, *rc->initial_metadata, initial_metadata_);
- switch (rc->type) {
- case RequestedCall::Type::BATCH_CALL:
- GPR_ASSERT(host_.has_value());
- GPR_ASSERT(path_.has_value());
- rc->data.batch.details->host = grpc_slice_ref_internal(*host_);
- rc->data.batch.details->method = grpc_slice_ref_internal(*path_);
- rc->data.batch.details->deadline =
- grpc_millis_to_timespec(deadline_, GPR_CLOCK_MONOTONIC);
- rc->data.batch.details->flags = recv_initial_metadata_flags_;
- break;
- case RequestedCall::Type::REGISTERED_CALL:
- *rc->data.registered.deadline =
- grpc_millis_to_timespec(deadline_, GPR_CLOCK_MONOTONIC);
- if (rc->data.registered.optional_payload != nullptr) {
- *rc->data.registered.optional_payload = payload_;
- payload_ = nullptr;
- }
- break;
- default:
- GPR_UNREACHABLE_CODE(return );
- }
- grpc_cq_end_op(cq_new_, rc->tag, GRPC_ERROR_NONE, Server::DoneRequestEvent,
- rc, &rc->completion, true);
-}
-
-void Server::CallData::PublishNewRpc(void* arg, grpc_error* error) {
- grpc_call_element* call_elem = static_cast<grpc_call_element*>(arg);
- auto* calld = static_cast<Server::CallData*>(call_elem->call_data);
- auto* chand = static_cast<Server::ChannelData*>(call_elem->channel_data);
- RequestMatcherInterface* rm = calld->matcher_;
- Server* server = rm->server();
- if (error != GRPC_ERROR_NONE ||
- server->shutdown_flag_.load(std::memory_order_acquire)) {
- calld->state_.Store(CallState::ZOMBIED, MemoryOrder::RELAXED);
- calld->KillZombie();
- return;
- }
- rm->MatchOrQueue(chand->cq_idx(), calld);
-}
-
-namespace {
-
-void KillZombieClosure(void* call, grpc_error* /*error*/) {
- grpc_call_unref(static_cast<grpc_call*>(call));
-}
-
-} // namespace
-
-void Server::CallData::KillZombie() {
- GRPC_CLOSURE_INIT(&kill_zombie_closure_, KillZombieClosure, call_,
- grpc_schedule_on_exec_ctx);
- ExecCtx::Run(DEBUG_LOCATION, &kill_zombie_closure_, GRPC_ERROR_NONE);
-}
-
-void Server::CallData::StartNewRpc(grpc_call_element* elem) {
- auto* chand = static_cast<ChannelData*>(elem->channel_data);
- if (server_->shutdown_flag_.load(std::memory_order_acquire)) {
- state_.Store(CallState::ZOMBIED, MemoryOrder::RELAXED);
- KillZombie();
- return;
- }
- // Find request matcher.
- matcher_ = server_->unregistered_request_matcher_.get();
- grpc_server_register_method_payload_handling payload_handling =
- GRPC_SRM_PAYLOAD_NONE;
- if (path_.has_value() && host_.has_value()) {
- ChannelRegisteredMethod* rm =
- chand->GetRegisteredMethod(*host_, *path_,
- (recv_initial_metadata_flags_ &
- GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST));
- if (rm != nullptr) {
- matcher_ = rm->server_registered_method->matcher.get();
- payload_handling = rm->server_registered_method->payload_handling;
- }
- }
- // Start recv_message op if needed.
- switch (payload_handling) {
- case GRPC_SRM_PAYLOAD_NONE:
- PublishNewRpc(elem, GRPC_ERROR_NONE);
- break;
- case GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER: {
- grpc_op op;
- op.op = GRPC_OP_RECV_MESSAGE;
- op.flags = 0;
- op.reserved = nullptr;
- op.data.recv_message.recv_message = &payload_;
- GRPC_CLOSURE_INIT(&publish_, PublishNewRpc, elem,
- grpc_schedule_on_exec_ctx);
- grpc_call_start_batch_and_execute(call_, &op, 1, &publish_);
- break;
- }
- }
-}
-
-void Server::CallData::RecvInitialMetadataBatchComplete(void* arg,
- grpc_error* error) {
- grpc_call_element* elem = static_cast<grpc_call_element*>(arg);
- auto* calld = static_cast<Server::CallData*>(elem->call_data);
- if (error != GRPC_ERROR_NONE) {
- calld->FailCallCreation();
- return;
- }
- calld->StartNewRpc(elem);
-}
-
-void Server::CallData::StartTransportStreamOpBatchImpl(
- grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
- if (batch->recv_initial_metadata) {
- GPR_ASSERT(batch->payload->recv_initial_metadata.recv_flags == nullptr);
- recv_initial_metadata_ =
- batch->payload->recv_initial_metadata.recv_initial_metadata;
- original_recv_initial_metadata_ready_ =
- batch->payload->recv_initial_metadata.recv_initial_metadata_ready;
- batch->payload->recv_initial_metadata.recv_initial_metadata_ready =
- &recv_initial_metadata_ready_;
- batch->payload->recv_initial_metadata.recv_flags =
- &recv_initial_metadata_flags_;
- }
- if (batch->recv_trailing_metadata) {
- original_recv_trailing_metadata_ready_ =
- batch->payload->recv_trailing_metadata.recv_trailing_metadata_ready;
- batch->payload->recv_trailing_metadata.recv_trailing_metadata_ready =
- &recv_trailing_metadata_ready_;
- }
- grpc_call_next_op(elem, batch);
-}
-
-void Server::CallData::RecvInitialMetadataReady(void* ptr, grpc_error* error) {
- grpc_call_element* elem = static_cast<grpc_call_element*>(ptr);
- CallData* calld = static_cast<CallData*>(elem->call_data);
- grpc_millis op_deadline;
- if (error == GRPC_ERROR_NONE) {
- GPR_DEBUG_ASSERT(calld->recv_initial_metadata_->idx.named.path != nullptr);
- GPR_DEBUG_ASSERT(calld->recv_initial_metadata_->idx.named.authority !=
- nullptr);
- calld->path_.emplace(grpc_slice_ref_internal(
- GRPC_MDVALUE(calld->recv_initial_metadata_->idx.named.path->md)));
- calld->host_.emplace(grpc_slice_ref_internal(
- GRPC_MDVALUE(calld->recv_initial_metadata_->idx.named.authority->md)));
- grpc_metadata_batch_remove(calld->recv_initial_metadata_, GRPC_BATCH_PATH);
- grpc_metadata_batch_remove(calld->recv_initial_metadata_,
- GRPC_BATCH_AUTHORITY);
- } else {
- GRPC_ERROR_REF(error);
- }
- op_deadline = calld->recv_initial_metadata_->deadline;
- if (op_deadline != GRPC_MILLIS_INF_FUTURE) {
- calld->deadline_ = op_deadline;
- }
- if (calld->host_.has_value() && calld->path_.has_value()) {
- /* do nothing */
- } else {
- /* Pass the error reference to calld->recv_initial_metadata_error */
- grpc_error* src_error = error;
- error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "Missing :authority or :path", &src_error, 1);
- GRPC_ERROR_UNREF(src_error);
- calld->recv_initial_metadata_error_ = GRPC_ERROR_REF(error);
- }
- grpc_closure* closure = calld->original_recv_initial_metadata_ready_;
- calld->original_recv_initial_metadata_ready_ = nullptr;
- if (calld->seen_recv_trailing_metadata_ready_) {
- GRPC_CALL_COMBINER_START(calld->call_combiner_,
- &calld->recv_trailing_metadata_ready_,
- calld->recv_trailing_metadata_error_,
- "continue server recv_trailing_metadata_ready");
- }
- Closure::Run(DEBUG_LOCATION, closure, error);
-}
-
-void Server::CallData::RecvTrailingMetadataReady(void* user_data,
- grpc_error* error) {
- grpc_call_element* elem = static_cast<grpc_call_element*>(user_data);
- CallData* calld = static_cast<CallData*>(elem->call_data);
- if (calld->original_recv_initial_metadata_ready_ != nullptr) {
- calld->recv_trailing_metadata_error_ = GRPC_ERROR_REF(error);
- calld->seen_recv_trailing_metadata_ready_ = true;
- GRPC_CLOSURE_INIT(&calld->recv_trailing_metadata_ready_,
- RecvTrailingMetadataReady, elem,
- grpc_schedule_on_exec_ctx);
- GRPC_CALL_COMBINER_STOP(calld->call_combiner_,
- "deferring server recv_trailing_metadata_ready "
- "until after recv_initial_metadata_ready");
- return;
- }
- error =
- grpc_error_add_child(GRPC_ERROR_REF(error),
- GRPC_ERROR_REF(calld->recv_initial_metadata_error_));
- Closure::Run(DEBUG_LOCATION, calld->original_recv_trailing_metadata_ready_,
- error);
-}
-
-grpc_error* Server::CallData::InitCallElement(
- grpc_call_element* elem, const grpc_call_element_args* args) {
- auto* chand = static_cast<ChannelData*>(elem->channel_data);
- new (elem->call_data) Server::CallData(elem, *args, chand->server());
- return GRPC_ERROR_NONE;
-}
-
-void Server::CallData::DestroyCallElement(
- grpc_call_element* elem, const grpc_call_final_info* /*final_info*/,
- grpc_closure* /*ignored*/) {
- auto* calld = static_cast<CallData*>(elem->call_data);
- calld->~CallData();
-}
-
-void Server::CallData::StartTransportStreamOpBatch(
- grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
- auto* calld = static_cast<CallData*>(elem->call_data);
- calld->StartTransportStreamOpBatchImpl(elem, batch);
-}
-
-} // namespace grpc_core
-
-//
-// C-core API
-//
-
-grpc_server* grpc_server_create(const grpc_channel_args* args, void* reserved) {
- grpc_core::ExecCtx exec_ctx;
- GRPC_API_TRACE("grpc_server_create(%p, %p)", 2, (args, reserved));
- grpc_server* c_server = new grpc_server;
- c_server->core_server = grpc_core::MakeOrphanable<grpc_core::Server>(args);
- return c_server;
-}
-
void grpc_server_register_completion_queue(grpc_server* server,
grpc_completion_queue* cq,
void* reserved) {
GRPC_API_TRACE(
"grpc_server_register_completion_queue(server=%p, cq=%p, reserved=%p)", 3,
(server, cq, reserved));
- GPR_ASSERT(!reserved);
+ GPR_ASSERT(!reserved);
auto cq_type = grpc_get_cq_completion_type(cq);
if (cq_type != GRPC_CQ_NEXT && cq_type != GRPC_CQ_CALLBACK) {
gpr_log(GPR_INFO,
@@ -1468,7 +1468,7 @@ void grpc_server_register_completion_queue(grpc_server* server,
/* Ideally we should log an error and abort but ruby-wrapped-language API
calls grpc_completion_queue_pluck() on server completion queues */
}
- server->core_server->RegisterCompletionQueue(cq);
+ server->core_server->RegisterCompletionQueue(cq);
}
void* grpc_server_register_method(
@@ -1479,14 +1479,14 @@ void* grpc_server_register_method(
"grpc_server_register_method(server=%p, method=%s, host=%s, "
"flags=0x%08x)",
4, (server, method, host, flags));
- return server->core_server->RegisterMethod(method, host, payload_handling,
- flags);
+ return server->core_server->RegisterMethod(method, host, payload_handling,
+ flags);
}
void grpc_server_start(grpc_server* server) {
grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE("grpc_server_start(server=%p)", 1, (server));
- server->core_server->Start();
+ server->core_server->Start();
}
void grpc_server_shutdown_and_notify(grpc_server* server,
@@ -1495,26 +1495,26 @@ void grpc_server_shutdown_and_notify(grpc_server* server,
grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE("grpc_server_shutdown_and_notify(server=%p, cq=%p, tag=%p)", 3,
(server, cq, tag));
- server->core_server->ShutdownAndNotify(cq, tag);
+ server->core_server->ShutdownAndNotify(cq, tag);
}
void grpc_server_cancel_all_calls(grpc_server* server) {
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE("grpc_server_cancel_all_calls(server=%p)", 1, (server));
- server->core_server->CancelAllCalls();
+ server->core_server->CancelAllCalls();
}
void grpc_server_destroy(grpc_server* server) {
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE("grpc_server_destroy(server=%p)", 1, (server));
- delete server;
+ delete server;
}
grpc_call_error grpc_server_request_call(
grpc_server* server, grpc_call** call, grpc_call_details* details,
- grpc_metadata_array* request_metadata,
+ grpc_metadata_array* request_metadata,
grpc_completion_queue* cq_bound_to_call,
grpc_completion_queue* cq_for_notification, void* tag) {
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
@@ -1525,31 +1525,31 @@ grpc_call_error grpc_server_request_call(
"server=%p, call=%p, details=%p, initial_metadata=%p, "
"cq_bound_to_call=%p, cq_for_notification=%p, tag=%p)",
7,
- (server, call, details, request_metadata, cq_bound_to_call,
+ (server, call, details, request_metadata, cq_bound_to_call,
cq_for_notification, tag));
- return server->core_server->RequestCall(call, details, request_metadata,
- cq_bound_to_call, cq_for_notification,
- tag);
+ return server->core_server->RequestCall(call, details, request_metadata,
+ cq_bound_to_call, cq_for_notification,
+ tag);
}
grpc_call_error grpc_server_request_registered_call(
grpc_server* server, void* rmp, grpc_call** call, gpr_timespec* deadline,
- grpc_metadata_array* request_metadata, grpc_byte_buffer** optional_payload,
+ grpc_metadata_array* request_metadata, grpc_byte_buffer** optional_payload,
grpc_completion_queue* cq_bound_to_call,
- grpc_completion_queue* cq_for_notification, void* tag_new) {
+ grpc_completion_queue* cq_for_notification, void* tag_new) {
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
GRPC_STATS_INC_SERVER_REQUESTED_CALLS();
- auto* rm = static_cast<grpc_core::Server::RegisteredMethod*>(rmp);
+ auto* rm = static_cast<grpc_core::Server::RegisteredMethod*>(rmp);
GRPC_API_TRACE(
"grpc_server_request_registered_call("
- "server=%p, rmp=%p, call=%p, deadline=%p, request_metadata=%p, "
+ "server=%p, rmp=%p, call=%p, deadline=%p, request_metadata=%p, "
"optional_payload=%p, cq_bound_to_call=%p, cq_for_notification=%p, "
"tag=%p)",
9,
- (server, rmp, call, deadline, request_metadata, optional_payload,
- cq_bound_to_call, cq_for_notification, tag_new));
- return server->core_server->RequestRegisteredCall(
- rm, call, deadline, request_metadata, optional_payload, cq_bound_to_call,
- cq_for_notification, tag_new);
+ (server, rmp, call, deadline, request_metadata, optional_payload,
+ cq_bound_to_call, cq_for_notification, tag_new));
+ return server->core_server->RequestRegisteredCall(
+ rm, call, deadline, request_metadata, optional_payload, cq_bound_to_call,
+ cq_for_notification, tag_new);
}
diff --git a/contrib/libs/grpc/src/core/lib/surface/server.h b/contrib/libs/grpc/src/core/lib/surface/server.h
index 9eeca08dc4..f4f4ff6449 100644
--- a/contrib/libs/grpc/src/core/lib/surface/server.h
+++ b/contrib/libs/grpc/src/core/lib/surface/server.h
@@ -1,397 +1,397 @@
-//
-// Copyright 2015 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+//
+// Copyright 2015 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
#ifndef GRPC_CORE_LIB_SURFACE_SERVER_H
#define GRPC_CORE_LIB_SURFACE_SERVER_H
#include <grpc/support/port_platform.h>
-#include <list>
-#include <vector>
-
-#include "y_absl/types/optional.h"
-
+#include <list>
+#include <vector>
+
+#include "y_absl/types/optional.h"
+
#include <grpc/grpc.h>
-
-#include "src/core/lib/channel/channel_args.h"
+
+#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/channel/channelz.h"
#include "src/core/lib/debug/trace.h"
-#include "src/core/lib/gprpp/atomic.h"
-#include "src/core/lib/surface/completion_queue.h"
+#include "src/core/lib/gprpp/atomic.h"
+#include "src/core/lib/surface/completion_queue.h"
#include "src/core/lib/transport/transport.h"
-namespace grpc_core {
-
-extern TraceFlag grpc_server_channel_trace;
-
-class Server : public InternallyRefCounted<Server> {
- public:
- // Filter vtable.
- static const grpc_channel_filter kServerTopFilter;
-
- // Opaque type used for registered methods.
- struct RegisteredMethod;
-
- // An object to represent the most relevant characteristics of a
- // newly-allocated call object when using an AllocatingRequestMatcherBatch.
- struct BatchCallAllocation {
- grpc_experimental_completion_queue_functor* tag;
- grpc_call** call;
- grpc_metadata_array* initial_metadata;
- grpc_call_details* details;
- };
-
- // An object to represent the most relevant characteristics of a
- // newly-allocated call object when using an
- // AllocatingRequestMatcherRegistered.
- struct RegisteredCallAllocation {
- grpc_experimental_completion_queue_functor* tag;
- grpc_call** call;
- grpc_metadata_array* initial_metadata;
- gpr_timespec* deadline;
- grpc_byte_buffer** optional_payload;
- };
-
- /// Interface for listeners.
- /// Implementations must override the Orphan() method, which should stop
- /// listening and initiate destruction of the listener.
- class ListenerInterface : public Orphanable {
- public:
- virtual ~ListenerInterface() = default;
-
- /// Starts listening. This listener may refer to the pollset object beyond
- /// this call, so it is a pointer rather than a reference.
- virtual void Start(Server* server,
- const std::vector<grpc_pollset*>* pollsets) = 0;
-
- /// Returns the channelz node for the listen socket, or null if not
- /// supported.
- virtual channelz::ListenSocketNode* channelz_listen_socket_node() const = 0;
-
- /// Sets a closure to be invoked by the listener when its destruction
- /// is complete.
- virtual void SetOnDestroyDone(grpc_closure* on_destroy_done) = 0;
- };
-
- explicit Server(const grpc_channel_args* args);
- ~Server();
-
- void Orphan() override;
-
- const grpc_channel_args* channel_args() const { return channel_args_; }
- grpc_resource_user* default_resource_user() const {
- return default_resource_user_;
- }
- channelz::ServerNode* channelz_node() const { return channelz_node_.get(); }
-
- // Do not call this before Start(). Returns the pollsets. The
- // vector itself is immutable, but the pollsets inside are mutable. The
- // result is valid for the lifetime of the server.
- const std::vector<grpc_pollset*>& pollsets() const { return pollsets_; }
-
- bool HasOpenConnections();
-
- // Adds a listener to the server. When the server starts, it will call
- // the listener's Start() method, and when it shuts down, it will orphan
- // the listener.
- void AddListener(OrphanablePtr<ListenerInterface> listener);
-
- // Starts listening for connections.
- void Start();
-
- // Sets up a transport. Creates a channel stack and binds the transport to
- // the server. Called from the listener when a new connection is accepted.
- void SetupTransport(grpc_transport* transport,
- grpc_pollset* accepting_pollset,
- const grpc_channel_args* args,
- const RefCountedPtr<channelz::SocketNode>& socket_node,
- grpc_resource_user* resource_user = nullptr);
-
- void RegisterCompletionQueue(grpc_completion_queue* cq);
-
- // Functions to specify that a specific registered method or the unregistered
- // collection should use a specific allocator for request matching.
- void SetRegisteredMethodAllocator(
- grpc_completion_queue* cq, void* method_tag,
- std::function<RegisteredCallAllocation()> allocator);
- void SetBatchMethodAllocator(grpc_completion_queue* cq,
- std::function<BatchCallAllocation()> allocator);
-
- RegisteredMethod* RegisterMethod(
- const char* method, const char* host,
- grpc_server_register_method_payload_handling payload_handling,
- uint32_t flags);
-
- grpc_call_error RequestCall(grpc_call** call, grpc_call_details* details,
- grpc_metadata_array* request_metadata,
- grpc_completion_queue* cq_bound_to_call,
- grpc_completion_queue* cq_for_notification,
- void* tag);
-
- grpc_call_error RequestRegisteredCall(
- RegisteredMethod* rm, grpc_call** call, gpr_timespec* deadline,
- grpc_metadata_array* request_metadata,
- grpc_byte_buffer** optional_payload,
- grpc_completion_queue* cq_bound_to_call,
- grpc_completion_queue* cq_for_notification, void* tag_new);
-
- void ShutdownAndNotify(grpc_completion_queue* cq, void* tag);
-
- void CancelAllCalls();
-
- private:
- struct RequestedCall;
-
- struct ChannelRegisteredMethod {
- RegisteredMethod* server_registered_method = nullptr;
- uint32_t flags;
- bool has_host;
- ExternallyManagedSlice method;
- ExternallyManagedSlice host;
- };
-
- class RequestMatcherInterface;
- class RealRequestMatcher;
- class AllocatingRequestMatcherBase;
- class AllocatingRequestMatcherBatch;
- class AllocatingRequestMatcherRegistered;
-
- class ChannelData {
- public:
- ChannelData() = default;
- ~ChannelData();
-
- void InitTransport(RefCountedPtr<Server> server, grpc_channel* channel,
- size_t cq_idx, grpc_transport* transport,
- intptr_t channelz_socket_uuid);
-
- RefCountedPtr<Server> server() const { return server_; }
- grpc_channel* channel() const { return channel_; }
- size_t cq_idx() const { return cq_idx_; }
-
- ChannelRegisteredMethod* GetRegisteredMethod(const grpc_slice& host,
- const grpc_slice& path,
- bool is_idempotent);
-
- // Filter vtable functions.
- static grpc_error* InitChannelElement(grpc_channel_element* elem,
- grpc_channel_element_args* args);
- static void DestroyChannelElement(grpc_channel_element* elem);
-
- private:
- class ConnectivityWatcher;
-
- static void AcceptStream(void* arg, grpc_transport* /*transport*/,
- const void* transport_server_data);
-
- void Destroy();
-
- static void FinishDestroy(void* arg, grpc_error* error);
-
- RefCountedPtr<Server> server_;
- grpc_channel* channel_;
- // The index into Server::cqs_ of the CQ used as a starting point for
- // where to publish new incoming calls.
- size_t cq_idx_;
- y_absl::optional<std::list<ChannelData*>::iterator> list_position_;
- // A hash-table of the methods and hosts of the registered methods.
- // TODO(vjpai): Convert this to an STL map type as opposed to a direct
- // bucket implementation. (Consider performance impact, hash function to
- // use, etc.)
- std::unique_ptr<std::vector<ChannelRegisteredMethod>> registered_methods_;
- uint32_t registered_method_max_probes_;
- grpc_closure finish_destroy_channel_closure_;
- intptr_t channelz_socket_uuid_;
- };
-
- class CallData {
- public:
- enum class CallState {
- NOT_STARTED, // Waiting for metadata.
- PENDING, // Initial metadata read, not flow controlled in yet.
- ACTIVATED, // Flow controlled in, on completion queue.
- ZOMBIED, // Cancelled before being queued.
- };
-
- CallData(grpc_call_element* elem, const grpc_call_element_args& args,
- RefCountedPtr<Server> server);
- ~CallData();
-
- // Starts the recv_initial_metadata batch on the call.
- // Invoked from ChannelData::AcceptStream().
- void Start(grpc_call_element* elem);
-
- void SetState(CallState state);
-
- // Attempts to move from PENDING to ACTIVATED state. Returns true
- // on success.
- bool MaybeActivate();
-
- // Publishes an incoming call to the application after it has been
- // matched.
- void Publish(size_t cq_idx, RequestedCall* rc);
-
- void KillZombie();
-
- void FailCallCreation();
-
- // Filter vtable functions.
- static grpc_error* InitCallElement(grpc_call_element* elem,
- const grpc_call_element_args* args);
- static void DestroyCallElement(grpc_call_element* elem,
- const grpc_call_final_info* /*final_info*/,
- grpc_closure* /*ignored*/);
- static void StartTransportStreamOpBatch(
- grpc_call_element* elem, grpc_transport_stream_op_batch* batch);
-
- private:
- // Helper functions for handling calls at the top of the call stack.
- static void RecvInitialMetadataBatchComplete(void* arg, grpc_error* error);
- void StartNewRpc(grpc_call_element* elem);
- static void PublishNewRpc(void* arg, grpc_error* error);
-
- // Functions used inside the call stack.
- void StartTransportStreamOpBatchImpl(grpc_call_element* elem,
- grpc_transport_stream_op_batch* batch);
- static void RecvInitialMetadataReady(void* arg, grpc_error* error);
- static void RecvTrailingMetadataReady(void* arg, grpc_error* error);
-
- RefCountedPtr<Server> server_;
-
- grpc_call* call_;
-
- Atomic<CallState> state_{CallState::NOT_STARTED};
-
- y_absl::optional<grpc_slice> path_;
- y_absl::optional<grpc_slice> host_;
- grpc_millis deadline_ = GRPC_MILLIS_INF_FUTURE;
-
- grpc_completion_queue* cq_new_ = nullptr;
-
- RequestMatcherInterface* matcher_ = nullptr;
- grpc_byte_buffer* payload_ = nullptr;
-
- grpc_closure kill_zombie_closure_;
-
- grpc_metadata_array initial_metadata_ =
- grpc_metadata_array(); // Zero-initialize the C struct.
- grpc_closure recv_initial_metadata_batch_complete_;
-
- grpc_metadata_batch* recv_initial_metadata_ = nullptr;
- uint32_t recv_initial_metadata_flags_ = 0;
- grpc_closure recv_initial_metadata_ready_;
- grpc_closure* original_recv_initial_metadata_ready_;
- grpc_error* recv_initial_metadata_error_ = GRPC_ERROR_NONE;
-
- bool seen_recv_trailing_metadata_ready_ = false;
- grpc_closure recv_trailing_metadata_ready_;
- grpc_closure* original_recv_trailing_metadata_ready_;
- grpc_error* recv_trailing_metadata_error_ = GRPC_ERROR_NONE;
-
- grpc_closure publish_;
-
- CallCombiner* call_combiner_;
- };
-
- struct Listener {
- explicit Listener(OrphanablePtr<ListenerInterface> l)
- : listener(std::move(l)) {}
- OrphanablePtr<ListenerInterface> listener;
- grpc_closure destroy_done;
- };
-
- struct ShutdownTag {
- ShutdownTag(void* tag_arg, grpc_completion_queue* cq_arg)
- : tag(tag_arg), cq(cq_arg) {}
- void* const tag;
- grpc_completion_queue* const cq;
- grpc_cq_completion completion;
- };
-
- static void ListenerDestroyDone(void* arg, grpc_error* error);
-
- static void DoneShutdownEvent(void* server,
- grpc_cq_completion* /*completion*/) {
- static_cast<Server*>(server)->Unref();
- }
-
- static void DoneRequestEvent(void* req, grpc_cq_completion* completion);
-
- void FailCall(size_t cq_idx, RequestedCall* rc, grpc_error* error);
- grpc_call_error QueueRequestedCall(size_t cq_idx, RequestedCall* rc);
-
- void MaybeFinishShutdown();
-
- void KillPendingWorkLocked(grpc_error* error);
-
- static grpc_call_error ValidateServerRequest(
- grpc_completion_queue* cq_for_notification, void* tag,
- grpc_byte_buffer** optional_payload, RegisteredMethod* rm);
- grpc_call_error ValidateServerRequestAndCq(
- size_t* cq_idx, grpc_completion_queue* cq_for_notification, void* tag,
- grpc_byte_buffer** optional_payload, RegisteredMethod* rm);
-
- std::vector<grpc_channel*> GetChannelsLocked() const;
-
- grpc_channel_args* const channel_args_;
- grpc_resource_user* default_resource_user_ = nullptr;
- RefCountedPtr<channelz::ServerNode> channelz_node_;
-
- std::vector<grpc_completion_queue*> cqs_;
- std::vector<grpc_pollset*> pollsets_;
- bool started_ = false;
-
- // The two following mutexes control access to server-state.
- // mu_global_ controls access to non-call-related state (e.g., channel state).
- // mu_call_ controls access to call-related state (e.g., the call lists).
- //
- // If they are ever required to be nested, you must lock mu_global_
- // before mu_call_. This is currently used in shutdown processing
- // (ShutdownAndNotify() and MaybeFinishShutdown()).
- Mutex mu_global_; // mutex for server and channel state
- Mutex mu_call_; // mutex for call-specific state
-
- // startup synchronization: flag is protected by mu_global_, signals whether
- // we are doing the listener start routine or not.
- bool starting_ = false;
- CondVar starting_cv_;
-
- std::vector<std::unique_ptr<RegisteredMethod>> registered_methods_;
-
- // Request matcher for unregistered methods.
- std::unique_ptr<RequestMatcherInterface> unregistered_request_matcher_;
-
- std::atomic_bool shutdown_flag_{false};
- bool shutdown_published_ = false;
- std::vector<ShutdownTag> shutdown_tags_;
-
- std::list<ChannelData*> channels_;
-
- std::list<Listener> listeners_;
- size_t listeners_destroyed_ = 0;
-
- // The last time we printed a shutdown progress message.
- gpr_timespec last_shutdown_message_time_;
-};
-
-} // namespace grpc_core
-
-struct grpc_server {
- grpc_core::OrphanablePtr<grpc_core::Server> core_server;
-};
-
+namespace grpc_core {
+
+extern TraceFlag grpc_server_channel_trace;
+
+class Server : public InternallyRefCounted<Server> {
+ public:
+ // Filter vtable.
+ static const grpc_channel_filter kServerTopFilter;
+
+ // Opaque type used for registered methods.
+ struct RegisteredMethod;
+
+ // An object to represent the most relevant characteristics of a
+ // newly-allocated call object when using an AllocatingRequestMatcherBatch.
+ struct BatchCallAllocation {
+ grpc_experimental_completion_queue_functor* tag;
+ grpc_call** call;
+ grpc_metadata_array* initial_metadata;
+ grpc_call_details* details;
+ };
+
+ // An object to represent the most relevant characteristics of a
+ // newly-allocated call object when using an
+ // AllocatingRequestMatcherRegistered.
+ struct RegisteredCallAllocation {
+ grpc_experimental_completion_queue_functor* tag;
+ grpc_call** call;
+ grpc_metadata_array* initial_metadata;
+ gpr_timespec* deadline;
+ grpc_byte_buffer** optional_payload;
+ };
+
+ /// Interface for listeners.
+ /// Implementations must override the Orphan() method, which should stop
+ /// listening and initiate destruction of the listener.
+ class ListenerInterface : public Orphanable {
+ public:
+ virtual ~ListenerInterface() = default;
+
+ /// Starts listening. This listener may refer to the pollset object beyond
+ /// this call, so it is a pointer rather than a reference.
+ virtual void Start(Server* server,
+ const std::vector<grpc_pollset*>* pollsets) = 0;
+
+ /// Returns the channelz node for the listen socket, or null if not
+ /// supported.
+ virtual channelz::ListenSocketNode* channelz_listen_socket_node() const = 0;
+
+ /// Sets a closure to be invoked by the listener when its destruction
+ /// is complete.
+ virtual void SetOnDestroyDone(grpc_closure* on_destroy_done) = 0;
+ };
+
+ explicit Server(const grpc_channel_args* args);
+ ~Server();
+
+ void Orphan() override;
+
+ const grpc_channel_args* channel_args() const { return channel_args_; }
+ grpc_resource_user* default_resource_user() const {
+ return default_resource_user_;
+ }
+ channelz::ServerNode* channelz_node() const { return channelz_node_.get(); }
+
+ // Do not call this before Start(). Returns the pollsets. The
+ // vector itself is immutable, but the pollsets inside are mutable. The
+ // result is valid for the lifetime of the server.
+ const std::vector<grpc_pollset*>& pollsets() const { return pollsets_; }
+
+ bool HasOpenConnections();
+
+ // Adds a listener to the server. When the server starts, it will call
+ // the listener's Start() method, and when it shuts down, it will orphan
+ // the listener.
+ void AddListener(OrphanablePtr<ListenerInterface> listener);
+
+ // Starts listening for connections.
+ void Start();
+
+ // Sets up a transport. Creates a channel stack and binds the transport to
+ // the server. Called from the listener when a new connection is accepted.
+ void SetupTransport(grpc_transport* transport,
+ grpc_pollset* accepting_pollset,
+ const grpc_channel_args* args,
+ const RefCountedPtr<channelz::SocketNode>& socket_node,
+ grpc_resource_user* resource_user = nullptr);
+
+ void RegisterCompletionQueue(grpc_completion_queue* cq);
+
+ // Functions to specify that a specific registered method or the unregistered
+ // collection should use a specific allocator for request matching.
+ void SetRegisteredMethodAllocator(
+ grpc_completion_queue* cq, void* method_tag,
+ std::function<RegisteredCallAllocation()> allocator);
+ void SetBatchMethodAllocator(grpc_completion_queue* cq,
+ std::function<BatchCallAllocation()> allocator);
+
+ RegisteredMethod* RegisterMethod(
+ const char* method, const char* host,
+ grpc_server_register_method_payload_handling payload_handling,
+ uint32_t flags);
+
+ grpc_call_error RequestCall(grpc_call** call, grpc_call_details* details,
+ grpc_metadata_array* request_metadata,
+ grpc_completion_queue* cq_bound_to_call,
+ grpc_completion_queue* cq_for_notification,
+ void* tag);
+
+ grpc_call_error RequestRegisteredCall(
+ RegisteredMethod* rm, grpc_call** call, gpr_timespec* deadline,
+ grpc_metadata_array* request_metadata,
+ grpc_byte_buffer** optional_payload,
+ grpc_completion_queue* cq_bound_to_call,
+ grpc_completion_queue* cq_for_notification, void* tag_new);
+
+ void ShutdownAndNotify(grpc_completion_queue* cq, void* tag);
+
+ void CancelAllCalls();
+
+ private:
+ struct RequestedCall;
+
+ struct ChannelRegisteredMethod {
+ RegisteredMethod* server_registered_method = nullptr;
+ uint32_t flags;
+ bool has_host;
+ ExternallyManagedSlice method;
+ ExternallyManagedSlice host;
+ };
+
+ class RequestMatcherInterface;
+ class RealRequestMatcher;
+ class AllocatingRequestMatcherBase;
+ class AllocatingRequestMatcherBatch;
+ class AllocatingRequestMatcherRegistered;
+
+ class ChannelData {
+ public:
+ ChannelData() = default;
+ ~ChannelData();
+
+ void InitTransport(RefCountedPtr<Server> server, grpc_channel* channel,
+ size_t cq_idx, grpc_transport* transport,
+ intptr_t channelz_socket_uuid);
+
+ RefCountedPtr<Server> server() const { return server_; }
+ grpc_channel* channel() const { return channel_; }
+ size_t cq_idx() const { return cq_idx_; }
+
+ ChannelRegisteredMethod* GetRegisteredMethod(const grpc_slice& host,
+ const grpc_slice& path,
+ bool is_idempotent);
+
+ // Filter vtable functions.
+ static grpc_error* InitChannelElement(grpc_channel_element* elem,
+ grpc_channel_element_args* args);
+ static void DestroyChannelElement(grpc_channel_element* elem);
+
+ private:
+ class ConnectivityWatcher;
+
+ static void AcceptStream(void* arg, grpc_transport* /*transport*/,
+ const void* transport_server_data);
+
+ void Destroy();
+
+ static void FinishDestroy(void* arg, grpc_error* error);
+
+ RefCountedPtr<Server> server_;
+ grpc_channel* channel_;
+ // The index into Server::cqs_ of the CQ used as a starting point for
+ // where to publish new incoming calls.
+ size_t cq_idx_;
+ y_absl::optional<std::list<ChannelData*>::iterator> list_position_;
+ // A hash-table of the methods and hosts of the registered methods.
+ // TODO(vjpai): Convert this to an STL map type as opposed to a direct
+ // bucket implementation. (Consider performance impact, hash function to
+ // use, etc.)
+ std::unique_ptr<std::vector<ChannelRegisteredMethod>> registered_methods_;
+ uint32_t registered_method_max_probes_;
+ grpc_closure finish_destroy_channel_closure_;
+ intptr_t channelz_socket_uuid_;
+ };
+
+ class CallData {
+ public:
+ enum class CallState {
+ NOT_STARTED, // Waiting for metadata.
+ PENDING, // Initial metadata read, not flow controlled in yet.
+ ACTIVATED, // Flow controlled in, on completion queue.
+ ZOMBIED, // Cancelled before being queued.
+ };
+
+ CallData(grpc_call_element* elem, const grpc_call_element_args& args,
+ RefCountedPtr<Server> server);
+ ~CallData();
+
+ // Starts the recv_initial_metadata batch on the call.
+ // Invoked from ChannelData::AcceptStream().
+ void Start(grpc_call_element* elem);
+
+ void SetState(CallState state);
+
+ // Attempts to move from PENDING to ACTIVATED state. Returns true
+ // on success.
+ bool MaybeActivate();
+
+ // Publishes an incoming call to the application after it has been
+ // matched.
+ void Publish(size_t cq_idx, RequestedCall* rc);
+
+ void KillZombie();
+
+ void FailCallCreation();
+
+ // Filter vtable functions.
+ static grpc_error* InitCallElement(grpc_call_element* elem,
+ const grpc_call_element_args* args);
+ static void DestroyCallElement(grpc_call_element* elem,
+ const grpc_call_final_info* /*final_info*/,
+ grpc_closure* /*ignored*/);
+ static void StartTransportStreamOpBatch(
+ grpc_call_element* elem, grpc_transport_stream_op_batch* batch);
+
+ private:
+ // Helper functions for handling calls at the top of the call stack.
+ static void RecvInitialMetadataBatchComplete(void* arg, grpc_error* error);
+ void StartNewRpc(grpc_call_element* elem);
+ static void PublishNewRpc(void* arg, grpc_error* error);
+
+ // Functions used inside the call stack.
+ void StartTransportStreamOpBatchImpl(grpc_call_element* elem,
+ grpc_transport_stream_op_batch* batch);
+ static void RecvInitialMetadataReady(void* arg, grpc_error* error);
+ static void RecvTrailingMetadataReady(void* arg, grpc_error* error);
+
+ RefCountedPtr<Server> server_;
+
+ grpc_call* call_;
+
+ Atomic<CallState> state_{CallState::NOT_STARTED};
+
+ y_absl::optional<grpc_slice> path_;
+ y_absl::optional<grpc_slice> host_;
+ grpc_millis deadline_ = GRPC_MILLIS_INF_FUTURE;
+
+ grpc_completion_queue* cq_new_ = nullptr;
+
+ RequestMatcherInterface* matcher_ = nullptr;
+ grpc_byte_buffer* payload_ = nullptr;
+
+ grpc_closure kill_zombie_closure_;
+
+ grpc_metadata_array initial_metadata_ =
+ grpc_metadata_array(); // Zero-initialize the C struct.
+ grpc_closure recv_initial_metadata_batch_complete_;
+
+ grpc_metadata_batch* recv_initial_metadata_ = nullptr;
+ uint32_t recv_initial_metadata_flags_ = 0;
+ grpc_closure recv_initial_metadata_ready_;
+ grpc_closure* original_recv_initial_metadata_ready_;
+ grpc_error* recv_initial_metadata_error_ = GRPC_ERROR_NONE;
+
+ bool seen_recv_trailing_metadata_ready_ = false;
+ grpc_closure recv_trailing_metadata_ready_;
+ grpc_closure* original_recv_trailing_metadata_ready_;
+ grpc_error* recv_trailing_metadata_error_ = GRPC_ERROR_NONE;
+
+ grpc_closure publish_;
+
+ CallCombiner* call_combiner_;
+ };
+
+ struct Listener {
+ explicit Listener(OrphanablePtr<ListenerInterface> l)
+ : listener(std::move(l)) {}
+ OrphanablePtr<ListenerInterface> listener;
+ grpc_closure destroy_done;
+ };
+
+ struct ShutdownTag {
+ ShutdownTag(void* tag_arg, grpc_completion_queue* cq_arg)
+ : tag(tag_arg), cq(cq_arg) {}
+ void* const tag;
+ grpc_completion_queue* const cq;
+ grpc_cq_completion completion;
+ };
+
+ static void ListenerDestroyDone(void* arg, grpc_error* error);
+
+ static void DoneShutdownEvent(void* server,
+ grpc_cq_completion* /*completion*/) {
+ static_cast<Server*>(server)->Unref();
+ }
+
+ static void DoneRequestEvent(void* req, grpc_cq_completion* completion);
+
+ void FailCall(size_t cq_idx, RequestedCall* rc, grpc_error* error);
+ grpc_call_error QueueRequestedCall(size_t cq_idx, RequestedCall* rc);
+
+ void MaybeFinishShutdown();
+
+ void KillPendingWorkLocked(grpc_error* error);
+
+ static grpc_call_error ValidateServerRequest(
+ grpc_completion_queue* cq_for_notification, void* tag,
+ grpc_byte_buffer** optional_payload, RegisteredMethod* rm);
+ grpc_call_error ValidateServerRequestAndCq(
+ size_t* cq_idx, grpc_completion_queue* cq_for_notification, void* tag,
+ grpc_byte_buffer** optional_payload, RegisteredMethod* rm);
+
+ std::vector<grpc_channel*> GetChannelsLocked() const;
+
+ grpc_channel_args* const channel_args_;
+ grpc_resource_user* default_resource_user_ = nullptr;
+ RefCountedPtr<channelz::ServerNode> channelz_node_;
+
+ std::vector<grpc_completion_queue*> cqs_;
+ std::vector<grpc_pollset*> pollsets_;
+ bool started_ = false;
+
+ // The two following mutexes control access to server-state.
+ // mu_global_ controls access to non-call-related state (e.g., channel state).
+ // mu_call_ controls access to call-related state (e.g., the call lists).
+ //
+ // If they are ever required to be nested, you must lock mu_global_
+ // before mu_call_. This is currently used in shutdown processing
+ // (ShutdownAndNotify() and MaybeFinishShutdown()).
+ Mutex mu_global_; // mutex for server and channel state
+ Mutex mu_call_; // mutex for call-specific state
+
+ // startup synchronization: flag is protected by mu_global_, signals whether
+ // we are doing the listener start routine or not.
+ bool starting_ = false;
+ CondVar starting_cv_;
+
+ std::vector<std::unique_ptr<RegisteredMethod>> registered_methods_;
+
+ // Request matcher for unregistered methods.
+ std::unique_ptr<RequestMatcherInterface> unregistered_request_matcher_;
+
+ std::atomic_bool shutdown_flag_{false};
+ bool shutdown_published_ = false;
+ std::vector<ShutdownTag> shutdown_tags_;
+
+ std::list<ChannelData*> channels_;
+
+ std::list<Listener> listeners_;
+ size_t listeners_destroyed_ = 0;
+
+ // The last time we printed a shutdown progress message.
+ gpr_timespec last_shutdown_message_time_;
+};
+
+} // namespace grpc_core
+
+struct grpc_server {
+ grpc_core::OrphanablePtr<grpc_core::Server> core_server;
+};
+
#endif /* GRPC_CORE_LIB_SURFACE_SERVER_H */
diff --git a/contrib/libs/grpc/src/core/lib/surface/version.cc b/contrib/libs/grpc/src/core/lib/surface/version.cc
index 1cf5eafd0b..bed4f427e9 100644
--- a/contrib/libs/grpc/src/core/lib/surface/version.cc
+++ b/contrib/libs/grpc/src/core/lib/surface/version.cc
@@ -23,6 +23,6 @@
#include <grpc/grpc.h>
-const char* grpc_version_string(void) { return "13.0.0"; }
+const char* grpc_version_string(void) { return "13.0.0"; }
-const char* grpc_g_stands_for(void) { return "geeky"; }
+const char* grpc_g_stands_for(void) { return "geeky"; }
diff --git a/contrib/libs/grpc/src/core/lib/transport/authority_override.cc b/contrib/libs/grpc/src/core/lib/transport/authority_override.cc
index 5abb13386e..8c13320b73 100644
--- a/contrib/libs/grpc/src/core/lib/transport/authority_override.cc
+++ b/contrib/libs/grpc/src/core/lib/transport/authority_override.cc
@@ -1,38 +1,38 @@
-//
-// Copyright 2020 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-#include <grpc/support/port_platform.h>
-
-#include "src/core/lib/channel/channel_args.h"
-
-// Channel arg key for the authority override.
-#define GRPC_ARG_AUTHORITY_OVERRIDE "grpc.authority_override"
-
-namespace grpc_core {
-
-/// Returns a channel argument containing \a authority.
-grpc_arg CreateAuthorityOverrideChannelArg(const char* authority) {
- return grpc_channel_arg_string_create(
- const_cast<char*>(GRPC_ARG_AUTHORITY_OVERRIDE),
- const_cast<char*>(authority));
-}
-
-/// Returns the authority override from \a args or nullptr.
-const char* FindAuthorityOverrideInArgs(const grpc_channel_args* args) {
- return grpc_channel_args_find_string(args, GRPC_ARG_AUTHORITY_OVERRIDE);
-}
-
-} // namespace grpc_core
+//
+// Copyright 2020 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <grpc/support/port_platform.h>
+
+#include "src/core/lib/channel/channel_args.h"
+
+// Channel arg key for the authority override.
+#define GRPC_ARG_AUTHORITY_OVERRIDE "grpc.authority_override"
+
+namespace grpc_core {
+
+/// Returns a channel argument containing \a authority.
+grpc_arg CreateAuthorityOverrideChannelArg(const char* authority) {
+ return grpc_channel_arg_string_create(
+ const_cast<char*>(GRPC_ARG_AUTHORITY_OVERRIDE),
+ const_cast<char*>(authority));
+}
+
+/// Returns the authority override from \a args or nullptr.
+const char* FindAuthorityOverrideInArgs(const grpc_channel_args* args) {
+ return grpc_channel_args_find_string(args, GRPC_ARG_AUTHORITY_OVERRIDE);
+}
+
+} // namespace grpc_core
diff --git a/contrib/libs/grpc/src/core/lib/transport/authority_override.h b/contrib/libs/grpc/src/core/lib/transport/authority_override.h
index 667b33aaf4..9e584b56cb 100644
--- a/contrib/libs/grpc/src/core/lib/transport/authority_override.h
+++ b/contrib/libs/grpc/src/core/lib/transport/authority_override.h
@@ -1,32 +1,32 @@
-//
-// Copyright 2020 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-#ifndef GRPC_CORE_LIB_TRANSPORT_AUTHORITY_OVERRIDE_H
-#define GRPC_CORE_LIB_TRANSPORT_AUTHORITY_OVERRIDE_H
-
-#include <grpc/support/port_platform.h>
-
-namespace grpc_core {
-
-/// Returns a channel argument containing \a authority.
-grpc_arg CreateAuthorityOverrideChannelArg(const char* authority);
-
-/// Returns the authority override from \a args or nullptr.
-const char* FindAuthorityOverrideInArgs(const grpc_channel_args* args);
-
-} // namespace grpc_core
-
-#endif /* GRPC_CORE_LIB_TRANSPORT_AUTHORITY_OVERRIDE_H */
+//
+// Copyright 2020 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef GRPC_CORE_LIB_TRANSPORT_AUTHORITY_OVERRIDE_H
+#define GRPC_CORE_LIB_TRANSPORT_AUTHORITY_OVERRIDE_H
+
+#include <grpc/support/port_platform.h>
+
+namespace grpc_core {
+
+/// Returns a channel argument containing \a authority.
+grpc_arg CreateAuthorityOverrideChannelArg(const char* authority);
+
+/// Returns the authority override from \a args or nullptr.
+const char* FindAuthorityOverrideInArgs(const grpc_channel_args* args);
+
+} // namespace grpc_core
+
+#endif /* GRPC_CORE_LIB_TRANSPORT_AUTHORITY_OVERRIDE_H */
diff --git a/contrib/libs/grpc/src/core/lib/transport/bdp_estimator.h b/contrib/libs/grpc/src/core/lib/transport/bdp_estimator.h
index babbdab93f..7eb336d8bb 100644
--- a/contrib/libs/grpc/src/core/lib/transport/bdp_estimator.h
+++ b/contrib/libs/grpc/src/core/lib/transport/bdp_estimator.h
@@ -74,8 +74,8 @@ class BdpEstimator {
// Completes a previously started ping, returns when to schedule the next one
grpc_millis CompletePing();
- int64_t accumulator() { return accumulator_; }
-
+ int64_t accumulator() { return accumulator_; }
+
private:
enum class PingState { UNSCHEDULED, SCHEDULED, STARTED };
diff --git a/contrib/libs/grpc/src/core/lib/transport/byte_stream.h b/contrib/libs/grpc/src/core/lib/transport/byte_stream.h
index f56eeeb5ae..ecb605ad9b 100644
--- a/contrib/libs/grpc/src/core/lib/transport/byte_stream.h
+++ b/contrib/libs/grpc/src/core/lib/transport/byte_stream.h
@@ -26,15 +26,15 @@
#include "src/core/lib/iomgr/closure.h"
/** Internal bit flag for grpc_begin_message's \a flags signaling the use of
- * compression for the message. (Does not apply for stream compression.) */
+ * compression for the message. (Does not apply for stream compression.) */
#define GRPC_WRITE_INTERNAL_COMPRESS (0x80000000u)
-/** Internal bit flag for determining whether the message was compressed and had
- * to be decompressed by the message_decompress filter. (Does not apply for
- * stream compression.) */
-#define GRPC_WRITE_INTERNAL_TEST_ONLY_WAS_COMPRESSED (0x40000000u)
+/** Internal bit flag for determining whether the message was compressed and had
+ * to be decompressed by the message_decompress filter. (Does not apply for
+ * stream compression.) */
+#define GRPC_WRITE_INTERNAL_TEST_ONLY_WAS_COMPRESSED (0x40000000u)
/** Mask of all valid internal flags. */
-#define GRPC_WRITE_INTERNAL_USED_MASK \
- (GRPC_WRITE_INTERNAL_COMPRESS | GRPC_WRITE_INTERNAL_TEST_ONLY_WAS_COMPRESSED)
+#define GRPC_WRITE_INTERNAL_USED_MASK \
+ (GRPC_WRITE_INTERNAL_COMPRESS | GRPC_WRITE_INTERNAL_TEST_ONLY_WAS_COMPRESSED)
namespace grpc_core {
diff --git a/contrib/libs/grpc/src/core/lib/transport/connectivity_state.cc b/contrib/libs/grpc/src/core/lib/transport/connectivity_state.cc
index 016faa39c1..7b13049017 100644
--- a/contrib/libs/grpc/src/core/lib/transport/connectivity_state.cc
+++ b/contrib/libs/grpc/src/core/lib/transport/connectivity_state.cc
@@ -58,13 +58,13 @@ const char* ConnectivityStateName(grpc_connectivity_state state) {
class AsyncConnectivityStateWatcherInterface::Notifier {
public:
Notifier(RefCountedPtr<AsyncConnectivityStateWatcherInterface> watcher,
- grpc_connectivity_state state, const y_absl::Status& status,
- const std::shared_ptr<WorkSerializer>& work_serializer)
- : watcher_(std::move(watcher)), state_(state), status_(status) {
- if (work_serializer != nullptr) {
- work_serializer->Run(
- [this]() { SendNotification(this, GRPC_ERROR_NONE); },
- DEBUG_LOCATION);
+ grpc_connectivity_state state, const y_absl::Status& status,
+ const std::shared_ptr<WorkSerializer>& work_serializer)
+ : watcher_(std::move(watcher)), state_(state), status_(status) {
+ if (work_serializer != nullptr) {
+ work_serializer->Run(
+ [this]() { SendNotification(this, GRPC_ERROR_NONE); },
+ DEBUG_LOCATION);
} else {
GRPC_CLOSURE_INIT(&closure_, SendNotification, this,
grpc_schedule_on_exec_ctx);
@@ -76,24 +76,24 @@ class AsyncConnectivityStateWatcherInterface::Notifier {
static void SendNotification(void* arg, grpc_error* /*ignored*/) {
Notifier* self = static_cast<Notifier*>(arg);
if (GRPC_TRACE_FLAG_ENABLED(grpc_connectivity_state_trace)) {
- gpr_log(GPR_INFO, "watcher %p: delivering async notification for %s (%s)",
- self->watcher_.get(), ConnectivityStateName(self->state_),
- self->status_.ToString().c_str());
+ gpr_log(GPR_INFO, "watcher %p: delivering async notification for %s (%s)",
+ self->watcher_.get(), ConnectivityStateName(self->state_),
+ self->status_.ToString().c_str());
}
- self->watcher_->OnConnectivityStateChange(self->state_, self->status_);
+ self->watcher_->OnConnectivityStateChange(self->state_, self->status_);
delete self;
}
RefCountedPtr<AsyncConnectivityStateWatcherInterface> watcher_;
const grpc_connectivity_state state_;
- const y_absl::Status status_;
+ const y_absl::Status status_;
grpc_closure closure_;
};
void AsyncConnectivityStateWatcherInterface::Notify(
- grpc_connectivity_state state, const y_absl::Status& status) {
- new Notifier(Ref(), state, status,
- work_serializer_); // Deletes itself when done.
+ grpc_connectivity_state state, const y_absl::Status& status) {
+ new Notifier(Ref(), state, status,
+ work_serializer_); // Deletes itself when done.
}
//
@@ -110,7 +110,7 @@ ConnectivityStateTracker::~ConnectivityStateTracker() {
name_, this, p.first, ConnectivityStateName(current_state),
ConnectivityStateName(GRPC_CHANNEL_SHUTDOWN));
}
- p.second->Notify(GRPC_CHANNEL_SHUTDOWN, y_absl::Status());
+ p.second->Notify(GRPC_CHANNEL_SHUTDOWN, y_absl::Status());
}
}
@@ -129,7 +129,7 @@ void ConnectivityStateTracker::AddWatcher(
name_, this, watcher.get(), ConnectivityStateName(initial_state),
ConnectivityStateName(current_state));
}
- watcher->Notify(current_state, status_);
+ watcher->Notify(current_state, status_);
}
// If we're in state SHUTDOWN, don't add the watcher, so that it will
// be orphaned immediately.
@@ -148,17 +148,17 @@ void ConnectivityStateTracker::RemoveWatcher(
}
void ConnectivityStateTracker::SetState(grpc_connectivity_state state,
- const y_absl::Status& status,
+ const y_absl::Status& status,
const char* reason) {
grpc_connectivity_state current_state = state_.Load(MemoryOrder::RELAXED);
if (state == current_state) return;
if (GRPC_TRACE_FLAG_ENABLED(grpc_connectivity_state_trace)) {
- gpr_log(GPR_INFO, "ConnectivityStateTracker %s[%p]: %s -> %s (%s, %s)",
- name_, this, ConnectivityStateName(current_state),
- ConnectivityStateName(state), reason, status.ToString().c_str());
+ gpr_log(GPR_INFO, "ConnectivityStateTracker %s[%p]: %s -> %s (%s, %s)",
+ name_, this, ConnectivityStateName(current_state),
+ ConnectivityStateName(state), reason, status.ToString().c_str());
}
state_.Store(state, MemoryOrder::RELAXED);
- status_ = status;
+ status_ = status;
for (const auto& p : watchers_) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_connectivity_state_trace)) {
gpr_log(GPR_INFO,
@@ -166,7 +166,7 @@ void ConnectivityStateTracker::SetState(grpc_connectivity_state state,
name_, this, p.first, ConnectivityStateName(current_state),
ConnectivityStateName(state));
}
- p.second->Notify(state, status);
+ p.second->Notify(state, status);
}
// If the new state is SHUTDOWN, orphan all of the watchers. This
// avoids the need for the callers to explicitly cancel them.
diff --git a/contrib/libs/grpc/src/core/lib/transport/connectivity_state.h b/contrib/libs/grpc/src/core/lib/transport/connectivity_state.h
index 21408bab6b..9e34c646c7 100644
--- a/contrib/libs/grpc/src/core/lib/transport/connectivity_state.h
+++ b/contrib/libs/grpc/src/core/lib/transport/connectivity_state.h
@@ -21,8 +21,8 @@
#include <grpc/support/port_platform.h>
-#include "y_absl/status/status.h"
-
+#include "y_absl/status/status.h"
+
#include <grpc/grpc.h>
#include "src/core/lib/debug/trace.h"
@@ -31,7 +31,7 @@
#include "src/core/lib/gprpp/orphanable.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/exec_ctx.h"
-#include "src/core/lib/iomgr/work_serializer.h"
+#include "src/core/lib/iomgr/work_serializer.h"
namespace grpc_core {
@@ -51,8 +51,8 @@ class ConnectivityStateWatcherInterface
virtual ~ConnectivityStateWatcherInterface() = default;
// Notifies the watcher that the state has changed to new_state.
- virtual void Notify(grpc_connectivity_state new_state,
- const y_absl::Status& status) = 0;
+ virtual void Notify(grpc_connectivity_state new_state,
+ const y_absl::Status& status) = 0;
void Orphan() override { Unref(); }
};
@@ -67,24 +67,24 @@ class AsyncConnectivityStateWatcherInterface
// Schedules a closure on the ExecCtx to invoke
// OnConnectivityStateChange() asynchronously.
- void Notify(grpc_connectivity_state new_state,
- const y_absl::Status& status) override final;
+ void Notify(grpc_connectivity_state new_state,
+ const y_absl::Status& status) override final;
protected:
class Notifier;
- // If \a work_serializer is nullptr, then the notification will be scheduled
- // on the ExecCtx.
- explicit AsyncConnectivityStateWatcherInterface(
- std::shared_ptr<WorkSerializer> work_serializer = nullptr)
- : work_serializer_(std::move(work_serializer)) {}
+ // If \a work_serializer is nullptr, then the notification will be scheduled
+ // on the ExecCtx.
+ explicit AsyncConnectivityStateWatcherInterface(
+ std::shared_ptr<WorkSerializer> work_serializer = nullptr)
+ : work_serializer_(std::move(work_serializer)) {}
// Invoked asynchronously when Notify() is called.
- virtual void OnConnectivityStateChange(grpc_connectivity_state new_state,
- const y_absl::Status& status) = 0;
+ virtual void OnConnectivityStateChange(grpc_connectivity_state new_state,
+ const y_absl::Status& status) = 0;
private:
- std::shared_ptr<WorkSerializer> work_serializer_;
+ std::shared_ptr<WorkSerializer> work_serializer_;
};
// Tracks connectivity state. Maintains a list of watchers that are
@@ -96,9 +96,9 @@ class AsyncConnectivityStateWatcherInterface
class ConnectivityStateTracker {
public:
ConnectivityStateTracker(const char* name,
- grpc_connectivity_state state = GRPC_CHANNEL_IDLE,
- const y_absl::Status& status = y_absl::Status())
- : name_(name), state_(state), status_(status) {}
+ grpc_connectivity_state state = GRPC_CHANNEL_IDLE,
+ const y_absl::Status& status = y_absl::Status())
+ : name_(name), state_(state), status_(status) {}
~ConnectivityStateTracker();
@@ -116,21 +116,21 @@ class ConnectivityStateTracker {
// Sets connectivity state.
// Not thread safe; access must be serialized with an external lock.
- void SetState(grpc_connectivity_state state, const y_absl::Status& status,
- const char* reason);
+ void SetState(grpc_connectivity_state state, const y_absl::Status& status,
+ const char* reason);
// Gets the current state.
// Thread safe; no need to use an external lock.
grpc_connectivity_state state() const;
- // Get the current status.
- // Not thread safe; access must be serialized with an external lock.
- y_absl::Status status() const { return status_; }
-
+ // Get the current status.
+ // Not thread safe; access must be serialized with an external lock.
+ y_absl::Status status() const { return status_; }
+
private:
const char* name_;
Atomic<grpc_connectivity_state> state_;
- y_absl::Status status_;
+ y_absl::Status status_;
// TODO(roth): Once we can use C++-14 heterogeneous lookups, this can
// be a set instead of a map.
std::map<ConnectivityStateWatcherInterface*,
diff --git a/contrib/libs/grpc/src/core/lib/transport/error_utils.cc b/contrib/libs/grpc/src/core/lib/transport/error_utils.cc
index a17e630f94..9634f09ad1 100644
--- a/contrib/libs/grpc/src/core/lib/transport/error_utils.cc
+++ b/contrib/libs/grpc/src/core/lib/transport/error_utils.cc
@@ -123,19 +123,19 @@ void grpc_error_get_status(grpc_error* error, grpc_millis deadline,
}
}
-y_absl::Status grpc_error_to_absl_status(grpc_error* error) {
- grpc_status_code status;
- // TODO(yashykt): This should be updated once we decide on how to use the
- // y_absl::Status payload to capture all the contents of grpc_error.
- grpc_slice message;
- grpc_error_get_status(error, GRPC_MILLIS_INF_FUTURE, &status, &message,
- nullptr /* http_error */, nullptr /* error_string */);
- return y_absl::Status(static_cast<y_absl::StatusCode>(status),
- y_absl::string_view(reinterpret_cast<const char*>(
- GRPC_SLICE_START_PTR(message)),
- GRPC_SLICE_LENGTH(message)));
-}
-
+y_absl::Status grpc_error_to_absl_status(grpc_error* error) {
+ grpc_status_code status;
+ // TODO(yashykt): This should be updated once we decide on how to use the
+ // y_absl::Status payload to capture all the contents of grpc_error.
+ grpc_slice message;
+ grpc_error_get_status(error, GRPC_MILLIS_INF_FUTURE, &status, &message,
+ nullptr /* http_error */, nullptr /* error_string */);
+ return y_absl::Status(static_cast<y_absl::StatusCode>(status),
+ y_absl::string_view(reinterpret_cast<const char*>(
+ GRPC_SLICE_START_PTR(message)),
+ GRPC_SLICE_LENGTH(message)));
+}
+
bool grpc_error_has_clear_grpc_status(grpc_error* error) {
intptr_t unused;
if (grpc_error_get_int(error, GRPC_ERROR_INT_GRPC_STATUS, &unused)) {
diff --git a/contrib/libs/grpc/src/core/lib/transport/error_utils.h b/contrib/libs/grpc/src/core/lib/transport/error_utils.h
index 8d34d99341..fb967202f3 100644
--- a/contrib/libs/grpc/src/core/lib/transport/error_utils.h
+++ b/contrib/libs/grpc/src/core/lib/transport/error_utils.h
@@ -21,8 +21,8 @@
#include <grpc/support/port_platform.h>
-#include "y_absl/status/status.h"
-
+#include "y_absl/status/status.h"
+
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/transport/http2_errors.h"
@@ -39,10 +39,10 @@ void grpc_error_get_status(grpc_error* error, grpc_millis deadline,
grpc_http2_error_code* http_status,
const char** error_string);
-/// Utility Function to convert a grpc_error * \a error to an y_absl::Status.
-/// Does NOT consume a ref to grpc_error.
-y_absl::Status grpc_error_to_absl_status(grpc_error* error);
-
+/// Utility Function to convert a grpc_error * \a error to an y_absl::Status.
+/// Does NOT consume a ref to grpc_error.
+y_absl::Status grpc_error_to_absl_status(grpc_error* error);
+
/// A utility function to check whether there is a clear status code that
/// doesn't need to be guessed in \a error. This means that \a error or some
/// child has GRPC_ERROR_INT_GRPC_STATUS set, or that it is GRPC_ERROR_NONE or
diff --git a/contrib/libs/grpc/src/core/lib/transport/metadata.cc b/contrib/libs/grpc/src/core/lib/transport/metadata.cc
index 51a86f7596..33d4d5ac70 100644
--- a/contrib/libs/grpc/src/core/lib/transport/metadata.cc
+++ b/contrib/libs/grpc/src/core/lib/transport/metadata.cc
@@ -250,25 +250,25 @@ void grpc_mdctx_global_shutdown() {
gpr_mu_destroy(&shard->mu);
gc_mdtab(shard);
if (shard->count != 0) {
- gpr_log(GPR_ERROR, "WARNING: %" PRIuPTR " metadata elements were leaked",
+ gpr_log(GPR_ERROR, "WARNING: %" PRIuPTR " metadata elements were leaked",
shard->count);
- for (int i = 0; i < shard->capacity; i++) {
- for (InternedMetadata* md = shard->elems[i].next; md;
- md = md->bucket_next()) {
- char* key_str = grpc_slice_to_c_string(md->key());
- char* value_str = grpc_slice_to_c_string(md->value());
- gpr_log(GPR_ERROR, "mdelem '%s' = '%s'", key_str, value_str);
- gpr_free(key_str);
- gpr_free(value_str);
- }
- }
+ for (int i = 0; i < shard->capacity; i++) {
+ for (InternedMetadata* md = shard->elems[i].next; md;
+ md = md->bucket_next()) {
+ char* key_str = grpc_slice_to_c_string(md->key());
+ char* value_str = grpc_slice_to_c_string(md->value());
+ gpr_log(GPR_ERROR, "mdelem '%s' = '%s'", key_str, value_str);
+ gpr_free(key_str);
+ gpr_free(value_str);
+ }
+ }
if (grpc_iomgr_abort_on_leaks()) {
abort();
}
}
- // For ASAN builds, we don't want to crash here, because that will
- // prevent ASAN from providing leak detection information, which is
- // far more useful than this simple assertion.
+ // For ASAN builds, we don't want to crash here, because that will
+ // prevent ASAN from providing leak detection information, which is
+ // far more useful than this simple assertion.
#ifndef GRPC_ASAN_ENABLED
GPR_DEBUG_ASSERT(shard->count == 0);
#endif
diff --git a/contrib/libs/grpc/src/core/lib/transport/static_metadata.cc b/contrib/libs/grpc/src/core/lib/transport/static_metadata.cc
index 6ee9665700..e027c00d39 100644
--- a/contrib/libs/grpc/src/core/lib/transport/static_metadata.cc
+++ b/contrib/libs/grpc/src/core/lib/transport/static_metadata.cc
@@ -68,68 +68,68 @@ static constexpr uint8_t g_bytes[] = {
114, 118, 105, 99, 101, 46, 108, 111, 97, 100, 95, 115, 116, 97, 116,
115, 46, 118, 50, 46, 76, 111, 97, 100, 82, 101, 112, 111, 114, 116,
105, 110, 103, 83, 101, 114, 118, 105, 99, 101, 47, 83, 116, 114, 101,
- 97, 109, 76, 111, 97, 100, 83, 116, 97, 116, 115, 47, 101, 110, 118,
- 111, 121, 46, 115, 101, 114, 118, 105, 99, 101, 46, 108, 111, 97, 100,
- 95, 115, 116, 97, 116, 115, 46, 118, 51, 46, 76, 111, 97, 100, 82,
- 101, 112, 111, 114, 116, 105, 110, 103, 83, 101, 114, 118, 105, 99, 101,
- 47, 83, 116, 114, 101, 97, 109, 76, 111, 97, 100, 83, 116, 97, 116,
- 115, 47, 103, 114, 112, 99, 46, 104, 101, 97, 108, 116, 104, 46, 118,
- 49, 46, 72, 101, 97, 108, 116, 104, 47, 87, 97, 116, 99, 104, 47,
- 101, 110, 118, 111, 121, 46, 115, 101, 114, 118, 105, 99, 101, 46, 100,
- 105, 115, 99, 111, 118, 101, 114, 121, 46, 118, 50, 46, 65, 103, 103,
- 114, 101, 103, 97, 116, 101, 100, 68, 105, 115, 99, 111, 118, 101, 114,
- 121, 83, 101, 114, 118, 105, 99, 101, 47, 83, 116, 114, 101, 97, 109,
- 65, 103, 103, 114, 101, 103, 97, 116, 101, 100, 82, 101, 115, 111, 117,
- 114, 99, 101, 115, 47, 101, 110, 118, 111, 121, 46, 115, 101, 114, 118,
- 105, 99, 101, 46, 100, 105, 115, 99, 111, 118, 101, 114, 121, 46, 118,
- 51, 46, 65, 103, 103, 114, 101, 103, 97, 116, 101, 100, 68, 105, 115,
- 99, 111, 118, 101, 114, 121, 83, 101, 114, 118, 105, 99, 101, 47, 83,
- 116, 114, 101, 97, 109, 65, 103, 103, 114, 101, 103, 97, 116, 101, 100,
- 82, 101, 115, 111, 117, 114, 99, 101, 115, 100, 101, 102, 108, 97, 116,
- 101, 103, 122, 105, 112, 115, 116, 114, 101, 97, 109, 47, 103, 122, 105,
- 112, 71, 69, 84, 80, 79, 83, 84, 47, 47, 105, 110, 100, 101, 120,
- 46, 104, 116, 109, 108, 104, 116, 116, 112, 104, 116, 116, 112, 115, 50,
- 48, 48, 50, 48, 52, 50, 48, 54, 51, 48, 52, 52, 48, 48, 52,
- 48, 52, 53, 48, 48, 97, 99, 99, 101, 112, 116, 45, 99, 104, 97,
- 114, 115, 101, 116, 103, 122, 105, 112, 44, 32, 100, 101, 102, 108, 97,
- 116, 101, 97, 99, 99, 101, 112, 116, 45, 108, 97, 110, 103, 117, 97,
- 103, 101, 97, 99, 99, 101, 112, 116, 45, 114, 97, 110, 103, 101, 115,
- 97, 99, 99, 101, 112, 116, 97, 99, 99, 101, 115, 115, 45, 99, 111,
- 110, 116, 114, 111, 108, 45, 97, 108, 108, 111, 119, 45, 111, 114, 105,
- 103, 105, 110, 97, 103, 101, 97, 108, 108, 111, 119, 97, 117, 116, 104,
- 111, 114, 105, 122, 97, 116, 105, 111, 110, 99, 97, 99, 104, 101, 45,
- 99, 111, 110, 116, 114, 111, 108, 99, 111, 110, 116, 101, 110, 116, 45,
- 100, 105, 115, 112, 111, 115, 105, 116, 105, 111, 110, 99, 111, 110, 116,
- 101, 110, 116, 45, 108, 97, 110, 103, 117, 97, 103, 101, 99, 111, 110,
- 116, 101, 110, 116, 45, 108, 101, 110, 103, 116, 104, 99, 111, 110, 116,
- 101, 110, 116, 45, 108, 111, 99, 97, 116, 105, 111, 110, 99, 111, 110,
- 116, 101, 110, 116, 45, 114, 97, 110, 103, 101, 99, 111, 111, 107, 105,
- 101, 100, 97, 116, 101, 101, 116, 97, 103, 101, 120, 112, 101, 99, 116,
- 101, 120, 112, 105, 114, 101, 115, 102, 114, 111, 109, 105, 102, 45, 109,
- 97, 116, 99, 104, 105, 102, 45, 109, 111, 100, 105, 102, 105, 101, 100,
- 45, 115, 105, 110, 99, 101, 105, 102, 45, 110, 111, 110, 101, 45, 109,
- 97, 116, 99, 104, 105, 102, 45, 114, 97, 110, 103, 101, 105, 102, 45,
- 117, 110, 109, 111, 100, 105, 102, 105, 101, 100, 45, 115, 105, 110, 99,
- 101, 108, 97, 115, 116, 45, 109, 111, 100, 105, 102, 105, 101, 100, 108,
- 105, 110, 107, 108, 111, 99, 97, 116, 105, 111, 110, 109, 97, 120, 45,
- 102, 111, 114, 119, 97, 114, 100, 115, 112, 114, 111, 120, 121, 45, 97,
- 117, 116, 104, 101, 110, 116, 105, 99, 97, 116, 101, 112, 114, 111, 120,
- 121, 45, 97, 117, 116, 104, 111, 114, 105, 122, 97, 116, 105, 111, 110,
- 114, 97, 110, 103, 101, 114, 101, 102, 101, 114, 101, 114, 114, 101, 102,
- 114, 101, 115, 104, 114, 101, 116, 114, 121, 45, 97, 102, 116, 101, 114,
- 115, 101, 114, 118, 101, 114, 115, 101, 116, 45, 99, 111, 111, 107, 105,
- 101, 115, 116, 114, 105, 99, 116, 45, 116, 114, 97, 110, 115, 112, 111,
- 114, 116, 45, 115, 101, 99, 117, 114, 105, 116, 121, 116, 114, 97, 110,
- 115, 102, 101, 114, 45, 101, 110, 99, 111, 100, 105, 110, 103, 118, 97,
- 114, 121, 118, 105, 97, 119, 119, 119, 45, 97, 117, 116, 104, 101, 110,
- 116, 105, 99, 97, 116, 101, 48, 105, 100, 101, 110, 116, 105, 116, 121,
- 116, 114, 97, 105, 108, 101, 114, 115, 97, 112, 112, 108, 105, 99, 97,
- 116, 105, 111, 110, 47, 103, 114, 112, 99, 103, 114, 112, 99, 80, 85,
- 84, 108, 98, 45, 99, 111, 115, 116, 45, 98, 105, 110, 105, 100, 101,
- 110, 116, 105, 116, 121, 44, 100, 101, 102, 108, 97, 116, 101, 105, 100,
- 101, 110, 116, 105, 116, 121, 44, 103, 122, 105, 112, 100, 101, 102, 108,
- 97, 116, 101, 44, 103, 122, 105, 112, 105, 100, 101, 110, 116, 105, 116,
- 121, 44, 100, 101, 102, 108, 97, 116, 101, 44, 103, 122, 105, 112};
+ 97, 109, 76, 111, 97, 100, 83, 116, 97, 116, 115, 47, 101, 110, 118,
+ 111, 121, 46, 115, 101, 114, 118, 105, 99, 101, 46, 108, 111, 97, 100,
+ 95, 115, 116, 97, 116, 115, 46, 118, 51, 46, 76, 111, 97, 100, 82,
+ 101, 112, 111, 114, 116, 105, 110, 103, 83, 101, 114, 118, 105, 99, 101,
+ 47, 83, 116, 114, 101, 97, 109, 76, 111, 97, 100, 83, 116, 97, 116,
+ 115, 47, 103, 114, 112, 99, 46, 104, 101, 97, 108, 116, 104, 46, 118,
+ 49, 46, 72, 101, 97, 108, 116, 104, 47, 87, 97, 116, 99, 104, 47,
+ 101, 110, 118, 111, 121, 46, 115, 101, 114, 118, 105, 99, 101, 46, 100,
+ 105, 115, 99, 111, 118, 101, 114, 121, 46, 118, 50, 46, 65, 103, 103,
+ 114, 101, 103, 97, 116, 101, 100, 68, 105, 115, 99, 111, 118, 101, 114,
+ 121, 83, 101, 114, 118, 105, 99, 101, 47, 83, 116, 114, 101, 97, 109,
+ 65, 103, 103, 114, 101, 103, 97, 116, 101, 100, 82, 101, 115, 111, 117,
+ 114, 99, 101, 115, 47, 101, 110, 118, 111, 121, 46, 115, 101, 114, 118,
+ 105, 99, 101, 46, 100, 105, 115, 99, 111, 118, 101, 114, 121, 46, 118,
+ 51, 46, 65, 103, 103, 114, 101, 103, 97, 116, 101, 100, 68, 105, 115,
+ 99, 111, 118, 101, 114, 121, 83, 101, 114, 118, 105, 99, 101, 47, 83,
+ 116, 114, 101, 97, 109, 65, 103, 103, 114, 101, 103, 97, 116, 101, 100,
+ 82, 101, 115, 111, 117, 114, 99, 101, 115, 100, 101, 102, 108, 97, 116,
+ 101, 103, 122, 105, 112, 115, 116, 114, 101, 97, 109, 47, 103, 122, 105,
+ 112, 71, 69, 84, 80, 79, 83, 84, 47, 47, 105, 110, 100, 101, 120,
+ 46, 104, 116, 109, 108, 104, 116, 116, 112, 104, 116, 116, 112, 115, 50,
+ 48, 48, 50, 48, 52, 50, 48, 54, 51, 48, 52, 52, 48, 48, 52,
+ 48, 52, 53, 48, 48, 97, 99, 99, 101, 112, 116, 45, 99, 104, 97,
+ 114, 115, 101, 116, 103, 122, 105, 112, 44, 32, 100, 101, 102, 108, 97,
+ 116, 101, 97, 99, 99, 101, 112, 116, 45, 108, 97, 110, 103, 117, 97,
+ 103, 101, 97, 99, 99, 101, 112, 116, 45, 114, 97, 110, 103, 101, 115,
+ 97, 99, 99, 101, 112, 116, 97, 99, 99, 101, 115, 115, 45, 99, 111,
+ 110, 116, 114, 111, 108, 45, 97, 108, 108, 111, 119, 45, 111, 114, 105,
+ 103, 105, 110, 97, 103, 101, 97, 108, 108, 111, 119, 97, 117, 116, 104,
+ 111, 114, 105, 122, 97, 116, 105, 111, 110, 99, 97, 99, 104, 101, 45,
+ 99, 111, 110, 116, 114, 111, 108, 99, 111, 110, 116, 101, 110, 116, 45,
+ 100, 105, 115, 112, 111, 115, 105, 116, 105, 111, 110, 99, 111, 110, 116,
+ 101, 110, 116, 45, 108, 97, 110, 103, 117, 97, 103, 101, 99, 111, 110,
+ 116, 101, 110, 116, 45, 108, 101, 110, 103, 116, 104, 99, 111, 110, 116,
+ 101, 110, 116, 45, 108, 111, 99, 97, 116, 105, 111, 110, 99, 111, 110,
+ 116, 101, 110, 116, 45, 114, 97, 110, 103, 101, 99, 111, 111, 107, 105,
+ 101, 100, 97, 116, 101, 101, 116, 97, 103, 101, 120, 112, 101, 99, 116,
+ 101, 120, 112, 105, 114, 101, 115, 102, 114, 111, 109, 105, 102, 45, 109,
+ 97, 116, 99, 104, 105, 102, 45, 109, 111, 100, 105, 102, 105, 101, 100,
+ 45, 115, 105, 110, 99, 101, 105, 102, 45, 110, 111, 110, 101, 45, 109,
+ 97, 116, 99, 104, 105, 102, 45, 114, 97, 110, 103, 101, 105, 102, 45,
+ 117, 110, 109, 111, 100, 105, 102, 105, 101, 100, 45, 115, 105, 110, 99,
+ 101, 108, 97, 115, 116, 45, 109, 111, 100, 105, 102, 105, 101, 100, 108,
+ 105, 110, 107, 108, 111, 99, 97, 116, 105, 111, 110, 109, 97, 120, 45,
+ 102, 111, 114, 119, 97, 114, 100, 115, 112, 114, 111, 120, 121, 45, 97,
+ 117, 116, 104, 101, 110, 116, 105, 99, 97, 116, 101, 112, 114, 111, 120,
+ 121, 45, 97, 117, 116, 104, 111, 114, 105, 122, 97, 116, 105, 111, 110,
+ 114, 97, 110, 103, 101, 114, 101, 102, 101, 114, 101, 114, 114, 101, 102,
+ 114, 101, 115, 104, 114, 101, 116, 114, 121, 45, 97, 102, 116, 101, 114,
+ 115, 101, 114, 118, 101, 114, 115, 101, 116, 45, 99, 111, 111, 107, 105,
+ 101, 115, 116, 114, 105, 99, 116, 45, 116, 114, 97, 110, 115, 112, 111,
+ 114, 116, 45, 115, 101, 99, 117, 114, 105, 116, 121, 116, 114, 97, 110,
+ 115, 102, 101, 114, 45, 101, 110, 99, 111, 100, 105, 110, 103, 118, 97,
+ 114, 121, 118, 105, 97, 119, 119, 119, 45, 97, 117, 116, 104, 101, 110,
+ 116, 105, 99, 97, 116, 101, 48, 105, 100, 101, 110, 116, 105, 116, 121,
+ 116, 114, 97, 105, 108, 101, 114, 115, 97, 112, 112, 108, 105, 99, 97,
+ 116, 105, 111, 110, 47, 103, 114, 112, 99, 103, 114, 112, 99, 80, 85,
+ 84, 108, 98, 45, 99, 111, 115, 116, 45, 98, 105, 110, 105, 100, 101,
+ 110, 116, 105, 116, 121, 44, 100, 101, 102, 108, 97, 116, 101, 105, 100,
+ 101, 110, 116, 105, 116, 121, 44, 103, 122, 105, 112, 100, 101, 102, 108,
+ 97, 116, 101, 44, 103, 122, 105, 112, 105, 100, 101, 110, 116, 105, 116,
+ 121, 44, 100, 101, 102, 108, 97, 116, 101, 44, 103, 122, 105, 112};
grpc_slice_refcount grpc_core::StaticSliceRefcount::kStaticSubRefcount;
@@ -194,7 +194,7 @@ struct StaticMetadataCtx {
StaticSliceRefcount(102), StaticSliceRefcount(103),
StaticSliceRefcount(104), StaticSliceRefcount(105),
StaticSliceRefcount(106), StaticSliceRefcount(107),
- StaticSliceRefcount(108), StaticSliceRefcount(109),
+ StaticSliceRefcount(108), StaticSliceRefcount(109),
};
const StaticMetadataSlice slices[GRPC_STATIC_MDSTR_COUNT] = {
@@ -235,80 +235,80 @@ struct StaticMetadataCtx {
grpc_core::StaticMetadataSlice(&refcounts[33].base, 31, g_bytes + 434),
grpc_core::StaticMetadataSlice(&refcounts[34].base, 36, g_bytes + 465),
grpc_core::StaticMetadataSlice(&refcounts[35].base, 65, g_bytes + 501),
- grpc_core::StaticMetadataSlice(&refcounts[36].base, 65, g_bytes + 566),
- grpc_core::StaticMetadataSlice(&refcounts[37].base, 28, g_bytes + 631),
- grpc_core::StaticMetadataSlice(&refcounts[38].base, 80, g_bytes + 659),
- grpc_core::StaticMetadataSlice(&refcounts[39].base, 80, g_bytes + 739),
- grpc_core::StaticMetadataSlice(&refcounts[40].base, 7, g_bytes + 819),
- grpc_core::StaticMetadataSlice(&refcounts[41].base, 4, g_bytes + 826),
- grpc_core::StaticMetadataSlice(&refcounts[42].base, 11, g_bytes + 830),
- grpc_core::StaticMetadataSlice(&refcounts[43].base, 3, g_bytes + 841),
- grpc_core::StaticMetadataSlice(&refcounts[44].base, 4, g_bytes + 844),
- grpc_core::StaticMetadataSlice(&refcounts[45].base, 1, g_bytes + 848),
- grpc_core::StaticMetadataSlice(&refcounts[46].base, 11, g_bytes + 849),
- grpc_core::StaticMetadataSlice(&refcounts[47].base, 4, g_bytes + 860),
- grpc_core::StaticMetadataSlice(&refcounts[48].base, 5, g_bytes + 864),
- grpc_core::StaticMetadataSlice(&refcounts[49].base, 3, g_bytes + 869),
- grpc_core::StaticMetadataSlice(&refcounts[50].base, 3, g_bytes + 872),
- grpc_core::StaticMetadataSlice(&refcounts[51].base, 3, g_bytes + 875),
- grpc_core::StaticMetadataSlice(&refcounts[52].base, 3, g_bytes + 878),
- grpc_core::StaticMetadataSlice(&refcounts[53].base, 3, g_bytes + 881),
- grpc_core::StaticMetadataSlice(&refcounts[54].base, 3, g_bytes + 884),
- grpc_core::StaticMetadataSlice(&refcounts[55].base, 3, g_bytes + 887),
- grpc_core::StaticMetadataSlice(&refcounts[56].base, 14, g_bytes + 890),
- grpc_core::StaticMetadataSlice(&refcounts[57].base, 13, g_bytes + 904),
- grpc_core::StaticMetadataSlice(&refcounts[58].base, 15, g_bytes + 917),
- grpc_core::StaticMetadataSlice(&refcounts[59].base, 13, g_bytes + 932),
- grpc_core::StaticMetadataSlice(&refcounts[60].base, 6, g_bytes + 945),
- grpc_core::StaticMetadataSlice(&refcounts[61].base, 27, g_bytes + 951),
- grpc_core::StaticMetadataSlice(&refcounts[62].base, 3, g_bytes + 978),
- grpc_core::StaticMetadataSlice(&refcounts[63].base, 5, g_bytes + 981),
- grpc_core::StaticMetadataSlice(&refcounts[64].base, 13, g_bytes + 986),
- grpc_core::StaticMetadataSlice(&refcounts[65].base, 13, g_bytes + 999),
- grpc_core::StaticMetadataSlice(&refcounts[66].base, 19, g_bytes + 1012),
- grpc_core::StaticMetadataSlice(&refcounts[67].base, 16, g_bytes + 1031),
- grpc_core::StaticMetadataSlice(&refcounts[68].base, 14, g_bytes + 1047),
- grpc_core::StaticMetadataSlice(&refcounts[69].base, 16, g_bytes + 1061),
- grpc_core::StaticMetadataSlice(&refcounts[70].base, 13, g_bytes + 1077),
- grpc_core::StaticMetadataSlice(&refcounts[71].base, 6, g_bytes + 1090),
- grpc_core::StaticMetadataSlice(&refcounts[72].base, 4, g_bytes + 1096),
- grpc_core::StaticMetadataSlice(&refcounts[73].base, 4, g_bytes + 1100),
- grpc_core::StaticMetadataSlice(&refcounts[74].base, 6, g_bytes + 1104),
- grpc_core::StaticMetadataSlice(&refcounts[75].base, 7, g_bytes + 1110),
- grpc_core::StaticMetadataSlice(&refcounts[76].base, 4, g_bytes + 1117),
- grpc_core::StaticMetadataSlice(&refcounts[77].base, 8, g_bytes + 1121),
- grpc_core::StaticMetadataSlice(&refcounts[78].base, 17, g_bytes + 1129),
- grpc_core::StaticMetadataSlice(&refcounts[79].base, 13, g_bytes + 1146),
- grpc_core::StaticMetadataSlice(&refcounts[80].base, 8, g_bytes + 1159),
- grpc_core::StaticMetadataSlice(&refcounts[81].base, 19, g_bytes + 1167),
- grpc_core::StaticMetadataSlice(&refcounts[82].base, 13, g_bytes + 1186),
- grpc_core::StaticMetadataSlice(&refcounts[83].base, 4, g_bytes + 1199),
- grpc_core::StaticMetadataSlice(&refcounts[84].base, 8, g_bytes + 1203),
- grpc_core::StaticMetadataSlice(&refcounts[85].base, 12, g_bytes + 1211),
- grpc_core::StaticMetadataSlice(&refcounts[86].base, 18, g_bytes + 1223),
- grpc_core::StaticMetadataSlice(&refcounts[87].base, 19, g_bytes + 1241),
- grpc_core::StaticMetadataSlice(&refcounts[88].base, 5, g_bytes + 1260),
- grpc_core::StaticMetadataSlice(&refcounts[89].base, 7, g_bytes + 1265),
- grpc_core::StaticMetadataSlice(&refcounts[90].base, 7, g_bytes + 1272),
- grpc_core::StaticMetadataSlice(&refcounts[91].base, 11, g_bytes + 1279),
- grpc_core::StaticMetadataSlice(&refcounts[92].base, 6, g_bytes + 1290),
- grpc_core::StaticMetadataSlice(&refcounts[93].base, 10, g_bytes + 1296),
- grpc_core::StaticMetadataSlice(&refcounts[94].base, 25, g_bytes + 1306),
- grpc_core::StaticMetadataSlice(&refcounts[95].base, 17, g_bytes + 1331),
- grpc_core::StaticMetadataSlice(&refcounts[96].base, 4, g_bytes + 1348),
- grpc_core::StaticMetadataSlice(&refcounts[97].base, 3, g_bytes + 1352),
- grpc_core::StaticMetadataSlice(&refcounts[98].base, 16, g_bytes + 1355),
- grpc_core::StaticMetadataSlice(&refcounts[99].base, 1, g_bytes + 1371),
- grpc_core::StaticMetadataSlice(&refcounts[100].base, 8, g_bytes + 1372),
- grpc_core::StaticMetadataSlice(&refcounts[101].base, 8, g_bytes + 1380),
- grpc_core::StaticMetadataSlice(&refcounts[102].base, 16, g_bytes + 1388),
- grpc_core::StaticMetadataSlice(&refcounts[103].base, 4, g_bytes + 1404),
- grpc_core::StaticMetadataSlice(&refcounts[104].base, 3, g_bytes + 1408),
- grpc_core::StaticMetadataSlice(&refcounts[105].base, 11, g_bytes + 1411),
- grpc_core::StaticMetadataSlice(&refcounts[106].base, 16, g_bytes + 1422),
- grpc_core::StaticMetadataSlice(&refcounts[107].base, 13, g_bytes + 1438),
- grpc_core::StaticMetadataSlice(&refcounts[108].base, 12, g_bytes + 1451),
- grpc_core::StaticMetadataSlice(&refcounts[109].base, 21, g_bytes + 1463),
+ grpc_core::StaticMetadataSlice(&refcounts[36].base, 65, g_bytes + 566),
+ grpc_core::StaticMetadataSlice(&refcounts[37].base, 28, g_bytes + 631),
+ grpc_core::StaticMetadataSlice(&refcounts[38].base, 80, g_bytes + 659),
+ grpc_core::StaticMetadataSlice(&refcounts[39].base, 80, g_bytes + 739),
+ grpc_core::StaticMetadataSlice(&refcounts[40].base, 7, g_bytes + 819),
+ grpc_core::StaticMetadataSlice(&refcounts[41].base, 4, g_bytes + 826),
+ grpc_core::StaticMetadataSlice(&refcounts[42].base, 11, g_bytes + 830),
+ grpc_core::StaticMetadataSlice(&refcounts[43].base, 3, g_bytes + 841),
+ grpc_core::StaticMetadataSlice(&refcounts[44].base, 4, g_bytes + 844),
+ grpc_core::StaticMetadataSlice(&refcounts[45].base, 1, g_bytes + 848),
+ grpc_core::StaticMetadataSlice(&refcounts[46].base, 11, g_bytes + 849),
+ grpc_core::StaticMetadataSlice(&refcounts[47].base, 4, g_bytes + 860),
+ grpc_core::StaticMetadataSlice(&refcounts[48].base, 5, g_bytes + 864),
+ grpc_core::StaticMetadataSlice(&refcounts[49].base, 3, g_bytes + 869),
+ grpc_core::StaticMetadataSlice(&refcounts[50].base, 3, g_bytes + 872),
+ grpc_core::StaticMetadataSlice(&refcounts[51].base, 3, g_bytes + 875),
+ grpc_core::StaticMetadataSlice(&refcounts[52].base, 3, g_bytes + 878),
+ grpc_core::StaticMetadataSlice(&refcounts[53].base, 3, g_bytes + 881),
+ grpc_core::StaticMetadataSlice(&refcounts[54].base, 3, g_bytes + 884),
+ grpc_core::StaticMetadataSlice(&refcounts[55].base, 3, g_bytes + 887),
+ grpc_core::StaticMetadataSlice(&refcounts[56].base, 14, g_bytes + 890),
+ grpc_core::StaticMetadataSlice(&refcounts[57].base, 13, g_bytes + 904),
+ grpc_core::StaticMetadataSlice(&refcounts[58].base, 15, g_bytes + 917),
+ grpc_core::StaticMetadataSlice(&refcounts[59].base, 13, g_bytes + 932),
+ grpc_core::StaticMetadataSlice(&refcounts[60].base, 6, g_bytes + 945),
+ grpc_core::StaticMetadataSlice(&refcounts[61].base, 27, g_bytes + 951),
+ grpc_core::StaticMetadataSlice(&refcounts[62].base, 3, g_bytes + 978),
+ grpc_core::StaticMetadataSlice(&refcounts[63].base, 5, g_bytes + 981),
+ grpc_core::StaticMetadataSlice(&refcounts[64].base, 13, g_bytes + 986),
+ grpc_core::StaticMetadataSlice(&refcounts[65].base, 13, g_bytes + 999),
+ grpc_core::StaticMetadataSlice(&refcounts[66].base, 19, g_bytes + 1012),
+ grpc_core::StaticMetadataSlice(&refcounts[67].base, 16, g_bytes + 1031),
+ grpc_core::StaticMetadataSlice(&refcounts[68].base, 14, g_bytes + 1047),
+ grpc_core::StaticMetadataSlice(&refcounts[69].base, 16, g_bytes + 1061),
+ grpc_core::StaticMetadataSlice(&refcounts[70].base, 13, g_bytes + 1077),
+ grpc_core::StaticMetadataSlice(&refcounts[71].base, 6, g_bytes + 1090),
+ grpc_core::StaticMetadataSlice(&refcounts[72].base, 4, g_bytes + 1096),
+ grpc_core::StaticMetadataSlice(&refcounts[73].base, 4, g_bytes + 1100),
+ grpc_core::StaticMetadataSlice(&refcounts[74].base, 6, g_bytes + 1104),
+ grpc_core::StaticMetadataSlice(&refcounts[75].base, 7, g_bytes + 1110),
+ grpc_core::StaticMetadataSlice(&refcounts[76].base, 4, g_bytes + 1117),
+ grpc_core::StaticMetadataSlice(&refcounts[77].base, 8, g_bytes + 1121),
+ grpc_core::StaticMetadataSlice(&refcounts[78].base, 17, g_bytes + 1129),
+ grpc_core::StaticMetadataSlice(&refcounts[79].base, 13, g_bytes + 1146),
+ grpc_core::StaticMetadataSlice(&refcounts[80].base, 8, g_bytes + 1159),
+ grpc_core::StaticMetadataSlice(&refcounts[81].base, 19, g_bytes + 1167),
+ grpc_core::StaticMetadataSlice(&refcounts[82].base, 13, g_bytes + 1186),
+ grpc_core::StaticMetadataSlice(&refcounts[83].base, 4, g_bytes + 1199),
+ grpc_core::StaticMetadataSlice(&refcounts[84].base, 8, g_bytes + 1203),
+ grpc_core::StaticMetadataSlice(&refcounts[85].base, 12, g_bytes + 1211),
+ grpc_core::StaticMetadataSlice(&refcounts[86].base, 18, g_bytes + 1223),
+ grpc_core::StaticMetadataSlice(&refcounts[87].base, 19, g_bytes + 1241),
+ grpc_core::StaticMetadataSlice(&refcounts[88].base, 5, g_bytes + 1260),
+ grpc_core::StaticMetadataSlice(&refcounts[89].base, 7, g_bytes + 1265),
+ grpc_core::StaticMetadataSlice(&refcounts[90].base, 7, g_bytes + 1272),
+ grpc_core::StaticMetadataSlice(&refcounts[91].base, 11, g_bytes + 1279),
+ grpc_core::StaticMetadataSlice(&refcounts[92].base, 6, g_bytes + 1290),
+ grpc_core::StaticMetadataSlice(&refcounts[93].base, 10, g_bytes + 1296),
+ grpc_core::StaticMetadataSlice(&refcounts[94].base, 25, g_bytes + 1306),
+ grpc_core::StaticMetadataSlice(&refcounts[95].base, 17, g_bytes + 1331),
+ grpc_core::StaticMetadataSlice(&refcounts[96].base, 4, g_bytes + 1348),
+ grpc_core::StaticMetadataSlice(&refcounts[97].base, 3, g_bytes + 1352),
+ grpc_core::StaticMetadataSlice(&refcounts[98].base, 16, g_bytes + 1355),
+ grpc_core::StaticMetadataSlice(&refcounts[99].base, 1, g_bytes + 1371),
+ grpc_core::StaticMetadataSlice(&refcounts[100].base, 8, g_bytes + 1372),
+ grpc_core::StaticMetadataSlice(&refcounts[101].base, 8, g_bytes + 1380),
+ grpc_core::StaticMetadataSlice(&refcounts[102].base, 16, g_bytes + 1388),
+ grpc_core::StaticMetadataSlice(&refcounts[103].base, 4, g_bytes + 1404),
+ grpc_core::StaticMetadataSlice(&refcounts[104].base, 3, g_bytes + 1408),
+ grpc_core::StaticMetadataSlice(&refcounts[105].base, 11, g_bytes + 1411),
+ grpc_core::StaticMetadataSlice(&refcounts[106].base, 16, g_bytes + 1422),
+ grpc_core::StaticMetadataSlice(&refcounts[107].base, 13, g_bytes + 1438),
+ grpc_core::StaticMetadataSlice(&refcounts[108].base, 12, g_bytes + 1451),
+ grpc_core::StaticMetadataSlice(&refcounts[109].base, 21, g_bytes + 1463),
};
StaticMetadata static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = {
StaticMetadata(
@@ -317,107 +317,107 @@ struct StaticMetadataCtx {
0),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[1].base, 7, g_bytes + 5),
- grpc_core::StaticMetadataSlice(&refcounts[43].base, 3, g_bytes + 841),
+ grpc_core::StaticMetadataSlice(&refcounts[43].base, 3, g_bytes + 841),
1),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[1].base, 7, g_bytes + 5),
- grpc_core::StaticMetadataSlice(&refcounts[44].base, 4, g_bytes + 844),
+ grpc_core::StaticMetadataSlice(&refcounts[44].base, 4, g_bytes + 844),
2),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[0].base, 5, g_bytes + 0),
- grpc_core::StaticMetadataSlice(&refcounts[45].base, 1, g_bytes + 848),
+ grpc_core::StaticMetadataSlice(&refcounts[45].base, 1, g_bytes + 848),
3),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[0].base, 5, g_bytes + 0),
- grpc_core::StaticMetadataSlice(&refcounts[46].base, 11,
- g_bytes + 849),
+ grpc_core::StaticMetadataSlice(&refcounts[46].base, 11,
+ g_bytes + 849),
4),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[4].base, 7, g_bytes + 29),
- grpc_core::StaticMetadataSlice(&refcounts[47].base, 4, g_bytes + 860),
+ grpc_core::StaticMetadataSlice(&refcounts[47].base, 4, g_bytes + 860),
5),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[4].base, 7, g_bytes + 29),
- grpc_core::StaticMetadataSlice(&refcounts[48].base, 5, g_bytes + 864),
+ grpc_core::StaticMetadataSlice(&refcounts[48].base, 5, g_bytes + 864),
6),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[2].base, 7, g_bytes + 12),
- grpc_core::StaticMetadataSlice(&refcounts[49].base, 3, g_bytes + 869),
+ grpc_core::StaticMetadataSlice(&refcounts[49].base, 3, g_bytes + 869),
7),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[2].base, 7, g_bytes + 12),
- grpc_core::StaticMetadataSlice(&refcounts[50].base, 3, g_bytes + 872),
+ grpc_core::StaticMetadataSlice(&refcounts[50].base, 3, g_bytes + 872),
8),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[2].base, 7, g_bytes + 12),
- grpc_core::StaticMetadataSlice(&refcounts[51].base, 3, g_bytes + 875),
+ grpc_core::StaticMetadataSlice(&refcounts[51].base, 3, g_bytes + 875),
9),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[2].base, 7, g_bytes + 12),
- grpc_core::StaticMetadataSlice(&refcounts[52].base, 3, g_bytes + 878),
+ grpc_core::StaticMetadataSlice(&refcounts[52].base, 3, g_bytes + 878),
10),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[2].base, 7, g_bytes + 12),
- grpc_core::StaticMetadataSlice(&refcounts[53].base, 3, g_bytes + 881),
+ grpc_core::StaticMetadataSlice(&refcounts[53].base, 3, g_bytes + 881),
11),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[2].base, 7, g_bytes + 12),
- grpc_core::StaticMetadataSlice(&refcounts[54].base, 3, g_bytes + 884),
+ grpc_core::StaticMetadataSlice(&refcounts[54].base, 3, g_bytes + 884),
12),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[2].base, 7, g_bytes + 12),
- grpc_core::StaticMetadataSlice(&refcounts[55].base, 3, g_bytes + 887),
+ grpc_core::StaticMetadataSlice(&refcounts[55].base, 3, g_bytes + 887),
13),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[56].base, 14,
- g_bytes + 890),
+ grpc_core::StaticMetadataSlice(&refcounts[56].base, 14,
+ g_bytes + 890),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
14),
StaticMetadata(grpc_core::StaticMetadataSlice(&refcounts[16].base, 15,
g_bytes + 186),
- grpc_core::StaticMetadataSlice(&refcounts[57].base, 13,
- g_bytes + 904),
+ grpc_core::StaticMetadataSlice(&refcounts[57].base, 13,
+ g_bytes + 904),
15),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[58].base, 15,
- g_bytes + 917),
+ grpc_core::StaticMetadataSlice(&refcounts[58].base, 15,
+ g_bytes + 917),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
16),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[59].base, 13,
- g_bytes + 932),
+ grpc_core::StaticMetadataSlice(&refcounts[59].base, 13,
+ g_bytes + 932),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
17),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[60].base, 6, g_bytes + 945),
+ grpc_core::StaticMetadataSlice(&refcounts[60].base, 6, g_bytes + 945),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
18),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[61].base, 27,
- g_bytes + 951),
+ grpc_core::StaticMetadataSlice(&refcounts[61].base, 27,
+ g_bytes + 951),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
19),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[62].base, 3, g_bytes + 978),
+ grpc_core::StaticMetadataSlice(&refcounts[62].base, 3, g_bytes + 978),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
20),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[63].base, 5, g_bytes + 981),
+ grpc_core::StaticMetadataSlice(&refcounts[63].base, 5, g_bytes + 981),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
21),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[64].base, 13,
- g_bytes + 986),
+ grpc_core::StaticMetadataSlice(&refcounts[64].base, 13,
+ g_bytes + 986),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
22),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[65].base, 13,
- g_bytes + 999),
+ grpc_core::StaticMetadataSlice(&refcounts[65].base, 13,
+ g_bytes + 999),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
23),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[66].base, 19,
- g_bytes + 1012),
+ grpc_core::StaticMetadataSlice(&refcounts[66].base, 19,
+ g_bytes + 1012),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
24),
StaticMetadata(
@@ -426,23 +426,23 @@ struct StaticMetadataCtx {
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
25),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[67].base, 16,
- g_bytes + 1031),
+ grpc_core::StaticMetadataSlice(&refcounts[67].base, 16,
+ g_bytes + 1031),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
26),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[68].base, 14,
- g_bytes + 1047),
+ grpc_core::StaticMetadataSlice(&refcounts[68].base, 14,
+ g_bytes + 1047),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
27),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[69].base, 16,
- g_bytes + 1061),
+ grpc_core::StaticMetadataSlice(&refcounts[69].base, 16,
+ g_bytes + 1061),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
28),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[70].base, 13,
- g_bytes + 1077),
+ grpc_core::StaticMetadataSlice(&refcounts[70].base, 13,
+ g_bytes + 1077),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
29),
StaticMetadata(
@@ -451,33 +451,33 @@ struct StaticMetadataCtx {
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
30),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[71].base, 6,
- g_bytes + 1090),
+ grpc_core::StaticMetadataSlice(&refcounts[71].base, 6,
+ g_bytes + 1090),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
31),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[72].base, 4,
- g_bytes + 1096),
+ grpc_core::StaticMetadataSlice(&refcounts[72].base, 4,
+ g_bytes + 1096),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
32),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[73].base, 4,
- g_bytes + 1100),
+ grpc_core::StaticMetadataSlice(&refcounts[73].base, 4,
+ g_bytes + 1100),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
33),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[74].base, 6,
- g_bytes + 1104),
+ grpc_core::StaticMetadataSlice(&refcounts[74].base, 6,
+ g_bytes + 1104),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
34),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[75].base, 7,
- g_bytes + 1110),
+ grpc_core::StaticMetadataSlice(&refcounts[75].base, 7,
+ g_bytes + 1110),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
35),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[76].base, 4,
- g_bytes + 1117),
+ grpc_core::StaticMetadataSlice(&refcounts[76].base, 4,
+ g_bytes + 1117),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
36),
StaticMetadata(
@@ -485,98 +485,98 @@ struct StaticMetadataCtx {
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
37),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[77].base, 8,
- g_bytes + 1121),
+ grpc_core::StaticMetadataSlice(&refcounts[77].base, 8,
+ g_bytes + 1121),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
38),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[78].base, 17,
- g_bytes + 1129),
+ grpc_core::StaticMetadataSlice(&refcounts[78].base, 17,
+ g_bytes + 1129),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
39),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[79].base, 13,
- g_bytes + 1146),
+ grpc_core::StaticMetadataSlice(&refcounts[79].base, 13,
+ g_bytes + 1146),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
40),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[80].base, 8,
- g_bytes + 1159),
+ grpc_core::StaticMetadataSlice(&refcounts[80].base, 8,
+ g_bytes + 1159),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
41),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[81].base, 19,
- g_bytes + 1167),
+ grpc_core::StaticMetadataSlice(&refcounts[81].base, 19,
+ g_bytes + 1167),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
42),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[82].base, 13,
- g_bytes + 1186),
+ grpc_core::StaticMetadataSlice(&refcounts[82].base, 13,
+ g_bytes + 1186),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
43),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[83].base, 4,
- g_bytes + 1199),
+ grpc_core::StaticMetadataSlice(&refcounts[83].base, 4,
+ g_bytes + 1199),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
44),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[84].base, 8,
- g_bytes + 1203),
+ grpc_core::StaticMetadataSlice(&refcounts[84].base, 8,
+ g_bytes + 1203),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
45),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[85].base, 12,
- g_bytes + 1211),
+ grpc_core::StaticMetadataSlice(&refcounts[85].base, 12,
+ g_bytes + 1211),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
46),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[86].base, 18,
- g_bytes + 1223),
+ grpc_core::StaticMetadataSlice(&refcounts[86].base, 18,
+ g_bytes + 1223),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
47),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[87].base, 19,
- g_bytes + 1241),
+ grpc_core::StaticMetadataSlice(&refcounts[87].base, 19,
+ g_bytes + 1241),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
48),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[88].base, 5,
- g_bytes + 1260),
+ grpc_core::StaticMetadataSlice(&refcounts[88].base, 5,
+ g_bytes + 1260),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
49),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[89].base, 7,
- g_bytes + 1265),
+ grpc_core::StaticMetadataSlice(&refcounts[89].base, 7,
+ g_bytes + 1265),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
50),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[90].base, 7,
- g_bytes + 1272),
+ grpc_core::StaticMetadataSlice(&refcounts[90].base, 7,
+ g_bytes + 1272),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
51),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[91].base, 11,
- g_bytes + 1279),
+ grpc_core::StaticMetadataSlice(&refcounts[91].base, 11,
+ g_bytes + 1279),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
52),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[92].base, 6,
- g_bytes + 1290),
+ grpc_core::StaticMetadataSlice(&refcounts[92].base, 6,
+ g_bytes + 1290),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
53),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[93].base, 10,
- g_bytes + 1296),
+ grpc_core::StaticMetadataSlice(&refcounts[93].base, 10,
+ g_bytes + 1296),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
54),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[94].base, 25,
- g_bytes + 1306),
+ grpc_core::StaticMetadataSlice(&refcounts[94].base, 25,
+ g_bytes + 1306),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
55),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[95].base, 17,
- g_bytes + 1331),
+ grpc_core::StaticMetadataSlice(&refcounts[95].base, 17,
+ g_bytes + 1331),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
56),
StaticMetadata(
@@ -585,24 +585,24 @@ struct StaticMetadataCtx {
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
57),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[96].base, 4,
- g_bytes + 1348),
+ grpc_core::StaticMetadataSlice(&refcounts[96].base, 4,
+ g_bytes + 1348),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
58),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[97].base, 3,
- g_bytes + 1352),
+ grpc_core::StaticMetadataSlice(&refcounts[97].base, 3,
+ g_bytes + 1352),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
59),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[98].base, 16,
- g_bytes + 1355),
+ grpc_core::StaticMetadataSlice(&refcounts[98].base, 16,
+ g_bytes + 1355),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
60),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[7].base, 11, g_bytes + 50),
- grpc_core::StaticMetadataSlice(&refcounts[99].base, 1,
- g_bytes + 1371),
+ grpc_core::StaticMetadataSlice(&refcounts[99].base, 1,
+ g_bytes + 1371),
61),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[7].base, 11, g_bytes + 50),
@@ -614,36 +614,36 @@ struct StaticMetadataCtx {
63),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[9].base, 13, g_bytes + 77),
- grpc_core::StaticMetadataSlice(&refcounts[100].base, 8,
- g_bytes + 1372),
+ grpc_core::StaticMetadataSlice(&refcounts[100].base, 8,
+ g_bytes + 1372),
64),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[9].base, 13, g_bytes + 77),
- grpc_core::StaticMetadataSlice(&refcounts[41].base, 4, g_bytes + 826),
+ grpc_core::StaticMetadataSlice(&refcounts[41].base, 4, g_bytes + 826),
65),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[9].base, 13, g_bytes + 77),
- grpc_core::StaticMetadataSlice(&refcounts[40].base, 7, g_bytes + 819),
+ grpc_core::StaticMetadataSlice(&refcounts[40].base, 7, g_bytes + 819),
66),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[5].base, 2, g_bytes + 36),
- grpc_core::StaticMetadataSlice(&refcounts[101].base, 8,
- g_bytes + 1380),
+ grpc_core::StaticMetadataSlice(&refcounts[101].base, 8,
+ g_bytes + 1380),
67),
StaticMetadata(grpc_core::StaticMetadataSlice(&refcounts[14].base, 12,
g_bytes + 158),
- grpc_core::StaticMetadataSlice(&refcounts[102].base, 16,
- g_bytes + 1388),
+ grpc_core::StaticMetadataSlice(&refcounts[102].base, 16,
+ g_bytes + 1388),
68),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[4].base, 7, g_bytes + 29),
- grpc_core::StaticMetadataSlice(&refcounts[103].base, 4,
- g_bytes + 1404),
+ grpc_core::StaticMetadataSlice(&refcounts[103].base, 4,
+ g_bytes + 1404),
69),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[1].base, 7, g_bytes + 5),
- grpc_core::StaticMetadataSlice(&refcounts[104].base, 3,
- g_bytes + 1408),
+ grpc_core::StaticMetadataSlice(&refcounts[104].base, 3,
+ g_bytes + 1408),
70),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[16].base, 15,
@@ -652,66 +652,66 @@ struct StaticMetadataCtx {
71),
StaticMetadata(grpc_core::StaticMetadataSlice(&refcounts[15].base, 16,
g_bytes + 170),
- grpc_core::StaticMetadataSlice(&refcounts[100].base, 8,
- g_bytes + 1372),
+ grpc_core::StaticMetadataSlice(&refcounts[100].base, 8,
+ g_bytes + 1372),
72),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[15].base, 16,
g_bytes + 170),
- grpc_core::StaticMetadataSlice(&refcounts[41].base, 4, g_bytes + 826),
+ grpc_core::StaticMetadataSlice(&refcounts[41].base, 4, g_bytes + 826),
73),
StaticMetadata(
- grpc_core::StaticMetadataSlice(&refcounts[105].base, 11,
- g_bytes + 1411),
+ grpc_core::StaticMetadataSlice(&refcounts[105].base, 11,
+ g_bytes + 1411),
grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373),
74),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[10].base, 20, g_bytes + 90),
- grpc_core::StaticMetadataSlice(&refcounts[100].base, 8,
- g_bytes + 1372),
+ grpc_core::StaticMetadataSlice(&refcounts[100].base, 8,
+ g_bytes + 1372),
75),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[10].base, 20, g_bytes + 90),
- grpc_core::StaticMetadataSlice(&refcounts[40].base, 7, g_bytes + 819),
+ grpc_core::StaticMetadataSlice(&refcounts[40].base, 7, g_bytes + 819),
76),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[10].base, 20, g_bytes + 90),
- grpc_core::StaticMetadataSlice(&refcounts[106].base, 16,
- g_bytes + 1422),
+ grpc_core::StaticMetadataSlice(&refcounts[106].base, 16,
+ g_bytes + 1422),
77),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[10].base, 20, g_bytes + 90),
- grpc_core::StaticMetadataSlice(&refcounts[41].base, 4, g_bytes + 826),
+ grpc_core::StaticMetadataSlice(&refcounts[41].base, 4, g_bytes + 826),
78),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[10].base, 20, g_bytes + 90),
- grpc_core::StaticMetadataSlice(&refcounts[107].base, 13,
- g_bytes + 1438),
+ grpc_core::StaticMetadataSlice(&refcounts[107].base, 13,
+ g_bytes + 1438),
79),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[10].base, 20, g_bytes + 90),
- grpc_core::StaticMetadataSlice(&refcounts[108].base, 12,
- g_bytes + 1451),
+ grpc_core::StaticMetadataSlice(&refcounts[108].base, 12,
+ g_bytes + 1451),
80),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[10].base, 20, g_bytes + 90),
- grpc_core::StaticMetadataSlice(&refcounts[109].base, 21,
- g_bytes + 1463),
+ grpc_core::StaticMetadataSlice(&refcounts[109].base, 21,
+ g_bytes + 1463),
81),
StaticMetadata(grpc_core::StaticMetadataSlice(&refcounts[16].base, 15,
g_bytes + 186),
- grpc_core::StaticMetadataSlice(&refcounts[100].base, 8,
- g_bytes + 1372),
+ grpc_core::StaticMetadataSlice(&refcounts[100].base, 8,
+ g_bytes + 1372),
82),
StaticMetadata(
grpc_core::StaticMetadataSlice(&refcounts[16].base, 15,
g_bytes + 186),
- grpc_core::StaticMetadataSlice(&refcounts[41].base, 4, g_bytes + 826),
+ grpc_core::StaticMetadataSlice(&refcounts[41].base, 4, g_bytes + 826),
83),
StaticMetadata(grpc_core::StaticMetadataSlice(&refcounts[16].base, 15,
g_bytes + 186),
- grpc_core::StaticMetadataSlice(&refcounts[107].base, 13,
- g_bytes + 1438),
+ grpc_core::StaticMetadataSlice(&refcounts[107].base, 13,
+ g_bytes + 1438),
84),
};
@@ -1195,16 +1195,16 @@ uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 4, 6, 6, 8, 8, 2, 4, 4};
static const int8_t elems_r[] = {
- 15, 10, -8, 0, 2, -43, -83, -44, 0, 4, -8, 0, 0, 0, 10, 0, -7, 0,
- 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, -68, 0, -53, -56, -53, -77, 0, 30, 29, 28, 27, 26, 25, 24, 35, 22,
- 21, 20, 19, 18, 17, 16, 15, 16, 16, 16, 15, 14, 13, 12, 11, 10, 9, 8,
- 7, 6, 5, 4, 3, 2, 3, 2, 2, 6, 0, 0, 0, 0, 0, 0, -7, 0};
+ 15, 10, -8, 0, 2, -43, -83, -44, 0, 4, -8, 0, 0, 0, 10, 0, -7, 0,
+ 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, -68, 0, -53, -56, -53, -77, 0, 30, 29, 28, 27, 26, 25, 24, 35, 22,
+ 21, 20, 19, 18, 17, 16, 15, 16, 16, 16, 15, 14, 13, 12, 11, 10, 9, 8,
+ 7, 6, 5, 4, 3, 2, 3, 2, 2, 6, 0, 0, 0, 0, 0, 0, -7, 0};
static uint32_t elems_phash(uint32_t i) {
- i -= 45;
- uint32_t x = i % 108;
- uint32_t y = i / 108;
+ i -= 45;
+ uint32_t x = i % 108;
+ uint32_t y = i / 108;
uint32_t h = x;
if (y < GPR_ARRAY_SIZE(elems_r)) {
uint32_t delta = (uint32_t)elems_r[y];
@@ -1214,26 +1214,26 @@ static uint32_t elems_phash(uint32_t i) {
}
static const uint16_t elem_keys[] = {
- 269, 270, 271, 272, 273, 274, 275, 1140, 1141, 1789, 153,
- 154, 487, 488, 1679, 45, 46, 1030, 1031, 795, 796, 1801,
- 1569, 651, 869, 2119, 1691, 2229, 6189, 6739, 6849, 6959, 7069,
- 7179, 7289, 7399, 7509, 1817, 7729, 7839, 7949, 8059, 8169, 8279,
- 8389, 8499, 6519, 6409, 8609, 7619, 8719, 6629, 8829, 8939, 9049,
- 9159, 9269, 9379, 9489, 9599, 9709, 9819, 9929, 10039, 10149, 10259,
- 10369, 1200, 543, 10479, 10589, 214, 10699, 1206, 1207, 1208, 1209,
- 1090, 10809, 11579, 1860, 0, 0, 0, 0, 1750, 0, 1867,
- 0, 0, 359, 0, 0, 0, 0, 1642};
+ 269, 270, 271, 272, 273, 274, 275, 1140, 1141, 1789, 153,
+ 154, 487, 488, 1679, 45, 46, 1030, 1031, 795, 796, 1801,
+ 1569, 651, 869, 2119, 1691, 2229, 6189, 6739, 6849, 6959, 7069,
+ 7179, 7289, 7399, 7509, 1817, 7729, 7839, 7949, 8059, 8169, 8279,
+ 8389, 8499, 6519, 6409, 8609, 7619, 8719, 6629, 8829, 8939, 9049,
+ 9159, 9269, 9379, 9489, 9599, 9709, 9819, 9929, 10039, 10149, 10259,
+ 10369, 1200, 543, 10479, 10589, 214, 10699, 1206, 1207, 1208, 1209,
+ 1090, 10809, 11579, 1860, 0, 0, 0, 0, 1750, 0, 1867,
+ 0, 0, 359, 0, 0, 0, 0, 1642};
static const uint8_t elem_idxs[] = {
- 7, 8, 9, 10, 11, 12, 13, 76, 78, 71, 1, 2, 5, 6, 25, 3,
- 4, 66, 65, 62, 63, 83, 30, 67, 61, 57, 73, 37, 14, 19, 20, 21,
- 22, 23, 24, 26, 27, 15, 29, 31, 32, 33, 34, 35, 36, 38, 17, 16,
- 39, 28, 40, 18, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
- 53, 54, 55, 75, 69, 56, 58, 70, 59, 77, 79, 80, 81, 64, 60, 74,
- 82, 255, 255, 255, 255, 72, 255, 84, 255, 255, 0, 255, 255, 255, 255, 68};
+ 7, 8, 9, 10, 11, 12, 13, 76, 78, 71, 1, 2, 5, 6, 25, 3,
+ 4, 66, 65, 62, 63, 83, 30, 67, 61, 57, 73, 37, 14, 19, 20, 21,
+ 22, 23, 24, 26, 27, 15, 29, 31, 32, 33, 34, 35, 36, 38, 17, 16,
+ 39, 28, 40, 18, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
+ 53, 54, 55, 75, 69, 56, 58, 70, 59, 77, 79, 80, 81, 64, 60, 74,
+ 82, 255, 255, 255, 255, 72, 255, 84, 255, 255, 0, 255, 255, 255, 255, 68};
grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b) {
if (a == -1 || b == -1) return GRPC_MDNULL;
- uint32_t k = static_cast<uint32_t>(a * 110 + b);
+ uint32_t k = static_cast<uint32_t>(a * 110 + b);
uint32_t h = elems_phash(k);
return h < GPR_ARRAY_SIZE(elem_keys) && elem_keys[h] == k &&
elem_idxs[h] != 255
diff --git a/contrib/libs/grpc/src/core/lib/transport/static_metadata.h b/contrib/libs/grpc/src/core/lib/transport/static_metadata.h
index 5c5624617a..5d844af558 100644
--- a/contrib/libs/grpc/src/core/lib/transport/static_metadata.h
+++ b/contrib/libs/grpc/src/core/lib/transport/static_metadata.h
@@ -36,7 +36,7 @@
static_assert(
std::is_trivially_destructible<grpc_core::StaticMetadataSlice>::value,
"grpc_core::StaticMetadataSlice must be trivially destructible.");
-#define GRPC_STATIC_MDSTR_COUNT 110
+#define GRPC_STATIC_MDSTR_COUNT 110
void grpc_init_static_metadata_ctx(void);
void grpc_destroy_static_metadata_ctx(void);
@@ -46,7 +46,7 @@ constexpr uint64_t kGrpcStaticMetadataInitCanary = 0xCAFEF00DC0FFEE11L;
uint64_t StaticMetadataInitCanary();
#endif
extern const StaticMetadataSlice* g_static_metadata_slice_table;
-} // namespace grpc_core
+} // namespace grpc_core
inline const grpc_core::StaticMetadataSlice* grpc_static_slice_table() {
GPR_DEBUG_ASSERT(grpc_core::StaticMetadataInitCanary() ==
grpc_core::kGrpcStaticMetadataInitCanary);
@@ -132,161 +132,161 @@ inline const grpc_core::StaticMetadataSlice* grpc_static_slice_table() {
/* "/envoy.service.load_stats.v2.LoadReportingService/StreamLoadStats" */
#define GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_LOAD_STATS_DOT_V2_DOT_LOADREPORTINGSERVICE_SLASH_STREAMLOADSTATS \
(grpc_static_slice_table()[35])
-/* "/envoy.service.load_stats.v3.LoadReportingService/StreamLoadStats" */
-#define GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_LOAD_STATS_DOT_V3_DOT_LOADREPORTINGSERVICE_SLASH_STREAMLOADSTATS \
- (grpc_static_slice_table()[36])
+/* "/envoy.service.load_stats.v3.LoadReportingService/StreamLoadStats" */
+#define GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_LOAD_STATS_DOT_V3_DOT_LOADREPORTINGSERVICE_SLASH_STREAMLOADSTATS \
+ (grpc_static_slice_table()[36])
/* "/grpc.health.v1.Health/Watch" */
#define GRPC_MDSTR_SLASH_GRPC_DOT_HEALTH_DOT_V1_DOT_HEALTH_SLASH_WATCH \
- (grpc_static_slice_table()[37])
+ (grpc_static_slice_table()[37])
/* "/envoy.service.discovery.v2.AggregatedDiscoveryService/StreamAggregatedResources"
*/
#define GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_DISCOVERY_DOT_V2_DOT_AGGREGATEDDISCOVERYSERVICE_SLASH_STREAMAGGREGATEDRESOURCES \
- (grpc_static_slice_table()[38])
-/* "/envoy.service.discovery.v3.AggregatedDiscoveryService/StreamAggregatedResources"
- */
-#define GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_DISCOVERY_DOT_V3_DOT_AGGREGATEDDISCOVERYSERVICE_SLASH_STREAMAGGREGATEDRESOURCES \
- (grpc_static_slice_table()[39])
+ (grpc_static_slice_table()[38])
+/* "/envoy.service.discovery.v3.AggregatedDiscoveryService/StreamAggregatedResources"
+ */
+#define GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_DISCOVERY_DOT_V3_DOT_AGGREGATEDDISCOVERYSERVICE_SLASH_STREAMAGGREGATEDRESOURCES \
+ (grpc_static_slice_table()[39])
/* "deflate" */
-#define GRPC_MDSTR_DEFLATE (grpc_static_slice_table()[40])
+#define GRPC_MDSTR_DEFLATE (grpc_static_slice_table()[40])
/* "gzip" */
-#define GRPC_MDSTR_GZIP (grpc_static_slice_table()[41])
+#define GRPC_MDSTR_GZIP (grpc_static_slice_table()[41])
/* "stream/gzip" */
-#define GRPC_MDSTR_STREAM_SLASH_GZIP (grpc_static_slice_table()[42])
+#define GRPC_MDSTR_STREAM_SLASH_GZIP (grpc_static_slice_table()[42])
/* "GET" */
-#define GRPC_MDSTR_GET (grpc_static_slice_table()[43])
+#define GRPC_MDSTR_GET (grpc_static_slice_table()[43])
/* "POST" */
-#define GRPC_MDSTR_POST (grpc_static_slice_table()[44])
+#define GRPC_MDSTR_POST (grpc_static_slice_table()[44])
/* "/" */
-#define GRPC_MDSTR_SLASH (grpc_static_slice_table()[45])
+#define GRPC_MDSTR_SLASH (grpc_static_slice_table()[45])
/* "/index.html" */
-#define GRPC_MDSTR_SLASH_INDEX_DOT_HTML (grpc_static_slice_table()[46])
+#define GRPC_MDSTR_SLASH_INDEX_DOT_HTML (grpc_static_slice_table()[46])
/* "http" */
-#define GRPC_MDSTR_HTTP (grpc_static_slice_table()[47])
+#define GRPC_MDSTR_HTTP (grpc_static_slice_table()[47])
/* "https" */
-#define GRPC_MDSTR_HTTPS (grpc_static_slice_table()[48])
+#define GRPC_MDSTR_HTTPS (grpc_static_slice_table()[48])
/* "200" */
-#define GRPC_MDSTR_200 (grpc_static_slice_table()[49])
+#define GRPC_MDSTR_200 (grpc_static_slice_table()[49])
/* "204" */
-#define GRPC_MDSTR_204 (grpc_static_slice_table()[50])
+#define GRPC_MDSTR_204 (grpc_static_slice_table()[50])
/* "206" */
-#define GRPC_MDSTR_206 (grpc_static_slice_table()[51])
+#define GRPC_MDSTR_206 (grpc_static_slice_table()[51])
/* "304" */
-#define GRPC_MDSTR_304 (grpc_static_slice_table()[52])
+#define GRPC_MDSTR_304 (grpc_static_slice_table()[52])
/* "400" */
-#define GRPC_MDSTR_400 (grpc_static_slice_table()[53])
+#define GRPC_MDSTR_400 (grpc_static_slice_table()[53])
/* "404" */
-#define GRPC_MDSTR_404 (grpc_static_slice_table()[54])
+#define GRPC_MDSTR_404 (grpc_static_slice_table()[54])
/* "500" */
-#define GRPC_MDSTR_500 (grpc_static_slice_table()[55])
+#define GRPC_MDSTR_500 (grpc_static_slice_table()[55])
/* "accept-charset" */
-#define GRPC_MDSTR_ACCEPT_CHARSET (grpc_static_slice_table()[56])
+#define GRPC_MDSTR_ACCEPT_CHARSET (grpc_static_slice_table()[56])
/* "gzip, deflate" */
-#define GRPC_MDSTR_GZIP_COMMA_DEFLATE (grpc_static_slice_table()[57])
+#define GRPC_MDSTR_GZIP_COMMA_DEFLATE (grpc_static_slice_table()[57])
/* "accept-language" */
-#define GRPC_MDSTR_ACCEPT_LANGUAGE (grpc_static_slice_table()[58])
+#define GRPC_MDSTR_ACCEPT_LANGUAGE (grpc_static_slice_table()[58])
/* "accept-ranges" */
-#define GRPC_MDSTR_ACCEPT_RANGES (grpc_static_slice_table()[59])
+#define GRPC_MDSTR_ACCEPT_RANGES (grpc_static_slice_table()[59])
/* "accept" */
-#define GRPC_MDSTR_ACCEPT (grpc_static_slice_table()[60])
+#define GRPC_MDSTR_ACCEPT (grpc_static_slice_table()[60])
/* "access-control-allow-origin" */
-#define GRPC_MDSTR_ACCESS_CONTROL_ALLOW_ORIGIN (grpc_static_slice_table()[61])
+#define GRPC_MDSTR_ACCESS_CONTROL_ALLOW_ORIGIN (grpc_static_slice_table()[61])
/* "age" */
-#define GRPC_MDSTR_AGE (grpc_static_slice_table()[62])
+#define GRPC_MDSTR_AGE (grpc_static_slice_table()[62])
/* "allow" */
-#define GRPC_MDSTR_ALLOW (grpc_static_slice_table()[63])
+#define GRPC_MDSTR_ALLOW (grpc_static_slice_table()[63])
/* "authorization" */
-#define GRPC_MDSTR_AUTHORIZATION (grpc_static_slice_table()[64])
+#define GRPC_MDSTR_AUTHORIZATION (grpc_static_slice_table()[64])
/* "cache-control" */
-#define GRPC_MDSTR_CACHE_CONTROL (grpc_static_slice_table()[65])
+#define GRPC_MDSTR_CACHE_CONTROL (grpc_static_slice_table()[65])
/* "content-disposition" */
-#define GRPC_MDSTR_CONTENT_DISPOSITION (grpc_static_slice_table()[66])
+#define GRPC_MDSTR_CONTENT_DISPOSITION (grpc_static_slice_table()[66])
/* "content-language" */
-#define GRPC_MDSTR_CONTENT_LANGUAGE (grpc_static_slice_table()[67])
+#define GRPC_MDSTR_CONTENT_LANGUAGE (grpc_static_slice_table()[67])
/* "content-length" */
-#define GRPC_MDSTR_CONTENT_LENGTH (grpc_static_slice_table()[68])
+#define GRPC_MDSTR_CONTENT_LENGTH (grpc_static_slice_table()[68])
/* "content-location" */
-#define GRPC_MDSTR_CONTENT_LOCATION (grpc_static_slice_table()[69])
+#define GRPC_MDSTR_CONTENT_LOCATION (grpc_static_slice_table()[69])
/* "content-range" */
-#define GRPC_MDSTR_CONTENT_RANGE (grpc_static_slice_table()[70])
+#define GRPC_MDSTR_CONTENT_RANGE (grpc_static_slice_table()[70])
/* "cookie" */
-#define GRPC_MDSTR_COOKIE (grpc_static_slice_table()[71])
+#define GRPC_MDSTR_COOKIE (grpc_static_slice_table()[71])
/* "date" */
-#define GRPC_MDSTR_DATE (grpc_static_slice_table()[72])
+#define GRPC_MDSTR_DATE (grpc_static_slice_table()[72])
/* "etag" */
-#define GRPC_MDSTR_ETAG (grpc_static_slice_table()[73])
+#define GRPC_MDSTR_ETAG (grpc_static_slice_table()[73])
/* "expect" */
-#define GRPC_MDSTR_EXPECT (grpc_static_slice_table()[74])
+#define GRPC_MDSTR_EXPECT (grpc_static_slice_table()[74])
/* "expires" */
-#define GRPC_MDSTR_EXPIRES (grpc_static_slice_table()[75])
+#define GRPC_MDSTR_EXPIRES (grpc_static_slice_table()[75])
/* "from" */
-#define GRPC_MDSTR_FROM (grpc_static_slice_table()[76])
+#define GRPC_MDSTR_FROM (grpc_static_slice_table()[76])
/* "if-match" */
-#define GRPC_MDSTR_IF_MATCH (grpc_static_slice_table()[77])
+#define GRPC_MDSTR_IF_MATCH (grpc_static_slice_table()[77])
/* "if-modified-since" */
-#define GRPC_MDSTR_IF_MODIFIED_SINCE (grpc_static_slice_table()[78])
+#define GRPC_MDSTR_IF_MODIFIED_SINCE (grpc_static_slice_table()[78])
/* "if-none-match" */
-#define GRPC_MDSTR_IF_NONE_MATCH (grpc_static_slice_table()[79])
+#define GRPC_MDSTR_IF_NONE_MATCH (grpc_static_slice_table()[79])
/* "if-range" */
-#define GRPC_MDSTR_IF_RANGE (grpc_static_slice_table()[80])
+#define GRPC_MDSTR_IF_RANGE (grpc_static_slice_table()[80])
/* "if-unmodified-since" */
-#define GRPC_MDSTR_IF_UNMODIFIED_SINCE (grpc_static_slice_table()[81])
+#define GRPC_MDSTR_IF_UNMODIFIED_SINCE (grpc_static_slice_table()[81])
/* "last-modified" */
-#define GRPC_MDSTR_LAST_MODIFIED (grpc_static_slice_table()[82])
+#define GRPC_MDSTR_LAST_MODIFIED (grpc_static_slice_table()[82])
/* "link" */
-#define GRPC_MDSTR_LINK (grpc_static_slice_table()[83])
+#define GRPC_MDSTR_LINK (grpc_static_slice_table()[83])
/* "location" */
-#define GRPC_MDSTR_LOCATION (grpc_static_slice_table()[84])
+#define GRPC_MDSTR_LOCATION (grpc_static_slice_table()[84])
/* "max-forwards" */
-#define GRPC_MDSTR_MAX_FORWARDS (grpc_static_slice_table()[85])
+#define GRPC_MDSTR_MAX_FORWARDS (grpc_static_slice_table()[85])
/* "proxy-authenticate" */
-#define GRPC_MDSTR_PROXY_AUTHENTICATE (grpc_static_slice_table()[86])
+#define GRPC_MDSTR_PROXY_AUTHENTICATE (grpc_static_slice_table()[86])
/* "proxy-authorization" */
-#define GRPC_MDSTR_PROXY_AUTHORIZATION (grpc_static_slice_table()[87])
+#define GRPC_MDSTR_PROXY_AUTHORIZATION (grpc_static_slice_table()[87])
/* "range" */
-#define GRPC_MDSTR_RANGE (grpc_static_slice_table()[88])
+#define GRPC_MDSTR_RANGE (grpc_static_slice_table()[88])
/* "referer" */
-#define GRPC_MDSTR_REFERER (grpc_static_slice_table()[89])
+#define GRPC_MDSTR_REFERER (grpc_static_slice_table()[89])
/* "refresh" */
-#define GRPC_MDSTR_REFRESH (grpc_static_slice_table()[90])
+#define GRPC_MDSTR_REFRESH (grpc_static_slice_table()[90])
/* "retry-after" */
-#define GRPC_MDSTR_RETRY_AFTER (grpc_static_slice_table()[91])
+#define GRPC_MDSTR_RETRY_AFTER (grpc_static_slice_table()[91])
/* "server" */
-#define GRPC_MDSTR_SERVER (grpc_static_slice_table()[92])
+#define GRPC_MDSTR_SERVER (grpc_static_slice_table()[92])
/* "set-cookie" */
-#define GRPC_MDSTR_SET_COOKIE (grpc_static_slice_table()[93])
+#define GRPC_MDSTR_SET_COOKIE (grpc_static_slice_table()[93])
/* "strict-transport-security" */
-#define GRPC_MDSTR_STRICT_TRANSPORT_SECURITY (grpc_static_slice_table()[94])
+#define GRPC_MDSTR_STRICT_TRANSPORT_SECURITY (grpc_static_slice_table()[94])
/* "transfer-encoding" */
-#define GRPC_MDSTR_TRANSFER_ENCODING (grpc_static_slice_table()[95])
+#define GRPC_MDSTR_TRANSFER_ENCODING (grpc_static_slice_table()[95])
/* "vary" */
-#define GRPC_MDSTR_VARY (grpc_static_slice_table()[96])
+#define GRPC_MDSTR_VARY (grpc_static_slice_table()[96])
/* "via" */
-#define GRPC_MDSTR_VIA (grpc_static_slice_table()[97])
+#define GRPC_MDSTR_VIA (grpc_static_slice_table()[97])
/* "www-authenticate" */
-#define GRPC_MDSTR_WWW_AUTHENTICATE (grpc_static_slice_table()[98])
+#define GRPC_MDSTR_WWW_AUTHENTICATE (grpc_static_slice_table()[98])
/* "0" */
-#define GRPC_MDSTR_0 (grpc_static_slice_table()[99])
+#define GRPC_MDSTR_0 (grpc_static_slice_table()[99])
/* "identity" */
-#define GRPC_MDSTR_IDENTITY (grpc_static_slice_table()[100])
+#define GRPC_MDSTR_IDENTITY (grpc_static_slice_table()[100])
/* "trailers" */
-#define GRPC_MDSTR_TRAILERS (grpc_static_slice_table()[101])
+#define GRPC_MDSTR_TRAILERS (grpc_static_slice_table()[101])
/* "application/grpc" */
-#define GRPC_MDSTR_APPLICATION_SLASH_GRPC (grpc_static_slice_table()[102])
+#define GRPC_MDSTR_APPLICATION_SLASH_GRPC (grpc_static_slice_table()[102])
/* "grpc" */
-#define GRPC_MDSTR_GRPC (grpc_static_slice_table()[103])
+#define GRPC_MDSTR_GRPC (grpc_static_slice_table()[103])
/* "PUT" */
-#define GRPC_MDSTR_PUT (grpc_static_slice_table()[104])
+#define GRPC_MDSTR_PUT (grpc_static_slice_table()[104])
/* "lb-cost-bin" */
-#define GRPC_MDSTR_LB_COST_BIN (grpc_static_slice_table()[105])
+#define GRPC_MDSTR_LB_COST_BIN (grpc_static_slice_table()[105])
/* "identity,deflate" */
-#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE (grpc_static_slice_table()[106])
+#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE (grpc_static_slice_table()[106])
/* "identity,gzip" */
-#define GRPC_MDSTR_IDENTITY_COMMA_GZIP (grpc_static_slice_table()[107])
+#define GRPC_MDSTR_IDENTITY_COMMA_GZIP (grpc_static_slice_table()[107])
/* "deflate,gzip" */
-#define GRPC_MDSTR_DEFLATE_COMMA_GZIP (grpc_static_slice_table()[108])
+#define GRPC_MDSTR_DEFLATE_COMMA_GZIP (grpc_static_slice_table()[108])
/* "identity,deflate,gzip" */
#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE_COMMA_GZIP \
- (grpc_static_slice_table()[109])
+ (grpc_static_slice_table()[109])
namespace grpc_core {
struct StaticSliceRefcount;
diff --git a/contrib/libs/grpc/src/core/lib/transport/transport.h b/contrib/libs/grpc/src/core/lib/transport/transport.h
index 817faf357f..2404455f9f 100644
--- a/contrib/libs/grpc/src/core/lib/transport/transport.h
+++ b/contrib/libs/grpc/src/core/lib/transport/transport.h
@@ -242,12 +242,12 @@ struct grpc_transport_stream_op_batch_payload {
struct {
grpc_metadata_batch* send_trailing_metadata = nullptr;
- // Set by the transport to true if the stream successfully wrote the
- // trailing metadata. If this is not set but there was a send trailing
- // metadata op present, this can indicate that a server call can be marked
- // as a cancellation (since the stream was write-closed before status could
- // be delivered).
- bool* sent = nullptr;
+ // Set by the transport to true if the stream successfully wrote the
+ // trailing metadata. If this is not set but there was a send trailing
+ // metadata op present, this can indicate that a server call can be marked
+ // as a cancellation (since the stream was write-closed before status could
+ // be delivered).
+ bool* sent = nullptr;
} send_trailing_metadata;
struct {
@@ -414,9 +414,9 @@ void grpc_transport_stream_op_batch_finish_with_failure(
grpc_transport_stream_op_batch* op, grpc_error* error,
grpc_core::CallCombiner* call_combiner);
-TString grpc_transport_stream_op_batch_string(
- grpc_transport_stream_op_batch* op);
-TString grpc_transport_op_string(grpc_transport_op* op);
+TString grpc_transport_stream_op_batch_string(
+ grpc_transport_stream_op_batch* op);
+TString grpc_transport_op_string(grpc_transport_op* op);
/* Send a batch of operations on a transport
@@ -459,11 +459,11 @@ grpc_transport_op* grpc_make_transport_op(grpc_closure* on_consumed);
grpc_transport_stream_op_batch* grpc_make_transport_stream_op(
grpc_closure* on_consumed);
-namespace grpc_core {
-// This is the key to be used for loading/storing keepalive_throttling in the
-// y_absl::Status object.
-constexpr const char* kKeepaliveThrottlingKey =
- "grpc.internal.keepalive_throttling";
-} // namespace grpc_core
-
+namespace grpc_core {
+// This is the key to be used for loading/storing keepalive_throttling in the
+// y_absl::Status object.
+constexpr const char* kKeepaliveThrottlingKey =
+ "grpc.internal.keepalive_throttling";
+} // namespace grpc_core
+
#endif /* GRPC_CORE_LIB_TRANSPORT_TRANSPORT_H */
diff --git a/contrib/libs/grpc/src/core/lib/transport/transport_op_string.cc b/contrib/libs/grpc/src/core/lib/transport/transport_op_string.cc
index e4d79fae42..b26ee0a4fd 100644
--- a/contrib/libs/grpc/src/core/lib/transport/transport_op_string.cc
+++ b/contrib/libs/grpc/src/core/lib/transport/transport_op_string.cc
@@ -25,12 +25,12 @@
#include <stdio.h>
#include <string.h>
-#include <vector>
-
-#include "y_absl/strings/str_cat.h"
-#include "y_absl/strings/str_format.h"
-#include "y_absl/strings/str_join.h"
-
+#include <vector>
+
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/str_join.h"
+
#include <grpc/support/alloc.h>
#include <grpc/support/string_util.h>
#include "src/core/lib/gpr/string.h"
@@ -40,130 +40,130 @@
/* These routines are here to facilitate debugging - they produce string
representations of various transport data structures */
-static void put_metadata(grpc_mdelem md, std::vector<TString>* out) {
- out->push_back("key=");
- char* dump = grpc_dump_slice(GRPC_MDKEY(md), GPR_DUMP_HEX | GPR_DUMP_ASCII);
- out->push_back(dump);
- gpr_free(dump);
- out->push_back(" value=");
- dump = grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_HEX | GPR_DUMP_ASCII);
- out->push_back(dump);
- gpr_free(dump);
+static void put_metadata(grpc_mdelem md, std::vector<TString>* out) {
+ out->push_back("key=");
+ char* dump = grpc_dump_slice(GRPC_MDKEY(md), GPR_DUMP_HEX | GPR_DUMP_ASCII);
+ out->push_back(dump);
+ gpr_free(dump);
+ out->push_back(" value=");
+ dump = grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_HEX | GPR_DUMP_ASCII);
+ out->push_back(dump);
+ gpr_free(dump);
}
-static void put_metadata_list(grpc_metadata_batch md,
- std::vector<TString>* out) {
+static void put_metadata_list(grpc_metadata_batch md,
+ std::vector<TString>* out) {
grpc_linked_mdelem* m;
for (m = md.list.head; m != nullptr; m = m->next) {
- if (m != md.list.head) out->push_back(", ");
- put_metadata(m->md, out);
+ if (m != md.list.head) out->push_back(", ");
+ put_metadata(m->md, out);
}
if (md.deadline != GRPC_MILLIS_INF_FUTURE) {
- out->push_back(y_absl::StrFormat(" deadline=%" PRId64, md.deadline));
+ out->push_back(y_absl::StrFormat(" deadline=%" PRId64, md.deadline));
}
}
-TString grpc_transport_stream_op_batch_string(
+TString grpc_transport_stream_op_batch_string(
grpc_transport_stream_op_batch* op) {
- std::vector<TString> out;
+ std::vector<TString> out;
if (op->send_initial_metadata) {
- out.push_back(" SEND_INITIAL_METADATA{");
- put_metadata_list(*op->payload->send_initial_metadata.send_initial_metadata,
- &out);
- out.push_back("}");
+ out.push_back(" SEND_INITIAL_METADATA{");
+ put_metadata_list(*op->payload->send_initial_metadata.send_initial_metadata,
+ &out);
+ out.push_back("}");
}
if (op->send_message) {
if (op->payload->send_message.send_message != nullptr) {
- out.push_back(
- y_absl::StrFormat(" SEND_MESSAGE:flags=0x%08x:len=%d",
- op->payload->send_message.send_message->flags(),
- op->payload->send_message.send_message->length()));
+ out.push_back(
+ y_absl::StrFormat(" SEND_MESSAGE:flags=0x%08x:len=%d",
+ op->payload->send_message.send_message->flags(),
+ op->payload->send_message.send_message->length()));
} else {
// This can happen when we check a batch after the transport has
// processed and cleared the send_message op.
- out.push_back(" SEND_MESSAGE(flag and length unknown, already orphaned)");
+ out.push_back(" SEND_MESSAGE(flag and length unknown, already orphaned)");
}
}
if (op->send_trailing_metadata) {
- out.push_back(" SEND_TRAILING_METADATA{");
+ out.push_back(" SEND_TRAILING_METADATA{");
put_metadata_list(
- *op->payload->send_trailing_metadata.send_trailing_metadata, &out);
- out.push_back("}");
+ *op->payload->send_trailing_metadata.send_trailing_metadata, &out);
+ out.push_back("}");
}
if (op->recv_initial_metadata) {
- out.push_back(" RECV_INITIAL_METADATA");
+ out.push_back(" RECV_INITIAL_METADATA");
}
if (op->recv_message) {
- out.push_back(" RECV_MESSAGE");
+ out.push_back(" RECV_MESSAGE");
}
if (op->recv_trailing_metadata) {
- out.push_back(" RECV_TRAILING_METADATA");
+ out.push_back(" RECV_TRAILING_METADATA");
}
if (op->cancel_stream) {
- out.push_back(y_absl::StrCat(
- " CANCEL:",
- grpc_error_string(op->payload->cancel_stream.cancel_error)));
+ out.push_back(y_absl::StrCat(
+ " CANCEL:",
+ grpc_error_string(op->payload->cancel_stream.cancel_error)));
}
- return y_absl::StrJoin(out, "");
+ return y_absl::StrJoin(out, "");
}
-TString grpc_transport_op_string(grpc_transport_op* op) {
- std::vector<TString> out;
+TString grpc_transport_op_string(grpc_transport_op* op) {
+ std::vector<TString> out;
if (op->start_connectivity_watch != nullptr) {
- out.push_back(y_absl::StrFormat(
- " START_CONNECTIVITY_WATCH:watcher=%p:from=%s",
+ out.push_back(y_absl::StrFormat(
+ " START_CONNECTIVITY_WATCH:watcher=%p:from=%s",
op->start_connectivity_watch.get(),
- grpc_core::ConnectivityStateName(op->start_connectivity_watch_state)));
+ grpc_core::ConnectivityStateName(op->start_connectivity_watch_state)));
}
if (op->stop_connectivity_watch != nullptr) {
- out.push_back(y_absl::StrFormat(" STOP_CONNECTIVITY_WATCH:watcher=%p",
- op->stop_connectivity_watch));
+ out.push_back(y_absl::StrFormat(" STOP_CONNECTIVITY_WATCH:watcher=%p",
+ op->stop_connectivity_watch));
}
if (op->disconnect_with_error != GRPC_ERROR_NONE) {
- out.push_back(y_absl::StrCat(" DISCONNECT:",
- grpc_error_string(op->disconnect_with_error)));
+ out.push_back(y_absl::StrCat(" DISCONNECT:",
+ grpc_error_string(op->disconnect_with_error)));
}
if (op->goaway_error) {
- out.push_back(
- y_absl::StrCat(" SEND_GOAWAY:%s", grpc_error_string(op->goaway_error)));
+ out.push_back(
+ y_absl::StrCat(" SEND_GOAWAY:%s", grpc_error_string(op->goaway_error)));
}
if (op->set_accept_stream) {
- out.push_back(y_absl::StrFormat(" SET_ACCEPT_STREAM:%p(%p,...)",
- op->set_accept_stream_fn,
- op->set_accept_stream_user_data));
+ out.push_back(y_absl::StrFormat(" SET_ACCEPT_STREAM:%p(%p,...)",
+ op->set_accept_stream_fn,
+ op->set_accept_stream_user_data));
}
if (op->bind_pollset != nullptr) {
- out.push_back(" BIND_POLLSET");
+ out.push_back(" BIND_POLLSET");
}
if (op->bind_pollset_set != nullptr) {
- out.push_back(" BIND_POLLSET_SET");
+ out.push_back(" BIND_POLLSET_SET");
}
if (op->send_ping.on_initiate != nullptr || op->send_ping.on_ack != nullptr) {
- out.push_back(" SEND_PING");
+ out.push_back(" SEND_PING");
}
- return y_absl::StrJoin(out, "");
+ return y_absl::StrJoin(out, "");
}
void grpc_call_log_op(const char* file, int line, gpr_log_severity severity,
grpc_call_element* elem,
grpc_transport_stream_op_batch* op) {
- gpr_log(file, line, severity, "OP[%s:%p]: %s", elem->filter->name, elem,
- grpc_transport_stream_op_batch_string(op).c_str());
+ gpr_log(file, line, severity, "OP[%s:%p]: %s", elem->filter->name, elem,
+ grpc_transport_stream_op_batch_string(op).c_str());
}
diff --git a/contrib/libs/grpc/src/core/lib/uri/uri_parser.cc b/contrib/libs/grpc/src/core/lib/uri/uri_parser.cc
index 88143d09b8..1215e0d206 100644
--- a/contrib/libs/grpc/src/core/lib/uri/uri_parser.cc
+++ b/contrib/libs/grpc/src/core/lib/uri/uri_parser.cc
@@ -22,10 +22,10 @@
#include <string.h>
-#include <util/generic/string.h>
-
-#include "y_absl/strings/str_format.h"
-
+#include <util/generic/string.h>
+
+#include "y_absl/strings/str_format.h"
+
#include <grpc/slice_buffer.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@@ -38,25 +38,25 @@
/** a size_t default value... maps to all 1's */
#define NOT_SET (~(size_t)0)
-static grpc_uri* bad_uri(y_absl::string_view uri_text, size_t pos,
- const char* section, bool suppress_errors) {
+static grpc_uri* bad_uri(y_absl::string_view uri_text, size_t pos,
+ const char* section, bool suppress_errors) {
if (!suppress_errors) {
- TString line_prefix = y_absl::StrFormat("bad uri.%s: '", section);
- gpr_log(GPR_ERROR, "%s%s'", line_prefix.c_str(),
- TString(uri_text).c_str());
- size_t pfx_len = line_prefix.size() + pos;
- gpr_log(GPR_ERROR, "%s^ here", TString(pfx_len, ' ').c_str());
+ TString line_prefix = y_absl::StrFormat("bad uri.%s: '", section);
+ gpr_log(GPR_ERROR, "%s%s'", line_prefix.c_str(),
+ TString(uri_text).c_str());
+ size_t pfx_len = line_prefix.size() + pos;
+ gpr_log(GPR_ERROR, "%s^ here", TString(pfx_len, ' ').c_str());
}
return nullptr;
}
/** Returns a copy of percent decoded \a src[begin, end) */
-static char* decode_and_copy_component(y_absl::string_view src, size_t begin,
+static char* decode_and_copy_component(y_absl::string_view src, size_t begin,
size_t end) {
grpc_slice component =
(begin == NOT_SET || end == NOT_SET)
? grpc_empty_slice()
- : grpc_slice_from_copied_buffer(src.data() + begin, end - begin);
+ : grpc_slice_from_copied_buffer(src.data() + begin, end - begin);
grpc_slice decoded_component =
grpc_permissive_percent_decode_slice(component);
char* out = grpc_dump_slice(decoded_component, GPR_DUMP_ASCII);
@@ -73,7 +73,7 @@ static bool valid_hex(char c) {
/** Returns how many chars to advance if \a uri_text[i] begins a valid \a pchar
* production. If \a uri_text[i] introduces an invalid \a pchar (such as percent
* sign not followed by two hex digits), NOT_SET is returned. */
-static size_t parse_pchar(y_absl::string_view uri_text, size_t i) {
+static size_t parse_pchar(y_absl::string_view uri_text, size_t i) {
/* pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
* pct-encoded = "%" HEXDIG HEXDIG
@@ -106,8 +106,8 @@ static size_t parse_pchar(y_absl::string_view uri_text, size_t i) {
case '=':
return 1;
case '%': /* pct-encoded */
- if (uri_text.size() > i + 2 && valid_hex(uri_text[i + 1]) &&
- valid_hex(uri_text[i + 2])) {
+ if (uri_text.size() > i + 2 && valid_hex(uri_text[i + 1]) &&
+ valid_hex(uri_text[i + 2])) {
return 2;
}
return NOT_SET;
@@ -116,8 +116,8 @@ static size_t parse_pchar(y_absl::string_view uri_text, size_t i) {
}
/* *( pchar / "?" / "/" ) */
-static int parse_fragment_or_query(y_absl::string_view uri_text, size_t* i) {
- while (uri_text.size() > *i) {
+static int parse_fragment_or_query(y_absl::string_view uri_text, size_t* i) {
+ while (uri_text.size() > *i) {
const size_t advance = parse_pchar(uri_text, *i); /* pchar */
switch (advance) {
case 0: /* uri_text[i] isn't in pchar */
@@ -179,7 +179,7 @@ static void parse_query_parts(grpc_uri* uri) {
}
}
-grpc_uri* grpc_uri_parse(y_absl::string_view uri_text, bool suppress_errors) {
+grpc_uri* grpc_uri_parse(y_absl::string_view uri_text, bool suppress_errors) {
grpc_uri* uri;
size_t scheme_begin = 0;
size_t scheme_end = NOT_SET;
@@ -193,7 +193,7 @@ grpc_uri* grpc_uri_parse(y_absl::string_view uri_text, bool suppress_errors) {
size_t fragment_end = NOT_SET;
size_t i;
- for (i = scheme_begin; i < uri_text.size(); ++i) {
+ for (i = scheme_begin; i < uri_text.size(); ++i) {
if (uri_text[i] == ':') {
scheme_end = i;
break;
@@ -212,16 +212,16 @@ grpc_uri* grpc_uri_parse(y_absl::string_view uri_text, bool suppress_errors) {
return bad_uri(uri_text, i, "scheme", suppress_errors);
}
- if (uri_text.size() > scheme_end + 2 && uri_text[scheme_end + 1] == '/' &&
- uri_text[scheme_end + 2] == '/') {
+ if (uri_text.size() > scheme_end + 2 && uri_text[scheme_end + 1] == '/' &&
+ uri_text[scheme_end + 2] == '/') {
authority_begin = scheme_end + 3;
- for (i = authority_begin; uri_text.size() > i && authority_end == NOT_SET;
+ for (i = authority_begin; uri_text.size() > i && authority_end == NOT_SET;
i++) {
if (uri_text[i] == '/' || uri_text[i] == '?' || uri_text[i] == '#') {
authority_end = i;
}
}
- if (authority_end == NOT_SET && uri_text.size() == i) {
+ if (authority_end == NOT_SET && uri_text.size() == i) {
authority_end = i;
}
if (authority_end == NOT_SET) {
@@ -233,34 +233,34 @@ grpc_uri* grpc_uri_parse(y_absl::string_view uri_text, bool suppress_errors) {
path_begin = scheme_end + 1;
}
- for (i = path_begin; i < uri_text.size(); ++i) {
+ for (i = path_begin; i < uri_text.size(); ++i) {
if (uri_text[i] == '?' || uri_text[i] == '#') {
path_end = i;
break;
}
}
- if (path_end == NOT_SET && uri_text.size() == i) {
+ if (path_end == NOT_SET && uri_text.size() == i) {
path_end = i;
}
if (path_end == NOT_SET) {
return bad_uri(uri_text, i, "path", suppress_errors);
}
- if (uri_text.size() > i && uri_text[i] == '?') {
+ if (uri_text.size() > i && uri_text[i] == '?') {
query_begin = ++i;
if (!parse_fragment_or_query(uri_text, &i)) {
return bad_uri(uri_text, i, "query", suppress_errors);
- } else if (uri_text.size() > i && uri_text[i] != '#') {
+ } else if (uri_text.size() > i && uri_text[i] != '#') {
/* We must be at the end or at the beginning of a fragment */
return bad_uri(uri_text, i, "query", suppress_errors);
}
query_end = i;
}
- if (uri_text.size() > i && uri_text[i] == '#') {
+ if (uri_text.size() > i && uri_text[i] == '#') {
fragment_begin = ++i;
if (!parse_fragment_or_query(uri_text, &i)) {
return bad_uri(uri_text, i - fragment_end, "fragment", suppress_errors);
- } else if (uri_text.size() > i) {
+ } else if (uri_text.size() > i) {
/* We must be at the end */
return bad_uri(uri_text, i, "fragment", suppress_errors);
}
diff --git a/contrib/libs/grpc/src/core/lib/uri/uri_parser.h b/contrib/libs/grpc/src/core/lib/uri/uri_parser.h
index 9f0e6f4a1b..ccb9a4f29e 100644
--- a/contrib/libs/grpc/src/core/lib/uri/uri_parser.h
+++ b/contrib/libs/grpc/src/core/lib/uri/uri_parser.h
@@ -21,8 +21,8 @@
#include <grpc/support/port_platform.h>
-#include "y_absl/strings/string_view.h"
-
+#include "y_absl/strings/string_view.h"
+
#include <stddef.h>
struct grpc_uri {
@@ -39,7 +39,7 @@ struct grpc_uri {
char* fragment;
};
/** parse a uri, return NULL on failure */
-grpc_uri* grpc_uri_parse(y_absl::string_view uri_text, bool suppress_errors);
+grpc_uri* grpc_uri_parse(y_absl::string_view uri_text, bool suppress_errors);
/** return the part of a query string after the '=' in "?key=xxx&...", or NULL
* if key is not present */
diff --git a/contrib/libs/grpc/src/core/lib/ya.make b/contrib/libs/grpc/src/core/lib/ya.make
index 0baf847eec..93f59abe37 100644
--- a/contrib/libs/grpc/src/core/lib/ya.make
+++ b/contrib/libs/grpc/src/core/lib/ya.make
@@ -6,30 +6,30 @@ OWNER(g:cpp-contrib)
LICENSE(Apache-2.0)
-LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-
+LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
+
PEERDIR(
- contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_wait
- contrib/restricted/abseil-cpp-tstring/y_absl/container
- contrib/restricted/abseil-cpp-tstring/y_absl/memory
- contrib/restricted/abseil-cpp-tstring/y_absl/strings
- contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format
- contrib/restricted/abseil-cpp-tstring/y_absl/synchronization
- contrib/restricted/abseil-cpp-tstring/y_absl/time
+ contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_wait
+ contrib/restricted/abseil-cpp-tstring/y_absl/container
+ contrib/restricted/abseil-cpp-tstring/y_absl/memory
+ contrib/restricted/abseil-cpp-tstring/y_absl/strings
+ contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format
+ contrib/restricted/abseil-cpp-tstring/y_absl/synchronization
+ contrib/restricted/abseil-cpp-tstring/y_absl/time
)
ADDINCL(
GLOBAL contrib/libs/grpc/include
- ${ARCADIA_BUILD_ROOT}/contrib/libs/grpc
+ ${ARCADIA_BUILD_ROOT}/contrib/libs/grpc
contrib/libs/grpc
)
NO_COMPILER_WARNINGS()
IF (OS_LINUX OR OS_DARWIN)
- CFLAGS(
- -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1
- )
+ CFLAGS(
+ -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1
+ )
ENDIF()
SRCS(
@@ -53,7 +53,7 @@ SRCS(
gpr/string_util_windows.cc
gpr/string_windows.cc
gpr/sync.cc
- gpr/sync_abseil.cc
+ gpr/sync_abseil.cc
gpr/sync_posix.cc
gpr/sync_windows.cc
gpr/time.cc