grpc 0.14.1 → 0.15.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 +1398 -817
- data/include/grpc/compression.h +2 -1
- data/include/grpc/grpc.h +10 -1
- data/include/grpc/grpc_cronet.h +51 -0
- data/include/grpc/grpc_posix.h +70 -0
- data/include/grpc/impl/codegen/atm.h +2 -2
- data/include/grpc/impl/codegen/{atm_win32.h → atm_windows.h} +3 -3
- data/include/grpc/impl/codegen/compression_types.h +39 -5
- data/include/grpc/impl/codegen/connectivity_state.h +1 -1
- data/include/grpc/impl/codegen/grpc_types.h +10 -0
- data/include/grpc/impl/codegen/log.h +2 -1
- data/include/grpc/impl/codegen/port_platform.h +30 -12
- data/include/grpc/impl/codegen/slice_buffer.h +2 -3
- data/include/grpc/impl/codegen/sync.h +2 -2
- data/include/grpc/impl/codegen/{sync_win32.h → sync_windows.h} +3 -3
- data/include/grpc/support/{sync_win32.h → atm_windows.h} +4 -4
- data/include/grpc/support/avl.h +5 -0
- data/include/grpc/support/{log_win32.h → log_windows.h} +3 -3
- data/include/grpc/support/string_util.h +2 -1
- data/include/grpc/support/{atm_win32.h → sync_windows.h} +4 -4
- data/src/core/ext/census/gen/census.pb.c +179 -0
- data/src/core/ext/census/gen/census.pb.h +294 -0
- data/src/core/ext/census/grpc_filter.c +11 -7
- data/src/core/ext/client_config/channel_connectivity.c +28 -14
- data/src/core/ext/client_config/client_channel.c +77 -53
- data/src/core/ext/client_config/connector.h +1 -1
- data/src/core/ext/client_config/lb_policy.c +9 -6
- data/src/core/ext/client_config/lb_policy.h +9 -5
- data/src/core/ext/client_config/subchannel.c +58 -39
- data/src/core/ext/client_config/subchannel.h +3 -2
- data/src/core/ext/client_config/subchannel_call_holder.c +34 -19
- data/src/core/ext/client_config/subchannel_call_holder.h +2 -1
- data/src/core/ext/client_config/subchannel_index.c +20 -9
- data/src/core/ext/lb_policy/grpclb/load_balancer_api.c +7 -7
- data/src/core/ext/lb_policy/grpclb/load_balancer_api.h +5 -5
- data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/{v0 → v1}/load_balancer.pb.c +29 -30
- data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +178 -0
- data/src/core/ext/lb_policy/pick_first/pick_first.c +65 -45
- data/src/core/ext/lb_policy/round_robin/round_robin.c +84 -43
- data/src/core/ext/load_reporting/load_reporting.c +133 -0
- data/src/core/ext/load_reporting/load_reporting.h +75 -0
- data/src/core/ext/load_reporting/load_reporting_filter.c +151 -0
- data/src/core/ext/load_reporting/load_reporting_filter.h +41 -0
- data/src/core/ext/resolver/dns/native/dns_resolver.c +22 -8
- data/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +2 -2
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +4 -4
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c +95 -0
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +14 -18
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +49 -24
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c +82 -0
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +104 -60
- data/src/core/ext/transport/chttp2/transport/bin_decoder.c +232 -0
- data/src/{ruby/ext/grpc/rb_signal.c → core/ext/transport/chttp2/transport/bin_decoder.h} +27 -31
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +481 -260
- data/src/core/ext/transport/chttp2/transport/frame.h +1 -7
- data/src/core/ext/transport/chttp2/transport/frame_data.c +44 -27
- data/src/core/ext/transport/chttp2/transport/frame_data.h +6 -5
- data/src/core/ext/transport/chttp2/transport/frame_goaway.c +23 -17
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_ping.c +12 -7
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +3 -3
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +25 -12
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_settings.c +23 -21
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_window_update.c +17 -9
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +2 -2
- data/src/core/ext/transport/chttp2/transport/hpack_parser.c +365 -287
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +8 -6
- data/src/core/ext/transport/chttp2/transport/hpack_table.c +24 -20
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +5 -4
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +1 -0
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +1 -0
- data/src/core/ext/transport/chttp2/transport/internal.h +34 -32
- data/src/core/ext/transport/chttp2/transport/parsing.c +296 -212
- data/src/core/ext/transport/chttp2/transport/writing.c +12 -9
- data/src/core/lib/channel/channel_args.c +26 -12
- data/src/core/lib/channel/channel_args.h +1 -1
- data/src/core/lib/channel/channel_stack.c +12 -8
- data/src/core/lib/channel/channel_stack.h +27 -11
- data/src/core/lib/channel/channel_stack_builder.c +2 -2
- data/src/core/lib/channel/compress_filter.c +26 -31
- data/src/core/lib/channel/compress_filter.h +4 -4
- data/src/core/lib/channel/connected_channel.c +7 -5
- data/src/core/lib/channel/http_client_filter.c +34 -8
- data/src/core/lib/channel/http_client_filter.h +1 -1
- data/src/core/lib/channel/http_server_filter.c +21 -12
- data/src/core/lib/compression/{compression_algorithm.c → compression.c} +22 -21
- data/src/core/lib/http/httpcli.c +81 -59
- data/src/core/lib/http/httpcli.h +11 -15
- data/src/core/lib/http/httpcli_security_connector.c +5 -3
- data/src/core/lib/http/parser.c +127 -118
- data/src/core/lib/http/parser.h +11 -6
- data/src/core/lib/iomgr/closure.c +20 -16
- data/src/core/lib/iomgr/closure.h +19 -15
- data/src/core/lib/iomgr/endpoint.h +1 -1
- data/src/core/lib/iomgr/endpoint_pair_posix.c +2 -2
- data/src/core/lib/iomgr/error.c +535 -0
- data/src/core/lib/iomgr/error.h +192 -0
- data/src/core/lib/iomgr/ev_poll_and_epoll_posix.c +190 -83
- data/src/core/lib/iomgr/ev_poll_posix.c +1267 -0
- data/src/{ruby/ext/grpc/rb_signal.h → core/lib/iomgr/ev_poll_posix.h} +7 -5
- data/src/core/lib/iomgr/ev_posix.c +104 -14
- data/src/core/lib/iomgr/ev_posix.h +17 -7
- data/src/core/lib/iomgr/exec_ctx.c +25 -7
- data/src/core/lib/iomgr/exec_ctx.h +27 -8
- data/src/core/lib/iomgr/executor.c +2 -2
- data/src/core/lib/iomgr/executor.h +1 -1
- data/src/core/lib/iomgr/iocp_windows.c +2 -41
- data/src/core/lib/iomgr/iocp_windows.h +0 -8
- data/src/core/lib/iomgr/iomgr.c +5 -4
- data/src/core/lib/iomgr/iomgr_posix.c +5 -1
- data/src/core/lib/iomgr/iomgr_windows.c +1 -1
- data/src/core/lib/{support → iomgr}/load_file.c +15 -17
- data/src/core/lib/{support → iomgr}/load_file.h +8 -7
- data/src/core/lib/iomgr/polling_entity.c +104 -0
- data/src/core/lib/iomgr/polling_entity.h +81 -0
- data/src/core/lib/iomgr/pollset.h +6 -5
- data/src/core/lib/iomgr/pollset_set_windows.c +4 -1
- data/src/core/lib/iomgr/pollset_windows.c +10 -6
- data/src/core/lib/iomgr/resolve_address.h +5 -9
- data/src/core/lib/iomgr/resolve_address_posix.c +55 -38
- data/src/core/lib/iomgr/resolve_address_windows.c +51 -37
- data/src/core/lib/iomgr/sockaddr.h +2 -2
- data/src/core/lib/iomgr/{sockaddr_win32.h → sockaddr_windows.h} +3 -3
- data/src/core/lib/iomgr/socket_utils_common_posix.c +92 -45
- data/src/core/lib/iomgr/socket_utils_posix.h +19 -12
- data/src/core/lib/iomgr/socket_windows.c +61 -2
- data/src/core/lib/iomgr/socket_windows.h +13 -0
- data/src/core/lib/iomgr/tcp_client_posix.c +54 -39
- data/src/core/lib/iomgr/tcp_client_windows.c +34 -34
- data/src/core/lib/iomgr/tcp_posix.c +43 -39
- data/src/core/lib/iomgr/tcp_server.h +5 -3
- data/src/core/lib/iomgr/tcp_server_posix.c +103 -64
- data/src/core/lib/iomgr/tcp_server_windows.c +114 -101
- data/src/core/lib/iomgr/tcp_windows.c +45 -50
- data/src/core/lib/iomgr/tcp_windows.h +1 -1
- data/src/core/lib/iomgr/timer.c +26 -13
- data/src/core/lib/iomgr/udp_server.c +28 -4
- data/src/core/lib/iomgr/udp_server.h +5 -1
- data/src/core/lib/iomgr/unix_sockets_posix.c +8 -7
- data/src/core/lib/iomgr/unix_sockets_posix.h +2 -1
- data/src/core/lib/iomgr/unix_sockets_posix_noop.c +4 -2
- data/src/core/lib/iomgr/wakeup_fd_eventfd.c +15 -5
- data/src/core/lib/iomgr/wakeup_fd_pipe.c +13 -9
- data/src/core/lib/iomgr/wakeup_fd_posix.c +6 -6
- data/src/core/lib/iomgr/wakeup_fd_posix.h +9 -6
- data/src/core/lib/iomgr/workqueue.h +5 -4
- data/src/core/lib/iomgr/workqueue_posix.c +40 -26
- data/src/core/lib/iomgr/workqueue_windows.c +2 -2
- data/src/core/lib/profiling/basic_timers.c +2 -2
- data/src/core/lib/security/{security_context.c → context/security_context.c} +1 -1
- data/src/core/lib/security/{security_context.h → context/security_context.h} +4 -4
- data/src/core/lib/security/credentials/composite/composite_credentials.c +263 -0
- data/src/core/lib/security/credentials/composite/composite_credentials.h +72 -0
- data/src/core/lib/security/credentials/credentials.c +233 -0
- data/src/core/lib/security/{credentials.h → credentials/credentials.h} +19 -157
- data/src/core/lib/security/{credentials_metadata.c → credentials/credentials_metadata.c} +1 -1
- data/src/core/lib/security/credentials/fake/fake_credentials.c +139 -0
- data/src/core/lib/security/credentials/fake/fake_credentials.h +56 -0
- data/src/core/lib/security/{credentials_posix.c → credentials/google_default/credentials_posix.c} +1 -1
- data/src/core/lib/security/{credentials_win32.c → credentials/google_default/credentials_windows.c} +3 -3
- data/src/core/lib/security/{google_default_credentials.c → credentials/google_default/google_default_credentials.c} +93 -35
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +46 -0
- data/src/core/lib/security/credentials/iam/iam_credentials.c +85 -0
- data/src/core/lib/security/credentials/iam/iam_credentials.h +44 -0
- data/src/core/lib/security/{json_token.c → credentials/jwt/json_token.c} +10 -101
- data/src/core/lib/security/{json_token.h → credentials/jwt/json_token.h} +3 -33
- data/src/core/lib/security/credentials/jwt/jwt_credentials.c +160 -0
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +62 -0
- data/src/core/lib/security/{jwt_verifier.c → credentials/jwt/jwt_verifier.c} +35 -15
- data/src/core/lib/security/{jwt_verifier.h → credentials/jwt/jwt_verifier.h} +3 -3
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +433 -0
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +109 -0
- data/src/core/lib/security/credentials/plugin/plugin_credentials.c +129 -0
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +45 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.c +240 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +48 -0
- data/src/core/lib/security/{auth_filters.h → transport/auth_filters.h} +3 -3
- data/src/core/lib/security/{client_auth_filter.c → transport/client_auth_filter.c} +27 -20
- data/src/core/lib/security/{handshake.c → transport/handshake.c} +77 -45
- data/src/core/lib/security/{handshake.h → transport/handshake.h} +9 -11
- data/src/core/lib/security/{secure_endpoint.c → transport/secure_endpoint.c} +19 -12
- data/src/core/lib/security/{secure_endpoint.h → transport/secure_endpoint.h} +3 -3
- data/src/core/lib/security/{security_connector.c → transport/security_connector.c} +26 -17
- data/src/core/lib/security/{security_connector.h → transport/security_connector.h} +8 -8
- data/src/core/lib/security/{server_auth_filter.c → transport/server_auth_filter.c} +24 -16
- data/src/core/lib/security/transport/tsi_error.c +40 -0
- data/src/core/lib/security/transport/tsi_error.h +42 -0
- data/src/core/lib/security/{b64.c → util/b64.c} +1 -1
- data/src/core/lib/security/{b64.h → util/b64.h} +3 -3
- data/src/core/lib/security/util/json_util.c +61 -0
- data/src/core/lib/security/util/json_util.h +55 -0
- data/src/core/lib/support/avl.c +11 -0
- data/src/core/lib/support/cpu_windows.c +2 -2
- data/src/core/lib/support/{env_win32.c → env_windows.c} +3 -3
- data/src/core/lib/support/log.c +3 -1
- data/src/core/lib/support/log_linux.c +2 -2
- data/src/core/lib/support/{log_win32.c → log_windows.c} +4 -4
- data/src/core/lib/support/murmur_hash.c +3 -5
- data/src/core/lib/support/string.c +10 -0
- data/src/core/lib/support/string.h +4 -0
- data/src/core/lib/support/{string_util_win32.c → string_util_windows.c} +3 -3
- data/src/core/lib/support/{string_win32.c → string_windows.c} +2 -2
- data/src/core/lib/support/{string_win32.h → string_windows.h} +5 -5
- data/src/core/lib/support/subprocess_windows.c +1 -1
- data/src/core/lib/support/{sync_win32.c → sync_windows.c} +2 -2
- data/src/core/lib/support/{thd_win32.c → thd_windows.c} +2 -2
- data/src/core/lib/support/{time_win32.c → time_windows.c} +2 -2
- data/src/core/lib/support/tmpfile_msys.c +1 -1
- data/src/core/lib/support/{tmpfile_win32.c → tmpfile_windows.c} +3 -3
- data/src/core/lib/surface/alarm.c +2 -2
- data/src/core/lib/surface/byte_buffer_reader.c +13 -6
- data/src/core/lib/surface/call.c +323 -123
- data/src/core/lib/surface/call.h +2 -0
- data/src/core/lib/surface/call_log_batch.c +1 -1
- data/src/core/lib/surface/channel.c +64 -15
- data/src/core/lib/surface/channel.h +9 -0
- data/src/core/lib/surface/channel_ping.c +3 -3
- data/src/core/lib/surface/completion_queue.c +75 -19
- data/src/core/lib/surface/completion_queue.h +7 -2
- data/src/core/lib/surface/init.c +2 -1
- data/src/core/lib/surface/init_secure.c +4 -4
- data/src/core/lib/surface/lame_client.c +12 -8
- data/src/core/lib/surface/server.c +213 -120
- data/src/core/lib/surface/server.h +1 -0
- data/src/core/lib/surface/version.c +1 -1
- data/src/core/lib/transport/connectivity_state.c +40 -18
- data/src/core/lib/transport/connectivity_state.h +4 -1
- data/src/core/lib/transport/metadata.c +23 -23
- data/src/core/lib/transport/metadata.h +4 -0
- data/src/core/lib/transport/metadata_batch.c +9 -0
- data/src/core/lib/transport/metadata_batch.h +3 -0
- data/src/core/lib/transport/static_metadata.c +6 -5
- data/src/core/lib/transport/static_metadata.h +64 -60
- data/src/core/lib/transport/transport.c +24 -12
- data/src/core/lib/transport/transport.h +6 -5
- data/src/core/lib/transport/transport_impl.h +4 -0
- data/src/core/lib/transport/transport_op_string.c +2 -2
- data/src/core/plugin_registry/grpc_plugin_registry.c +4 -0
- data/src/ruby/bin/math_services.rb +41 -2
- data/src/ruby/ext/grpc/rb_call.c +42 -40
- data/src/ruby/ext/grpc/rb_channel.c +1 -1
- data/src/ruby/ext/grpc/rb_completion_queue.c +59 -6
- data/src/ruby/ext/grpc/rb_completion_queue.h +1 -1
- data/src/ruby/ext/grpc/rb_grpc.c +1 -3
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +12 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +21 -5
- data/src/ruby/ext/grpc/rb_loader.c +1 -1
- data/src/ruby/ext/grpc/rb_server.c +5 -3
- data/src/ruby/lib/grpc.rb +0 -3
- data/src/ruby/lib/grpc/errors.rb +3 -2
- data/src/ruby/lib/grpc/generic/active_call.rb +32 -42
- data/src/ruby/lib/grpc/generic/bidi_call.rb +20 -0
- data/src/ruby/lib/grpc/generic/client_stub.rb +31 -54
- data/src/ruby/lib/grpc/generic/rpc_desc.rb +4 -4
- data/src/ruby/lib/grpc/generic/rpc_server.rb +12 -23
- data/src/ruby/lib/grpc/generic/service.rb +8 -8
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/v1/health_services.rb +30 -2
- data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services.rb +34 -4
- data/src/ruby/pb/grpc/testing/metrics_services.rb +39 -2
- data/src/ruby/pb/src/proto/grpc/testing/empty.rb +15 -0
- data/src/ruby/pb/src/proto/grpc/testing/messages.rb +84 -0
- data/src/ruby/pb/src/proto/grpc/testing/test.rb +14 -0
- data/src/ruby/pb/src/proto/grpc/testing/test_services.rb +110 -0
- data/src/ruby/pb/test/client.rb +5 -2
- data/src/ruby/spec/generic/active_call_spec.rb +3 -2
- data/src/ruby/spec/generic/client_stub_spec.rb +27 -24
- data/src/ruby/spec/generic/rpc_desc_spec.rb +11 -11
- data/src/ruby/spec/generic/rpc_server_spec.rb +42 -61
- data/src/ruby/spec/pb/health/checker_spec.rb +3 -5
- metadata +86 -48
- data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h +0 -182
- data/src/core/lib/security/credentials.c +0 -1296
- data/src/ruby/lib/grpc/signals.rb +0 -69
@@ -50,24 +50,20 @@ typedef struct {
|
|
50
50
|
grpc_resolved_address *addrs;
|
51
51
|
} grpc_resolved_addresses;
|
52
52
|
|
53
|
-
/* Async result callback:
|
54
|
-
On success: addresses is the result, and the callee must call
|
55
|
-
grpc_resolved_addresses_destroy when it's done with them
|
56
|
-
On failure: addresses is NULL */
|
57
|
-
typedef void (*grpc_resolve_cb)(grpc_exec_ctx *exec_ctx, void *arg,
|
58
|
-
grpc_resolved_addresses *addresses);
|
59
53
|
/* Asynchronously resolve addr. Use default_port if a port isn't designated
|
60
54
|
in addr, otherwise use the port in addr. */
|
61
55
|
/* TODO(ctiller): add a timeout here */
|
62
56
|
extern void (*grpc_resolve_address)(grpc_exec_ctx *exec_ctx, const char *addr,
|
63
57
|
const char *default_port,
|
64
|
-
|
58
|
+
grpc_closure *on_done,
|
59
|
+
grpc_resolved_addresses **addresses);
|
65
60
|
/* Destroy resolved addresses */
|
66
61
|
void grpc_resolved_addresses_destroy(grpc_resolved_addresses *addresses);
|
67
62
|
|
68
63
|
/* Resolve addr in a blocking fashion. Returns NULL on failure. On success,
|
69
64
|
result must be freed with grpc_resolved_addresses_destroy. */
|
70
|
-
extern
|
71
|
-
const char *name, const char *default_port
|
65
|
+
extern grpc_error *(*grpc_blocking_resolve_address)(
|
66
|
+
const char *name, const char *default_port,
|
67
|
+
grpc_resolved_addresses **addresses);
|
72
68
|
|
73
69
|
#endif /* GRPC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_H */
|
@@ -54,38 +54,33 @@
|
|
54
54
|
#include "src/core/lib/support/block_annotate.h"
|
55
55
|
#include "src/core/lib/support/string.h"
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
grpc_resolve_cb cb;
|
61
|
-
grpc_closure request_closure;
|
62
|
-
void *arg;
|
63
|
-
} request;
|
64
|
-
|
65
|
-
static grpc_resolved_addresses *blocking_resolve_address_impl(
|
66
|
-
const char *name, const char *default_port) {
|
57
|
+
static grpc_error *blocking_resolve_address_impl(
|
58
|
+
const char *name, const char *default_port,
|
59
|
+
grpc_resolved_addresses **addresses) {
|
67
60
|
struct addrinfo hints;
|
68
61
|
struct addrinfo *result = NULL, *resp;
|
69
62
|
char *host;
|
70
63
|
char *port;
|
71
64
|
int s;
|
72
65
|
size_t i;
|
73
|
-
|
66
|
+
grpc_error *err;
|
74
67
|
|
75
68
|
if (name[0] == 'u' && name[1] == 'n' && name[2] == 'i' && name[3] == 'x' &&
|
76
69
|
name[4] == ':' && name[5] != 0) {
|
77
|
-
return grpc_resolve_unix_domain_address(name + 5);
|
70
|
+
return grpc_resolve_unix_domain_address(name + 5, addresses);
|
78
71
|
}
|
79
72
|
|
80
73
|
/* parse name, splitting it into host and port parts */
|
81
74
|
gpr_split_host_port(name, &host, &port);
|
82
75
|
if (host == NULL) {
|
83
|
-
|
76
|
+
err = grpc_error_set_str(GRPC_ERROR_CREATE("unparseable host:port"),
|
77
|
+
GRPC_ERROR_STR_TARGET_ADDRESS, name);
|
84
78
|
goto done;
|
85
79
|
}
|
86
80
|
if (port == NULL) {
|
87
81
|
if (default_port == NULL) {
|
88
|
-
|
82
|
+
err = grpc_error_set_str(GRPC_ERROR_CREATE("no port in name"),
|
83
|
+
GRPC_ERROR_STR_TARGET_ADDRESS, name);
|
89
84
|
goto done;
|
90
85
|
}
|
91
86
|
port = gpr_strdup(default_port);
|
@@ -115,23 +110,31 @@ static grpc_resolved_addresses *blocking_resolve_address_impl(
|
|
115
110
|
}
|
116
111
|
|
117
112
|
if (s != 0) {
|
118
|
-
|
113
|
+
err = grpc_error_set_str(
|
114
|
+
grpc_error_set_str(
|
115
|
+
grpc_error_set_str(grpc_error_set_int(GRPC_ERROR_CREATE("OS Error"),
|
116
|
+
GRPC_ERROR_INT_ERRNO, s),
|
117
|
+
GRPC_ERROR_STR_OS_ERROR, gai_strerror(s)),
|
118
|
+
GRPC_ERROR_STR_SYSCALL, "getaddrinfo"),
|
119
|
+
GRPC_ERROR_STR_TARGET_ADDRESS, name);
|
119
120
|
goto done;
|
120
121
|
}
|
121
122
|
|
122
123
|
/* Success path: set addrs non-NULL, fill it in */
|
123
|
-
|
124
|
-
|
124
|
+
*addresses = gpr_malloc(sizeof(grpc_resolved_addresses));
|
125
|
+
(*addresses)->naddrs = 0;
|
125
126
|
for (resp = result; resp != NULL; resp = resp->ai_next) {
|
126
|
-
|
127
|
+
(*addresses)->naddrs++;
|
127
128
|
}
|
128
|
-
|
129
|
+
(*addresses)->addrs =
|
130
|
+
gpr_malloc(sizeof(grpc_resolved_address) * (*addresses)->naddrs);
|
129
131
|
i = 0;
|
130
132
|
for (resp = result; resp != NULL; resp = resp->ai_next) {
|
131
|
-
memcpy(&
|
132
|
-
|
133
|
+
memcpy(&(*addresses)->addrs[i].addr, resp->ai_addr, resp->ai_addrlen);
|
134
|
+
(*addresses)->addrs[i].len = resp->ai_addrlen;
|
133
135
|
i++;
|
134
136
|
}
|
137
|
+
err = GRPC_ERROR_NONE;
|
135
138
|
|
136
139
|
done:
|
137
140
|
gpr_free(host);
|
@@ -139,45 +142,59 @@ done:
|
|
139
142
|
if (result) {
|
140
143
|
freeaddrinfo(result);
|
141
144
|
}
|
142
|
-
return
|
145
|
+
return err;
|
143
146
|
}
|
144
147
|
|
145
|
-
|
146
|
-
const char *name, const char *default_port
|
148
|
+
grpc_error *(*grpc_blocking_resolve_address)(
|
149
|
+
const char *name, const char *default_port,
|
150
|
+
grpc_resolved_addresses **addresses) = blocking_resolve_address_impl;
|
151
|
+
|
152
|
+
typedef struct {
|
153
|
+
char *name;
|
154
|
+
char *default_port;
|
155
|
+
grpc_closure *on_done;
|
156
|
+
grpc_resolved_addresses **addrs_out;
|
157
|
+
grpc_closure request_closure;
|
158
|
+
void *arg;
|
159
|
+
} request;
|
147
160
|
|
148
161
|
/* Callback to be passed to grpc_executor to asynch-ify
|
149
162
|
* grpc_blocking_resolve_address */
|
150
|
-
static void do_request_thread(grpc_exec_ctx *exec_ctx, void *rp,
|
163
|
+
static void do_request_thread(grpc_exec_ctx *exec_ctx, void *rp,
|
164
|
+
grpc_error *error) {
|
151
165
|
request *r = rp;
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
166
|
+
grpc_exec_ctx_sched(
|
167
|
+
exec_ctx, r->on_done,
|
168
|
+
grpc_blocking_resolve_address(r->name, r->default_port, r->addrs_out),
|
169
|
+
NULL);
|
156
170
|
gpr_free(r->name);
|
157
171
|
gpr_free(r->default_port);
|
158
|
-
cb(exec_ctx, arg, resolved);
|
159
172
|
gpr_free(r);
|
160
173
|
}
|
161
174
|
|
162
175
|
void grpc_resolved_addresses_destroy(grpc_resolved_addresses *addrs) {
|
163
|
-
|
176
|
+
if (addrs != NULL) {
|
177
|
+
gpr_free(addrs->addrs);
|
178
|
+
}
|
164
179
|
gpr_free(addrs);
|
165
180
|
}
|
166
181
|
|
167
182
|
static void resolve_address_impl(grpc_exec_ctx *exec_ctx, const char *name,
|
168
|
-
const char *default_port,
|
169
|
-
|
183
|
+
const char *default_port,
|
184
|
+
grpc_closure *on_done,
|
185
|
+
grpc_resolved_addresses **addrs) {
|
170
186
|
request *r = gpr_malloc(sizeof(request));
|
171
187
|
grpc_closure_init(&r->request_closure, do_request_thread, r);
|
172
188
|
r->name = gpr_strdup(name);
|
173
189
|
r->default_port = gpr_strdup(default_port);
|
174
|
-
r->
|
175
|
-
r->
|
176
|
-
|
190
|
+
r->on_done = on_done;
|
191
|
+
r->addrs_out = addrs;
|
192
|
+
grpc_executor_push(&r->request_closure, GRPC_ERROR_NONE);
|
177
193
|
}
|
178
194
|
|
179
195
|
void (*grpc_resolve_address)(grpc_exec_ctx *exec_ctx, const char *name,
|
180
|
-
const char *default_port,
|
181
|
-
|
196
|
+
const char *default_port, grpc_closure *on_done,
|
197
|
+
grpc_resolved_addresses **addrs) =
|
198
|
+
resolve_address_impl;
|
182
199
|
|
183
200
|
#endif
|
@@ -43,7 +43,7 @@
|
|
43
43
|
#include <grpc/support/alloc.h>
|
44
44
|
#include <grpc/support/host_port.h>
|
45
45
|
#include <grpc/support/log.h>
|
46
|
-
#include <grpc/support/
|
46
|
+
#include <grpc/support/log_windows.h>
|
47
47
|
#include <grpc/support/string_util.h>
|
48
48
|
#include <grpc/support/thd.h>
|
49
49
|
#include <grpc/support/time.h>
|
@@ -56,30 +56,37 @@
|
|
56
56
|
typedef struct {
|
57
57
|
char *name;
|
58
58
|
char *default_port;
|
59
|
-
grpc_resolve_cb cb;
|
60
59
|
grpc_closure request_closure;
|
61
|
-
|
60
|
+
grpc_closure *on_done;
|
61
|
+
grpc_resolved_addresses **addresses;
|
62
62
|
} request;
|
63
63
|
|
64
|
-
static
|
65
|
-
const char *name, const char *default_port
|
64
|
+
static grpc_error *blocking_resolve_address_impl(
|
65
|
+
const char *name, const char *default_port,
|
66
|
+
grpc_resolved_addresses **addresses) {
|
66
67
|
struct addrinfo hints;
|
67
68
|
struct addrinfo *result = NULL, *resp;
|
68
69
|
char *host;
|
69
70
|
char *port;
|
70
71
|
int s;
|
71
72
|
size_t i;
|
72
|
-
|
73
|
+
grpc_error *error = GRPC_ERROR_NONE;
|
73
74
|
|
74
75
|
/* parse name, splitting it into host and port parts */
|
75
76
|
gpr_split_host_port(name, &host, &port);
|
76
77
|
if (host == NULL) {
|
77
|
-
|
78
|
+
char *msg;
|
79
|
+
gpr_asprintf(&msg, "unparseable host:port: '%s'", name);
|
80
|
+
error = GRPC_ERROR_CREATE(msg);
|
81
|
+
gpr_free(msg);
|
78
82
|
goto done;
|
79
83
|
}
|
80
84
|
if (port == NULL) {
|
81
85
|
if (default_port == NULL) {
|
82
|
-
|
86
|
+
char *msg;
|
87
|
+
gpr_asprintf(&msg, "no port in name '%s'", name);
|
88
|
+
error = GRPC_ERROR_CREATE(msg);
|
89
|
+
gpr_free(msg);
|
83
90
|
goto done;
|
84
91
|
}
|
85
92
|
port = gpr_strdup(default_port);
|
@@ -95,31 +102,30 @@ static grpc_resolved_addresses *blocking_resolve_address_impl(
|
|
95
102
|
s = getaddrinfo(host, port, &hints, &result);
|
96
103
|
GRPC_SCHEDULING_END_BLOCKING_REGION;
|
97
104
|
if (s != 0) {
|
98
|
-
|
99
|
-
gpr_log(GPR_ERROR, "getaddrinfo: %s", error_message);
|
100
|
-
gpr_free(error_message);
|
105
|
+
error = GRPC_WSA_ERROR(WSAGetLastError(), "getaddrinfo");
|
101
106
|
goto done;
|
102
107
|
}
|
103
108
|
|
104
109
|
/* Success path: set addrs non-NULL, fill it in */
|
105
|
-
|
106
|
-
|
110
|
+
(*addresses) = gpr_malloc(sizeof(grpc_resolved_addresses));
|
111
|
+
(*addresses)->naddrs = 0;
|
107
112
|
for (resp = result; resp != NULL; resp = resp->ai_next) {
|
108
|
-
|
113
|
+
(*addresses)->naddrs++;
|
109
114
|
}
|
110
|
-
|
115
|
+
(*addresses)->addrs =
|
116
|
+
gpr_malloc(sizeof(grpc_resolved_address) * (*addresses)->naddrs);
|
111
117
|
i = 0;
|
112
118
|
for (resp = result; resp != NULL; resp = resp->ai_next) {
|
113
|
-
memcpy(&
|
114
|
-
|
119
|
+
memcpy(&(*addresses)->addrs[i].addr, resp->ai_addr, resp->ai_addrlen);
|
120
|
+
(*addresses)->addrs[i].len = resp->ai_addrlen;
|
115
121
|
i++;
|
116
122
|
}
|
117
123
|
|
118
124
|
{
|
119
|
-
for (i = 0; i <
|
125
|
+
for (i = 0; i < (*addresses)->naddrs; i++) {
|
120
126
|
char *buf;
|
121
|
-
grpc_sockaddr_to_string(
|
122
|
-
|
127
|
+
grpc_sockaddr_to_string(
|
128
|
+
&buf, (struct sockaddr *)&(*addresses)->addrs[i].addr, 0);
|
123
129
|
gpr_free(buf);
|
124
130
|
}
|
125
131
|
}
|
@@ -130,45 +136,53 @@ done:
|
|
130
136
|
if (result) {
|
131
137
|
freeaddrinfo(result);
|
132
138
|
}
|
133
|
-
return
|
139
|
+
return error;
|
134
140
|
}
|
135
141
|
|
136
|
-
|
137
|
-
const char *name, const char *default_port
|
142
|
+
grpc_error *(*grpc_blocking_resolve_address)(
|
143
|
+
const char *name, const char *default_port,
|
144
|
+
grpc_resolved_addresses **addresses) = blocking_resolve_address_impl;
|
138
145
|
|
139
146
|
/* Callback to be passed to grpc_executor to asynch-ify
|
140
147
|
* grpc_blocking_resolve_address */
|
141
|
-
static void do_request_thread(grpc_exec_ctx *exec_ctx, void *rp,
|
148
|
+
static void do_request_thread(grpc_exec_ctx *exec_ctx, void *rp,
|
149
|
+
grpc_error *error) {
|
142
150
|
request *r = rp;
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
151
|
+
if (error == GRPC_ERROR_NONE) {
|
152
|
+
error =
|
153
|
+
grpc_blocking_resolve_address(r->name, r->default_port, r->addresses);
|
154
|
+
} else {
|
155
|
+
GRPC_ERROR_REF(error);
|
156
|
+
}
|
157
|
+
grpc_exec_ctx_sched(exec_ctx, r->on_done, error, NULL);
|
147
158
|
gpr_free(r->name);
|
148
159
|
gpr_free(r->default_port);
|
149
|
-
cb(exec_ctx, arg, resolved);
|
150
160
|
gpr_free(r);
|
151
161
|
}
|
152
162
|
|
153
163
|
void grpc_resolved_addresses_destroy(grpc_resolved_addresses *addrs) {
|
154
|
-
|
164
|
+
if (addrs != NULL) {
|
165
|
+
gpr_free(addrs->addrs);
|
166
|
+
}
|
155
167
|
gpr_free(addrs);
|
156
168
|
}
|
157
169
|
|
158
170
|
static void resolve_address_impl(grpc_exec_ctx *exec_ctx, const char *name,
|
159
|
-
const char *default_port,
|
160
|
-
|
171
|
+
const char *default_port,
|
172
|
+
grpc_closure *on_done,
|
173
|
+
grpc_resolved_addresses **addresses) {
|
161
174
|
request *r = gpr_malloc(sizeof(request));
|
162
175
|
grpc_closure_init(&r->request_closure, do_request_thread, r);
|
163
176
|
r->name = gpr_strdup(name);
|
164
177
|
r->default_port = gpr_strdup(default_port);
|
165
|
-
r->
|
166
|
-
r->
|
167
|
-
|
178
|
+
r->on_done = on_done;
|
179
|
+
r->addresses = addresses;
|
180
|
+
grpc_executor_push(&r->request_closure, GRPC_ERROR_NONE);
|
168
181
|
}
|
169
182
|
|
170
183
|
void (*grpc_resolve_address)(grpc_exec_ctx *exec_ctx, const char *name,
|
171
|
-
const char *default_port,
|
172
|
-
|
184
|
+
const char *default_port, grpc_closure *on_done,
|
185
|
+
grpc_resolved_addresses **addresses) =
|
186
|
+
resolve_address_impl;
|
173
187
|
|
174
188
|
#endif
|
@@ -31,8 +31,8 @@
|
|
31
31
|
*
|
32
32
|
*/
|
33
33
|
|
34
|
-
#ifndef
|
35
|
-
#define
|
34
|
+
#ifndef GRPC_CORE_LIB_IOMGR_SOCKADDR_WINDOWS_H
|
35
|
+
#define GRPC_CORE_LIB_IOMGR_SOCKADDR_WINDOWS_H
|
36
36
|
|
37
37
|
#include <winsock2.h>
|
38
38
|
#include <ws2tcpip.h>
|
@@ -40,4 +40,4 @@
|
|
40
40
|
// must be included after the above
|
41
41
|
#include <mswsock.h>
|
42
42
|
|
43
|
-
#endif /*
|
43
|
+
#endif /* GRPC_CORE_LIB_IOMGR_SOCKADDR_WINDOWS_H */
|
@@ -49,6 +49,7 @@
|
|
49
49
|
#include <sys/types.h>
|
50
50
|
#include <unistd.h>
|
51
51
|
|
52
|
+
#include <grpc/support/alloc.h>
|
52
53
|
#include <grpc/support/host_port.h>
|
53
54
|
#include <grpc/support/log.h>
|
54
55
|
#include <grpc/support/port_platform.h>
|
@@ -57,10 +58,10 @@
|
|
57
58
|
#include "src/core/lib/support/string.h"
|
58
59
|
|
59
60
|
/* set a socket to non blocking mode */
|
60
|
-
|
61
|
+
grpc_error *grpc_set_socket_nonblocking(int fd, int non_blocking) {
|
61
62
|
int oldflags = fcntl(fd, F_GETFL, 0);
|
62
63
|
if (oldflags < 0) {
|
63
|
-
return
|
64
|
+
return GRPC_OS_ERROR(errno, "fcntl");
|
64
65
|
}
|
65
66
|
|
66
67
|
if (non_blocking) {
|
@@ -70,52 +71,71 @@ int grpc_set_socket_nonblocking(int fd, int non_blocking) {
|
|
70
71
|
}
|
71
72
|
|
72
73
|
if (fcntl(fd, F_SETFL, oldflags) != 0) {
|
73
|
-
return
|
74
|
+
return GRPC_OS_ERROR(errno, "fcntl");
|
74
75
|
}
|
75
76
|
|
76
|
-
return
|
77
|
+
return GRPC_ERROR_NONE;
|
77
78
|
}
|
78
79
|
|
79
|
-
|
80
|
+
grpc_error *grpc_set_socket_no_sigpipe_if_possible(int fd) {
|
80
81
|
#ifdef GPR_HAVE_SO_NOSIGPIPE
|
81
82
|
int val = 1;
|
82
83
|
int newval;
|
83
84
|
socklen_t intlen = sizeof(newval);
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
85
|
+
if (0 != setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &val, sizeof(val))) {
|
86
|
+
return GRPC_OS_ERROR(errno, "setsockopt(SO_NOSIGPIPE)");
|
87
|
+
}
|
88
|
+
if (0 != getsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &newval, &intlen)) {
|
89
|
+
return GRPC_OS_ERROR(errno, "getsockopt(SO_NOSIGPIPE)");
|
90
|
+
}
|
91
|
+
if ((newval != 0) != (val != 0)) {
|
92
|
+
return GRPC_ERROR_CREATE("Failed to set SO_NOSIGPIPE");
|
93
|
+
}
|
89
94
|
#endif
|
95
|
+
return GRPC_ERROR_NONE;
|
90
96
|
}
|
91
97
|
|
92
|
-
|
98
|
+
grpc_error *grpc_set_socket_ip_pktinfo_if_possible(int fd) {
|
93
99
|
#ifdef GPR_HAVE_IP_PKTINFO
|
94
100
|
int get_local_ip = 1;
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
return 1;
|
101
|
+
if (0 != setsockopt(fd, IPPROTO_IP, IP_PKTINFO, &get_local_ip,
|
102
|
+
sizeof(get_local_ip))) {
|
103
|
+
return GRPC_OS_ERROR(errno, "setsockopt(IP_PKTINFO)");
|
104
|
+
}
|
100
105
|
#endif
|
106
|
+
return GRPC_ERROR_NONE;
|
101
107
|
}
|
102
108
|
|
103
|
-
|
109
|
+
grpc_error *grpc_set_socket_ipv6_recvpktinfo_if_possible(int fd) {
|
104
110
|
#ifdef GPR_HAVE_IPV6_RECVPKTINFO
|
105
111
|
int get_local_ip = 1;
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
return 1;
|
112
|
+
if (0 != setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &get_local_ip,
|
113
|
+
sizeof(get_local_ip))) {
|
114
|
+
return GRPC_OS_ERROR(errno, "setsockopt(IPV6_RECVPKTINFO)");
|
115
|
+
}
|
111
116
|
#endif
|
117
|
+
return GRPC_ERROR_NONE;
|
118
|
+
}
|
119
|
+
|
120
|
+
grpc_error *grpc_set_socket_sndbuf(int fd, int buffer_size_bytes) {
|
121
|
+
return 0 == setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &buffer_size_bytes,
|
122
|
+
sizeof(buffer_size_bytes))
|
123
|
+
? GRPC_ERROR_NONE
|
124
|
+
: GRPC_OS_ERROR(errno, "setsockopt(SO_SNDBUF)");
|
125
|
+
}
|
126
|
+
|
127
|
+
grpc_error *grpc_set_socket_rcvbuf(int fd, int buffer_size_bytes) {
|
128
|
+
return 0 == setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &buffer_size_bytes,
|
129
|
+
sizeof(buffer_size_bytes))
|
130
|
+
? GRPC_ERROR_NONE
|
131
|
+
: GRPC_OS_ERROR(errno, "setsockopt(SO_RCVBUF)");
|
112
132
|
}
|
113
133
|
|
114
134
|
/* set a socket to close on exec */
|
115
|
-
|
135
|
+
grpc_error *grpc_set_socket_cloexec(int fd, int close_on_exec) {
|
116
136
|
int oldflags = fcntl(fd, F_GETFD, 0);
|
117
137
|
if (oldflags < 0) {
|
118
|
-
return
|
138
|
+
return GRPC_OS_ERROR(errno, "fcntl");
|
119
139
|
}
|
120
140
|
|
121
141
|
if (close_on_exec) {
|
@@ -125,30 +145,45 @@ int grpc_set_socket_cloexec(int fd, int close_on_exec) {
|
|
125
145
|
}
|
126
146
|
|
127
147
|
if (fcntl(fd, F_SETFD, oldflags) != 0) {
|
128
|
-
return
|
148
|
+
return GRPC_OS_ERROR(errno, "fcntl");
|
129
149
|
}
|
130
150
|
|
131
|
-
return
|
151
|
+
return GRPC_ERROR_NONE;
|
132
152
|
}
|
133
153
|
|
134
154
|
/* set a socket to reuse old addresses */
|
135
|
-
|
155
|
+
grpc_error *grpc_set_socket_reuse_addr(int fd, int reuse) {
|
136
156
|
int val = (reuse != 0);
|
137
157
|
int newval;
|
138
158
|
socklen_t intlen = sizeof(newval);
|
139
|
-
|
140
|
-
|
141
|
-
|
159
|
+
if (0 != setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val))) {
|
160
|
+
return GRPC_OS_ERROR(errno, "setsockopt(SO_REUSEADDR)");
|
161
|
+
}
|
162
|
+
if (0 != getsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &newval, &intlen)) {
|
163
|
+
return GRPC_OS_ERROR(errno, "getsockopt(SO_REUSEADDR)");
|
164
|
+
}
|
165
|
+
if ((newval != 0) != val) {
|
166
|
+
return GRPC_ERROR_CREATE("Failed to set SO_REUSEADDR");
|
167
|
+
}
|
168
|
+
|
169
|
+
return GRPC_ERROR_NONE;
|
142
170
|
}
|
143
171
|
|
144
172
|
/* disable nagle */
|
145
|
-
|
173
|
+
grpc_error *grpc_set_socket_low_latency(int fd, int low_latency) {
|
146
174
|
int val = (low_latency != 0);
|
147
175
|
int newval;
|
148
176
|
socklen_t intlen = sizeof(newval);
|
149
|
-
|
150
|
-
|
151
|
-
|
177
|
+
if (0 != setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val))) {
|
178
|
+
return GRPC_OS_ERROR(errno, "setsockopt(TCP_NODELAY)");
|
179
|
+
}
|
180
|
+
if (0 != getsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &newval, &intlen)) {
|
181
|
+
return GRPC_OS_ERROR(errno, "getsockopt(TCP_NODELAY)");
|
182
|
+
}
|
183
|
+
if ((newval != 0) != val) {
|
184
|
+
return GRPC_ERROR_CREATE("Failed to set TCP_NODELAY");
|
185
|
+
}
|
186
|
+
return GRPC_ERROR_NONE;
|
152
187
|
}
|
153
188
|
|
154
189
|
static gpr_once g_probe_ipv6_once = GPR_ONCE_INIT;
|
@@ -196,35 +231,47 @@ static int set_socket_dualstack(int fd) {
|
|
196
231
|
}
|
197
232
|
}
|
198
233
|
|
199
|
-
int
|
200
|
-
|
234
|
+
static grpc_error *error_for_fd(int fd, const struct sockaddr *addr) {
|
235
|
+
if (fd >= 0) return GRPC_ERROR_NONE;
|
236
|
+
char *addr_str;
|
237
|
+
grpc_sockaddr_to_string(&addr_str, addr, 0);
|
238
|
+
grpc_error *err = grpc_error_set_str(GRPC_OS_ERROR(errno, "socket"),
|
239
|
+
GRPC_ERROR_STR_TARGET_ADDRESS, addr_str);
|
240
|
+
gpr_free(addr_str);
|
241
|
+
return err;
|
242
|
+
}
|
243
|
+
|
244
|
+
grpc_error *grpc_create_dualstack_socket(const struct sockaddr *addr, int type,
|
245
|
+
int protocol,
|
246
|
+
grpc_dualstack_mode *dsmode,
|
247
|
+
int *newfd) {
|
201
248
|
int family = addr->sa_family;
|
202
249
|
if (family == AF_INET6) {
|
203
|
-
int fd;
|
204
250
|
if (grpc_ipv6_loopback_available()) {
|
205
|
-
|
251
|
+
*newfd = socket(family, type, protocol);
|
206
252
|
} else {
|
207
|
-
|
253
|
+
*newfd = -1;
|
208
254
|
errno = EAFNOSUPPORT;
|
209
255
|
}
|
210
256
|
/* Check if we've got a valid dualstack socket. */
|
211
|
-
if (
|
257
|
+
if (*newfd >= 0 && set_socket_dualstack(*newfd)) {
|
212
258
|
*dsmode = GRPC_DSMODE_DUALSTACK;
|
213
|
-
return
|
259
|
+
return GRPC_ERROR_NONE;
|
214
260
|
}
|
215
261
|
/* If this isn't an IPv4 address, then return whatever we've got. */
|
216
262
|
if (!grpc_sockaddr_is_v4mapped(addr, NULL)) {
|
217
263
|
*dsmode = GRPC_DSMODE_IPV6;
|
218
|
-
return
|
264
|
+
return error_for_fd(*newfd, addr);
|
219
265
|
}
|
220
266
|
/* Fall back to AF_INET. */
|
221
|
-
if (
|
222
|
-
close(
|
267
|
+
if (*newfd >= 0) {
|
268
|
+
close(*newfd);
|
223
269
|
}
|
224
270
|
family = AF_INET;
|
225
271
|
}
|
226
272
|
*dsmode = family == AF_INET ? GRPC_DSMODE_IPV4 : GRPC_DSMODE_NONE;
|
227
|
-
|
273
|
+
*newfd = socket(family, type, protocol);
|
274
|
+
return error_for_fd(*newfd, addr);
|
228
275
|
}
|
229
276
|
|
230
277
|
#endif
|