grpc 1.22.0 → 1.23.0
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 +487 -649
- data/include/grpc/grpc_security.h +25 -0
- data/include/grpc/impl/codegen/grpc_types.h +11 -2
- data/include/grpc/impl/codegen/port_platform.h +12 -0
- data/src/core/ext/filters/client_channel/backup_poller.cc +4 -2
- data/src/core/ext/filters/client_channel/client_channel.cc +477 -182
- data/src/core/ext/filters/client_channel/client_channel_channelz.cc +25 -16
- data/src/core/ext/filters/client_channel/client_channel_channelz.h +11 -6
- data/src/core/ext/filters/client_channel/connector.h +10 -2
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +3 -3
- data/src/core/ext/filters/client_channel/http_proxy.cc +9 -10
- data/src/core/ext/filters/client_channel/lb_policy.cc +2 -17
- data/src/core/ext/filters/client_channel/lb_policy.h +36 -8
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +22 -8
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +86 -52
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +7 -0
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +73 -72
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +8 -12
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +25 -101
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +5 -5
- data/src/core/ext/filters/client_channel/parse_address.cc +29 -26
- data/src/core/ext/filters/client_channel/resolver.h +3 -11
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +5 -3
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +405 -82
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +44 -51
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +0 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +0 -1
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +11 -6
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +130 -65
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +8 -3
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +31 -14
- data/src/core/ext/filters/client_channel/resolver_factory.h +4 -0
- data/src/core/ext/filters/client_channel/resolver_registry.cc +11 -0
- data/src/core/ext/filters/client_channel/resolver_registry.h +3 -0
- data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +10 -49
- data/src/core/ext/filters/client_channel/resolving_lb_policy.h +1 -14
- data/src/core/ext/filters/client_channel/retry_throttle.h +2 -3
- data/src/core/ext/filters/client_channel/subchannel.cc +65 -58
- data/src/core/ext/filters/client_channel/subchannel.h +65 -45
- data/src/core/ext/filters/client_channel/subchannel_interface.h +15 -30
- data/src/core/ext/filters/client_idle/client_idle_filter.cc +262 -0
- data/src/core/ext/filters/http/client/http_client_filter.cc +4 -5
- data/src/core/ext/filters/http/client_authority_filter.cc +2 -2
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +140 -152
- data/src/core/ext/filters/max_age/max_age_filter.cc +3 -3
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +3 -4
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +7 -6
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +63 -38
- data/src/core/ext/transport/chttp2/transport/context_list.cc +3 -1
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +4 -4
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +1 -0
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +8 -0
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +7 -0
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +1 -0
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +37 -22
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +136 -81
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +8 -0
- data/src/core/ext/transport/chttp2/transport/hpack_table.cc +7 -166
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +41 -15
- data/src/core/ext/transport/chttp2/transport/internal.h +13 -2
- data/src/core/ext/transport/chttp2/transport/parsing.cc +35 -22
- data/src/core/ext/transport/chttp2/transport/stream_map.cc +28 -18
- data/src/core/ext/transport/chttp2/transport/writing.cc +1 -0
- data/src/core/ext/transport/inproc/inproc_transport.cc +1 -1
- data/src/core/lib/channel/channelz.cc +80 -33
- data/src/core/lib/channel/channelz.h +28 -13
- data/src/core/lib/compression/compression.cc +1 -2
- data/src/core/lib/compression/compression_args.cc +13 -6
- data/src/core/lib/compression/compression_args.h +3 -2
- data/src/core/lib/compression/compression_internal.cc +1 -1
- data/src/core/lib/gpr/env_linux.cc +10 -21
- data/src/core/lib/gpr/env_posix.cc +0 -5
- data/src/core/lib/gpr/string.cc +7 -2
- data/src/core/lib/gpr/string.h +1 -0
- data/src/core/lib/gpr/sync_posix.cc +0 -129
- data/src/core/lib/gprpp/debug_location.h +3 -2
- data/src/core/lib/gprpp/fork.cc +14 -21
- data/src/core/lib/gprpp/fork.h +15 -4
- data/src/core/lib/gprpp/host_port.cc +118 -0
- data/src/core/lib/{gpr → gprpp}/host_port.h +27 -11
- data/src/core/lib/gprpp/map.h +25 -0
- data/src/core/lib/gprpp/memory.h +26 -9
- data/src/core/lib/gprpp/ref_counted.h +63 -21
- data/src/core/lib/gprpp/string_view.h +143 -0
- data/src/core/lib/gprpp/thd.h +10 -1
- data/src/core/lib/gprpp/thd_posix.cc +25 -0
- data/src/core/lib/gprpp/thd_windows.cc +9 -1
- data/src/core/lib/http/httpcli_security_connector.cc +3 -1
- data/src/core/lib/iomgr/cfstream_handle.cc +6 -1
- data/src/core/lib/iomgr/cfstream_handle.h +8 -2
- data/src/core/lib/iomgr/combiner.cc +4 -4
- data/src/core/lib/iomgr/error.cc +18 -8
- data/src/core/lib/iomgr/error.h +2 -0
- data/src/core/lib/iomgr/ev_posix.cc +4 -2
- data/src/core/lib/iomgr/executor.cc +4 -1
- data/src/core/lib/iomgr/executor/mpmcqueue.cc +183 -0
- data/src/core/lib/iomgr/executor/mpmcqueue.h +178 -0
- data/src/core/lib/iomgr/executor/threadpool.cc +138 -0
- data/src/core/lib/iomgr/executor/threadpool.h +153 -0
- data/src/core/lib/iomgr/fork_posix.cc +4 -2
- data/src/core/lib/iomgr/iocp_windows.cc +2 -2
- data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +14 -0
- data/src/core/lib/iomgr/iomgr_uv.cc +3 -0
- data/src/core/lib/iomgr/lockfree_event.cc +3 -3
- data/src/core/lib/iomgr/resolve_address_custom.cc +16 -20
- data/src/core/lib/iomgr/resolve_address_posix.cc +8 -10
- data/src/core/lib/iomgr/resolve_address_windows.cc +6 -8
- data/src/core/lib/iomgr/sockaddr_utils.cc +5 -3
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +0 -1
- data/src/core/lib/iomgr/socket_windows.h +1 -1
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +7 -6
- data/src/core/lib/iomgr/tcp_client_custom.cc +1 -0
- data/src/core/lib/iomgr/tcp_custom.cc +4 -0
- data/src/core/lib/iomgr/tcp_posix.cc +8 -2
- data/src/core/lib/iomgr/tcp_server_custom.cc +1 -0
- data/src/core/lib/iomgr/tcp_server_windows.cc +1 -1
- data/src/core/lib/iomgr/tcp_windows.cc +7 -7
- data/src/core/lib/iomgr/timer_custom.cc +1 -0
- data/src/core/lib/iomgr/timer_manager.cc +0 -29
- data/src/core/lib/security/credentials/credentials.cc +84 -0
- data/src/core/lib/security/credentials/credentials.h +58 -2
- data/src/core/lib/security/credentials/jwt/json_token.cc +6 -2
- data/src/core/lib/security/credentials/jwt/json_token.h +1 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +245 -24
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +16 -0
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +3 -2
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +21 -25
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +3 -2
- data/src/core/lib/security/security_connector/security_connector.cc +1 -1
- data/src/core/lib/security/security_connector/security_connector.h +1 -1
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +19 -19
- data/src/core/lib/security/security_connector/ssl_utils.cc +26 -31
- data/src/core/lib/security/security_connector/ssl_utils.h +11 -8
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +16 -20
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.h +4 -3
- data/src/core/lib/security/transport/client_auth_filter.cc +1 -2
- data/src/core/lib/security/util/json_util.cc +19 -5
- data/src/core/lib/security/util/json_util.h +3 -1
- data/src/core/lib/slice/slice.cc +69 -50
- data/src/core/lib/slice/slice_buffer.cc +6 -5
- data/src/core/lib/slice/slice_hash_table.h +3 -7
- data/src/core/lib/slice/slice_intern.cc +130 -39
- data/src/core/lib/slice/slice_internal.h +8 -0
- data/src/core/lib/slice/slice_utils.h +120 -0
- data/src/core/lib/slice/slice_weak_hash_table.h +2 -7
- data/src/core/lib/surface/call.cc +8 -3
- data/src/core/lib/surface/channel.cc +31 -8
- data/src/core/lib/surface/completion_queue.cc +17 -7
- data/src/core/lib/surface/init_secure.cc +4 -1
- data/src/core/lib/surface/lame_client.cc +2 -2
- data/src/core/lib/surface/server.cc +34 -35
- data/src/core/lib/surface/server.h +8 -17
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/lib/transport/byte_stream.cc +3 -5
- data/src/core/lib/transport/byte_stream.h +1 -2
- data/src/core/lib/transport/error_utils.cc +10 -1
- data/src/core/lib/transport/metadata.cc +202 -35
- data/src/core/lib/transport/metadata.h +81 -6
- data/src/core/lib/transport/static_metadata.cc +1257 -465
- data/src/core/lib/transport/static_metadata.h +190 -347
- data/src/core/lib/transport/timeout_encoding.cc +7 -0
- data/src/core/lib/transport/timeout_encoding.h +3 -2
- data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -0
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +0 -1
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +2 -7
- data/src/core/tsi/ssl_transport_security.cc +35 -43
- data/src/core/tsi/ssl_transport_security.h +2 -1
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +3 -0
- data/src/ruby/lib/grpc/generic/rpc_server.rb +1 -1
- data/src/ruby/lib/grpc/grpc.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- metadata +39 -33
- data/src/core/lib/gpr/host_port.cc +0 -98
@@ -59,8 +59,10 @@ void grpc_prefork() {
|
|
59
59
|
"environment variable GRPC_ENABLE_FORK_SUPPORT=1");
|
60
60
|
return;
|
61
61
|
}
|
62
|
-
|
63
|
-
|
62
|
+
const char* poll_strategy_name = grpc_get_poll_strategy_name();
|
63
|
+
if (poll_strategy_name == nullptr ||
|
64
|
+
(strcmp(poll_strategy_name, "epoll1") != 0 &&
|
65
|
+
strcmp(poll_strategy_name, "poll") != 0)) {
|
64
66
|
gpr_log(GPR_INFO,
|
65
67
|
"Fork support is only compatible with the epoll1 and poll polling "
|
66
68
|
"strategies");
|
@@ -90,12 +90,12 @@ grpc_iocp_work_status grpc_iocp_work(grpc_millis deadline) {
|
|
90
90
|
abort();
|
91
91
|
}
|
92
92
|
if (socket->shutdown_called) {
|
93
|
-
info->
|
93
|
+
info->bytes_transferred = 0;
|
94
94
|
info->wsa_error = WSA_OPERATION_ABORTED;
|
95
95
|
} else {
|
96
96
|
success = WSAGetOverlappedResult(socket->socket, &info->overlapped, &bytes,
|
97
97
|
FALSE, &flags);
|
98
|
-
info->
|
98
|
+
info->bytes_transferred = bytes;
|
99
99
|
info->wsa_error = success ? 0 : WSAGetLastError();
|
100
100
|
}
|
101
101
|
GPR_ASSERT(overlapped == &info->overlapped);
|
@@ -78,9 +78,19 @@ static grpc_iomgr_platform_vtable vtable = {
|
|
78
78
|
void grpc_set_default_iomgr_platform() {
|
79
79
|
char* enable_cfstream = getenv(grpc_cfstream_env_var);
|
80
80
|
grpc_tcp_client_vtable* client_vtable = &grpc_posix_tcp_client_vtable;
|
81
|
+
// CFStream is enabled by default on iOS, and disabled by default on other
|
82
|
+
// platforms. Defaults can be overriden by setting the grpc_cfstream
|
83
|
+
// environment variable.
|
84
|
+
#if TARGET_OS_IPHONE
|
85
|
+
if (enable_cfstream == nullptr || enable_cfstream[0] == '1') {
|
86
|
+
client_vtable = &grpc_cfstream_client_vtable;
|
87
|
+
}
|
88
|
+
#else
|
81
89
|
if (enable_cfstream != nullptr && enable_cfstream[0] == '1') {
|
82
90
|
client_vtable = &grpc_cfstream_client_vtable;
|
83
91
|
}
|
92
|
+
#endif
|
93
|
+
|
84
94
|
grpc_set_tcp_client_impl(client_vtable);
|
85
95
|
grpc_set_tcp_server_impl(&grpc_posix_tcp_server_vtable);
|
86
96
|
grpc_set_timer_impl(&grpc_generic_timer_vtable);
|
@@ -90,4 +100,8 @@ void grpc_set_default_iomgr_platform() {
|
|
90
100
|
grpc_set_iomgr_platform_vtable(&vtable);
|
91
101
|
}
|
92
102
|
|
103
|
+
bool grpc_iomgr_run_in_background() {
|
104
|
+
return grpc_event_engine_run_in_background();
|
105
|
+
}
|
106
|
+
|
93
107
|
#endif /* GRPC_CFSTREAM_IOMGR */
|
@@ -95,7 +95,7 @@ void LockfreeEvent::NotifyOn(grpc_closure* closure) {
|
|
95
95
|
* referencing it. */
|
96
96
|
gpr_atm curr = gpr_atm_acq_load(&state_);
|
97
97
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_polling_trace)) {
|
98
|
-
gpr_log(
|
98
|
+
gpr_log(GPR_DEBUG, "LockfreeEvent::NotifyOn: %p curr=%p closure=%p", this,
|
99
99
|
(void*)curr, closure);
|
100
100
|
}
|
101
101
|
switch (curr) {
|
@@ -161,7 +161,7 @@ bool LockfreeEvent::SetShutdown(grpc_error* shutdown_err) {
|
|
161
161
|
while (true) {
|
162
162
|
gpr_atm curr = gpr_atm_no_barrier_load(&state_);
|
163
163
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_polling_trace)) {
|
164
|
-
gpr_log(
|
164
|
+
gpr_log(GPR_DEBUG, "LockfreeEvent::SetShutdown: %p curr=%p err=%s",
|
165
165
|
&state_, (void*)curr, grpc_error_string(shutdown_err));
|
166
166
|
}
|
167
167
|
switch (curr) {
|
@@ -210,7 +210,7 @@ void LockfreeEvent::SetReady() {
|
|
210
210
|
gpr_atm curr = gpr_atm_no_barrier_load(&state_);
|
211
211
|
|
212
212
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_polling_trace)) {
|
213
|
-
gpr_log(
|
213
|
+
gpr_log(GPR_DEBUG, "LockfreeEvent::SetReady: %p curr=%p", &state_,
|
214
214
|
(void*)curr);
|
215
215
|
}
|
216
216
|
|
@@ -24,9 +24,9 @@
|
|
24
24
|
#include <grpc/support/string_util.h>
|
25
25
|
|
26
26
|
#include <grpc/support/log.h>
|
27
|
-
#include "src/core/lib/gpr/host_port.h"
|
28
27
|
#include "src/core/lib/gpr/string.h"
|
29
28
|
#include "src/core/lib/gpr/useful.h"
|
29
|
+
#include "src/core/lib/gprpp/host_port.h"
|
30
30
|
|
31
31
|
#include "src/core/lib/iomgr/iomgr_custom.h"
|
32
32
|
#include "src/core/lib/iomgr/resolve_address_custom.h"
|
@@ -71,6 +71,7 @@ void grpc_custom_resolve_callback(grpc_custom_resolver* r,
|
|
71
71
|
grpc_resolved_addresses* result,
|
72
72
|
grpc_error* error) {
|
73
73
|
GRPC_CUSTOM_IOMGR_ASSERT_SAME_THREAD();
|
74
|
+
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
|
74
75
|
grpc_core::ExecCtx exec_ctx;
|
75
76
|
if (error == GRPC_ERROR_NONE) {
|
76
77
|
*r->addresses = result;
|
@@ -86,11 +87,12 @@ void grpc_custom_resolve_callback(grpc_custom_resolver* r,
|
|
86
87
|
}
|
87
88
|
|
88
89
|
static grpc_error* try_split_host_port(const char* name,
|
89
|
-
const char* default_port,
|
90
|
-
char
|
90
|
+
const char* default_port,
|
91
|
+
grpc_core::UniquePtr<char>* host,
|
92
|
+
grpc_core::UniquePtr<char>* port) {
|
91
93
|
/* parse name, splitting it into host and port parts */
|
92
94
|
grpc_error* error;
|
93
|
-
|
95
|
+
SplitHostPort(name, host, port);
|
94
96
|
if (*host == nullptr) {
|
95
97
|
char* msg;
|
96
98
|
gpr_asprintf(&msg, "unparseable host:port: '%s'", name);
|
@@ -107,7 +109,7 @@ static grpc_error* try_split_host_port(const char* name,
|
|
107
109
|
gpr_free(msg);
|
108
110
|
return error;
|
109
111
|
}
|
110
|
-
|
112
|
+
port->reset(gpr_strdup(default_port));
|
111
113
|
}
|
112
114
|
return GRPC_ERROR_NONE;
|
113
115
|
}
|
@@ -115,28 +117,26 @@ static grpc_error* try_split_host_port(const char* name,
|
|
115
117
|
static grpc_error* blocking_resolve_address_impl(
|
116
118
|
const char* name, const char* default_port,
|
117
119
|
grpc_resolved_addresses** addresses) {
|
118
|
-
char
|
119
|
-
char
|
120
|
+
grpc_core::UniquePtr<char> host;
|
121
|
+
grpc_core::UniquePtr<char> port;
|
120
122
|
grpc_error* err;
|
121
123
|
|
122
124
|
GRPC_CUSTOM_IOMGR_ASSERT_SAME_THREAD();
|
123
125
|
|
124
126
|
err = try_split_host_port(name, default_port, &host, &port);
|
125
127
|
if (err != GRPC_ERROR_NONE) {
|
126
|
-
gpr_free(host);
|
127
|
-
gpr_free(port);
|
128
128
|
return err;
|
129
129
|
}
|
130
130
|
|
131
131
|
/* Call getaddrinfo */
|
132
132
|
grpc_custom_resolver resolver;
|
133
|
-
resolver.host = host;
|
134
|
-
resolver.port = port;
|
133
|
+
resolver.host = host.get();
|
134
|
+
resolver.port = port.get();
|
135
135
|
|
136
136
|
grpc_resolved_addresses* addrs;
|
137
137
|
grpc_core::ExecCtx* curr = grpc_core::ExecCtx::Get();
|
138
138
|
grpc_core::ExecCtx::Set(nullptr);
|
139
|
-
err = resolve_address_vtable->resolve(host, port, &addrs);
|
139
|
+
err = resolve_address_vtable->resolve(host.get(), port.get(), &addrs);
|
140
140
|
if (err != GRPC_ERROR_NONE) {
|
141
141
|
if (retry_named_port_failure(&resolver, &addrs)) {
|
142
142
|
GRPC_ERROR_UNREF(err);
|
@@ -147,8 +147,6 @@ static grpc_error* blocking_resolve_address_impl(
|
|
147
147
|
if (err == GRPC_ERROR_NONE) {
|
148
148
|
*addresses = addrs;
|
149
149
|
}
|
150
|
-
gpr_free(resolver.host);
|
151
|
-
gpr_free(resolver.port);
|
152
150
|
return err;
|
153
151
|
}
|
154
152
|
|
@@ -157,22 +155,20 @@ static void resolve_address_impl(const char* name, const char* default_port,
|
|
157
155
|
grpc_closure* on_done,
|
158
156
|
grpc_resolved_addresses** addrs) {
|
159
157
|
grpc_custom_resolver* r = nullptr;
|
160
|
-
char
|
161
|
-
char
|
158
|
+
grpc_core::UniquePtr<char> host;
|
159
|
+
grpc_core::UniquePtr<char> port;
|
162
160
|
grpc_error* err;
|
163
161
|
GRPC_CUSTOM_IOMGR_ASSERT_SAME_THREAD();
|
164
162
|
err = try_split_host_port(name, default_port, &host, &port);
|
165
163
|
if (err != GRPC_ERROR_NONE) {
|
166
164
|
GRPC_CLOSURE_SCHED(on_done, err);
|
167
|
-
gpr_free(host);
|
168
|
-
gpr_free(port);
|
169
165
|
return;
|
170
166
|
}
|
171
167
|
r = (grpc_custom_resolver*)gpr_malloc(sizeof(grpc_custom_resolver));
|
172
168
|
r->on_done = on_done;
|
173
169
|
r->addresses = addrs;
|
174
|
-
r->host = host;
|
175
|
-
r->port = port;
|
170
|
+
r->host = host.release();
|
171
|
+
r->port = port.release();
|
176
172
|
|
177
173
|
/* Call getaddrinfo */
|
178
174
|
resolve_address_vtable->resolve_async(r, r->host, r->port);
|
@@ -33,9 +33,9 @@
|
|
33
33
|
#include <grpc/support/string_util.h>
|
34
34
|
#include <grpc/support/time.h>
|
35
35
|
|
36
|
-
#include "src/core/lib/gpr/host_port.h"
|
37
36
|
#include "src/core/lib/gpr/string.h"
|
38
37
|
#include "src/core/lib/gpr/useful.h"
|
38
|
+
#include "src/core/lib/gprpp/host_port.h"
|
39
39
|
#include "src/core/lib/gprpp/thd.h"
|
40
40
|
#include "src/core/lib/iomgr/block_annotate.h"
|
41
41
|
#include "src/core/lib/iomgr/executor.h"
|
@@ -48,8 +48,6 @@ static grpc_error* posix_blocking_resolve_address(
|
|
48
48
|
grpc_core::ExecCtx exec_ctx;
|
49
49
|
struct addrinfo hints;
|
50
50
|
struct addrinfo *result = nullptr, *resp;
|
51
|
-
char* host;
|
52
|
-
char* port;
|
53
51
|
int s;
|
54
52
|
size_t i;
|
55
53
|
grpc_error* err;
|
@@ -59,8 +57,10 @@ static grpc_error* posix_blocking_resolve_address(
|
|
59
57
|
return grpc_resolve_unix_domain_address(name + 5, addresses);
|
60
58
|
}
|
61
59
|
|
60
|
+
grpc_core::UniquePtr<char> host;
|
61
|
+
grpc_core::UniquePtr<char> port;
|
62
62
|
/* parse name, splitting it into host and port parts */
|
63
|
-
|
63
|
+
grpc_core::SplitHostPort(name, &host, &port);
|
64
64
|
if (host == nullptr) {
|
65
65
|
err = grpc_error_set_str(
|
66
66
|
GRPC_ERROR_CREATE_FROM_STATIC_STRING("unparseable host:port"),
|
@@ -74,7 +74,7 @@ static grpc_error* posix_blocking_resolve_address(
|
|
74
74
|
GRPC_ERROR_STR_TARGET_ADDRESS, grpc_slice_from_copied_string(name));
|
75
75
|
goto done;
|
76
76
|
}
|
77
|
-
port
|
77
|
+
port.reset(gpr_strdup(default_port));
|
78
78
|
}
|
79
79
|
|
80
80
|
/* Call getaddrinfo */
|
@@ -84,16 +84,16 @@ static grpc_error* posix_blocking_resolve_address(
|
|
84
84
|
hints.ai_flags = AI_PASSIVE; /* for wildcard IP address */
|
85
85
|
|
86
86
|
GRPC_SCHEDULING_START_BLOCKING_REGION;
|
87
|
-
s = getaddrinfo(host, port, &hints, &result);
|
87
|
+
s = getaddrinfo(host.get(), port.get(), &hints, &result);
|
88
88
|
GRPC_SCHEDULING_END_BLOCKING_REGION;
|
89
89
|
|
90
90
|
if (s != 0) {
|
91
91
|
/* Retry if well-known service name is recognized */
|
92
92
|
const char* svc[][2] = {{"http", "80"}, {"https", "443"}};
|
93
93
|
for (i = 0; i < GPR_ARRAY_SIZE(svc); i++) {
|
94
|
-
if (strcmp(port, svc[i][0]) == 0) {
|
94
|
+
if (strcmp(port.get(), svc[i][0]) == 0) {
|
95
95
|
GRPC_SCHEDULING_START_BLOCKING_REGION;
|
96
|
-
s = getaddrinfo(host, svc[i][1], &hints, &result);
|
96
|
+
s = getaddrinfo(host.get(), svc[i][1], &hints, &result);
|
97
97
|
GRPC_SCHEDULING_END_BLOCKING_REGION;
|
98
98
|
break;
|
99
99
|
}
|
@@ -133,8 +133,6 @@ static grpc_error* posix_blocking_resolve_address(
|
|
133
133
|
err = GRPC_ERROR_NONE;
|
134
134
|
|
135
135
|
done:
|
136
|
-
gpr_free(host);
|
137
|
-
gpr_free(port);
|
138
136
|
if (result) {
|
139
137
|
freeaddrinfo(result);
|
140
138
|
}
|
@@ -35,8 +35,8 @@
|
|
35
35
|
#include <grpc/support/string_util.h>
|
36
36
|
#include <grpc/support/time.h>
|
37
37
|
|
38
|
-
#include "src/core/lib/gpr/host_port.h"
|
39
38
|
#include "src/core/lib/gpr/string.h"
|
39
|
+
#include "src/core/lib/gprpp/host_port.h"
|
40
40
|
#include "src/core/lib/gprpp/thd.h"
|
41
41
|
#include "src/core/lib/iomgr/block_annotate.h"
|
42
42
|
#include "src/core/lib/iomgr/executor.h"
|
@@ -57,14 +57,14 @@ static grpc_error* windows_blocking_resolve_address(
|
|
57
57
|
grpc_core::ExecCtx exec_ctx;
|
58
58
|
struct addrinfo hints;
|
59
59
|
struct addrinfo *result = NULL, *resp;
|
60
|
-
char* host;
|
61
|
-
char* port;
|
62
60
|
int s;
|
63
61
|
size_t i;
|
64
62
|
grpc_error* error = GRPC_ERROR_NONE;
|
65
63
|
|
66
64
|
/* parse name, splitting it into host and port parts */
|
67
|
-
|
65
|
+
grpc_core::UniquePtr<char> host;
|
66
|
+
grpc_core::UniquePtr<char> port;
|
67
|
+
grpc_core::SplitHostPort(name, &host, &port);
|
68
68
|
if (host == NULL) {
|
69
69
|
char* msg;
|
70
70
|
gpr_asprintf(&msg, "unparseable host:port: '%s'", name);
|
@@ -80,7 +80,7 @@ static grpc_error* windows_blocking_resolve_address(
|
|
80
80
|
gpr_free(msg);
|
81
81
|
goto done;
|
82
82
|
}
|
83
|
-
port
|
83
|
+
port.reset(gpr_strdup(default_port));
|
84
84
|
}
|
85
85
|
|
86
86
|
/* Call getaddrinfo */
|
@@ -90,7 +90,7 @@ static grpc_error* windows_blocking_resolve_address(
|
|
90
90
|
hints.ai_flags = AI_PASSIVE; /* for wildcard IP address */
|
91
91
|
|
92
92
|
GRPC_SCHEDULING_START_BLOCKING_REGION;
|
93
|
-
s = getaddrinfo(host, port, &hints, &result);
|
93
|
+
s = getaddrinfo(host.get(), port.get(), &hints, &result);
|
94
94
|
GRPC_SCHEDULING_END_BLOCKING_REGION;
|
95
95
|
if (s != 0) {
|
96
96
|
error = GRPC_WSA_ERROR(WSAGetLastError(), "getaddrinfo");
|
@@ -122,8 +122,6 @@ static grpc_error* windows_blocking_resolve_address(
|
|
122
122
|
}
|
123
123
|
|
124
124
|
done:
|
125
|
-
gpr_free(host);
|
126
|
-
gpr_free(port);
|
127
125
|
if (result) {
|
128
126
|
freeaddrinfo(result);
|
129
127
|
}
|
@@ -28,8 +28,8 @@
|
|
28
28
|
#include <grpc/support/log.h>
|
29
29
|
#include <grpc/support/string_util.h>
|
30
30
|
|
31
|
-
#include "src/core/lib/gpr/host_port.h"
|
32
31
|
#include "src/core/lib/gpr/string.h"
|
32
|
+
#include "src/core/lib/gprpp/host_port.h"
|
33
33
|
#include "src/core/lib/iomgr/sockaddr.h"
|
34
34
|
#include "src/core/lib/iomgr/socket_utils.h"
|
35
35
|
#include "src/core/lib/iomgr/unix_sockets_posix.h"
|
@@ -181,15 +181,17 @@ int grpc_sockaddr_to_string(char** out,
|
|
181
181
|
}
|
182
182
|
if (ip != nullptr && grpc_inet_ntop(addr->sa_family, ip, ntop_buf,
|
183
183
|
sizeof(ntop_buf)) != nullptr) {
|
184
|
+
grpc_core::UniquePtr<char> tmp_out;
|
184
185
|
if (sin6_scope_id != 0) {
|
185
186
|
char* host_with_scope;
|
186
187
|
/* Enclose sin6_scope_id with the format defined in RFC 6784 section 2. */
|
187
188
|
gpr_asprintf(&host_with_scope, "%s%%25%" PRIu32, ntop_buf, sin6_scope_id);
|
188
|
-
ret =
|
189
|
+
ret = grpc_core::JoinHostPort(&tmp_out, host_with_scope, port);
|
189
190
|
gpr_free(host_with_scope);
|
190
191
|
} else {
|
191
|
-
ret =
|
192
|
+
ret = grpc_core::JoinHostPort(&tmp_out, ntop_buf, port);
|
192
193
|
}
|
194
|
+
*out = tmp_out.release();
|
193
195
|
} else {
|
194
196
|
ret = gpr_asprintf(out, "(sockaddr family=%d)", addr->sa_family);
|
195
197
|
}
|
@@ -46,7 +46,6 @@
|
|
46
46
|
#include <grpc/support/sync.h>
|
47
47
|
|
48
48
|
#include "src/core/lib/channel/channel_args.h"
|
49
|
-
#include "src/core/lib/gpr/host_port.h"
|
50
49
|
#include "src/core/lib/gpr/string.h"
|
51
50
|
#include "src/core/lib/iomgr/sockaddr.h"
|
52
51
|
#include "src/core/lib/iomgr/sockaddr_utils.h"
|
@@ -59,7 +59,7 @@ typedef struct grpc_winsocket_callback_info {
|
|
59
59
|
to hold a mutex for a long amount of time. */
|
60
60
|
int has_pending_iocp;
|
61
61
|
/* The results of the overlapped operation. */
|
62
|
-
DWORD
|
62
|
+
DWORD bytes_transferred;
|
63
63
|
int wsa_error;
|
64
64
|
} grpc_winsocket_callback_info;
|
65
65
|
|
@@ -34,7 +34,7 @@
|
|
34
34
|
#include <netinet/in.h>
|
35
35
|
|
36
36
|
#include "src/core/lib/channel/channel_args.h"
|
37
|
-
#include "src/core/lib/
|
37
|
+
#include "src/core/lib/gprpp/host_port.h"
|
38
38
|
#include "src/core/lib/iomgr/cfstream_handle.h"
|
39
39
|
#include "src/core/lib/iomgr/closure.h"
|
40
40
|
#include "src/core/lib/iomgr/endpoint_cfstream.h"
|
@@ -143,12 +143,13 @@ static void OnOpen(void* arg, grpc_error* error) {
|
|
143
143
|
|
144
144
|
static void ParseResolvedAddress(const grpc_resolved_address* addr,
|
145
145
|
CFStringRef* host, int* port) {
|
146
|
-
char
|
146
|
+
char* host_port;
|
147
147
|
grpc_sockaddr_to_string(&host_port, addr, 1);
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
148
|
+
grpc_core::UniquePtr<char> host_string;
|
149
|
+
grpc_core::UniquePtr<char> port_string;
|
150
|
+
grpc_core::SplitHostPort(host_port, &host_string, &port_string);
|
151
|
+
*host =
|
152
|
+
CFStringCreateWithCString(NULL, host_string.get(), kCFStringEncodingUTF8);
|
152
153
|
gpr_free(host_port);
|
153
154
|
*port = grpc_sockaddr_get_port(addr);
|
154
155
|
}
|
@@ -101,6 +101,7 @@ static void custom_connect_callback_internal(grpc_custom_socket* socket,
|
|
101
101
|
|
102
102
|
static void custom_connect_callback(grpc_custom_socket* socket,
|
103
103
|
grpc_error* error) {
|
104
|
+
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
|
104
105
|
if (grpc_core::ExecCtx::Get() == nullptr) {
|
105
106
|
/* If we are being run on a thread which does not have an exec_ctx created
|
106
107
|
* yet, we should create one. */
|
@@ -145,6 +145,7 @@ static void call_read_cb(custom_tcp_endpoint* tcp, grpc_error* error) {
|
|
145
145
|
|
146
146
|
static void custom_read_callback(grpc_custom_socket* socket, size_t nread,
|
147
147
|
grpc_error* error) {
|
148
|
+
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
|
148
149
|
grpc_core::ExecCtx exec_ctx;
|
149
150
|
grpc_slice_buffer garbage;
|
150
151
|
custom_tcp_endpoint* tcp = (custom_tcp_endpoint*)socket->endpoint;
|
@@ -207,6 +208,7 @@ static void endpoint_read(grpc_endpoint* ep, grpc_slice_buffer* read_slices,
|
|
207
208
|
|
208
209
|
static void custom_write_callback(grpc_custom_socket* socket,
|
209
210
|
grpc_error* error) {
|
211
|
+
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
|
210
212
|
grpc_core::ExecCtx exec_ctx;
|
211
213
|
custom_tcp_endpoint* tcp = (custom_tcp_endpoint*)socket->endpoint;
|
212
214
|
grpc_closure* cb = tcp->write_cb;
|
@@ -301,6 +303,7 @@ static void custom_close_callback(grpc_custom_socket* socket) {
|
|
301
303
|
grpc_custom_socket_vtable->destroy(socket);
|
302
304
|
gpr_free(socket);
|
303
305
|
} else if (socket->endpoint) {
|
306
|
+
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
|
304
307
|
grpc_core::ExecCtx exec_ctx;
|
305
308
|
custom_tcp_endpoint* tcp = (custom_tcp_endpoint*)socket->endpoint;
|
306
309
|
TCP_UNREF(tcp, "destroy");
|
@@ -343,6 +346,7 @@ grpc_endpoint* custom_tcp_endpoint_create(grpc_custom_socket* socket,
|
|
343
346
|
char* peer_string) {
|
344
347
|
custom_tcp_endpoint* tcp =
|
345
348
|
(custom_tcp_endpoint*)gpr_malloc(sizeof(custom_tcp_endpoint));
|
349
|
+
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
|
346
350
|
grpc_core::ExecCtx exec_ctx;
|
347
351
|
|
348
352
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) {
|
@@ -435,12 +435,17 @@ static void tcp_do_read(grpc_tcp* tcp) {
|
|
435
435
|
GPR_TIMER_SCOPE("tcp_do_read", 0);
|
436
436
|
struct msghdr msg;
|
437
437
|
struct iovec iov[MAX_READ_IOVEC];
|
438
|
-
char cmsgbuf[24 /*CMSG_SPACE(sizeof(int))*/];
|
439
438
|
ssize_t read_bytes;
|
440
439
|
size_t total_read_bytes = 0;
|
441
|
-
|
442
440
|
size_t iov_len =
|
443
441
|
std::min<size_t>(MAX_READ_IOVEC, tcp->incoming_buffer->count);
|
442
|
+
#ifdef GRPC_LINUX_ERRQUEUE
|
443
|
+
constexpr size_t cmsg_alloc_space =
|
444
|
+
CMSG_SPACE(sizeof(grpc_core::scm_timestamping)) + CMSG_SPACE(sizeof(int));
|
445
|
+
#else
|
446
|
+
constexpr size_t cmsg_alloc_space = 24 /* CMSG_SPACE(sizeof(int)) */;
|
447
|
+
#endif /* GRPC_LINUX_ERRQUEUE */
|
448
|
+
char cmsgbuf[cmsg_alloc_space];
|
444
449
|
for (size_t i = 0; i < iov_len; i++) {
|
445
450
|
iov[i].iov_base = GRPC_SLICE_START_PTR(tcp->incoming_buffer->slices[i]);
|
446
451
|
iov[i].iov_len = GRPC_SLICE_LENGTH(tcp->incoming_buffer->slices[i]);
|
@@ -524,6 +529,7 @@ static void tcp_do_read(grpc_tcp* tcp) {
|
|
524
529
|
if (cmsg->cmsg_level == SOL_TCP && cmsg->cmsg_type == TCP_CM_INQ &&
|
525
530
|
cmsg->cmsg_len == CMSG_LEN(sizeof(int))) {
|
526
531
|
tcp->inq = *reinterpret_cast<int*>(CMSG_DATA(cmsg));
|
532
|
+
break;
|
527
533
|
}
|
528
534
|
}
|
529
535
|
}
|