grpc 1.49.1 → 1.50.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +54 -153
- data/include/grpc/event_engine/endpoint_config.h +11 -5
- data/include/grpc/event_engine/event_engine.h +1 -1
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +19 -28
- data/include/grpc/impl/codegen/atm_gcc_sync.h +0 -2
- data/include/grpc/impl/codegen/atm_windows.h +0 -2
- data/include/grpc/impl/codegen/grpc_types.h +6 -0
- data/src/core/ext/filters/channel_idle/channel_idle_filter.cc +3 -3
- data/src/core/ext/filters/client_channel/backup_poller.cc +4 -6
- data/src/core/ext/filters/client_channel/client_channel.cc +33 -22
- data/src/core/ext/filters/client_channel/client_channel.h +1 -1
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +0 -16
- data/src/core/ext/filters/client_channel/http_proxy.cc +12 -19
- data/src/core/ext/filters/client_channel/http_proxy.h +3 -2
- data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +6 -4
- data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h +5 -4
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +0 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +112 -96
- data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.cc +20 -11
- data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.cc +106 -108
- data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h +16 -0
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +20 -13
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +165 -257
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +218 -231
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +10 -6
- data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +389 -444
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +16 -16
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +8 -13
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +84 -96
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +38 -37
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +106 -186
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +106 -93
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +170 -218
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +13 -15
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.cc +84 -37
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.h +11 -0
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +1 -0
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +5 -3
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +5 -4
- data/src/core/ext/filters/client_channel/retry_filter.cc +25 -29
- data/src/core/ext/filters/client_channel/subchannel.cc +38 -33
- data/src/core/ext/filters/client_channel/subchannel.h +12 -3
- data/src/core/ext/filters/client_channel/subchannel_stream_client.cc +1 -2
- data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +23 -16
- data/src/core/ext/filters/fault_injection/fault_injection_filter.h +8 -0
- data/src/core/ext/filters/http/client/http_client_filter.cc +1 -2
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +2 -4
- data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +0 -2
- data/src/core/ext/filters/http/server/http_server_filter.cc +1 -2
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +12 -8
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +32 -26
- data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +25 -130
- data/src/core/ext/transport/chttp2/transport/decode_huff.cc +287 -0
- data/src/core/ext/transport/chttp2/transport/decode_huff.h +1018 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +83 -51
- data/src/core/ext/transport/chttp2/transport/flow_control.h +11 -6
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +1 -2
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +2 -20
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +28 -28
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +1 -10
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +11 -6
- data/src/core/ext/transport/chttp2/transport/internal.h +2 -0
- data/src/core/ext/transport/chttp2/transport/parsing.cc +44 -0
- data/src/core/ext/transport/chttp2/transport/writing.cc +3 -14
- data/src/core/ext/transport/inproc/inproc_transport.cc +1 -3
- data/src/core/ext/xds/certificate_provider_store.cc +63 -3
- data/src/core/ext/xds/certificate_provider_store.h +9 -1
- data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +5 -5
- data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +1 -1
- data/src/core/ext/xds/xds_api.cc +21 -17
- data/src/core/ext/xds/xds_api.h +7 -0
- data/src/core/ext/xds/xds_bootstrap.cc +5 -537
- data/src/core/ext/xds/xds_bootstrap.h +39 -111
- data/src/core/ext/xds/xds_bootstrap_grpc.cc +370 -0
- data/src/core/ext/xds/xds_bootstrap_grpc.h +169 -0
- data/src/core/ext/xds/xds_client.cc +219 -145
- data/src/core/ext/xds/xds_client.h +19 -17
- data/src/core/ext/xds/xds_client_grpc.cc +18 -80
- data/src/core/ext/xds/xds_client_grpc.h +2 -25
- data/src/core/ext/xds/xds_client_stats.cc +4 -4
- data/src/core/ext/xds/xds_cluster.cc +87 -79
- data/src/core/ext/xds/xds_cluster.h +5 -5
- data/src/core/ext/xds/xds_cluster_specifier_plugin.cc +3 -1
- data/src/core/ext/xds/xds_common_types.cc +13 -5
- data/src/core/ext/xds/xds_endpoint.cc +8 -6
- data/src/core/ext/xds/xds_endpoint.h +3 -4
- data/src/core/ext/xds/xds_lb_policy_registry.cc +4 -2
- data/src/core/ext/xds/xds_listener.cc +25 -20
- data/src/core/ext/xds/xds_listener.h +3 -4
- data/src/core/ext/xds/xds_resource_type.h +11 -8
- data/src/core/ext/xds/xds_route_config.cc +15 -16
- data/src/core/ext/xds/xds_route_config.h +3 -3
- data/src/core/ext/xds/xds_server_config_fetcher.cc +7 -5
- data/src/core/ext/xds/xds_transport_grpc.cc +15 -7
- data/src/core/lib/backoff/backoff.cc +2 -4
- data/src/core/lib/channel/call_finalization.h +1 -3
- data/src/core/lib/channel/channel_args.h +114 -14
- data/src/core/lib/channel/channel_trace.cc +3 -4
- data/src/core/lib/channel/promise_based_filter.cc +18 -19
- data/src/core/lib/channel/status_util.cc +27 -0
- data/src/core/lib/channel/status_util.h +10 -0
- data/src/core/lib/config/core_configuration.cc +5 -1
- data/src/core/lib/config/core_configuration.h +33 -0
- data/src/core/lib/debug/stats.cc +26 -30
- data/src/core/lib/debug/stats.h +2 -12
- data/src/core/lib/debug/stats_data.cc +118 -614
- data/src/core/lib/debug/stats_data.h +67 -465
- data/src/core/lib/debug/trace.cc +0 -2
- data/src/core/lib/event_engine/channel_args_endpoint_config.cc +12 -20
- data/src/core/lib/event_engine/channel_args_endpoint_config.h +13 -7
- data/src/core/lib/event_engine/forkable.cc +1 -1
- data/src/core/lib/event_engine/poller.h +14 -12
- data/src/core/lib/event_engine/posix_engine/timer_manager.cc +53 -32
- data/src/core/lib/event_engine/posix_engine/timer_manager.h +23 -1
- data/src/core/lib/event_engine/thread_pool.cc +131 -94
- data/src/core/lib/event_engine/thread_pool.h +56 -23
- data/src/core/lib/event_engine/time_util.cc +30 -0
- data/src/core/lib/event_engine/time_util.h +32 -0
- data/src/core/lib/event_engine/utils.cc +0 -5
- data/src/core/lib/event_engine/utils.h +0 -4
- data/src/core/lib/event_engine/windows/iocp.cc +13 -7
- data/src/core/lib/event_engine/windows/iocp.h +2 -1
- data/src/core/lib/event_engine/windows/win_socket.cc +1 -1
- data/src/core/lib/experiments/config.cc +146 -0
- data/src/core/lib/experiments/config.h +43 -0
- data/src/core/lib/experiments/experiments.cc +75 -0
- data/src/core/lib/experiments/experiments.h +56 -0
- data/src/core/lib/gpr/alloc.cc +1 -9
- data/src/core/lib/gpr/log_windows.cc +0 -1
- data/src/core/lib/gpr/string_util_windows.cc +3 -30
- data/src/core/lib/gpr/sync_abseil.cc +0 -14
- data/src/core/lib/gpr/sync_posix.cc +0 -14
- data/src/core/lib/gpr/time_posix.cc +0 -6
- data/src/core/lib/gpr/time_precise.h +1 -1
- data/src/core/lib/gpr/tmpfile_windows.cc +5 -7
- data/src/core/lib/gpr/useful.h +11 -0
- data/src/core/lib/{gpr → gprpp}/env.h +25 -12
- data/src/core/lib/{gpr → gprpp}/env_linux.cc +20 -15
- data/src/core/lib/{gpr → gprpp}/env_posix.cc +11 -10
- data/src/core/lib/gprpp/env_windows.cc +56 -0
- data/src/core/lib/gprpp/fork.cc +14 -22
- data/src/core/lib/gprpp/fork.h +0 -8
- data/src/core/lib/gprpp/global_config_env.cc +7 -6
- data/src/core/lib/gprpp/notification.h +67 -0
- data/src/core/lib/gprpp/packed_table.h +40 -0
- data/src/core/lib/gprpp/ref_counted_ptr.h +20 -33
- data/src/core/lib/gprpp/sorted_pack.h +98 -0
- data/src/core/lib/gprpp/status_helper.h +6 -0
- data/src/core/lib/gprpp/table.h +9 -1
- data/src/core/lib/gprpp/tchar.cc +49 -0
- data/src/core/lib/gprpp/tchar.h +33 -0
- data/src/core/lib/gprpp/time.cc +21 -0
- data/src/core/lib/gprpp/time.h +55 -0
- data/src/core/lib/gprpp/validation_errors.cc +61 -0
- data/src/core/lib/gprpp/validation_errors.h +110 -0
- data/src/core/{ext/filters/client_channel → lib/handshaker}/proxy_mapper.h +3 -3
- data/src/core/{ext/filters/client_channel → lib/handshaker}/proxy_mapper_registry.cc +14 -36
- data/src/core/lib/handshaker/proxy_mapper_registry.h +75 -0
- data/src/core/lib/iomgr/call_combiner.cc +0 -8
- data/src/core/lib/iomgr/closure.h +0 -1
- data/src/core/lib/iomgr/endpoint_pair_posix.cc +14 -10
- data/src/core/lib/iomgr/endpoint_pair_windows.cc +2 -2
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +1 -38
- data/src/core/lib/iomgr/ev_poll_posix.cc +2 -17
- data/src/core/lib/iomgr/exec_ctx.cc +0 -10
- data/src/core/lib/iomgr/exec_ctx.h +7 -31
- data/src/core/lib/iomgr/iocp_windows.cc +1 -2
- data/src/core/lib/iomgr/iomgr.cc +6 -8
- data/src/core/lib/iomgr/iomgr_fwd.h +1 -0
- data/src/core/lib/iomgr/pollset.h +1 -1
- data/src/core/lib/iomgr/pollset_set.h +0 -1
- data/src/core/lib/iomgr/resolve_address.h +1 -0
- data/src/core/lib/iomgr/resolve_address_impl.h +1 -0
- data/src/core/lib/iomgr/resolve_address_posix.cc +1 -0
- data/src/core/lib/iomgr/resolve_address_windows.cc +1 -0
- data/src/core/lib/iomgr/sockaddr_utils_posix.cc +2 -1
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +12 -34
- data/src/core/lib/iomgr/socket_utils_posix.cc +83 -1
- data/src/core/lib/iomgr/socket_utils_posix.h +98 -6
- data/src/core/lib/iomgr/tcp_client.cc +6 -7
- data/src/core/lib/iomgr/tcp_client.h +11 -11
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +6 -6
- data/src/core/lib/iomgr/tcp_client_posix.cc +33 -29
- data/src/core/lib/iomgr/tcp_client_posix.h +12 -9
- data/src/core/lib/iomgr/tcp_client_windows.cc +6 -6
- data/src/core/lib/iomgr/tcp_posix.cc +131 -114
- data/src/core/lib/iomgr/tcp_posix.h +3 -1
- data/src/core/lib/iomgr/tcp_server.cc +5 -4
- data/src/core/lib/iomgr/tcp_server.h +9 -6
- data/src/core/lib/iomgr/tcp_server_posix.cc +17 -28
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +2 -2
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +3 -3
- data/src/core/lib/iomgr/tcp_server_windows.cc +6 -7
- data/src/core/lib/iomgr/tcp_windows.cc +0 -1
- data/src/core/lib/iomgr/tcp_windows.h +0 -1
- data/src/core/lib/iomgr/timer_generic.cc +4 -4
- data/src/core/lib/iomgr/timer_manager.cc +1 -2
- data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +0 -2
- data/src/core/lib/json/json_object_loader.cc +21 -52
- data/src/core/lib/json/json_object_loader.h +56 -76
- data/src/core/lib/json/json_util.cc +2 -1
- data/src/core/lib/load_balancing/lb_policy.h +5 -5
- data/src/core/lib/load_balancing/lb_policy_registry.cc +29 -55
- data/src/core/lib/load_balancing/lb_policy_registry.h +23 -11
- data/src/core/lib/promise/activity.h +2 -3
- data/src/core/lib/promise/context.h +1 -1
- data/src/core/lib/promise/sleep.cc +16 -4
- data/src/core/lib/promise/sleep.h +8 -2
- data/src/core/lib/resolver/resolver.h +13 -3
- data/src/core/lib/resource_quota/api.cc +9 -0
- data/src/core/lib/resource_quota/api.h +6 -0
- data/src/core/lib/resource_quota/arena.cc +1 -3
- data/src/core/lib/resource_quota/memory_quota.cc +8 -24
- data/src/core/lib/resource_quota/memory_quota.h +6 -19
- data/src/core/lib/resource_quota/periodic_update.cc +2 -3
- data/src/core/{ext/xds → lib/security/certificate_provider}/certificate_provider_factory.h +3 -3
- data/src/core/lib/security/certificate_provider/certificate_provider_registry.cc +60 -0
- data/src/core/lib/security/certificate_provider/certificate_provider_registry.h +70 -0
- data/src/core/lib/security/credentials/channel_creds_registry_init.cc +1 -0
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +15 -16
- data/src/core/lib/security/credentials/external/external_account_credentials.cc +2 -1
- data/src/core/lib/security/credentials/google_default/credentials_generic.cc +5 -8
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +6 -6
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +3 -2
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +1 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -2
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +4 -3
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +4 -2
- data/src/core/lib/security/credentials/tls/tls_utils.cc +3 -1
- data/src/core/lib/security/transport/client_auth_filter.cc +12 -1
- data/src/core/lib/security/transport/secure_endpoint.cc +0 -4
- data/src/core/lib/surface/call.cc +1 -11
- data/src/core/lib/surface/channel.cc +3 -2
- data/src/core/lib/surface/completion_queue.cc +16 -28
- data/src/core/lib/surface/completion_queue.h +1 -1
- data/src/core/lib/surface/completion_queue_factory.cc +5 -0
- data/src/core/lib/surface/init.cc +16 -11
- data/src/core/lib/surface/init_internally.cc +24 -0
- data/src/core/lib/surface/init_internally.h +28 -0
- data/src/core/lib/surface/server.cc +1 -7
- data/src/core/lib/surface/server.h +4 -6
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/bdp_estimator.cc +1 -3
- data/src/core/lib/transport/metadata_batch.cc +2 -3
- data/src/core/lib/transport/metadata_batch.h +9 -7
- data/src/core/lib/transport/parsed_metadata.h +4 -2
- data/src/core/lib/transport/status_conversion.cc +1 -3
- data/src/core/lib/transport/tcp_connect_handshaker.cc +9 -5
- data/src/core/lib/transport/transport.h +0 -1
- data/src/core/lib/transport/transport_impl.h +0 -1
- data/src/core/plugin_registry/grpc_plugin_registry.cc +23 -46
- data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +13 -25
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/channel_spec.rb +5 -0
- data/src/ruby/spec/generic/server_interceptors_spec.rb +1 -1
- data/src/ruby/spec/user_agent_spec.rb +1 -1
- metadata +33 -19
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +0 -56
- data/src/core/ext/xds/certificate_provider_registry.cc +0 -103
- data/src/core/ext/xds/certificate_provider_registry.h +0 -59
- data/src/core/lib/event_engine/promise.h +0 -78
- data/src/core/lib/gpr/env_windows.cc +0 -74
- data/src/core/lib/gpr/string_windows.h +0 -32
- data/src/core/lib/profiling/basic_timers.cc +0 -295
- data/src/core/lib/profiling/stap_timers.cc +0 -50
- data/src/core/lib/profiling/timers.h +0 -94
@@ -0,0 +1,30 @@
|
|
1
|
+
// Copyright 2022 gRPC authors.
|
2
|
+
//
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
// you may not use this file except in compliance with the License.
|
5
|
+
// You may obtain a copy of the License at
|
6
|
+
//
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
//
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
// See the License for the specific language governing permissions and
|
13
|
+
// limitations under the License.
|
14
|
+
#include <grpc/support/port_platform.h>
|
15
|
+
|
16
|
+
#include "src/core/lib/event_engine/time_util.h"
|
17
|
+
|
18
|
+
#include <chrono>
|
19
|
+
|
20
|
+
#include <grpc/event_engine/event_engine.h>
|
21
|
+
|
22
|
+
namespace grpc_event_engine {
|
23
|
+
namespace experimental {
|
24
|
+
|
25
|
+
size_t Milliseconds(EventEngine::Duration d) {
|
26
|
+
return std::chrono::duration_cast<std::chrono::milliseconds>(d).count();
|
27
|
+
}
|
28
|
+
|
29
|
+
} // namespace experimental
|
30
|
+
} // namespace grpc_event_engine
|
@@ -0,0 +1,32 @@
|
|
1
|
+
// Copyright 2022 gRPC authors.
|
2
|
+
//
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
// you may not use this file except in compliance with the License.
|
5
|
+
// You may obtain a copy of the License at
|
6
|
+
//
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
//
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
// See the License for the specific language governing permissions and
|
13
|
+
// limitations under the License.
|
14
|
+
#ifndef GRPC_CORE_LIB_EVENT_ENGINE_TIME_UTIL_H
|
15
|
+
#define GRPC_CORE_LIB_EVENT_ENGINE_TIME_UTIL_H
|
16
|
+
|
17
|
+
#include <grpc/support/port_platform.h>
|
18
|
+
|
19
|
+
#include <stddef.h>
|
20
|
+
|
21
|
+
#include <grpc/event_engine/event_engine.h>
|
22
|
+
|
23
|
+
namespace grpc_event_engine {
|
24
|
+
namespace experimental {
|
25
|
+
|
26
|
+
// Convert a duration to milliseconds
|
27
|
+
size_t Milliseconds(EventEngine::Duration d);
|
28
|
+
|
29
|
+
} // namespace experimental
|
30
|
+
} // namespace grpc_event_engine
|
31
|
+
|
32
|
+
#endif // GRPC_CORE_LIB_EVENT_ENGINE_TIME_UTIL_H
|
@@ -18,7 +18,6 @@
|
|
18
18
|
#include <stdint.h>
|
19
19
|
|
20
20
|
#include <algorithm>
|
21
|
-
#include <chrono>
|
22
21
|
|
23
22
|
#include "absl/strings/str_cat.h"
|
24
23
|
|
@@ -41,9 +40,5 @@ grpc_core::Timestamp ToTimestamp(grpc_core::Timestamp now,
|
|
41
40
|
grpc_core::Duration::Milliseconds(1);
|
42
41
|
}
|
43
42
|
|
44
|
-
size_t Milliseconds(EventEngine::Duration d) {
|
45
|
-
return std::chrono::duration_cast<std::chrono::milliseconds>(d).count();
|
46
|
-
}
|
47
|
-
|
48
43
|
} // namespace experimental
|
49
44
|
} // namespace grpc_event_engine
|
@@ -16,8 +16,6 @@
|
|
16
16
|
|
17
17
|
#include <grpc/support/port_platform.h>
|
18
18
|
|
19
|
-
#include <stddef.h>
|
20
|
-
|
21
19
|
#include <string>
|
22
20
|
|
23
21
|
#include <grpc/event_engine/event_engine.h>
|
@@ -32,8 +30,6 @@ std::string HandleToString(EventEngine::TaskHandle handle);
|
|
32
30
|
grpc_core::Timestamp ToTimestamp(grpc_core::Timestamp now,
|
33
31
|
EventEngine::Duration delta);
|
34
32
|
|
35
|
-
size_t Milliseconds(EventEngine::Duration d);
|
36
|
-
|
37
33
|
} // namespace experimental
|
38
34
|
} // namespace grpc_event_engine
|
39
35
|
|
@@ -22,8 +22,8 @@
|
|
22
22
|
#include <grpc/support/alloc.h>
|
23
23
|
#include <grpc/support/log_windows.h>
|
24
24
|
|
25
|
+
#include "src/core/lib/event_engine/time_util.h"
|
25
26
|
#include "src/core/lib/event_engine/trace.h"
|
26
|
-
#include "src/core/lib/event_engine/utils.h"
|
27
27
|
#include "src/core/lib/event_engine/windows/iocp.h"
|
28
28
|
#include "src/core/lib/event_engine/windows/win_socket.h"
|
29
29
|
|
@@ -59,12 +59,13 @@ WinSocket* IOCP::Watch(SOCKET socket) {
|
|
59
59
|
|
60
60
|
void IOCP::Shutdown() {
|
61
61
|
while (outstanding_kicks_.load() > 0) {
|
62
|
-
Work(std::chrono::hours(42));
|
62
|
+
Work(std::chrono::hours(42), []() {});
|
63
63
|
}
|
64
64
|
GPR_ASSERT(CloseHandle(iocp_handle_));
|
65
65
|
}
|
66
66
|
|
67
|
-
Poller::WorkResult IOCP::Work(EventEngine::Duration timeout
|
67
|
+
Poller::WorkResult IOCP::Work(EventEngine::Duration timeout,
|
68
|
+
absl::FunctionRef<void()> schedule_poll_again) {
|
68
69
|
static const absl::Status kDeadlineExceeded = absl::DeadlineExceededError(
|
69
70
|
absl::StrFormat("IOCP::%p: Received no completions", this));
|
70
71
|
static const absl::Status kKicked =
|
@@ -82,7 +83,7 @@ Poller::WorkResult IOCP::Work(EventEngine::Duration timeout) {
|
|
82
83
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_event_engine_trace)) {
|
83
84
|
gpr_log(GPR_DEBUG, "IOCP::%p deadline exceeded", this);
|
84
85
|
}
|
85
|
-
return Poller::
|
86
|
+
return Poller::WorkResult::kDeadlineExceeded;
|
86
87
|
}
|
87
88
|
GPR_ASSERT(completion_key && overlapped);
|
88
89
|
if (overlapped == &kick_overlap_) {
|
@@ -91,7 +92,7 @@ Poller::WorkResult IOCP::Work(EventEngine::Duration timeout) {
|
|
91
92
|
}
|
92
93
|
outstanding_kicks_.fetch_sub(1);
|
93
94
|
if (completion_key == (ULONG_PTR)&kick_token_) {
|
94
|
-
return Poller::
|
95
|
+
return Poller::WorkResult::kKicked;
|
95
96
|
}
|
96
97
|
gpr_log(GPR_ERROR, "Unknown custom completion key: %p", completion_key);
|
97
98
|
abort();
|
@@ -109,10 +110,15 @@ Poller::WorkResult IOCP::Work(EventEngine::Duration timeout) {
|
|
109
110
|
} else {
|
110
111
|
info->GetOverlappedResult();
|
111
112
|
}
|
112
|
-
if (info->closure() != nullptr)
|
113
|
+
if (info->closure() != nullptr) {
|
114
|
+
schedule_poll_again();
|
115
|
+
executor_->Run(info->closure());
|
116
|
+
return Poller::WorkResult::kOk;
|
117
|
+
}
|
113
118
|
// No callback registered. Set ready and return an empty set
|
114
119
|
info->SetReady();
|
115
|
-
|
120
|
+
schedule_poll_again();
|
121
|
+
return Poller::WorkResult::kOk;
|
116
122
|
}
|
117
123
|
|
118
124
|
void IOCP::Kick() {
|
@@ -42,7 +42,8 @@ class IOCP final : public Poller {
|
|
42
42
|
|
43
43
|
// interface methods
|
44
44
|
void Shutdown();
|
45
|
-
WorkResult Work(EventEngine::Duration timeout
|
45
|
+
WorkResult Work(EventEngine::Duration timeout,
|
46
|
+
absl::FunctionRef<void()> schedule_poll_again) override;
|
46
47
|
void Kick() override;
|
47
48
|
|
48
49
|
WinSocket* Watch(SOCKET socket);
|
@@ -82,7 +82,7 @@ void WinSocket::NotifyOnReady(OpState& info, EventEngine::Closure* closure) {
|
|
82
82
|
executor_->Run(closure);
|
83
83
|
return;
|
84
84
|
};
|
85
|
-
if (
|
85
|
+
if (std::exchange(info.has_pending_iocp_, false)) {
|
86
86
|
executor_->Run(closure);
|
87
87
|
} else {
|
88
88
|
info.closure_ = closure;
|
@@ -0,0 +1,146 @@
|
|
1
|
+
// Copyright 2022 gRPC authors.
|
2
|
+
//
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
// you may not use this file except in compliance with the License.
|
5
|
+
// You may obtain a copy of the License at
|
6
|
+
//
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
//
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
// See the License for the specific language governing permissions and
|
13
|
+
// limitations under the License.
|
14
|
+
|
15
|
+
#include <grpc/support/port_platform.h>
|
16
|
+
|
17
|
+
#include "src/core/lib/experiments/config.h"
|
18
|
+
|
19
|
+
#include <string.h>
|
20
|
+
|
21
|
+
#include <algorithm>
|
22
|
+
#include <atomic>
|
23
|
+
#include <memory>
|
24
|
+
#include <string>
|
25
|
+
|
26
|
+
#include "absl/strings/ascii.h"
|
27
|
+
#include "absl/strings/str_cat.h"
|
28
|
+
#include "absl/strings/str_split.h"
|
29
|
+
#include "absl/strings/string_view.h"
|
30
|
+
|
31
|
+
#include <grpc/support/log.h>
|
32
|
+
|
33
|
+
#include "src/core/lib/experiments/experiments.h"
|
34
|
+
#include "src/core/lib/gprpp/global_config.h"
|
35
|
+
#include "src/core/lib/gprpp/no_destruct.h"
|
36
|
+
|
37
|
+
GPR_GLOBAL_CONFIG_DEFINE_STRING(
|
38
|
+
grpc_experiments, "",
|
39
|
+
"List of grpc experiments to enable (or with a '-' prefix to disable).");
|
40
|
+
|
41
|
+
namespace grpc_core {
|
42
|
+
|
43
|
+
namespace {
|
44
|
+
struct Experiments {
|
45
|
+
bool enabled[kNumExperiments];
|
46
|
+
};
|
47
|
+
|
48
|
+
struct ForcedExperiment {
|
49
|
+
bool forced = false;
|
50
|
+
bool value;
|
51
|
+
};
|
52
|
+
ForcedExperiment g_forced_experiments[kNumExperiments];
|
53
|
+
|
54
|
+
std::atomic<bool> g_loaded;
|
55
|
+
|
56
|
+
GPR_ATTRIBUTE_NOINLINE Experiments LoadExperimentsFromConfigVariable() {
|
57
|
+
GPR_ASSERT(g_loaded.exchange(true, std::memory_order_relaxed) == false);
|
58
|
+
// Set defaults from metadata.
|
59
|
+
Experiments experiments;
|
60
|
+
for (size_t i = 0; i < kNumExperiments; i++) {
|
61
|
+
experiments.enabled[i] = g_experiment_metadata[i].default_value;
|
62
|
+
}
|
63
|
+
// Get the global config.
|
64
|
+
auto experiments_str = GPR_GLOBAL_CONFIG_GET(grpc_experiments);
|
65
|
+
// For each comma-separated experiment in the global config:
|
66
|
+
for (auto experiment :
|
67
|
+
absl::StrSplit(absl::string_view(experiments_str.get()), ',')) {
|
68
|
+
// Strip whitespace.
|
69
|
+
experiment = absl::StripAsciiWhitespace(experiment);
|
70
|
+
// Handle ",," without crashing.
|
71
|
+
if (experiment.empty()) continue;
|
72
|
+
// Enable unless prefixed with '-' (=> disable).
|
73
|
+
bool enable = true;
|
74
|
+
if (experiment[0] == '-') {
|
75
|
+
enable = false;
|
76
|
+
experiment.remove_prefix(1);
|
77
|
+
}
|
78
|
+
// See if we can find the experiment in the list in this binary.
|
79
|
+
bool found = false;
|
80
|
+
for (size_t i = 0; i < kNumExperiments; i++) {
|
81
|
+
if (experiment == g_experiment_metadata[i].name) {
|
82
|
+
experiments.enabled[i] = enable;
|
83
|
+
found = true;
|
84
|
+
break;
|
85
|
+
}
|
86
|
+
}
|
87
|
+
// If not found log an error, but don't take any other action.
|
88
|
+
// Allows us an easy path to disabling experiments.
|
89
|
+
if (!found) {
|
90
|
+
gpr_log(GPR_ERROR, "Unknown experiment: %s",
|
91
|
+
std::string(experiment).c_str());
|
92
|
+
}
|
93
|
+
}
|
94
|
+
return experiments;
|
95
|
+
}
|
96
|
+
} // namespace
|
97
|
+
|
98
|
+
bool IsExperimentEnabled(size_t experiment_id) {
|
99
|
+
// One time initialization:
|
100
|
+
static const NoDestruct<Experiments> experiments{
|
101
|
+
LoadExperimentsFromConfigVariable()};
|
102
|
+
// Normal path: just return the value;
|
103
|
+
return experiments->enabled[experiment_id];
|
104
|
+
}
|
105
|
+
|
106
|
+
void PrintExperimentsList() {
|
107
|
+
size_t max_experiment_length = 0;
|
108
|
+
for (size_t i = 0; i < kNumExperiments; i++) {
|
109
|
+
max_experiment_length =
|
110
|
+
std::max(max_experiment_length, strlen(g_experiment_metadata[i].name));
|
111
|
+
}
|
112
|
+
for (size_t i = 0; i < kNumExperiments; i++) {
|
113
|
+
gpr_log(GPR_DEBUG, "%s",
|
114
|
+
absl::StrCat(
|
115
|
+
"gRPC EXPERIMENT ", g_experiment_metadata[i].name,
|
116
|
+
std::string(max_experiment_length -
|
117
|
+
strlen(g_experiment_metadata[i].name) + 1,
|
118
|
+
' '),
|
119
|
+
IsExperimentEnabled(i) ? "ON " : "OFF", " (default:",
|
120
|
+
g_experiment_metadata[i].default_value ? "ON" : "OFF",
|
121
|
+
g_forced_experiments[i].forced
|
122
|
+
? absl::StrCat(" force:",
|
123
|
+
g_forced_experiments[i].value ? "ON" : "OFF")
|
124
|
+
: std::string(),
|
125
|
+
")")
|
126
|
+
.c_str());
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
130
|
+
void ForceEnableExperiment(absl::string_view experiment, bool enable) {
|
131
|
+
GPR_ASSERT(g_loaded.load(std::memory_order_relaxed) == false);
|
132
|
+
for (size_t i = 0; i < kNumExperiments; i++) {
|
133
|
+
if (g_experiment_metadata[i].name != experiment) continue;
|
134
|
+
if (g_forced_experiments[i].forced) {
|
135
|
+
GPR_ASSERT(g_forced_experiments[i].value == enable);
|
136
|
+
} else {
|
137
|
+
g_forced_experiments[i].forced = true;
|
138
|
+
g_forced_experiments[i].value = enable;
|
139
|
+
}
|
140
|
+
return;
|
141
|
+
}
|
142
|
+
gpr_log(GPR_INFO, "gRPC EXPERIMENT %s not found to force %s",
|
143
|
+
std::string(experiment).c_str(), enable ? "enable" : "disable");
|
144
|
+
}
|
145
|
+
|
146
|
+
} // namespace grpc_core
|
@@ -0,0 +1,43 @@
|
|
1
|
+
// Copyright 2022 gRPC authors.
|
2
|
+
//
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
// you may not use this file except in compliance with the License.
|
5
|
+
// You may obtain a copy of the License at
|
6
|
+
//
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
//
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
// See the License for the specific language governing permissions and
|
13
|
+
// limitations under the License.
|
14
|
+
|
15
|
+
#ifndef GRPC_CORE_LIB_EXPERIMENTS_CONFIG_H
|
16
|
+
#define GRPC_CORE_LIB_EXPERIMENTS_CONFIG_H
|
17
|
+
|
18
|
+
#include <grpc/support/port_platform.h>
|
19
|
+
|
20
|
+
#include <stddef.h>
|
21
|
+
|
22
|
+
#include "absl/strings/string_view.h"
|
23
|
+
|
24
|
+
namespace grpc_core {
|
25
|
+
|
26
|
+
// Return true if experiment \a experiment_id is enabled.
|
27
|
+
// Experiments are numbered by their order in the g_experiment_metadata array
|
28
|
+
// declared in experiments.h.
|
29
|
+
bool IsExperimentEnabled(size_t experiment_id);
|
30
|
+
|
31
|
+
// Print out a list of all experiments that are built into this binary.
|
32
|
+
void PrintExperimentsList();
|
33
|
+
|
34
|
+
// Force an experiment to be on or off.
|
35
|
+
// Must be called before experiments are configured (the first
|
36
|
+
// IsExperimentEnabled call).
|
37
|
+
// If the experiment does not exist, emits a warning but continues execution.
|
38
|
+
// If this is called twice for the same experiment, both calls must agree.
|
39
|
+
void ForceEnableExperiment(absl::string_view experiment_name, bool enable);
|
40
|
+
|
41
|
+
} // namespace grpc_core
|
42
|
+
|
43
|
+
#endif // GRPC_CORE_LIB_EXPERIMENTS_CONFIG_H
|
@@ -0,0 +1,75 @@
|
|
1
|
+
// Copyright 2022 gRPC authors.
|
2
|
+
//
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
// you may not use this file except in compliance with the License.
|
5
|
+
// You may obtain a copy of the License at
|
6
|
+
//
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
//
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
// See the License for the specific language governing permissions and
|
13
|
+
// limitations under the License.
|
14
|
+
|
15
|
+
// Automatically generated by tools/codegen/core/gen_experiments.py
|
16
|
+
|
17
|
+
#include <grpc/support/port_platform.h>
|
18
|
+
|
19
|
+
#include "src/core/lib/experiments/experiments.h"
|
20
|
+
|
21
|
+
namespace {
|
22
|
+
const char* const description_tcp_frame_size_tuning =
|
23
|
+
"If set, enables TCP to use RPC size estimation made by higher layers. TCP "
|
24
|
+
"would not indicate completion of a read operation until a specified "
|
25
|
+
"number of bytes have been read over the socket. Buffers are also "
|
26
|
+
"allocated according to estimated RPC sizes.";
|
27
|
+
const char* const description_tcp_read_chunks =
|
28
|
+
"Allocate only 8kb or 64kb chunks for TCP reads to reduce pressure on "
|
29
|
+
"malloc to recycle arbitrary large blocks.";
|
30
|
+
const char* const description_tcp_rcv_lowat =
|
31
|
+
"Use SO_RCVLOWAT to avoid wakeups on the read path.";
|
32
|
+
const char* const description_peer_state_based_framing =
|
33
|
+
"If set, the max sizes of frames sent to lower layers is controlled based "
|
34
|
+
"on the peer's memory pressure which is reflected in its max http2 frame "
|
35
|
+
"size.";
|
36
|
+
const char* const description_flow_control_fixes =
|
37
|
+
"Various fixes for flow control, max frame size setting.";
|
38
|
+
const char* const description_memory_pressure_controller =
|
39
|
+
"New memory pressure controller";
|
40
|
+
const char* const description_periodic_resource_quota_reclamation =
|
41
|
+
"Periodically return memory to the resource quota";
|
42
|
+
const char* const description_unconstrained_max_quota_buffer_size =
|
43
|
+
"Discard the cap on the max free pool size for one memory allocator";
|
44
|
+
const char* const description_new_hpack_huffman_decoder =
|
45
|
+
"New HPACK huffman decoder - should be much faster than the existing "
|
46
|
+
"implementation.";
|
47
|
+
const char* const description_event_engine_client =
|
48
|
+
"Use EventEngine clients instead of iomgr's grpc_tcp_client";
|
49
|
+
#ifdef NDEBUG
|
50
|
+
const bool kDefaultForDebugOnly = false;
|
51
|
+
#else
|
52
|
+
const bool kDefaultForDebugOnly = true;
|
53
|
+
#endif
|
54
|
+
} // namespace
|
55
|
+
|
56
|
+
namespace grpc_core {
|
57
|
+
|
58
|
+
const ExperimentMetadata g_experiment_metadata[] = {
|
59
|
+
{"tcp_frame_size_tuning", description_tcp_frame_size_tuning, false},
|
60
|
+
{"tcp_read_chunks", description_tcp_read_chunks, false},
|
61
|
+
{"tcp_rcv_lowat", description_tcp_rcv_lowat, false},
|
62
|
+
{"peer_state_based_framing", description_peer_state_based_framing, false},
|
63
|
+
{"flow_control_fixes", description_flow_control_fixes, false},
|
64
|
+
{"memory_pressure_controller", description_memory_pressure_controller,
|
65
|
+
false},
|
66
|
+
{"periodic_resource_quota_reclamation",
|
67
|
+
description_periodic_resource_quota_reclamation, false},
|
68
|
+
{"unconstrained_max_quota_buffer_size",
|
69
|
+
description_unconstrained_max_quota_buffer_size, false},
|
70
|
+
{"new_hpack_huffman_decoder", description_new_hpack_huffman_decoder,
|
71
|
+
kDefaultForDebugOnly},
|
72
|
+
{"event_engine_client", description_event_engine_client, false},
|
73
|
+
};
|
74
|
+
|
75
|
+
} // namespace grpc_core
|
@@ -0,0 +1,56 @@
|
|
1
|
+
// Copyright 2022 gRPC authors.
|
2
|
+
//
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
// you may not use this file except in compliance with the License.
|
5
|
+
// You may obtain a copy of the License at
|
6
|
+
//
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
//
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
// See the License for the specific language governing permissions and
|
13
|
+
// limitations under the License.
|
14
|
+
|
15
|
+
// Automatically generated by tools/codegen/core/gen_experiments.py
|
16
|
+
|
17
|
+
#ifndef GRPC_CORE_LIB_EXPERIMENTS_EXPERIMENTS_H
|
18
|
+
#define GRPC_CORE_LIB_EXPERIMENTS_EXPERIMENTS_H
|
19
|
+
|
20
|
+
#include <grpc/support/port_platform.h>
|
21
|
+
|
22
|
+
#include <stddef.h>
|
23
|
+
|
24
|
+
#include "src/core/lib/experiments/config.h"
|
25
|
+
|
26
|
+
namespace grpc_core {
|
27
|
+
|
28
|
+
inline bool IsTcpFrameSizeTuningEnabled() { return IsExperimentEnabled(0); }
|
29
|
+
inline bool IsTcpReadChunksEnabled() { return IsExperimentEnabled(1); }
|
30
|
+
inline bool IsTcpRcvLowatEnabled() { return IsExperimentEnabled(2); }
|
31
|
+
inline bool IsPeerStateBasedFramingEnabled() { return IsExperimentEnabled(3); }
|
32
|
+
inline bool IsFlowControlFixesEnabled() { return IsExperimentEnabled(4); }
|
33
|
+
inline bool IsMemoryPressureControllerEnabled() {
|
34
|
+
return IsExperimentEnabled(5);
|
35
|
+
}
|
36
|
+
inline bool IsPeriodicResourceQuotaReclamationEnabled() {
|
37
|
+
return IsExperimentEnabled(6);
|
38
|
+
}
|
39
|
+
inline bool IsUnconstrainedMaxQuotaBufferSizeEnabled() {
|
40
|
+
return IsExperimentEnabled(7);
|
41
|
+
}
|
42
|
+
inline bool IsNewHpackHuffmanDecoderEnabled() { return IsExperimentEnabled(8); }
|
43
|
+
inline bool IsEventEngineClientEnabled() { return IsExperimentEnabled(9); }
|
44
|
+
|
45
|
+
struct ExperimentMetadata {
|
46
|
+
const char* name;
|
47
|
+
const char* description;
|
48
|
+
bool default_value;
|
49
|
+
};
|
50
|
+
|
51
|
+
constexpr const size_t kNumExperiments = 10;
|
52
|
+
extern const ExperimentMetadata g_experiment_metadata[kNumExperiments];
|
53
|
+
|
54
|
+
} // namespace grpc_core
|
55
|
+
|
56
|
+
#endif // GRPC_CORE_LIB_EXPERIMENTS_EXPERIMENTS_H
|
data/src/core/lib/gpr/alloc.cc
CHANGED
@@ -24,10 +24,7 @@
|
|
24
24
|
#include <grpc/support/alloc.h>
|
25
25
|
#include <grpc/support/log.h>
|
26
26
|
|
27
|
-
#include "src/core/lib/profiling/timers.h"
|
28
|
-
|
29
27
|
void* gpr_malloc(size_t size) {
|
30
|
-
GPR_TIMER_SCOPE("gpr_malloc", 0);
|
31
28
|
void* p;
|
32
29
|
if (size == 0) return nullptr;
|
33
30
|
p = malloc(size);
|
@@ -38,7 +35,6 @@ void* gpr_malloc(size_t size) {
|
|
38
35
|
}
|
39
36
|
|
40
37
|
void* gpr_zalloc(size_t size) {
|
41
|
-
GPR_TIMER_SCOPE("gpr_zalloc", 0);
|
42
38
|
void* p;
|
43
39
|
if (size == 0) return nullptr;
|
44
40
|
p = calloc(size, 1);
|
@@ -48,13 +44,9 @@ void* gpr_zalloc(size_t size) {
|
|
48
44
|
return p;
|
49
45
|
}
|
50
46
|
|
51
|
-
void gpr_free(void* p) {
|
52
|
-
GPR_TIMER_SCOPE("gpr_free", 0);
|
53
|
-
free(p);
|
54
|
-
}
|
47
|
+
void gpr_free(void* p) { free(p); }
|
55
48
|
|
56
49
|
void* gpr_realloc(void* p, size_t size) {
|
57
|
-
GPR_TIMER_SCOPE("gpr_realloc", 0);
|
58
50
|
if ((size == 0) && (p == nullptr)) return nullptr;
|
59
51
|
p = realloc(p, size);
|
60
52
|
if (!p) {
|
@@ -37,46 +37,19 @@
|
|
37
37
|
#include <grpc/support/string_util.h>
|
38
38
|
|
39
39
|
#include "src/core/lib/gpr/string.h"
|
40
|
-
#include "src/core/lib/
|
41
|
-
|
42
|
-
#if defined UNICODE || defined _UNICODE
|
43
|
-
LPTSTR
|
44
|
-
gpr_char_to_tchar(LPCSTR input) {
|
45
|
-
LPTSTR ret;
|
46
|
-
int needed = MultiByteToWideChar(CP_UTF8, 0, input, -1, NULL, 0);
|
47
|
-
if (needed <= 0) return NULL;
|
48
|
-
ret = (LPTSTR)gpr_malloc((unsigned)needed * sizeof(TCHAR));
|
49
|
-
MultiByteToWideChar(CP_UTF8, 0, input, -1, ret, needed);
|
50
|
-
return ret;
|
51
|
-
}
|
52
|
-
|
53
|
-
LPSTR
|
54
|
-
gpr_tchar_to_char(LPCTSTR input) {
|
55
|
-
LPSTR ret;
|
56
|
-
int needed = WideCharToMultiByte(CP_UTF8, 0, input, -1, NULL, 0, NULL, NULL);
|
57
|
-
if (needed <= 0) return NULL;
|
58
|
-
ret = (LPSTR)gpr_malloc((unsigned)needed);
|
59
|
-
WideCharToMultiByte(CP_UTF8, 0, input, -1, ret, needed, NULL, NULL);
|
60
|
-
return ret;
|
61
|
-
}
|
62
|
-
#else
|
63
|
-
LPSTR gpr_tchar_to_char(LPCTSTR input) { return (LPSTR)gpr_strdup(input); }
|
64
|
-
|
65
|
-
LPTSTR gpr_char_to_tchar(LPCTSTR input) { return (LPTSTR)gpr_strdup(input); }
|
66
|
-
#endif
|
40
|
+
#include "src/core/lib/gprpp/tchar.h"
|
67
41
|
|
68
42
|
char* gpr_format_message(int messageid) {
|
69
43
|
LPTSTR tmessage;
|
70
|
-
char* message;
|
71
44
|
DWORD status = FormatMessage(
|
72
45
|
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
|
73
46
|
FORMAT_MESSAGE_IGNORE_INSERTS,
|
74
47
|
NULL, (DWORD)messageid, MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT),
|
75
48
|
(LPTSTR)(&tmessage), 0, NULL);
|
76
49
|
if (status == 0) return gpr_strdup("Unable to retrieve error string");
|
77
|
-
message =
|
50
|
+
auto message = grpc_core::TcharToChar(tmessage);
|
78
51
|
LocalFree(tmessage);
|
79
|
-
return message;
|
52
|
+
return gpr_strdup(message.c_str());
|
80
53
|
}
|
81
54
|
|
82
55
|
#endif /* GPR_WINDOWS */
|
@@ -33,14 +33,6 @@
|
|
33
33
|
#include <grpc/support/sync.h>
|
34
34
|
#include <grpc/support/time.h>
|
35
35
|
|
36
|
-
#include "src/core/lib/profiling/timers.h"
|
37
|
-
|
38
|
-
#ifdef GPR_LOW_LEVEL_COUNTERS
|
39
|
-
gpr_atm gpr_mu_locks = 0;
|
40
|
-
gpr_atm gpr_counter_atm_cas = 0;
|
41
|
-
gpr_atm gpr_counter_atm_add = 0;
|
42
|
-
#endif
|
43
|
-
|
44
36
|
void gpr_mu_init(gpr_mu* mu) {
|
45
37
|
static_assert(sizeof(gpr_mu) == sizeof(absl::Mutex),
|
46
38
|
"gpr_mu and Mutex must be the same size");
|
@@ -52,17 +44,14 @@ void gpr_mu_destroy(gpr_mu* mu) {
|
|
52
44
|
}
|
53
45
|
|
54
46
|
void gpr_mu_lock(gpr_mu* mu) ABSL_NO_THREAD_SAFETY_ANALYSIS {
|
55
|
-
GPR_TIMER_SCOPE("gpr_mu_lock", 0);
|
56
47
|
reinterpret_cast<absl::Mutex*>(mu)->Lock();
|
57
48
|
}
|
58
49
|
|
59
50
|
void gpr_mu_unlock(gpr_mu* mu) ABSL_NO_THREAD_SAFETY_ANALYSIS {
|
60
|
-
GPR_TIMER_SCOPE("gpr_mu_unlock", 0);
|
61
51
|
reinterpret_cast<absl::Mutex*>(mu)->Unlock();
|
62
52
|
}
|
63
53
|
|
64
54
|
int gpr_mu_trylock(gpr_mu* mu) {
|
65
|
-
GPR_TIMER_SCOPE("gpr_mu_trylock", 0);
|
66
55
|
return reinterpret_cast<absl::Mutex*>(mu)->TryLock();
|
67
56
|
}
|
68
57
|
|
@@ -79,7 +68,6 @@ void gpr_cv_destroy(gpr_cv* cv) {
|
|
79
68
|
}
|
80
69
|
|
81
70
|
int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu, gpr_timespec abs_deadline) {
|
82
|
-
GPR_TIMER_SCOPE("gpr_cv_wait", 0);
|
83
71
|
if (gpr_time_cmp(abs_deadline, gpr_inf_future(abs_deadline.clock_type)) ==
|
84
72
|
0) {
|
85
73
|
reinterpret_cast<absl::CondVar*>(cv)->Wait(
|
@@ -94,12 +82,10 @@ int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu, gpr_timespec abs_deadline) {
|
|
94
82
|
}
|
95
83
|
|
96
84
|
void gpr_cv_signal(gpr_cv* cv) {
|
97
|
-
GPR_TIMER_MARK("gpr_cv_signal", 0);
|
98
85
|
reinterpret_cast<absl::CondVar*>(cv)->Signal();
|
99
86
|
}
|
100
87
|
|
101
88
|
void gpr_cv_broadcast(gpr_cv* cv) {
|
102
|
-
GPR_TIMER_MARK("gpr_cv_broadcast", 0);
|
103
89
|
reinterpret_cast<absl::CondVar*>(cv)->SignalAll();
|
104
90
|
}
|
105
91
|
|