grpc 1.12.0 → 1.13.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 +314 -23
- data/include/grpc/impl/codegen/fork.h +4 -4
- data/include/grpc/impl/codegen/grpc_types.h +1 -1
- data/include/grpc/impl/codegen/port_platform.h +3 -0
- data/src/boringssl/err_data.c +256 -246
- data/src/core/ext/filters/client_channel/channel_connectivity.cc +1 -1
- data/src/core/ext/filters/client_channel/client_channel.cc +367 -272
- data/src/core/ext/filters/client_channel/lb_policy.h +1 -3
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +11 -9
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +42 -32
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +36 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +36 -102
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +37 -32
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +22 -19
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver.h +1 -3
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +3 -3
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +0 -1
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +4 -4
- data/src/core/ext/filters/client_channel/subchannel.cc +3 -3
- data/src/core/ext/filters/http/client_authority_filter.cc +5 -4
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +4 -4
- data/src/core/ext/filters/http/server/http_server_filter.cc +123 -131
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +9 -8
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +19 -19
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +10 -6
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +4 -3
- data/src/core/ext/transport/chttp2/transport/parsing.cc +14 -12
- data/src/core/ext/transport/chttp2/transport/writing.cc +6 -6
- data/src/core/lib/channel/channel_stack.cc +0 -5
- data/src/core/lib/channel/channel_stack.h +1 -1
- data/src/core/lib/channel/channel_stack_builder.cc +0 -3
- data/src/core/lib/channel/channel_stack_builder.h +0 -2
- data/src/core/lib/channel/channel_trace.cc +3 -3
- data/src/core/lib/channel/channelz_registry.cc +77 -0
- data/src/core/lib/channel/channelz_registry.h +99 -0
- data/src/core/lib/channel/handshaker.cc +20 -1
- data/src/core/lib/debug/stats.h +7 -0
- data/src/core/lib/debug/stats_data.cc +5 -0
- data/src/core/lib/debug/stats_data.h +120 -0
- data/src/core/lib/debug/trace.h +11 -9
- data/src/core/lib/gprpp/fork.cc +260 -0
- data/src/core/lib/gprpp/fork.h +79 -0
- data/src/core/lib/gprpp/memory.h +12 -0
- data/src/core/lib/gprpp/orphanable.h +2 -6
- data/src/core/lib/gprpp/ref_counted.h +2 -6
- data/src/core/lib/gprpp/thd.h +0 -3
- data/src/core/lib/gprpp/thd_posix.cc +4 -53
- data/src/core/lib/gprpp/thd_windows.cc +0 -7
- data/src/core/lib/http/httpcli_security_connector.cc +1 -3
- data/src/core/lib/iomgr/combiner.cc +19 -2
- data/src/core/lib/iomgr/combiner.h +1 -1
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +2 -2
- data/src/core/lib/iomgr/ev_epollex_linux.cc +59 -3
- data/src/core/lib/iomgr/ev_epollsig_linux.cc +1 -1
- data/src/core/lib/iomgr/ev_poll_posix.cc +2 -2
- data/src/core/lib/iomgr/ev_posix.cc +11 -4
- data/src/core/lib/iomgr/ev_posix.h +6 -0
- data/src/core/lib/iomgr/exec_ctx.cc +9 -9
- data/src/core/lib/iomgr/exec_ctx.h +39 -20
- data/src/core/lib/iomgr/fork_posix.cc +30 -18
- data/src/core/lib/iomgr/iomgr_posix.cc +2 -2
- data/src/core/lib/iomgr/polling_entity.cc +11 -2
- data/src/core/lib/iomgr/pollset_custom.cc +2 -2
- data/src/core/lib/iomgr/port.h +38 -1
- data/src/core/lib/iomgr/resolve_address.h +1 -1
- data/src/core/lib/iomgr/resolve_address_posix.cc +1 -1
- data/src/core/lib/iomgr/resource_quota.cc +1 -1
- data/src/core/lib/iomgr/sockaddr_posix.h +1 -1
- data/src/core/lib/iomgr/socket_factory_posix.cc +1 -1
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +1 -1
- data/src/core/lib/iomgr/tcp_client_custom.cc +3 -3
- data/src/core/lib/iomgr/tcp_client_posix.cc +3 -2
- data/src/core/lib/iomgr/tcp_custom.cc +1 -1
- data/src/core/lib/iomgr/tcp_posix.cc +18 -10
- data/src/core/lib/iomgr/tcp_server_posix.cc +9 -8
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +1 -1
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +16 -4
- data/src/core/lib/iomgr/timer.h +1 -1
- data/src/core/lib/iomgr/timer_generic.cc +113 -41
- data/src/core/lib/iomgr/timer_manager.cc +1 -1
- data/src/core/lib/security/credentials/credentials.h +1 -0
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +88 -115
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +16 -0
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +10 -6
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +1 -1
- data/src/core/lib/security/security_connector/alts_security_connector.cc +2 -1
- data/src/core/lib/security/security_connector/security_connector.cc +7 -7
- data/src/core/lib/security/transport/security_handshaker.cc +1 -0
- data/src/core/lib/security/util/json_util.cc +4 -0
- data/src/core/lib/slice/slice_buffer.cc +15 -3
- data/src/core/lib/surface/call.cc +31 -17
- data/src/core/lib/surface/call.h +5 -0
- data/src/core/lib/surface/channel.cc +2 -5
- data/src/core/lib/surface/completion_queue.cc +1 -3
- data/src/core/lib/surface/completion_queue.h +0 -1
- data/src/core/lib/surface/init.cc +7 -8
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/byte_stream.cc +1 -1
- data/src/core/lib/transport/transport.cc +2 -1
- data/src/core/lib/transport/transport.h +4 -8
- data/src/core/lib/transport/transport_op_string.cc +1 -1
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +19 -7
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.h +10 -0
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +28 -2
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h +3 -0
- data/src/core/tsi/fake_transport_security.cc +1 -0
- data/src/core/tsi/ssl_transport_security.cc +238 -110
- data/src/core/tsi/transport_security.cc +14 -0
- data/src/core/tsi/transport_security.h +2 -0
- data/src/core/tsi/transport_security_interface.h +11 -1
- data/src/ruby/bin/math_client.rb +17 -9
- data/src/ruby/lib/grpc/generic/rpc_server.rb +2 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +4 -1
- data/third_party/boringssl/crypto/asn1/a_int.c +33 -28
- data/third_party/boringssl/crypto/asn1/a_mbstr.c +24 -22
- data/third_party/boringssl/crypto/asn1/a_utf8.c +13 -11
- data/third_party/boringssl/crypto/asn1/asn1_locl.h +3 -0
- data/third_party/boringssl/crypto/bio/fd.c +1 -0
- data/third_party/boringssl/crypto/bio/file.c +2 -0
- data/third_party/boringssl/crypto/bn_extra/convert.c +6 -5
- data/third_party/boringssl/crypto/bytestring/ber.c +1 -4
- data/third_party/boringssl/crypto/bytestring/cbb.c +116 -16
- data/third_party/boringssl/crypto/bytestring/cbs.c +150 -20
- data/third_party/boringssl/crypto/cipher_extra/e_aesccm.c +171 -0
- data/third_party/boringssl/crypto/cipher_extra/e_rc2.c +2 -0
- data/third_party/boringssl/crypto/cipher_extra/e_tls.c +1 -2
- data/third_party/boringssl/crypto/cpu-aarch64-fuchsia.c +55 -0
- data/third_party/boringssl/crypto/cpu-aarch64-linux.c +2 -1
- data/third_party/boringssl/crypto/dsa/dsa.c +16 -54
- data/third_party/boringssl/crypto/fipsmodule/bcm.c +11 -542
- data/third_party/boringssl/crypto/fipsmodule/bn/add.c +33 -64
- data/third_party/boringssl/crypto/fipsmodule/bn/asm/x86_64-gcc.c +4 -3
- data/third_party/boringssl/crypto/fipsmodule/bn/bn.c +122 -70
- data/third_party/boringssl/crypto/fipsmodule/bn/bytes.c +32 -71
- data/third_party/boringssl/crypto/fipsmodule/bn/cmp.c +58 -112
- data/third_party/boringssl/crypto/fipsmodule/bn/div.c +198 -122
- data/third_party/boringssl/crypto/fipsmodule/bn/exponentiation.c +31 -65
- data/third_party/boringssl/crypto/fipsmodule/bn/generic.c +2 -1
- data/third_party/boringssl/crypto/fipsmodule/bn/internal.h +98 -15
- data/third_party/boringssl/crypto/fipsmodule/bn/jacobi.c +1 -1
- data/third_party/boringssl/crypto/fipsmodule/bn/montgomery.c +124 -81
- data/third_party/boringssl/crypto/fipsmodule/bn/montgomery_inv.c +8 -30
- data/third_party/boringssl/crypto/fipsmodule/bn/mul.c +303 -347
- data/third_party/boringssl/crypto/fipsmodule/bn/prime.c +2 -3
- data/third_party/boringssl/crypto/fipsmodule/bn/random.c +3 -4
- data/third_party/boringssl/crypto/fipsmodule/bn/rsaz_exp.c +199 -222
- data/third_party/boringssl/crypto/fipsmodule/bn/rsaz_exp.h +27 -47
- data/third_party/boringssl/crypto/fipsmodule/bn/shift.c +45 -28
- data/third_party/boringssl/crypto/fipsmodule/bn/sqrt.c +1 -1
- data/third_party/boringssl/crypto/fipsmodule/cipher/e_aes.c +10 -10
- data/third_party/boringssl/crypto/fipsmodule/des/internal.h +2 -0
- data/third_party/boringssl/crypto/fipsmodule/ec/ec.c +78 -47
- data/third_party/boringssl/crypto/fipsmodule/ec/ec_key.c +35 -54
- data/third_party/boringssl/crypto/fipsmodule/ec/ec_montgomery.c +3 -10
- data/third_party/boringssl/crypto/fipsmodule/ec/internal.h +36 -22
- data/third_party/boringssl/crypto/fipsmodule/ec/oct.c +59 -90
- data/third_party/boringssl/crypto/fipsmodule/ec/p224-64.c +29 -48
- data/third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64.c +17 -26
- data/third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64.h +15 -11
- data/third_party/boringssl/crypto/fipsmodule/ec/simple.c +45 -51
- data/third_party/boringssl/crypto/fipsmodule/ec/{util-64.c → util.c} +0 -5
- data/third_party/boringssl/crypto/fipsmodule/ec/wnaf.c +144 -264
- data/third_party/boringssl/crypto/fipsmodule/ecdsa/ecdsa.c +78 -56
- data/third_party/boringssl/crypto/fipsmodule/modes/ccm.c +256 -0
- data/third_party/boringssl/crypto/fipsmodule/modes/internal.h +36 -32
- data/third_party/boringssl/crypto/fipsmodule/rand/ctrdrbg.c +9 -7
- data/third_party/boringssl/crypto/fipsmodule/rsa/rsa.c +16 -10
- data/third_party/boringssl/crypto/fipsmodule/rsa/rsa_impl.c +255 -102
- data/third_party/boringssl/crypto/fipsmodule/self_check/self_check.c +581 -0
- data/third_party/boringssl/crypto/fipsmodule/tls/internal.h +39 -0
- data/third_party/boringssl/crypto/fipsmodule/tls/kdf.c +165 -0
- data/third_party/boringssl/crypto/internal.h +65 -2
- data/third_party/boringssl/crypto/mem.c +0 -2
- data/third_party/boringssl/crypto/obj/obj.c +6 -73
- data/third_party/boringssl/crypto/thread_pthread.c +35 -5
- data/third_party/boringssl/crypto/x509/a_strex.c +11 -11
- data/third_party/boringssl/crypto/x509/x_name.c +13 -0
- data/third_party/boringssl/include/openssl/aead.h +4 -0
- data/third_party/boringssl/include/openssl/asn1.h +1 -3
- data/third_party/boringssl/include/openssl/base.h +1 -14
- data/third_party/boringssl/include/openssl/bio.h +1 -1
- data/third_party/boringssl/include/openssl/bn.h +49 -15
- data/third_party/boringssl/include/openssl/bytestring.h +49 -24
- data/third_party/boringssl/include/openssl/crypto.h +4 -0
- data/third_party/boringssl/include/openssl/ec_key.h +7 -3
- data/third_party/boringssl/include/openssl/err.h +9 -9
- data/third_party/boringssl/include/openssl/evp.h +1 -1
- data/third_party/boringssl/include/openssl/rsa.h +34 -10
- data/third_party/boringssl/include/openssl/ssl.h +160 -17
- data/third_party/boringssl/include/openssl/stack.h +1 -1
- data/third_party/boringssl/include/openssl/tls1.h +10 -2
- data/third_party/boringssl/include/openssl/x509.h +3 -0
- data/third_party/boringssl/ssl/d1_both.cc +16 -2
- data/third_party/boringssl/ssl/dtls_method.cc +1 -1
- data/third_party/boringssl/ssl/handoff.cc +285 -0
- data/third_party/boringssl/ssl/handshake.cc +26 -12
- data/third_party/boringssl/ssl/handshake_client.cc +65 -31
- data/third_party/boringssl/ssl/handshake_server.cc +14 -2
- data/third_party/boringssl/ssl/internal.h +132 -79
- data/third_party/boringssl/ssl/s3_both.cc +2 -2
- data/third_party/boringssl/ssl/s3_lib.cc +3 -1
- data/third_party/boringssl/ssl/s3_pkt.cc +0 -18
- data/third_party/boringssl/ssl/ssl_aead_ctx.cc +1 -4
- data/third_party/boringssl/ssl/ssl_asn1.cc +47 -43
- data/third_party/boringssl/ssl/ssl_cipher.cc +8 -8
- data/third_party/boringssl/ssl/ssl_key_share.cc +3 -1
- data/third_party/boringssl/ssl/ssl_lib.cc +83 -14
- data/third_party/boringssl/ssl/ssl_privkey.cc +6 -0
- data/third_party/boringssl/ssl/ssl_stat.cc +6 -6
- data/third_party/boringssl/ssl/ssl_versions.cc +12 -85
- data/third_party/boringssl/ssl/ssl_x509.cc +59 -61
- data/third_party/boringssl/ssl/t1_enc.cc +73 -124
- data/third_party/boringssl/ssl/t1_lib.cc +367 -41
- data/third_party/boringssl/ssl/tls13_both.cc +8 -0
- data/third_party/boringssl/ssl/tls13_client.cc +98 -184
- data/third_party/boringssl/ssl/tls13_enc.cc +88 -158
- data/third_party/boringssl/ssl/tls13_server.cc +91 -137
- data/third_party/boringssl/ssl/tls_method.cc +0 -17
- data/third_party/boringssl/ssl/tls_record.cc +1 -10
- data/third_party/boringssl/third_party/fiat/curve25519.c +921 -2753
- data/third_party/boringssl/third_party/fiat/curve25519_tables.h +7880 -0
- data/third_party/boringssl/third_party/fiat/internal.h +32 -20
- data/third_party/boringssl/third_party/fiat/p256.c +1824 -0
- metadata +64 -64
- data/src/core/lib/channel/channel_trace_registry.cc +0 -80
- data/src/core/lib/channel/channel_trace_registry.h +0 -43
- data/src/core/lib/gpr/fork.cc +0 -78
- data/src/core/lib/gpr/fork.h +0 -35
- data/src/core/tsi/transport_security_adapter.cc +0 -235
- data/src/core/tsi/transport_security_adapter.h +0 -41
- data/src/ruby/bin/apis/google/protobuf/empty.rb +0 -29
- data/src/ruby/bin/apis/pubsub_demo.rb +0 -241
- data/src/ruby/bin/apis/tech/pubsub/proto/pubsub.rb +0 -159
- data/src/ruby/bin/apis/tech/pubsub/proto/pubsub_services.rb +0 -88
- data/src/ruby/pb/test/client.rb +0 -764
- data/src/ruby/pb/test/server.rb +0 -252
- data/third_party/boringssl/crypto/curve25519/x25519-x86_64.c +0 -247
- data/third_party/boringssl/crypto/fipsmodule/ec/p256-64.c +0 -1674
data/src/core/lib/iomgr/port.h
CHANGED
@@ -97,7 +97,26 @@
|
|
97
97
|
#define GRPC_MSG_IOVLEN_TYPE int
|
98
98
|
#define GRPC_POSIX_FORK 1
|
99
99
|
#define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1
|
100
|
+
#ifdef GRPC_CFSTREAM
|
101
|
+
#define GRPC_POSIX_SOCKET_IOMGR 1
|
102
|
+
#define GRPC_CFSTREAM_ENDPOINT 1
|
103
|
+
#define GRPC_CFSTREAM_CLIENT 1
|
104
|
+
#define GRPC_POSIX_SOCKET_ARES_EV_DRIVER 1
|
105
|
+
#define GRPC_POSIX_SOCKET_EV 1
|
106
|
+
#define GRPC_POSIX_SOCKET_EV_EPOLL1 1
|
107
|
+
#define GRPC_POSIX_SOCKET_EV_EPOLLEX 1
|
108
|
+
#define GRPC_POSIX_SOCKET_EV_EPOLLSIG 1
|
109
|
+
#define GRPC_POSIX_SOCKET_EV_POLL 1
|
110
|
+
#define GRPC_POSIX_SOCKET_RESOLVE_ADDRESS 1
|
111
|
+
#define GRPC_POSIX_SOCKET_SOCKADDR 1
|
112
|
+
#define GRPC_POSIX_SOCKET_SOCKET_FACTORY 1
|
113
|
+
#define GRPC_POSIX_SOCKET_TCP 1
|
114
|
+
#define GRPC_POSIX_SOCKET_TCP_SERVER 1
|
115
|
+
#define GRPC_POSIX_SOCKET_TCP_SERVER_UTILS_COMMON 1
|
116
|
+
#define GRPC_POSIX_SOCKET_UTILS_COMMON 1
|
117
|
+
#else
|
100
118
|
#define GRPC_POSIX_SOCKET 1
|
119
|
+
#endif
|
101
120
|
#define GRPC_POSIX_SOCKETUTILS 1
|
102
121
|
#define GRPC_POSIX_SYSCONF 1
|
103
122
|
#define GRPC_POSIX_WAKEUP_FD 1
|
@@ -131,12 +150,30 @@
|
|
131
150
|
#endif
|
132
151
|
|
133
152
|
#if defined(GRPC_POSIX_SOCKET) + defined(GRPC_WINSOCK_SOCKET) + \
|
134
|
-
defined(GRPC_CUSTOM_SOCKET) !=
|
153
|
+
defined(GRPC_CUSTOM_SOCKET) + defined(GRPC_CFSTREAM) != \
|
135
154
|
1
|
136
155
|
#error \
|
137
156
|
"Must define exactly one of GRPC_POSIX_SOCKET, GRPC_WINSOCK_SOCKET, GRPC_CUSTOM_SOCKET"
|
138
157
|
#endif
|
139
158
|
|
159
|
+
#ifdef GRPC_POSIX_SOCKET
|
160
|
+
#define GRPC_POSIX_SOCKET_ARES_EV_DRIVER 1
|
161
|
+
#define GRPC_POSIX_SOCKET_EV 1
|
162
|
+
#define GRPC_POSIX_SOCKET_EV_EPOLLEX 1
|
163
|
+
#define GRPC_POSIX_SOCKET_EV_EPOLLSIG 1
|
164
|
+
#define GRPC_POSIX_SOCKET_EV_POLL 1
|
165
|
+
#define GRPC_POSIX_SOCKET_EV_EPOLL1 1
|
166
|
+
#define GRPC_POSIX_SOCKET_IOMGR 1
|
167
|
+
#define GRPC_POSIX_SOCKET_RESOLVE_ADDRESS 1
|
168
|
+
#define GRPC_POSIX_SOCKET_SOCKADDR 1
|
169
|
+
#define GRPC_POSIX_SOCKET_SOCKET_FACTORY 1
|
170
|
+
#define GRPC_POSIX_SOCKET_TCP 1
|
171
|
+
#define GRPC_POSIX_SOCKET_TCP_CLIENT 1
|
172
|
+
#define GRPC_POSIX_SOCKET_TCP_SERVER 1
|
173
|
+
#define GRPC_POSIX_SOCKET_TCP_SERVER_UTILS_COMMON 1
|
174
|
+
#define GRPC_POSIX_SOCKET_UTILS_COMMON 1
|
175
|
+
#endif
|
176
|
+
|
140
177
|
#if defined(GRPC_POSIX_HOST_NAME_MAX) && defined(GRPC_POSIX_SYSCONF)
|
141
178
|
#error "Cannot define both GRPC_POSIX_HOST_NAME_MAX and GRPC_POSIX_SYSCONF"
|
142
179
|
#endif
|
@@ -386,7 +386,7 @@ static bool rq_reclaim(grpc_resource_quota* resource_quota, bool destructive) {
|
|
386
386
|
resource_quota->debug_only_last_reclaimer_resource_user = resource_user;
|
387
387
|
resource_quota->debug_only_last_initiated_reclaimer = c;
|
388
388
|
resource_user->reclaimers[destructive] = nullptr;
|
389
|
-
|
389
|
+
GRPC_CLOSURE_SCHED(c, GRPC_ERROR_NONE);
|
390
390
|
return true;
|
391
391
|
}
|
392
392
|
|
@@ -140,12 +140,12 @@ static void tcp_connect(grpc_closure* closure, grpc_endpoint** ep,
|
|
140
140
|
socket, connect->addr_name);
|
141
141
|
}
|
142
142
|
|
143
|
-
grpc_custom_socket_vtable->connect(
|
144
|
-
socket, (const grpc_sockaddr*)resolved_addr->addr, resolved_addr->len,
|
145
|
-
custom_connect_callback);
|
146
143
|
GRPC_CLOSURE_INIT(&connect->on_alarm, on_alarm, socket,
|
147
144
|
grpc_schedule_on_exec_ctx);
|
148
145
|
grpc_timer_init(&connect->alarm, deadline, &connect->on_alarm);
|
146
|
+
grpc_custom_socket_vtable->connect(
|
147
|
+
socket, (const grpc_sockaddr*)resolved_addr->addr, resolved_addr->len,
|
148
|
+
custom_connect_callback);
|
149
149
|
}
|
150
150
|
|
151
151
|
grpc_tcp_client_vtable custom_tcp_client_vtable = {tcp_connect};
|
@@ -20,7 +20,7 @@
|
|
20
20
|
|
21
21
|
#include "src/core/lib/iomgr/port.h"
|
22
22
|
|
23
|
-
#ifdef
|
23
|
+
#ifdef GRPC_POSIX_SOCKET_TCP_CLIENT
|
24
24
|
|
25
25
|
#include "src/core/lib/iomgr/tcp_client_posix.h"
|
26
26
|
|
@@ -45,6 +45,7 @@
|
|
45
45
|
#include "src/core/lib/iomgr/tcp_posix.h"
|
46
46
|
#include "src/core/lib/iomgr/timer.h"
|
47
47
|
#include "src/core/lib/iomgr/unix_sockets_posix.h"
|
48
|
+
#include "src/core/lib/slice/slice_internal.h"
|
48
49
|
|
49
50
|
extern grpc_core::TraceFlag grpc_tcp_trace;
|
50
51
|
|
@@ -233,7 +234,7 @@ finish:
|
|
233
234
|
error = grpc_error_set_str(error, GRPC_ERROR_STR_TARGET_ADDRESS,
|
234
235
|
addr_str_slice /* takes ownership */);
|
235
236
|
} else {
|
236
|
-
|
237
|
+
grpc_slice_unref_internal(addr_str_slice);
|
237
238
|
}
|
238
239
|
if (done) {
|
239
240
|
// This is safe even outside the lock, because "done", the sentinel, is
|
@@ -141,7 +141,7 @@ static void call_read_cb(custom_tcp_endpoint* tcp, grpc_error* error) {
|
|
141
141
|
TCP_UNREF(tcp, "read");
|
142
142
|
tcp->read_slices = nullptr;
|
143
143
|
tcp->read_cb = nullptr;
|
144
|
-
|
144
|
+
GRPC_CLOSURE_SCHED(cb, error);
|
145
145
|
}
|
146
146
|
|
147
147
|
static void custom_read_callback(grpc_custom_socket* socket, size_t nread,
|
@@ -20,7 +20,7 @@
|
|
20
20
|
|
21
21
|
#include "src/core/lib/iomgr/port.h"
|
22
22
|
|
23
|
-
#ifdef
|
23
|
+
#ifdef GRPC_POSIX_SOCKET_TCP
|
24
24
|
|
25
25
|
#include "src/core/lib/iomgr/network_status_tracker.h"
|
26
26
|
#include "src/core/lib/iomgr/tcp_posix.h"
|
@@ -70,7 +70,9 @@ struct grpc_tcp {
|
|
70
70
|
grpc_endpoint base;
|
71
71
|
grpc_fd* em_fd;
|
72
72
|
int fd;
|
73
|
-
|
73
|
+
/* Used by the endpoint read function to distinguish the very first read call
|
74
|
+
* from the rest */
|
75
|
+
bool is_first_read;
|
74
76
|
double target_length;
|
75
77
|
double bytes_read_this_round;
|
76
78
|
gpr_refcount refcount;
|
@@ -366,7 +368,7 @@ static void call_read_cb(grpc_tcp* tcp, grpc_error* error) {
|
|
366
368
|
|
367
369
|
tcp->read_cb = nullptr;
|
368
370
|
tcp->incoming_buffer = nullptr;
|
369
|
-
|
371
|
+
GRPC_CLOSURE_SCHED(cb, error);
|
370
372
|
}
|
371
373
|
|
372
374
|
#define MAX_READ_IOVEC 4
|
@@ -377,7 +379,6 @@ static void tcp_do_read(grpc_tcp* tcp) {
|
|
377
379
|
ssize_t read_bytes;
|
378
380
|
size_t i;
|
379
381
|
|
380
|
-
GPR_ASSERT(!tcp->finished_edge);
|
381
382
|
GPR_ASSERT(tcp->incoming_buffer->count <= MAX_READ_IOVEC);
|
382
383
|
|
383
384
|
for (i = 0; i < tcp->incoming_buffer->count; i++) {
|
@@ -473,7 +474,6 @@ static void tcp_continue_read(grpc_tcp* tcp) {
|
|
473
474
|
|
474
475
|
static void tcp_handle_read(void* arg /* grpc_tcp */, grpc_error* error) {
|
475
476
|
grpc_tcp* tcp = static_cast<grpc_tcp*>(arg);
|
476
|
-
GPR_ASSERT(!tcp->finished_edge);
|
477
477
|
if (grpc_tcp_trace.enabled()) {
|
478
478
|
gpr_log(GPR_INFO, "TCP:%p got_read: %s", tcp, grpc_error_string(error));
|
479
479
|
}
|
@@ -497,10 +497,17 @@ static void tcp_read(grpc_endpoint* ep, grpc_slice_buffer* incoming_buffer,
|
|
497
497
|
grpc_slice_buffer_reset_and_unref_internal(incoming_buffer);
|
498
498
|
grpc_slice_buffer_swap(incoming_buffer, &tcp->last_read_buffer);
|
499
499
|
TCP_REF(tcp, "read");
|
500
|
-
if (tcp->
|
501
|
-
|
500
|
+
if (tcp->is_first_read) {
|
501
|
+
/* Endpoint read called for the very first time. Register read callback with
|
502
|
+
* the polling engine */
|
503
|
+
tcp->is_first_read = false;
|
502
504
|
notify_on_read(tcp);
|
503
505
|
} else {
|
506
|
+
/* Not the first time. We may or may not have more bytes available. In any
|
507
|
+
* case call tcp->read_done_closure (i.e tcp_handle_read()) which does the
|
508
|
+
* right thing (i.e calls tcp_do_read() which either reads the available
|
509
|
+
* bytes or calls notify_on_read() to be notified when new bytes become
|
510
|
+
* available */
|
504
511
|
GRPC_CLOSURE_SCHED(&tcp->read_done_closure, GRPC_ERROR_NONE);
|
505
512
|
}
|
506
513
|
}
|
@@ -629,7 +636,7 @@ static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error) {
|
|
629
636
|
gpr_log(GPR_INFO, "write: %s", str);
|
630
637
|
}
|
631
638
|
|
632
|
-
|
639
|
+
GRPC_CLOSURE_SCHED(cb, error);
|
633
640
|
TCP_UNREF(tcp, "write");
|
634
641
|
}
|
635
642
|
}
|
@@ -778,7 +785,8 @@ grpc_endpoint* grpc_tcp_create(grpc_fd* em_fd,
|
|
778
785
|
tcp->min_read_chunk_size = tcp_min_read_chunk_size;
|
779
786
|
tcp->max_read_chunk_size = tcp_max_read_chunk_size;
|
780
787
|
tcp->bytes_read_this_round = 0;
|
781
|
-
|
788
|
+
/* Will be set to false by the very first endpoint read function */
|
789
|
+
tcp->is_first_read = true;
|
782
790
|
/* paired with unref in grpc_tcp_destroy */
|
783
791
|
gpr_ref_init(&tcp->refcount, 1);
|
784
792
|
gpr_atm_no_barrier_store(&tcp->shutdown_count, 0);
|
@@ -811,4 +819,4 @@ void grpc_tcp_destroy_and_release_fd(grpc_endpoint* ep, int* fd,
|
|
811
819
|
TCP_UNREF(tcp, "destroy");
|
812
820
|
}
|
813
821
|
|
814
|
-
#endif
|
822
|
+
#endif /* GRPC_POSIX_SOCKET_TCP */
|
@@ -25,7 +25,7 @@
|
|
25
25
|
|
26
26
|
#include "src/core/lib/iomgr/port.h"
|
27
27
|
|
28
|
-
#ifdef
|
28
|
+
#ifdef GRPC_POSIX_SOCKET_TCP_SERVER
|
29
29
|
|
30
30
|
#include "src/core/lib/iomgr/tcp_server.h"
|
31
31
|
|
@@ -187,11 +187,6 @@ static void on_read(void* arg, grpc_error* err) {
|
|
187
187
|
goto error;
|
188
188
|
}
|
189
189
|
|
190
|
-
read_notifier_pollset =
|
191
|
-
sp->server->pollsets[static_cast<size_t>(gpr_atm_no_barrier_fetch_add(
|
192
|
-
&sp->server->next_pollset_to_assign, 1)) %
|
193
|
-
sp->server->pollset_count];
|
194
|
-
|
195
190
|
/* loop until accept4 returns EAGAIN, and then re-arm notification */
|
196
191
|
for (;;) {
|
197
192
|
grpc_resolved_address addr;
|
@@ -233,6 +228,11 @@ static void on_read(void* arg, grpc_error* err) {
|
|
233
228
|
|
234
229
|
grpc_fd* fdobj = grpc_fd_create(fd, name);
|
235
230
|
|
231
|
+
read_notifier_pollset =
|
232
|
+
sp->server->pollsets[static_cast<size_t>(gpr_atm_no_barrier_fetch_add(
|
233
|
+
&sp->server->next_pollset_to_assign, 1)) %
|
234
|
+
sp->server->pollset_count];
|
235
|
+
|
236
236
|
grpc_pollset_add_fd(read_notifier_pollset, fdobj);
|
237
237
|
|
238
238
|
// Create acceptor.
|
@@ -346,7 +346,8 @@ static grpc_error* clone_port(grpc_tcp_listener* listener, unsigned count) {
|
|
346
346
|
err = grpc_create_dualstack_socket(&listener->addr, SOCK_STREAM, 0, &dsmode,
|
347
347
|
&fd);
|
348
348
|
if (err != GRPC_ERROR_NONE) return err;
|
349
|
-
err = grpc_tcp_server_prepare_socket(fd, &listener->addr,
|
349
|
+
err = grpc_tcp_server_prepare_socket(listener->server, fd, &listener->addr,
|
350
|
+
true, &port);
|
350
351
|
if (err != GRPC_ERROR_NONE) return err;
|
351
352
|
listener->server->nports++;
|
352
353
|
grpc_sockaddr_to_string(&addr_str, &listener->addr, 1);
|
@@ -558,4 +559,4 @@ grpc_tcp_server_vtable grpc_posix_tcp_server_vtable = {
|
|
558
559
|
tcp_server_shutdown_starting_add,
|
559
560
|
tcp_server_unref,
|
560
561
|
tcp_server_shutdown_listeners};
|
561
|
-
#endif
|
562
|
+
#endif /* GRPC_POSIX_SOCKET_TCP_SERVER */
|
@@ -113,7 +113,7 @@ grpc_error* grpc_tcp_server_add_all_local_addrs(grpc_tcp_server* s,
|
|
113
113
|
int* out_port);
|
114
114
|
|
115
115
|
/* Prepare a recently-created socket for listening. */
|
116
|
-
grpc_error* grpc_tcp_server_prepare_socket(int fd,
|
116
|
+
grpc_error* grpc_tcp_server_prepare_socket(grpc_tcp_server*, int fd,
|
117
117
|
const grpc_resolved_address* addr,
|
118
118
|
bool so_reuseport, int* port);
|
119
119
|
/* Ruturn true if the platform supports ifaddrs */
|
@@ -20,7 +20,7 @@
|
|
20
20
|
|
21
21
|
#include "src/core/lib/iomgr/port.h"
|
22
22
|
|
23
|
-
#ifdef
|
23
|
+
#ifdef GRPC_POSIX_SOCKET_TCP_SERVER_UTILS_COMMON
|
24
24
|
|
25
25
|
#include "src/core/lib/iomgr/tcp_server_utils_posix.h"
|
26
26
|
|
@@ -87,7 +87,7 @@ static grpc_error* add_socket_to_server(grpc_tcp_server* s, int fd,
|
|
87
87
|
char* name;
|
88
88
|
|
89
89
|
grpc_error* err =
|
90
|
-
grpc_tcp_server_prepare_socket(fd, addr, s->so_reuseport, &port);
|
90
|
+
grpc_tcp_server_prepare_socket(s, fd, addr, s->so_reuseport, &port);
|
91
91
|
if (err == GRPC_ERROR_NONE) {
|
92
92
|
GPR_ASSERT(port > 0);
|
93
93
|
grpc_sockaddr_to_string(&addr_str, addr, 1);
|
@@ -144,7 +144,7 @@ grpc_error* grpc_tcp_server_add_addr(grpc_tcp_server* s,
|
|
144
144
|
}
|
145
145
|
|
146
146
|
/* Prepare a recently-created socket for listening. */
|
147
|
-
grpc_error* grpc_tcp_server_prepare_socket(int fd,
|
147
|
+
grpc_error* grpc_tcp_server_prepare_socket(grpc_tcp_server* s, int fd,
|
148
148
|
const grpc_resolved_address* addr,
|
149
149
|
bool so_reuseport, int* port) {
|
150
150
|
grpc_resolved_address sockname_temp;
|
@@ -170,6 +170,18 @@ grpc_error* grpc_tcp_server_prepare_socket(int fd,
|
|
170
170
|
err = grpc_set_socket_no_sigpipe_if_possible(fd);
|
171
171
|
if (err != GRPC_ERROR_NONE) goto error;
|
172
172
|
|
173
|
+
if (s->channel_args) {
|
174
|
+
for (size_t i = 0; i < s->channel_args->num_args; i++) {
|
175
|
+
if (0 == strcmp(s->channel_args->args[i].key, GRPC_ARG_SOCKET_MUTATOR)) {
|
176
|
+
GPR_ASSERT(s->channel_args->args[i].type == GRPC_ARG_POINTER);
|
177
|
+
grpc_socket_mutator* mutator = static_cast<grpc_socket_mutator*>(
|
178
|
+
s->channel_args->args[i].value.pointer.p);
|
179
|
+
err = grpc_set_socket_with_mutator(fd, mutator);
|
180
|
+
if (err != GRPC_ERROR_NONE) goto error;
|
181
|
+
}
|
182
|
+
}
|
183
|
+
}
|
184
|
+
|
173
185
|
if (bind(fd, reinterpret_cast<grpc_sockaddr*>(const_cast<char*>(addr->addr)),
|
174
186
|
addr->len) < 0) {
|
175
187
|
err = GRPC_OS_ERROR(errno, "bind");
|
@@ -205,4 +217,4 @@ error:
|
|
205
217
|
return ret;
|
206
218
|
}
|
207
219
|
|
208
|
-
#endif /*
|
220
|
+
#endif /* GRPC_POSIX_SOCKET_TCP_SERVER_UTILS_COMMON */
|
data/src/core/lib/iomgr/timer.h
CHANGED
@@ -34,6 +34,7 @@
|
|
34
34
|
#include "src/core/lib/gpr/spinlock.h"
|
35
35
|
#include "src/core/lib/gpr/tls.h"
|
36
36
|
#include "src/core/lib/gpr/useful.h"
|
37
|
+
#include "src/core/lib/iomgr/exec_ctx.h"
|
37
38
|
#include "src/core/lib/iomgr/time_averaged_stats.h"
|
38
39
|
#include "src/core/lib/iomgr/timer_heap.h"
|
39
40
|
|
@@ -59,9 +60,9 @@ typedef struct {
|
|
59
60
|
gpr_mu mu;
|
60
61
|
grpc_time_averaged_stats stats;
|
61
62
|
/* All and only timers with deadlines <= this will be in the heap. */
|
62
|
-
|
63
|
+
grpc_millis queue_deadline_cap;
|
63
64
|
/* The deadline of the next timer due in this shard */
|
64
|
-
|
65
|
+
grpc_millis min_deadline;
|
65
66
|
/* Index of this timer_shard in the g_shard_queue */
|
66
67
|
uint32_t shard_queue_index;
|
67
68
|
/* This holds all timers with deadlines < queue_deadline_cap. Timers in this
|
@@ -209,15 +210,23 @@ static void validate_non_pending_timer(grpc_timer* t) {
|
|
209
210
|
|
210
211
|
#endif
|
211
212
|
|
213
|
+
#if GPR_ARCH_64
|
214
|
+
/* NOTE: TODO(sreek) - Currently the thread local storage support in grpc is
|
215
|
+
for intptr_t which means on 32-bit machines it is not wide enough to hold
|
216
|
+
grpc_millis which is 64-bit. Adding thread local support for 64 bit values
|
217
|
+
is a lot of work for very little gain. So we are currently restricting this
|
218
|
+
optimization to only 64 bit machines */
|
219
|
+
|
212
220
|
/* Thread local variable that stores the deadline of the next timer the thread
|
213
221
|
* has last-seen. This is an optimization to prevent the thread from checking
|
214
222
|
* shared_mutables.min_timer (which requires acquiring shared_mutables.mu lock,
|
215
223
|
* an expensive operation) */
|
216
224
|
GPR_TLS_DECL(g_last_seen_min_timer);
|
225
|
+
#endif
|
217
226
|
|
218
227
|
struct shared_mutables {
|
219
228
|
/* The deadline of the next timer due across all timer shards */
|
220
|
-
|
229
|
+
grpc_millis min_timer;
|
221
230
|
/* Allow only one run_some_expired_timers at once */
|
222
231
|
gpr_spinlock checker_mu;
|
223
232
|
bool initialized;
|
@@ -227,18 +236,18 @@ struct shared_mutables {
|
|
227
236
|
|
228
237
|
static struct shared_mutables g_shared_mutables;
|
229
238
|
|
230
|
-
static
|
231
|
-
if (a >
|
232
|
-
return
|
239
|
+
static grpc_millis saturating_add(grpc_millis a, grpc_millis b) {
|
240
|
+
if (a > GRPC_MILLIS_INF_FUTURE - b) {
|
241
|
+
return GRPC_MILLIS_INF_FUTURE;
|
233
242
|
}
|
234
243
|
return a + b;
|
235
244
|
}
|
236
245
|
|
237
|
-
static grpc_timer_check_result run_some_expired_timers(
|
238
|
-
|
246
|
+
static grpc_timer_check_result run_some_expired_timers(grpc_millis now,
|
247
|
+
grpc_millis* next,
|
239
248
|
grpc_error* error);
|
240
249
|
|
241
|
-
static
|
250
|
+
static grpc_millis compute_min_deadline(timer_shard* shard) {
|
242
251
|
return grpc_timer_heap_is_empty(&shard->heap)
|
243
252
|
? saturating_add(shard->queue_deadline_cap, 1)
|
244
253
|
: grpc_timer_heap_top(&shard->heap)->deadline;
|
@@ -257,8 +266,11 @@ static void timer_list_init() {
|
|
257
266
|
g_shared_mutables.checker_mu = GPR_SPINLOCK_INITIALIZER;
|
258
267
|
gpr_mu_init(&g_shared_mutables.mu);
|
259
268
|
g_shared_mutables.min_timer = grpc_core::ExecCtx::Get()->Now();
|
269
|
+
|
270
|
+
#if GPR_ARCH_64
|
260
271
|
gpr_tls_init(&g_last_seen_min_timer);
|
261
272
|
gpr_tls_set(&g_last_seen_min_timer, 0);
|
273
|
+
#endif
|
262
274
|
|
263
275
|
for (i = 0; i < g_num_shards; i++) {
|
264
276
|
timer_shard* shard = &g_shards[i];
|
@@ -287,7 +299,11 @@ static void timer_list_shutdown() {
|
|
287
299
|
grpc_timer_heap_destroy(&shard->heap);
|
288
300
|
}
|
289
301
|
gpr_mu_destroy(&g_shared_mutables.mu);
|
302
|
+
|
303
|
+
#if GPR_ARCH_64
|
290
304
|
gpr_tls_destroy(&g_last_seen_min_timer);
|
305
|
+
#endif
|
306
|
+
|
291
307
|
gpr_free(g_shards);
|
292
308
|
gpr_free(g_shard_queue);
|
293
309
|
g_shared_mutables.initialized = false;
|
@@ -346,7 +362,7 @@ static void timer_init(grpc_timer* timer, grpc_millis deadline,
|
|
346
362
|
#endif
|
347
363
|
|
348
364
|
if (grpc_timer_trace.enabled()) {
|
349
|
-
gpr_log(GPR_INFO, "TIMER %p: SET %"
|
365
|
+
gpr_log(GPR_INFO, "TIMER %p: SET %" PRId64 " now %" PRId64 " call %p[%p]",
|
350
366
|
timer, deadline, grpc_core::ExecCtx::Get()->Now(), closure,
|
351
367
|
closure->cb);
|
352
368
|
}
|
@@ -383,7 +399,7 @@ static void timer_init(grpc_timer* timer, grpc_millis deadline,
|
|
383
399
|
}
|
384
400
|
if (grpc_timer_trace.enabled()) {
|
385
401
|
gpr_log(GPR_INFO,
|
386
|
-
" .. add to shard %d with queue_deadline_cap=%"
|
402
|
+
" .. add to shard %d with queue_deadline_cap=%" PRId64
|
387
403
|
" => is_first_timer=%s",
|
388
404
|
static_cast<int>(shard - g_shards), shard->queue_deadline_cap,
|
389
405
|
is_first_timer ? "true" : "false");
|
@@ -404,15 +420,27 @@ static void timer_init(grpc_timer* timer, grpc_millis deadline,
|
|
404
420
|
if (is_first_timer) {
|
405
421
|
gpr_mu_lock(&g_shared_mutables.mu);
|
406
422
|
if (grpc_timer_trace.enabled()) {
|
407
|
-
gpr_log(GPR_INFO, " .. old shard min_deadline=%"
|
423
|
+
gpr_log(GPR_INFO, " .. old shard min_deadline=%" PRId64,
|
408
424
|
shard->min_deadline);
|
409
425
|
}
|
410
426
|
if (deadline < shard->min_deadline) {
|
411
|
-
|
427
|
+
grpc_millis old_min_deadline = g_shard_queue[0]->min_deadline;
|
412
428
|
shard->min_deadline = deadline;
|
413
429
|
note_deadline_change(shard);
|
414
430
|
if (shard->shard_queue_index == 0 && deadline < old_min_deadline) {
|
415
|
-
|
431
|
+
#if GPR_ARCH_64
|
432
|
+
// TODO: sreek - Using c-style cast here. static_cast<> gives an error
|
433
|
+
// (on mac platforms complaining that gpr_atm* is (long *) while
|
434
|
+
// (&g_shared_mutables.min_timer) is a (long long *). The cast should be
|
435
|
+
// safe since we know that both are pointer types and 64-bit wide.
|
436
|
+
gpr_atm_no_barrier_store((gpr_atm*)(&g_shared_mutables.min_timer),
|
437
|
+
deadline);
|
438
|
+
#else
|
439
|
+
// On 32-bit systems, gpr_atm_no_barrier_store does not work on 64-bit
|
440
|
+
// types (like grpc_millis). So all reads and writes to
|
441
|
+
// g_shared_mutables.min_timer varialbe under g_shared_mutables.mu
|
442
|
+
g_shared_mutables.min_timer = deadline;
|
443
|
+
#endif
|
416
444
|
grpc_kick_poller();
|
417
445
|
}
|
418
446
|
}
|
@@ -421,8 +449,10 @@ static void timer_init(grpc_timer* timer, grpc_millis deadline,
|
|
421
449
|
}
|
422
450
|
|
423
451
|
static void timer_consume_kick(void) {
|
424
|
-
|
452
|
+
#if GPR_ARCH_64
|
453
|
+
/* Force re-evaluation of last seen min */
|
425
454
|
gpr_tls_set(&g_last_seen_min_timer, 0);
|
455
|
+
#endif
|
426
456
|
}
|
427
457
|
|
428
458
|
static void timer_cancel(grpc_timer* timer) {
|
@@ -459,7 +489,7 @@ static void timer_cancel(grpc_timer* timer) {
|
|
459
489
|
'queue_deadline_cap') into into shard->heap.
|
460
490
|
Returns 'true' if shard->heap has atleast ONE element
|
461
491
|
REQUIRES: shard->mu locked */
|
462
|
-
static int refill_heap(timer_shard* shard,
|
492
|
+
static int refill_heap(timer_shard* shard, grpc_millis now) {
|
463
493
|
/* Compute the new queue window width and bound by the limits: */
|
464
494
|
double computed_deadline_delta =
|
465
495
|
grpc_time_averaged_stats_update_average(&shard->stats) *
|
@@ -472,10 +502,10 @@ static int refill_heap(timer_shard* shard, gpr_atm now) {
|
|
472
502
|
/* Compute the new cap and put all timers under it into the queue: */
|
473
503
|
shard->queue_deadline_cap =
|
474
504
|
saturating_add(GPR_MAX(now, shard->queue_deadline_cap),
|
475
|
-
static_cast<
|
505
|
+
static_cast<grpc_millis>(deadline_delta * 1000.0));
|
476
506
|
|
477
507
|
if (grpc_timer_check_trace.enabled()) {
|
478
|
-
gpr_log(GPR_INFO, " .. shard[%d]->queue_deadline_cap --> %"
|
508
|
+
gpr_log(GPR_INFO, " .. shard[%d]->queue_deadline_cap --> %" PRId64,
|
479
509
|
static_cast<int>(shard - g_shards), shard->queue_deadline_cap);
|
480
510
|
}
|
481
511
|
for (timer = shard->list.next; timer != &shard->list; timer = next) {
|
@@ -483,7 +513,7 @@ static int refill_heap(timer_shard* shard, gpr_atm now) {
|
|
483
513
|
|
484
514
|
if (timer->deadline < shard->queue_deadline_cap) {
|
485
515
|
if (grpc_timer_check_trace.enabled()) {
|
486
|
-
gpr_log(GPR_INFO, " .. add timer with deadline %"
|
516
|
+
gpr_log(GPR_INFO, " .. add timer with deadline %" PRId64 " to heap",
|
487
517
|
timer->deadline);
|
488
518
|
}
|
489
519
|
list_remove(timer);
|
@@ -496,7 +526,7 @@ static int refill_heap(timer_shard* shard, gpr_atm now) {
|
|
496
526
|
/* This pops the next non-cancelled timer with deadline <= now from the
|
497
527
|
queue, or returns NULL if there isn't one.
|
498
528
|
REQUIRES: shard->mu locked */
|
499
|
-
static grpc_timer* pop_one(timer_shard* shard,
|
529
|
+
static grpc_timer* pop_one(timer_shard* shard, grpc_millis now) {
|
500
530
|
grpc_timer* timer;
|
501
531
|
for (;;) {
|
502
532
|
if (grpc_timer_check_trace.enabled()) {
|
@@ -511,12 +541,12 @@ static grpc_timer* pop_one(timer_shard* shard, gpr_atm now) {
|
|
511
541
|
timer = grpc_timer_heap_top(&shard->heap);
|
512
542
|
if (grpc_timer_check_trace.enabled()) {
|
513
543
|
gpr_log(GPR_INFO,
|
514
|
-
" .. check top timer deadline=%"
|
544
|
+
" .. check top timer deadline=%" PRId64 " now=%" PRId64,
|
515
545
|
timer->deadline, now);
|
516
546
|
}
|
517
547
|
if (timer->deadline > now) return nullptr;
|
518
548
|
if (grpc_timer_trace.enabled()) {
|
519
|
-
gpr_log(GPR_INFO, "TIMER %p: FIRE %"
|
549
|
+
gpr_log(GPR_INFO, "TIMER %p: FIRE %" PRId64 "ms late via %s scheduler",
|
520
550
|
timer, now - timer->deadline,
|
521
551
|
timer->closure->scheduler->vtable->name);
|
522
552
|
}
|
@@ -527,8 +557,8 @@ static grpc_timer* pop_one(timer_shard* shard, gpr_atm now) {
|
|
527
557
|
}
|
528
558
|
|
529
559
|
/* REQUIRES: shard->mu unlocked */
|
530
|
-
static size_t pop_timers(timer_shard* shard,
|
531
|
-
|
560
|
+
static size_t pop_timers(timer_shard* shard, grpc_millis now,
|
561
|
+
grpc_millis* new_min_deadline, grpc_error* error) {
|
532
562
|
size_t n = 0;
|
533
563
|
grpc_timer* timer;
|
534
564
|
gpr_mu_lock(&shard->mu);
|
@@ -546,13 +576,27 @@ static size_t pop_timers(timer_shard* shard, gpr_atm now,
|
|
546
576
|
return n;
|
547
577
|
}
|
548
578
|
|
549
|
-
static grpc_timer_check_result run_some_expired_timers(
|
550
|
-
|
579
|
+
static grpc_timer_check_result run_some_expired_timers(grpc_millis now,
|
580
|
+
grpc_millis* next,
|
551
581
|
grpc_error* error) {
|
552
582
|
grpc_timer_check_result result = GRPC_TIMERS_NOT_CHECKED;
|
553
583
|
|
554
|
-
|
584
|
+
#if GPR_ARCH_64
|
585
|
+
// TODO: sreek - Using c-style cast here. static_cast<> gives an error (on
|
586
|
+
// mac platforms complaining that gpr_atm* is (long *) while
|
587
|
+
// (&g_shared_mutables.min_timer) is a (long long *). The cast should be
|
588
|
+
// safe since we know that both are pointer types and 64-bit wide
|
589
|
+
grpc_millis min_timer = static_cast<grpc_millis>(
|
590
|
+
gpr_atm_no_barrier_load((gpr_atm*)(&g_shared_mutables.min_timer)));
|
555
591
|
gpr_tls_set(&g_last_seen_min_timer, min_timer);
|
592
|
+
#else
|
593
|
+
// On 32-bit systems, gpr_atm_no_barrier_load does not work on 64-bit types
|
594
|
+
// (like grpc_millis). So all reads and writes to g_shared_mutables.min_timer
|
595
|
+
// are done under g_shared_mutables.mu
|
596
|
+
gpr_mu_lock(&g_shared_mutables.mu);
|
597
|
+
grpc_millis min_timer = g_shared_mutables.min_timer;
|
598
|
+
gpr_mu_unlock(&g_shared_mutables.mu);
|
599
|
+
#endif
|
556
600
|
if (now < min_timer) {
|
557
601
|
if (next != nullptr) *next = GPR_MIN(*next, min_timer);
|
558
602
|
return GRPC_TIMERS_CHECKED_AND_EMPTY;
|
@@ -563,14 +607,15 @@ static grpc_timer_check_result run_some_expired_timers(gpr_atm now,
|
|
563
607
|
result = GRPC_TIMERS_CHECKED_AND_EMPTY;
|
564
608
|
|
565
609
|
if (grpc_timer_check_trace.enabled()) {
|
566
|
-
gpr_log(GPR_INFO, " .. shard[%d]->min_deadline = %"
|
610
|
+
gpr_log(GPR_INFO, " .. shard[%d]->min_deadline = %" PRId64,
|
567
611
|
static_cast<int>(g_shard_queue[0] - g_shards),
|
568
612
|
g_shard_queue[0]->min_deadline);
|
569
613
|
}
|
570
614
|
|
571
615
|
while (g_shard_queue[0]->min_deadline < now ||
|
572
|
-
(now !=
|
573
|
-
|
616
|
+
(now != GRPC_MILLIS_INF_FUTURE &&
|
617
|
+
g_shard_queue[0]->min_deadline == now)) {
|
618
|
+
grpc_millis new_min_deadline;
|
574
619
|
|
575
620
|
/* For efficiency, we pop as many available timers as we can from the
|
576
621
|
shard. This may violate perfect timer deadline ordering, but that
|
@@ -582,8 +627,8 @@ static grpc_timer_check_result run_some_expired_timers(gpr_atm now,
|
|
582
627
|
if (grpc_timer_check_trace.enabled()) {
|
583
628
|
gpr_log(GPR_INFO,
|
584
629
|
" .. result --> %d"
|
585
|
-
", shard[%d]->min_deadline %"
|
586
|
-
", now=%"
|
630
|
+
", shard[%d]->min_deadline %" PRId64 " --> %" PRId64
|
631
|
+
", now=%" PRId64,
|
587
632
|
result, static_cast<int>(g_shard_queue[0] - g_shards),
|
588
633
|
g_shard_queue[0]->min_deadline, new_min_deadline, now);
|
589
634
|
}
|
@@ -601,8 +646,19 @@ static grpc_timer_check_result run_some_expired_timers(gpr_atm now,
|
|
601
646
|
*next = GPR_MIN(*next, g_shard_queue[0]->min_deadline);
|
602
647
|
}
|
603
648
|
|
604
|
-
|
649
|
+
#if GPR_ARCH_64
|
650
|
+
// TODO: sreek - Using c-style cast here. static_cast<> gives an error (on
|
651
|
+
// mac platforms complaining that gpr_atm* is (long *) while
|
652
|
+
// (&g_shared_mutables.min_timer) is a (long long *). The cast should be
|
653
|
+
// safe since we know that both are pointer types and 64-bit wide
|
654
|
+
gpr_atm_no_barrier_store((gpr_atm*)(&g_shared_mutables.min_timer),
|
605
655
|
g_shard_queue[0]->min_deadline);
|
656
|
+
#else
|
657
|
+
// On 32-bit systems, gpr_atm_no_barrier_store does not work on 64-bit
|
658
|
+
// types (like grpc_millis). So all reads and writes to
|
659
|
+
// g_shared_mutables.min_timer are done under g_shared_mutables.mu
|
660
|
+
g_shared_mutables.min_timer = g_shard_queue[0]->min_deadline;
|
661
|
+
#endif
|
606
662
|
gpr_mu_unlock(&g_shared_mutables.mu);
|
607
663
|
gpr_spinlock_unlock(&g_shared_mutables.checker_mu);
|
608
664
|
}
|
@@ -616,17 +672,28 @@ static grpc_timer_check_result timer_check(grpc_millis* next) {
|
|
616
672
|
// prelude
|
617
673
|
grpc_millis now = grpc_core::ExecCtx::Get()->Now();
|
618
674
|
|
675
|
+
#if GPR_ARCH_64
|
619
676
|
/* fetch from a thread-local first: this avoids contention on a globally
|
620
677
|
mutable cacheline in the common case */
|
621
678
|
grpc_millis min_timer = gpr_tls_get(&g_last_seen_min_timer);
|
679
|
+
#else
|
680
|
+
// On 32-bit systems, we currently do not have thread local support for 64-bit
|
681
|
+
// types. In this case, directly read from g_shared_mutables.min_timer.
|
682
|
+
// Also, note that on 32-bit systems, gpr_atm_no_barrier_store does not work
|
683
|
+
// on 64-bit types (like grpc_millis). So all reads and writes to
|
684
|
+
// g_shared_mutables.min_timer are done under g_shared_mutables.mu
|
685
|
+
gpr_mu_lock(&g_shared_mutables.mu);
|
686
|
+
grpc_millis min_timer = g_shared_mutables.min_timer;
|
687
|
+
gpr_mu_unlock(&g_shared_mutables.mu);
|
688
|
+
#endif
|
689
|
+
|
622
690
|
if (now < min_timer) {
|
623
691
|
if (next != nullptr) {
|
624
692
|
*next = GPR_MIN(*next, min_timer);
|
625
693
|
}
|
626
694
|
if (grpc_timer_check_trace.enabled()) {
|
627
|
-
gpr_log(GPR_INFO,
|
628
|
-
|
629
|
-
min_timer);
|
695
|
+
gpr_log(GPR_INFO, "TIMER CHECK SKIP: now=%" PRId64 " min_timer=%" PRId64,
|
696
|
+
now, min_timer);
|
630
697
|
}
|
631
698
|
return GRPC_TIMERS_CHECKED_AND_EMPTY;
|
632
699
|
}
|
@@ -642,13 +709,18 @@ static grpc_timer_check_result timer_check(grpc_millis* next) {
|
|
642
709
|
if (next == nullptr) {
|
643
710
|
next_str = gpr_strdup("NULL");
|
644
711
|
} else {
|
645
|
-
gpr_asprintf(&next_str, "%"
|
712
|
+
gpr_asprintf(&next_str, "%" PRId64, *next);
|
646
713
|
}
|
714
|
+
#if GPR_ARCH_64
|
647
715
|
gpr_log(GPR_INFO,
|
648
|
-
"TIMER CHECK BEGIN: now=%"
|
716
|
+
"TIMER CHECK BEGIN: now=%" PRId64 " next=%s tls_min=%" PRId64
|
649
717
|
" glob_min=%" PRIdPTR,
|
650
|
-
now, next_str,
|
651
|
-
gpr_atm_no_barrier_load(&g_shared_mutables.min_timer));
|
718
|
+
now, next_str, min_timer,
|
719
|
+
gpr_atm_no_barrier_load((gpr_atm*)(&g_shared_mutables.min_timer)));
|
720
|
+
#else
|
721
|
+
gpr_log(GPR_INFO, "TIMER CHECK BEGIN: now=%" PRId64 " next=%s min=%" PRId64,
|
722
|
+
now, next_str, min_timer);
|
723
|
+
#endif
|
652
724
|
gpr_free(next_str);
|
653
725
|
}
|
654
726
|
// actual code
|
@@ -660,7 +732,7 @@ static grpc_timer_check_result timer_check(grpc_millis* next) {
|
|
660
732
|
if (next == nullptr) {
|
661
733
|
next_str = gpr_strdup("NULL");
|
662
734
|
} else {
|
663
|
-
gpr_asprintf(&next_str, "%"
|
735
|
+
gpr_asprintf(&next_str, "%" PRId64, *next);
|
664
736
|
}
|
665
737
|
gpr_log(GPR_INFO, "TIMER CHECK END: r=%d; next=%s", r, next_str);
|
666
738
|
gpr_free(next_str);
|