aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/boringssl/err_data.c1252
-rwxr-xr-xsrc/boringssl/gen_build_yaml.py160
-rw-r--r--src/core/census/grpc_filter.c2
-rw-r--r--src/core/census/operation.c4
-rw-r--r--src/core/census/rpc_metric_id.h12
-rw-r--r--src/core/census/tracing.c2
-rw-r--r--src/core/channel/channel_stack.c2
-rw-r--r--src/core/channel/compress_filter.c10
-rw-r--r--src/core/channel/http_server_filter.c14
-rw-r--r--src/core/channel/subchannel_call_holder.c4
-rw-r--r--src/core/client_config/resolvers/sockaddr_resolver.c4
-rw-r--r--src/core/client_config/subchannel.c20
-rw-r--r--src/core/compression/algorithm.c6
-rw-r--r--src/core/httpcli/format_request.c2
-rw-r--r--src/core/httpcli/httpcli_security_connector.c5
-rw-r--r--src/core/httpcli/parser.c14
-rw-r--r--src/core/httpcli/parser.h2
-rw-r--r--src/core/iomgr/closure.c6
-rw-r--r--src/core/iomgr/closure.h2
-rw-r--r--src/core/iomgr/exec_ctx.c2
-rw-r--r--src/core/iomgr/fd_posix.c17
-rw-r--r--src/core/iomgr/fd_posix.h9
-rw-r--r--src/core/iomgr/iocp_windows.c2
-rw-r--r--src/core/iomgr/pollset_multipoller_with_poll_posix.c4
-rw-r--r--src/core/iomgr/pollset_posix.c15
-rw-r--r--src/core/iomgr/pollset_posix.h2
-rw-r--r--src/core/iomgr/sockaddr_utils.c12
-rw-r--r--src/core/iomgr/tcp_posix.c6
-rw-r--r--src/core/iomgr/tcp_posix.h6
-rw-r--r--src/core/iomgr/tcp_server_posix.c2
-rw-r--r--src/core/iomgr/tcp_server_windows.c2
-rw-r--r--src/core/iomgr/timer.c10
-rw-r--r--src/core/iomgr/timer.h2
-rw-r--r--src/core/iomgr/timer_heap.c20
-rw-r--r--src/core/iomgr/timer_heap.h4
-rw-r--r--src/core/iomgr/udp_server.c2
-rw-r--r--src/core/json/json_reader.c23
-rw-r--r--src/core/json/json_reader.h8
-rw-r--r--src/core/json/json_string.c38
-rw-r--r--src/core/json/json_writer.c16
-rw-r--r--src/core/profiling/basic_timers.c2
-rw-r--r--src/core/security/base64.c13
-rw-r--r--src/core/security/client_auth_filter.c8
-rw-r--r--src/core/security/credentials.c6
-rw-r--r--src/core/security/json_token.c6
-rw-r--r--src/core/security/jwt_verifier.c5
-rw-r--r--src/core/security/secure_endpoint.c22
-rw-r--r--src/core/security/security_connector.c20
-rw-r--r--src/core/security/security_connector.h7
-rw-r--r--src/core/security/server_auth_filter.c2
-rw-r--r--src/core/statistics/census_interface.h4
-rw-r--r--src/core/statistics/census_log.c29
-rw-r--r--src/core/statistics/census_rpc_stats.c4
-rw-r--r--src/core/statistics/census_rpc_stats.h6
-rw-r--r--src/core/statistics/census_tracing.c6
-rw-r--r--src/core/statistics/hash_table.c22
-rw-r--r--src/core/statistics/hash_table.h8
-rw-r--r--src/core/statistics/window_stats.c27
-rw-r--r--src/core/support/alloc.c2
-rw-r--r--src/core/support/cpu_posix.c2
-rw-r--r--src/core/support/histogram.c10
-rw-r--r--src/core/support/log_posix.c2
-rw-r--r--src/core/support/log_win32.c1
-rw-r--r--src/core/support/murmur_hash.c22
-rw-r--r--src/core/support/murmur_hash.h2
-rw-r--r--src/core/support/slice.c22
-rw-r--r--src/core/support/slice_buffer.c12
-rw-r--r--src/core/support/stack_lockfree.c18
-rw-r--r--src/core/support/string.c30
-rw-r--r--src/core/support/string.h10
-rw-r--r--src/core/support/sync.c8
-rw-r--r--src/core/support/sync_posix.c2
-rw-r--r--src/core/support/sync_win32.c6
-rw-r--r--src/core/support/time.c20
-rw-r--r--src/core/support/time_posix.c8
-rw-r--r--src/core/support/time_precise.c4
-rw-r--r--src/core/support/time_win32.c6
-rw-r--r--src/core/support/tls_pthread.c2
-rw-r--r--src/core/surface/byte_buffer_reader.c2
-rw-r--r--src/core/surface/call.c125
-rw-r--r--src/core/surface/call.h4
-rw-r--r--src/core/surface/call_test_only.h4
-rw-r--r--src/core/surface/channel.c12
-rw-r--r--src/core/surface/channel.h2
-rw-r--r--src/core/surface/completion_queue.c17
-rw-r--r--src/core/surface/completion_queue.h2
-rw-r--r--src/core/surface/init.c6
-rw-r--r--src/core/surface/server.c20
-rw-r--r--src/core/transport/byte_stream.c14
-rw-r--r--src/core/transport/byte_stream.h11
-rw-r--r--src/core/transport/chttp2/bin_encoder.c58
-rw-r--r--src/core/transport/chttp2/frame_data.c55
-rw-r--r--src/core/transport/chttp2/frame_data.h12
-rw-r--r--src/core/transport/chttp2/frame_goaway.c60
-rw-r--r--src/core/transport/chttp2/frame_goaway.h12
-rw-r--r--src/core/transport/chttp2/frame_ping.c12
-rw-r--r--src/core/transport/chttp2/frame_ping.h10
-rw-r--r--src/core/transport/chttp2/frame_rst_stream.c37
-rw-r--r--src/core/transport/chttp2/frame_rst_stream.h8
-rw-r--r--src/core/transport/chttp2/frame_settings.c60
-rw-r--r--src/core/transport/chttp2/frame_settings.h26
-rw-r--r--src/core/transport/chttp2/frame_window_update.c35
-rw-r--r--src/core/transport/chttp2/frame_window_update.h12
-rw-r--r--src/core/transport/chttp2/hpack_encoder.c142
-rw-r--r--src/core/transport/chttp2/hpack_encoder.h32
-rw-r--r--src/core/transport/chttp2/hpack_parser.c334
-rw-r--r--src/core/transport/chttp2/hpack_parser.h32
-rw-r--r--src/core/transport/chttp2/hpack_table.c26
-rw-r--r--src/core/transport/chttp2/hpack_table.h22
-rw-r--r--src/core/transport/chttp2/internal.h166
-rw-r--r--src/core/transport/chttp2/parsing.c50
-rw-r--r--src/core/transport/chttp2/stream_lists.c8
-rw-r--r--src/core/transport/chttp2/stream_map.c27
-rw-r--r--src/core/transport/chttp2/stream_map.h13
-rw-r--r--src/core/transport/chttp2/timeout_encoding.c22
-rw-r--r--src/core/transport/chttp2/varint.c17
-rw-r--r--src/core/transport/chttp2/varint.h15
-rw-r--r--src/core/transport/chttp2/writing.c30
-rw-r--r--src/core/transport/chttp2_transport.c193
-rw-r--r--src/core/transport/metadata.c71
-rw-r--r--src/core/transport/metadata.h8
-rw-r--r--src/core/transport/static_metadata.c31
-rw-r--r--src/core/transport/static_metadata.h10
-rw-r--r--src/core/tsi/fake_transport_security.c14
-rw-r--r--src/core/tsi/ssl_transport_security.c10
-rw-r--r--src/core/tsi/ssl_types.h55
-rw-r--r--src/cpp/proto/proto_utils.cc6
-rw-r--r--src/cpp/util/time.cc8
-rw-r--r--src/csharp/Grpc.Core.Tests/ServerTest.cs11
-rw-r--r--src/csharp/Grpc.Core/Internal/AsyncCallServer.cs2
-rw-r--r--src/csharp/Grpc.Core/Internal/AtomicCounter.cs33
-rw-r--r--src/csharp/Grpc.Core/Internal/CallSafeHandle.cs105
-rw-r--r--src/csharp/Grpc.Core/Internal/ChannelSafeHandle.cs2
-rw-r--r--src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs54
-rw-r--r--src/csharp/ext/grpc_csharp_ext.c52
-rw-r--r--src/node/ext/call.cc2
-rw-r--r--src/python/README.md7
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pxd2
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx72
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxd21
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/server.pyx2
-rw-r--r--src/python/grpcio/grpc/framework/interfaces/face/face.py8
-rw-r--r--src/python/grpcio/setup.py2
-rw-r--r--src/ruby/ext/grpc/rb_grpc.c2
144 files changed, 3096 insertions, 1350 deletions
diff --git a/src/boringssl/err_data.c b/src/boringssl/err_data.c
new file mode 100644
index 0000000000..1a1d950419
--- /dev/null
+++ b/src/boringssl/err_data.c
@@ -0,0 +1,1252 @@
+/* Copyright (c) 2015, Google Inc.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
+
+ /* This file was generated by err_data_generate.go. */
+
+#include <openssl/base.h>
+#include <openssl/err.h>
+#include <openssl/type_check.h>
+
+
+OPENSSL_COMPILE_ASSERT(ERR_LIB_NONE == 1, library_values_changed_1);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_SYS == 2, library_values_changed_2);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_BN == 3, library_values_changed_3);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_RSA == 4, library_values_changed_4);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_DH == 5, library_values_changed_5);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_EVP == 6, library_values_changed_6);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_BUF == 7, library_values_changed_7);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_OBJ == 8, library_values_changed_8);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_PEM == 9, library_values_changed_9);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_DSA == 10, library_values_changed_10);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_X509 == 11, library_values_changed_11);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_ASN1 == 12, library_values_changed_12);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_CONF == 13, library_values_changed_13);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_CRYPTO == 14, library_values_changed_14);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_EC == 15, library_values_changed_15);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_SSL == 16, library_values_changed_16);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_BIO == 17, library_values_changed_17);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_PKCS7 == 18, library_values_changed_18);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_PKCS8 == 19, library_values_changed_19);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_X509V3 == 20, library_values_changed_20);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_RAND == 21, library_values_changed_21);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_ENGINE == 22, library_values_changed_22);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_OCSP == 23, library_values_changed_23);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_UI == 24, library_values_changed_24);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_COMP == 25, library_values_changed_25);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_ECDSA == 26, library_values_changed_26);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_ECDH == 27, library_values_changed_27);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_HMAC == 28, library_values_changed_28);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_DIGEST == 29, library_values_changed_29);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_CIPHER == 30, library_values_changed_30);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_HKDF == 31, library_values_changed_31);
+OPENSSL_COMPILE_ASSERT(ERR_LIB_USER == 32, library_values_changed_32);
+OPENSSL_COMPILE_ASSERT(ERR_NUM_LIBS == 33, library_values_changed_num);
+
+const uint32_t kOpenSSLReasonValues[] = {
+ 0xc3207ba,
+ 0xc3287d4,
+ 0xc3307e3,
+ 0xc3387f3,
+ 0xc340802,
+ 0xc34881b,
+ 0xc350827,
+ 0xc358844,
+ 0xc360856,
+ 0xc368864,
+ 0xc370874,
+ 0xc378881,
+ 0xc380891,
+ 0xc38889c,
+ 0xc3908b2,
+ 0xc3988c1,
+ 0xc3a08d5,
+ 0xc3a87c7,
+ 0xc3b00b0,
+ 0x10321478,
+ 0x10329484,
+ 0x1033149d,
+ 0x103394b0,
+ 0x10340de1,
+ 0x103494cf,
+ 0x103514e4,
+ 0x10359516,
+ 0x1036152f,
+ 0x10369544,
+ 0x10371562,
+ 0x10379571,
+ 0x1038158d,
+ 0x103895a8,
+ 0x103915b7,
+ 0x103995d3,
+ 0x103a15ee,
+ 0x103a9605,
+ 0x103b1616,
+ 0x103b962a,
+ 0x103c1649,
+ 0x103c9658,
+ 0x103d166f,
+ 0x103d9682,
+ 0x103e0b6c,
+ 0x103e96b3,
+ 0x103f16c6,
+ 0x103f96e0,
+ 0x104016f0,
+ 0x10409704,
+ 0x1041171a,
+ 0x10419732,
+ 0x10421747,
+ 0x1042975b,
+ 0x1043176d,
+ 0x104385d0,
+ 0x104408c1,
+ 0x10449782,
+ 0x10451799,
+ 0x104597ae,
+ 0x104617bc,
+ 0x10469695,
+ 0x104714f7,
+ 0x104787c7,
+ 0x104800b0,
+ 0x104894c3,
+ 0x14320b4f,
+ 0x14328b5d,
+ 0x14330b6c,
+ 0x14338b7e,
+ 0x18320083,
+ 0x18328e47,
+ 0x18340e75,
+ 0x18348e89,
+ 0x18358ec0,
+ 0x18368eed,
+ 0x18370f00,
+ 0x18378f14,
+ 0x18380f38,
+ 0x18388f46,
+ 0x18390f5c,
+ 0x18398f70,
+ 0x183a0f80,
+ 0x183b0f90,
+ 0x183b8fa5,
+ 0x183c8fd0,
+ 0x183d0fe4,
+ 0x183d8ff4,
+ 0x183e0b9b,
+ 0x183e9001,
+ 0x183f1013,
+ 0x183f901e,
+ 0x1840102e,
+ 0x1840903f,
+ 0x18411050,
+ 0x18419062,
+ 0x1842108b,
+ 0x184290bd,
+ 0x184310cc,
+ 0x18451135,
+ 0x1845914b,
+ 0x18461166,
+ 0x18468ed8,
+ 0x184709d9,
+ 0x18478094,
+ 0x18480fbc,
+ 0x18489101,
+ 0x18490e5d,
+ 0x18498e9e,
+ 0x184a119c,
+ 0x184a9119,
+ 0x184b10e0,
+ 0x184b8e37,
+ 0x184c10a4,
+ 0x184c866b,
+ 0x184d1181,
+ 0x203211c3,
+ 0x243211cf,
+ 0x24328907,
+ 0x243311e1,
+ 0x243391ee,
+ 0x243411fb,
+ 0x2434920d,
+ 0x2435121c,
+ 0x24359239,
+ 0x24361246,
+ 0x24369254,
+ 0x24371262,
+ 0x24379270,
+ 0x24381279,
+ 0x24389286,
+ 0x24391299,
+ 0x28320b8f,
+ 0x28328b9b,
+ 0x28330b6c,
+ 0x28338bae,
+ 0x2c32281d,
+ 0x2c32a82b,
+ 0x2c33283d,
+ 0x2c33a84f,
+ 0x2c342863,
+ 0x2c34a875,
+ 0x2c352890,
+ 0x2c35a8a2,
+ 0x2c3628b5,
+ 0x2c3682f3,
+ 0x2c3728c2,
+ 0x2c37a8d4,
+ 0x2c3828e7,
+ 0x2c38a8f5,
+ 0x2c392905,
+ 0x2c39a917,
+ 0x2c3a292b,
+ 0x2c3aa93c,
+ 0x2c3b1359,
+ 0x2c3ba94d,
+ 0x2c3c2961,
+ 0x2c3ca977,
+ 0x2c3d2990,
+ 0x2c3da9be,
+ 0x2c3e29cc,
+ 0x2c3ea9e4,
+ 0x2c3f29fc,
+ 0x2c3faa09,
+ 0x2c402a2c,
+ 0x2c40aa4b,
+ 0x2c4111c3,
+ 0x2c41aa5c,
+ 0x2c422a6f,
+ 0x2c429135,
+ 0x2c432a80,
+ 0x2c4386a2,
+ 0x2c4429ad,
+ 0x30320000,
+ 0x30328015,
+ 0x3033001f,
+ 0x30338038,
+ 0x3034004a,
+ 0x30348064,
+ 0x3035006b,
+ 0x30358083,
+ 0x30360094,
+ 0x303680a1,
+ 0x303700b0,
+ 0x303780bd,
+ 0x303800d0,
+ 0x303880eb,
+ 0x30390100,
+ 0x30398114,
+ 0x303a0128,
+ 0x303a8139,
+ 0x303b0152,
+ 0x303b816f,
+ 0x303c017d,
+ 0x303c8191,
+ 0x303d01a1,
+ 0x303d81ba,
+ 0x303e01ca,
+ 0x303e81dd,
+ 0x303f01ec,
+ 0x303f81f8,
+ 0x3040020d,
+ 0x3040821d,
+ 0x30410234,
+ 0x30418241,
+ 0x30420254,
+ 0x30428263,
+ 0x30430278,
+ 0x30438299,
+ 0x304402ac,
+ 0x304482bf,
+ 0x304502d8,
+ 0x304582f3,
+ 0x30460310,
+ 0x30468329,
+ 0x30470337,
+ 0x30478348,
+ 0x30480357,
+ 0x3048836f,
+ 0x30490381,
+ 0x30498395,
+ 0x304a03b4,
+ 0x304a83c7,
+ 0x304b03d2,
+ 0x304b83e1,
+ 0x304c03f2,
+ 0x304c83fe,
+ 0x304d0414,
+ 0x304d8422,
+ 0x304e0438,
+ 0x304e844a,
+ 0x304f045c,
+ 0x304f846f,
+ 0x30500482,
+ 0x30508493,
+ 0x305104a3,
+ 0x305184bb,
+ 0x305204d0,
+ 0x305284e8,
+ 0x305304fc,
+ 0x30538514,
+ 0x3054052d,
+ 0x30548546,
+ 0x30550563,
+ 0x3055856e,
+ 0x30560586,
+ 0x30568596,
+ 0x305705a7,
+ 0x305785ba,
+ 0x305805d0,
+ 0x305885d9,
+ 0x305905ee,
+ 0x30598601,
+ 0x305a0610,
+ 0x305a8630,
+ 0x305b063f,
+ 0x305b864b,
+ 0x305c066b,
+ 0x305c8687,
+ 0x305d0698,
+ 0x305d86a2,
+ 0x34320ac9,
+ 0x34328add,
+ 0x34330afa,
+ 0x34338b0d,
+ 0x34340b1c,
+ 0x34348b39,
+ 0x3c320083,
+ 0x3c328bd8,
+ 0x3c330bf1,
+ 0x3c338c0c,
+ 0x3c340c29,
+ 0x3c348c44,
+ 0x3c350c5f,
+ 0x3c358c74,
+ 0x3c360c8d,
+ 0x3c368ca5,
+ 0x3c370cb6,
+ 0x3c378cc4,
+ 0x3c380cd1,
+ 0x3c388ce5,
+ 0x3c390b9b,
+ 0x3c398cf9,
+ 0x3c3a0d0d,
+ 0x3c3a8881,
+ 0x3c3b0d1d,
+ 0x3c3b8d38,
+ 0x3c3c0d4a,
+ 0x3c3c8d60,
+ 0x3c3d0d6a,
+ 0x3c3d8d7e,
+ 0x3c3e0d8c,
+ 0x3c3e8db1,
+ 0x3c3f0bc4,
+ 0x3c3f8d9a,
+ 0x403217d3,
+ 0x403297e9,
+ 0x40331817,
+ 0x40339821,
+ 0x40341838,
+ 0x40349856,
+ 0x40351866,
+ 0x40359878,
+ 0x40361885,
+ 0x40369891,
+ 0x403718a6,
+ 0x403798b8,
+ 0x403818c3,
+ 0x403898d5,
+ 0x40390de1,
+ 0x403998e5,
+ 0x403a18f8,
+ 0x403a9919,
+ 0x403b192a,
+ 0x403b993a,
+ 0x403c0064,
+ 0x403c8083,
+ 0x403d1946,
+ 0x403d995c,
+ 0x403e196b,
+ 0x403e997e,
+ 0x403f1998,
+ 0x403f99a6,
+ 0x404019bb,
+ 0x404099cf,
+ 0x404119ec,
+ 0x40419a07,
+ 0x40421a20,
+ 0x40429a33,
+ 0x40431a47,
+ 0x40439a5f,
+ 0x40441a76,
+ 0x40448094,
+ 0x40451a8b,
+ 0x40459a9d,
+ 0x40461ac1,
+ 0x40469ae1,
+ 0x40471aef,
+ 0x40479b03,
+ 0x40481b18,
+ 0x40489b31,
+ 0x40491b48,
+ 0x40499b62,
+ 0x404a1b79,
+ 0x404a9b97,
+ 0x404b1baf,
+ 0x404b9bc6,
+ 0x404c1bdc,
+ 0x404c9bee,
+ 0x404d1c0f,
+ 0x404d9c31,
+ 0x404e1c45,
+ 0x404e9c52,
+ 0x404f1c69,
+ 0x404f9c79,
+ 0x40501c89,
+ 0x40509c9d,
+ 0x40511cb8,
+ 0x40519cc8,
+ 0x40521cdf,
+ 0x40529cf1,
+ 0x40531d09,
+ 0x40539d1c,
+ 0x40541d31,
+ 0x40549d54,
+ 0x40551d62,
+ 0x40559d7f,
+ 0x40561d8c,
+ 0x40569da5,
+ 0x40571dbd,
+ 0x40579dd0,
+ 0x40581de5,
+ 0x40589df7,
+ 0x40591e07,
+ 0x40599e20,
+ 0x405a1e34,
+ 0x405a9e44,
+ 0x405b1e5c,
+ 0x405b9e6d,
+ 0x405c1e80,
+ 0x405c9e91,
+ 0x405d1e9e,
+ 0x405d9eb5,
+ 0x405e1ed5,
+ 0x405e8a17,
+ 0x405f1ef6,
+ 0x405f9f03,
+ 0x40601f11,
+ 0x40609f33,
+ 0x40611f5b,
+ 0x40619f70,
+ 0x40621f87,
+ 0x40629f98,
+ 0x40631fa9,
+ 0x40639fbe,
+ 0x40641fd5,
+ 0x40649fe6,
+ 0x40652001,
+ 0x4065a018,
+ 0x40662030,
+ 0x4066a05a,
+ 0x40672085,
+ 0x4067a0a6,
+ 0x406820b9,
+ 0x4068a0da,
+ 0x406920f5,
+ 0x4069a123,
+ 0x406a2144,
+ 0x406aa164,
+ 0x406b22ec,
+ 0x406ba30f,
+ 0x406c2325,
+ 0x406ca551,
+ 0x406d2580,
+ 0x406da5a8,
+ 0x406e25c1,
+ 0x406ea5d9,
+ 0x406f25f8,
+ 0x406fa60d,
+ 0x40702620,
+ 0x4070a63d,
+ 0x40710782,
+ 0x4071a64f,
+ 0x40722662,
+ 0x4072a67b,
+ 0x40732693,
+ 0x407390bd,
+ 0x407426a7,
+ 0x4074a6c1,
+ 0x407526d2,
+ 0x4075a6e6,
+ 0x407626f4,
+ 0x40769286,
+ 0x40772719,
+ 0x4077a73b,
+ 0x40782756,
+ 0x4078a76b,
+ 0x40792782,
+ 0x4079a798,
+ 0x407a27a4,
+ 0x407aa7b7,
+ 0x407b27cc,
+ 0x407ba7de,
+ 0x407c27f3,
+ 0x407ca7fc,
+ 0x41f42217,
+ 0x41f922a9,
+ 0x41fe219c,
+ 0x41fea378,
+ 0x41ff2469,
+ 0x42032230,
+ 0x42082252,
+ 0x4208a28e,
+ 0x42092180,
+ 0x4209a2c8,
+ 0x420a21d7,
+ 0x420aa1b7,
+ 0x420b21f7,
+ 0x420ba270,
+ 0x420c2485,
+ 0x420ca345,
+ 0x420d235f,
+ 0x420da396,
+ 0x421223b0,
+ 0x4217244c,
+ 0x4217a3f2,
+ 0x421c2414,
+ 0x421f23cf,
+ 0x4221249c,
+ 0x4226242f,
+ 0x422b2535,
+ 0x422ba4fe,
+ 0x422c251d,
+ 0x422ca4d8,
+ 0x422d24b7,
+ 0x443206ad,
+ 0x443286bc,
+ 0x443306c8,
+ 0x443386d6,
+ 0x443406e9,
+ 0x443486fa,
+ 0x44350701,
+ 0x4435870b,
+ 0x4436071e,
+ 0x44368734,
+ 0x44370746,
+ 0x44378753,
+ 0x44380762,
+ 0x4438876a,
+ 0x44390782,
+ 0x44398790,
+ 0x443a07a3,
+ 0x4c3212b0,
+ 0x4c3292c0,
+ 0x4c3312d3,
+ 0x4c3392f3,
+ 0x4c340094,
+ 0x4c3480b0,
+ 0x4c3512ff,
+ 0x4c35930d,
+ 0x4c361329,
+ 0x4c36933c,
+ 0x4c37134b,
+ 0x4c379359,
+ 0x4c38136e,
+ 0x4c38937a,
+ 0x4c39139a,
+ 0x4c3993c4,
+ 0x4c3a13dd,
+ 0x4c3a93f6,
+ 0x4c3b05d0,
+ 0x4c3b940f,
+ 0x4c3c1421,
+ 0x4c3c9430,
+ 0x4c3d10bd,
+ 0x4c3d9449,
+ 0x4c3e1456,
+ 0x50322a92,
+ 0x5032aaa1,
+ 0x50332aac,
+ 0x5033aabc,
+ 0x50342ad5,
+ 0x5034aaef,
+ 0x50352afd,
+ 0x5035ab13,
+ 0x50362b25,
+ 0x5036ab3b,
+ 0x50372b54,
+ 0x5037ab67,
+ 0x50382b7f,
+ 0x5038ab90,
+ 0x50392ba5,
+ 0x5039abb9,
+ 0x503a2bd9,
+ 0x503aabef,
+ 0x503b2c07,
+ 0x503bac19,
+ 0x503c2c35,
+ 0x503cac4c,
+ 0x503d2c65,
+ 0x503dac7b,
+ 0x503e2c88,
+ 0x503eac9e,
+ 0x503f2cb0,
+ 0x503f8348,
+ 0x50402cc3,
+ 0x5040acd3,
+ 0x50412ced,
+ 0x5041acfc,
+ 0x50422d16,
+ 0x5042ad33,
+ 0x50432d43,
+ 0x5043ad53,
+ 0x50442d62,
+ 0x50448414,
+ 0x50452d76,
+ 0x5045ad94,
+ 0x50462da7,
+ 0x5046adbd,
+ 0x50472dcf,
+ 0x5047ade4,
+ 0x50482e0a,
+ 0x5048ae18,
+ 0x50492e2b,
+ 0x5049ae40,
+ 0x504a2e56,
+ 0x504aae66,
+ 0x504b2e86,
+ 0x504bae99,
+ 0x504c2ebc,
+ 0x504caeea,
+ 0x504d2efc,
+ 0x504daf19,
+ 0x504e2f34,
+ 0x504eaf50,
+ 0x504f2f62,
+ 0x504faf79,
+ 0x50502f88,
+ 0x50508687,
+ 0x50512f9b,
+ 0x58320e1f,
+ 0x68320de1,
+ 0x68328b9b,
+ 0x68330bae,
+ 0x68338def,
+ 0x68340dff,
+ 0x683480b0,
+ 0x6c320dbd,
+ 0x6c328b7e,
+ 0x6c330dc8,
+ 0x7432098d,
+ 0x783208f2,
+ 0x78328907,
+ 0x78330913,
+ 0x78338083,
+ 0x78340922,
+ 0x78348937,
+ 0x78350956,
+ 0x78358978,
+ 0x7836098d,
+ 0x783689a3,
+ 0x783709b3,
+ 0x783789c6,
+ 0x783809d9,
+ 0x783889eb,
+ 0x783909f8,
+ 0x78398a17,
+ 0x783a0a2c,
+ 0x783a8a3a,
+ 0x783b0a44,
+ 0x783b8a58,
+ 0x783c0a6f,
+ 0x783c8a84,
+ 0x783d0a9b,
+ 0x783d8ab0,
+ 0x783e0a06,
+ 0x7c3211b2,
+};
+
+const size_t kOpenSSLReasonValuesLen = sizeof(kOpenSSLReasonValues) / sizeof(kOpenSSLReasonValues[0]);
+
+const char kOpenSSLReasonStringData[] =
+ "ASN1_LENGTH_MISMATCH\0"
+ "AUX_ERROR\0"
+ "BAD_GET_ASN1_OBJECT_CALL\0"
+ "BAD_OBJECT_HEADER\0"
+ "BMPSTRING_IS_WRONG_LENGTH\0"
+ "BN_LIB\0"
+ "BOOLEAN_IS_WRONG_LENGTH\0"
+ "BUFFER_TOO_SMALL\0"
+ "DECODE_ERROR\0"
+ "DEPTH_EXCEEDED\0"
+ "ENCODE_ERROR\0"
+ "ERROR_GETTING_TIME\0"
+ "EXPECTING_AN_ASN1_SEQUENCE\0"
+ "EXPECTING_AN_INTEGER\0"
+ "EXPECTING_AN_OBJECT\0"
+ "EXPECTING_A_BOOLEAN\0"
+ "EXPECTING_A_TIME\0"
+ "EXPLICIT_LENGTH_MISMATCH\0"
+ "EXPLICIT_TAG_NOT_CONSTRUCTED\0"
+ "FIELD_MISSING\0"
+ "FIRST_NUM_TOO_LARGE\0"
+ "HEADER_TOO_LONG\0"
+ "ILLEGAL_BITSTRING_FORMAT\0"
+ "ILLEGAL_BOOLEAN\0"
+ "ILLEGAL_CHARACTERS\0"
+ "ILLEGAL_FORMAT\0"
+ "ILLEGAL_HEX\0"
+ "ILLEGAL_IMPLICIT_TAG\0"
+ "ILLEGAL_INTEGER\0"
+ "ILLEGAL_NESTED_TAGGING\0"
+ "ILLEGAL_NULL\0"
+ "ILLEGAL_NULL_VALUE\0"
+ "ILLEGAL_OBJECT\0"
+ "ILLEGAL_OPTIONAL_ANY\0"
+ "ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE\0"
+ "ILLEGAL_TAGGED_ANY\0"
+ "ILLEGAL_TIME_VALUE\0"
+ "INTEGER_NOT_ASCII_FORMAT\0"
+ "INTEGER_TOO_LARGE_FOR_LONG\0"
+ "INVALID_BIT_STRING_BITS_LEFT\0"
+ "INVALID_BMPSTRING_LENGTH\0"
+ "INVALID_DIGIT\0"
+ "INVALID_MODIFIER\0"
+ "INVALID_NUMBER\0"
+ "INVALID_OBJECT_ENCODING\0"
+ "INVALID_SEPARATOR\0"
+ "INVALID_TIME_FORMAT\0"
+ "INVALID_UNIVERSALSTRING_LENGTH\0"
+ "INVALID_UTF8STRING\0"
+ "LIST_ERROR\0"
+ "MALLOC_FAILURE\0"
+ "MISSING_ASN1_EOS\0"
+ "MISSING_EOC\0"
+ "MISSING_SECOND_NUMBER\0"
+ "MISSING_VALUE\0"
+ "MSTRING_NOT_UNIVERSAL\0"
+ "MSTRING_WRONG_TAG\0"
+ "NESTED_ASN1_ERROR\0"
+ "NESTED_ASN1_STRING\0"
+ "NON_HEX_CHARACTERS\0"
+ "NOT_ASCII_FORMAT\0"
+ "NOT_ENOUGH_DATA\0"
+ "NO_MATCHING_CHOICE_TYPE\0"
+ "NULL_IS_WRONG_LENGTH\0"
+ "OBJECT_NOT_ASCII_FORMAT\0"
+ "ODD_NUMBER_OF_CHARS\0"
+ "SECOND_NUMBER_TOO_LARGE\0"
+ "SEQUENCE_LENGTH_MISMATCH\0"
+ "SEQUENCE_NOT_CONSTRUCTED\0"
+ "SEQUENCE_OR_SET_NEEDS_CONFIG\0"
+ "SHORT_LINE\0"
+ "STREAMING_NOT_SUPPORTED\0"
+ "STRING_TOO_LONG\0"
+ "STRING_TOO_SHORT\0"
+ "TAG_VALUE_TOO_HIGH\0"
+ "TIME_NOT_ASCII_FORMAT\0"
+ "TOO_LONG\0"
+ "TYPE_NOT_CONSTRUCTED\0"
+ "TYPE_NOT_PRIMITIVE\0"
+ "UNEXPECTED_EOC\0"
+ "UNIVERSALSTRING_IS_WRONG_LENGTH\0"
+ "UNKNOWN_FORMAT\0"
+ "UNKNOWN_TAG\0"
+ "UNSUPPORTED_ANY_DEFINED_BY_TYPE\0"
+ "UNSUPPORTED_PUBLIC_KEY_TYPE\0"
+ "UNSUPPORTED_TYPE\0"
+ "WRONG_TAG\0"
+ "WRONG_TYPE\0"
+ "BAD_FOPEN_MODE\0"
+ "BROKEN_PIPE\0"
+ "CONNECT_ERROR\0"
+ "ERROR_SETTING_NBIO\0"
+ "INVALID_ARGUMENT\0"
+ "IN_USE\0"
+ "KEEPALIVE\0"
+ "NBIO_CONNECT_ERROR\0"
+ "NO_HOSTNAME_SPECIFIED\0"
+ "NO_PORT_SPECIFIED\0"
+ "NO_SUCH_FILE\0"
+ "NULL_PARAMETER\0"
+ "SYS_LIB\0"
+ "UNABLE_TO_CREATE_SOCKET\0"
+ "UNINITIALIZED\0"
+ "UNSUPPORTED_METHOD\0"
+ "WRITE_TO_READ_ONLY_BIO\0"
+ "ARG2_LT_ARG3\0"
+ "BAD_ENCODING\0"
+ "BAD_RECIPROCAL\0"
+ "BIGNUM_TOO_LONG\0"
+ "BITS_TOO_SMALL\0"
+ "CALLED_WITH_EVEN_MODULUS\0"
+ "DIV_BY_ZERO\0"
+ "EXPAND_ON_STATIC_BIGNUM_DATA\0"
+ "INPUT_NOT_REDUCED\0"
+ "INVALID_RANGE\0"
+ "NEGATIVE_NUMBER\0"
+ "NOT_A_SQUARE\0"
+ "NOT_INITIALIZED\0"
+ "NO_INVERSE\0"
+ "PRIVATE_KEY_TOO_LARGE\0"
+ "P_IS_NOT_PRIME\0"
+ "TOO_MANY_ITERATIONS\0"
+ "TOO_MANY_TEMPORARY_VARIABLES\0"
+ "AES_KEY_SETUP_FAILED\0"
+ "BAD_DECRYPT\0"
+ "BAD_KEY_LENGTH\0"
+ "CTRL_NOT_IMPLEMENTED\0"
+ "CTRL_OPERATION_NOT_IMPLEMENTED\0"
+ "DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH\0"
+ "INITIALIZATION_ERROR\0"
+ "INPUT_NOT_INITIALIZED\0"
+ "INVALID_AD_SIZE\0"
+ "INVALID_KEY_LENGTH\0"
+ "INVALID_NONCE_SIZE\0"
+ "INVALID_OPERATION\0"
+ "IV_TOO_LARGE\0"
+ "NO_CIPHER_SET\0"
+ "NO_DIRECTION_SET\0"
+ "OUTPUT_ALIASES_INPUT\0"
+ "TAG_TOO_LARGE\0"
+ "TOO_LARGE\0"
+ "UNSUPPORTED_AD_SIZE\0"
+ "UNSUPPORTED_INPUT_SIZE\0"
+ "UNSUPPORTED_KEY_SIZE\0"
+ "UNSUPPORTED_NONCE_SIZE\0"
+ "UNSUPPORTED_TAG_SIZE\0"
+ "WRONG_FINAL_BLOCK_LENGTH\0"
+ "LIST_CANNOT_BE_NULL\0"
+ "MISSING_CLOSE_SQUARE_BRACKET\0"
+ "MISSING_EQUAL_SIGN\0"
+ "NO_CLOSE_BRACE\0"
+ "UNABLE_TO_CREATE_NEW_SECTION\0"
+ "VARIABLE_HAS_NO_VALUE\0"
+ "BAD_GENERATOR\0"
+ "INVALID_PUBKEY\0"
+ "MODULUS_TOO_LARGE\0"
+ "NO_PRIVATE_VALUE\0"
+ "BAD_Q_VALUE\0"
+ "MISSING_PARAMETERS\0"
+ "NEED_NEW_SETUP_VALUES\0"
+ "BIGNUM_OUT_OF_RANGE\0"
+ "COORDINATES_OUT_OF_RANGE\0"
+ "D2I_ECPKPARAMETERS_FAILURE\0"
+ "EC_GROUP_NEW_BY_NAME_FAILURE\0"
+ "GROUP2PKPARAMETERS_FAILURE\0"
+ "I2D_ECPKPARAMETERS_FAILURE\0"
+ "INCOMPATIBLE_OBJECTS\0"
+ "INVALID_COMPRESSED_POINT\0"
+ "INVALID_COMPRESSION_BIT\0"
+ "INVALID_ENCODING\0"
+ "INVALID_FIELD\0"
+ "INVALID_FORM\0"
+ "INVALID_GROUP_ORDER\0"
+ "INVALID_PRIVATE_KEY\0"
+ "MISSING_PRIVATE_KEY\0"
+ "NON_NAMED_CURVE\0"
+ "PKPARAMETERS2GROUP_FAILURE\0"
+ "POINT_AT_INFINITY\0"
+ "POINT_IS_NOT_ON_CURVE\0"
+ "SLOT_FULL\0"
+ "UNDEFINED_GENERATOR\0"
+ "UNKNOWN_GROUP\0"
+ "UNKNOWN_ORDER\0"
+ "WRONG_CURVE_PARAMETERS\0"
+ "WRONG_ORDER\0"
+ "KDF_FAILED\0"
+ "POINT_ARITHMETIC_FAILURE\0"
+ "BAD_SIGNATURE\0"
+ "NOT_IMPLEMENTED\0"
+ "RANDOM_NUMBER_GENERATION_FAILED\0"
+ "OPERATION_NOT_SUPPORTED\0"
+ "BN_DECODE_ERROR\0"
+ "COMMAND_NOT_SUPPORTED\0"
+ "CONTEXT_NOT_INITIALISED\0"
+ "DIFFERENT_KEY_TYPES\0"
+ "DIFFERENT_PARAMETERS\0"
+ "DIGEST_AND_KEY_TYPE_NOT_SUPPORTED\0"
+ "EXPECTING_AN_EC_KEY_KEY\0"
+ "EXPECTING_AN_RSA_KEY\0"
+ "EXPECTING_A_DH_KEY\0"
+ "EXPECTING_A_DSA_KEY\0"
+ "ILLEGAL_OR_UNSUPPORTED_PADDING_MODE\0"
+ "INVALID_CURVE\0"
+ "INVALID_DIGEST_LENGTH\0"
+ "INVALID_DIGEST_TYPE\0"
+ "INVALID_KEYBITS\0"
+ "INVALID_MGF1_MD\0"
+ "INVALID_PADDING_MODE\0"
+ "INVALID_PSS_PARAMETERS\0"
+ "INVALID_PSS_SALTLEN\0"
+ "INVALID_SALT_LENGTH\0"
+ "INVALID_TRAILER\0"
+ "KEYS_NOT_SET\0"
+ "NO_DEFAULT_DIGEST\0"
+ "NO_KEY_SET\0"
+ "NO_MDC2_SUPPORT\0"
+ "NO_NID_FOR_CURVE\0"
+ "NO_OPERATION_SET\0"
+ "NO_PARAMETERS_SET\0"
+ "OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE\0"
+ "OPERATON_NOT_INITIALIZED\0"
+ "PARAMETER_ENCODING_ERROR\0"
+ "UNKNOWN_DIGEST\0"
+ "UNKNOWN_MASK_DIGEST\0"
+ "UNKNOWN_MESSAGE_DIGEST_ALGORITHM\0"
+ "UNKNOWN_PUBLIC_KEY_TYPE\0"
+ "UNKNOWN_SIGNATURE_ALGORITHM\0"
+ "UNSUPPORTED_ALGORITHM\0"
+ "UNSUPPORTED_MASK_ALGORITHM\0"
+ "UNSUPPORTED_MASK_PARAMETER\0"
+ "UNSUPPORTED_SIGNATURE_TYPE\0"
+ "WRONG_PUBLIC_KEY_TYPE\0"
+ "OUTPUT_TOO_LARGE\0"
+ "UNKNOWN_NID\0"
+ "BAD_BASE64_DECODE\0"
+ "BAD_END_LINE\0"
+ "BAD_IV_CHARS\0"
+ "BAD_PASSWORD_READ\0"
+ "CIPHER_IS_NULL\0"
+ "ERROR_CONVERTING_PRIVATE_KEY\0"
+ "NOT_DEK_INFO\0"
+ "NOT_ENCRYPTED\0"
+ "NOT_PROC_TYPE\0"
+ "NO_START_LINE\0"
+ "READ_KEY\0"
+ "SHORT_HEADER\0"
+ "UNSUPPORTED_CIPHER\0"
+ "UNSUPPORTED_ENCRYPTION\0"
+ "BAD_PKCS12_DATA\0"
+ "BAD_PKCS12_VERSION\0"
+ "CIPHER_HAS_NO_OBJECT_IDENTIFIER\0"
+ "CRYPT_ERROR\0"
+ "ENCRYPT_ERROR\0"
+ "ERROR_SETTING_CIPHER_PARAMS\0"
+ "INCORRECT_PASSWORD\0"
+ "KEYGEN_FAILURE\0"
+ "KEY_GEN_ERROR\0"
+ "METHOD_NOT_SUPPORTED\0"
+ "MISSING_MAC\0"
+ "MULTIPLE_PRIVATE_KEYS_IN_PKCS12\0"
+ "PKCS12_PUBLIC_KEY_INTEGRITY_NOT_SUPPORTED\0"
+ "PKCS12_TOO_DEEPLY_NESTED\0"
+ "PRIVATE_KEY_DECODE_ERROR\0"
+ "PRIVATE_KEY_ENCODE_ERROR\0"
+ "UNKNOWN_ALGORITHM\0"
+ "UNKNOWN_CIPHER\0"
+ "UNKNOWN_CIPHER_ALGORITHM\0"
+ "UNKNOWN_HASH\0"
+ "UNSUPPORTED_PRIVATE_KEY_ALGORITHM\0"
+ "BAD_E_VALUE\0"
+ "BAD_FIXED_HEADER_DECRYPT\0"
+ "BAD_PAD_BYTE_COUNT\0"
+ "BAD_RSA_PARAMETERS\0"
+ "BAD_VERSION\0"
+ "BLOCK_TYPE_IS_NOT_01\0"
+ "BN_NOT_INITIALIZED\0"
+ "CANNOT_RECOVER_MULTI_PRIME_KEY\0"
+ "CRT_PARAMS_ALREADY_GIVEN\0"
+ "CRT_VALUES_INCORRECT\0"
+ "DATA_LEN_NOT_EQUAL_TO_MOD_LEN\0"
+ "DATA_TOO_LARGE\0"
+ "DATA_TOO_LARGE_FOR_KEY_SIZE\0"
+ "DATA_TOO_LARGE_FOR_MODULUS\0"
+ "DATA_TOO_SMALL\0"
+ "DATA_TOO_SMALL_FOR_KEY_SIZE\0"
+ "DIGEST_TOO_BIG_FOR_RSA_KEY\0"
+ "D_E_NOT_CONGRUENT_TO_1\0"
+ "EMPTY_PUBLIC_KEY\0"
+ "FIRST_OCTET_INVALID\0"
+ "INCONSISTENT_SET_OF_CRT_VALUES\0"
+ "INTERNAL_ERROR\0"
+ "INVALID_MESSAGE_LENGTH\0"
+ "KEY_SIZE_TOO_SMALL\0"
+ "LAST_OCTET_INVALID\0"
+ "MUST_HAVE_AT_LEAST_TWO_PRIMES\0"
+ "NO_PUBLIC_EXPONENT\0"
+ "NULL_BEFORE_BLOCK_MISSING\0"
+ "N_NOT_EQUAL_P_Q\0"
+ "OAEP_DECODING_ERROR\0"
+ "ONLY_ONE_OF_P_Q_GIVEN\0"
+ "OUTPUT_BUFFER_TOO_SMALL\0"
+ "PADDING_CHECK_FAILED\0"
+ "PKCS_DECODING_ERROR\0"
+ "SLEN_CHECK_FAILED\0"
+ "SLEN_RECOVERY_FAILED\0"
+ "UNKNOWN_ALGORITHM_TYPE\0"
+ "UNKNOWN_PADDING_TYPE\0"
+ "VALUE_MISSING\0"
+ "WRONG_SIGNATURE_LENGTH\0"
+ "APP_DATA_IN_HANDSHAKE\0"
+ "ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT\0"
+ "BAD_ALERT\0"
+ "BAD_CHANGE_CIPHER_SPEC\0"
+ "BAD_DATA_RETURNED_BY_CALLBACK\0"
+ "BAD_DH_P_LENGTH\0"
+ "BAD_DIGEST_LENGTH\0"
+ "BAD_ECC_CERT\0"
+ "BAD_ECPOINT\0"
+ "BAD_HANDSHAKE_RECORD\0"
+ "BAD_HELLO_REQUEST\0"
+ "BAD_LENGTH\0"
+ "BAD_PACKET_LENGTH\0"
+ "BAD_RSA_ENCRYPT\0"
+ "BAD_SRTP_MKI_VALUE\0"
+ "BAD_SRTP_PROTECTION_PROFILE_LIST\0"
+ "BAD_SSL_FILETYPE\0"
+ "BAD_WRITE_RETRY\0"
+ "BIO_NOT_SET\0"
+ "CA_DN_LENGTH_MISMATCH\0"
+ "CA_DN_TOO_LONG\0"
+ "CCS_RECEIVED_EARLY\0"
+ "CERTIFICATE_VERIFY_FAILED\0"
+ "CERT_CB_ERROR\0"
+ "CERT_LENGTH_MISMATCH\0"
+ "CHANNEL_ID_NOT_P256\0"
+ "CHANNEL_ID_SIGNATURE_INVALID\0"
+ "CIPHER_OR_HASH_UNAVAILABLE\0"
+ "CLIENTHELLO_PARSE_FAILED\0"
+ "CLIENTHELLO_TLSEXT\0"
+ "CONNECTION_REJECTED\0"
+ "CONNECTION_TYPE_NOT_SET\0"
+ "CUSTOM_EXTENSION_ERROR\0"
+ "DATA_LENGTH_TOO_LONG\0"
+ "DECRYPTION_FAILED\0"
+ "DECRYPTION_FAILED_OR_BAD_RECORD_MAC\0"
+ "DH_PUBLIC_VALUE_LENGTH_IS_WRONG\0"
+ "DH_P_TOO_LONG\0"
+ "DIGEST_CHECK_FAILED\0"
+ "DTLS_MESSAGE_TOO_BIG\0"
+ "ECC_CERT_NOT_FOR_SIGNING\0"
+ "EMS_STATE_INCONSISTENT\0"
+ "ENCRYPTED_LENGTH_TOO_LONG\0"
+ "ERROR_ADDING_EXTENSION\0"
+ "ERROR_IN_RECEIVED_CIPHER_LIST\0"
+ "ERROR_PARSING_EXTENSION\0"
+ "EXCESSIVE_MESSAGE_SIZE\0"
+ "EXTRA_DATA_IN_MESSAGE\0"
+ "FRAGMENT_MISMATCH\0"
+ "GOT_NEXT_PROTO_WITHOUT_EXTENSION\0"
+ "HANDSHAKE_FAILURE_ON_CLIENT_HELLO\0"
+ "HTTPS_PROXY_REQUEST\0"
+ "HTTP_REQUEST\0"
+ "INAPPROPRIATE_FALLBACK\0"
+ "INVALID_COMMAND\0"
+ "INVALID_MESSAGE\0"
+ "INVALID_SSL_SESSION\0"
+ "INVALID_TICKET_KEYS_LENGTH\0"
+ "LENGTH_MISMATCH\0"
+ "LIBRARY_HAS_NO_CIPHERS\0"
+ "MISSING_EXTENSION\0"
+ "MISSING_RSA_CERTIFICATE\0"
+ "MISSING_TMP_DH_KEY\0"
+ "MISSING_TMP_ECDH_KEY\0"
+ "MIXED_SPECIAL_OPERATOR_WITH_GROUPS\0"
+ "MTU_TOO_SMALL\0"
+ "NEGOTIATED_BOTH_NPN_AND_ALPN\0"
+ "NESTED_GROUP\0"
+ "NO_CERTIFICATES_RETURNED\0"
+ "NO_CERTIFICATE_ASSIGNED\0"
+ "NO_CERTIFICATE_SET\0"
+ "NO_CIPHERS_AVAILABLE\0"
+ "NO_CIPHERS_PASSED\0"
+ "NO_CIPHER_MATCH\0"
+ "NO_COMPRESSION_SPECIFIED\0"
+ "NO_METHOD_SPECIFIED\0"
+ "NO_P256_SUPPORT\0"
+ "NO_PRIVATE_KEY_ASSIGNED\0"
+ "NO_RENEGOTIATION\0"
+ "NO_REQUIRED_DIGEST\0"
+ "NO_SHARED_CIPHER\0"
+ "NULL_SSL_CTX\0"
+ "NULL_SSL_METHOD_PASSED\0"
+ "OLD_SESSION_CIPHER_NOT_RETURNED\0"
+ "OLD_SESSION_VERSION_NOT_RETURNED\0"
+ "PARSE_TLSEXT\0"
+ "PATH_TOO_LONG\0"
+ "PEER_DID_NOT_RETURN_A_CERTIFICATE\0"
+ "PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE\0"
+ "PROTOCOL_IS_SHUTDOWN\0"
+ "PSK_IDENTITY_NOT_FOUND\0"
+ "PSK_NO_CLIENT_CB\0"
+ "PSK_NO_SERVER_CB\0"
+ "READ_TIMEOUT_EXPIRED\0"
+ "RECORD_LENGTH_MISMATCH\0"
+ "RECORD_TOO_LARGE\0"
+ "RENEGOTIATION_ENCODING_ERR\0"
+ "RENEGOTIATION_MISMATCH\0"
+ "REQUIRED_CIPHER_MISSING\0"
+ "RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION\0"
+ "RESUMED_NON_EMS_SESSION_WITH_EMS_EXTENSION\0"
+ "SCSV_RECEIVED_WHEN_RENEGOTIATING\0"
+ "SERVERHELLO_TLSEXT\0"
+ "SESSION_ID_CONTEXT_UNINITIALIZED\0"
+ "SESSION_MAY_NOT_BE_CREATED\0"
+ "SIGNATURE_ALGORITHMS_EXTENSION_SENT_BY_SERVER\0"
+ "SRTP_COULD_NOT_ALLOCATE_PROFILES\0"
+ "SRTP_UNKNOWN_PROTECTION_PROFILE\0"
+ "SSL3_EXT_INVALID_SERVERNAME\0"
+ "SSLV3_ALERT_BAD_CERTIFICATE\0"
+ "SSLV3_ALERT_BAD_RECORD_MAC\0"
+ "SSLV3_ALERT_CERTIFICATE_EXPIRED\0"
+ "SSLV3_ALERT_CERTIFICATE_REVOKED\0"
+ "SSLV3_ALERT_CERTIFICATE_UNKNOWN\0"
+ "SSLV3_ALERT_CLOSE_NOTIFY\0"
+ "SSLV3_ALERT_DECOMPRESSION_FAILURE\0"
+ "SSLV3_ALERT_HANDSHAKE_FAILURE\0"
+ "SSLV3_ALERT_ILLEGAL_PARAMETER\0"
+ "SSLV3_ALERT_NO_CERTIFICATE\0"
+ "SSLV3_ALERT_UNEXPECTED_MESSAGE\0"
+ "SSLV3_ALERT_UNSUPPORTED_CERTIFICATE\0"
+ "SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION\0"
+ "SSL_HANDSHAKE_FAILURE\0"
+ "SSL_SESSION_ID_CONTEXT_TOO_LONG\0"
+ "TLSV1_ALERT_ACCESS_DENIED\0"
+ "TLSV1_ALERT_DECODE_ERROR\0"
+ "TLSV1_ALERT_DECRYPTION_FAILED\0"
+ "TLSV1_ALERT_DECRYPT_ERROR\0"
+ "TLSV1_ALERT_EXPORT_RESTRICTION\0"
+ "TLSV1_ALERT_INAPPROPRIATE_FALLBACK\0"
+ "TLSV1_ALERT_INSUFFICIENT_SECURITY\0"
+ "TLSV1_ALERT_INTERNAL_ERROR\0"
+ "TLSV1_ALERT_NO_RENEGOTIATION\0"
+ "TLSV1_ALERT_PROTOCOL_VERSION\0"
+ "TLSV1_ALERT_RECORD_OVERFLOW\0"
+ "TLSV1_ALERT_UNKNOWN_CA\0"
+ "TLSV1_ALERT_USER_CANCELLED\0"
+ "TLSV1_BAD_CERTIFICATE_HASH_VALUE\0"
+ "TLSV1_BAD_CERTIFICATE_STATUS_RESPONSE\0"
+ "TLSV1_CERTIFICATE_UNOBTAINABLE\0"
+ "TLSV1_UNRECOGNIZED_NAME\0"
+ "TLSV1_UNSUPPORTED_EXTENSION\0"
+ "TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST\0"
+ "TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG\0"
+ "TOO_MANY_EMPTY_FRAGMENTS\0"
+ "TOO_MANY_WARNING_ALERTS\0"
+ "UNABLE_TO_FIND_ECDH_PARAMETERS\0"
+ "UNEXPECTED_EXTENSION\0"
+ "UNEXPECTED_MESSAGE\0"
+ "UNEXPECTED_OPERATOR_IN_GROUP\0"
+ "UNEXPECTED_RECORD\0"
+ "UNKNOWN_ALERT_TYPE\0"
+ "UNKNOWN_CERTIFICATE_TYPE\0"
+ "UNKNOWN_CIPHER_RETURNED\0"
+ "UNKNOWN_CIPHER_TYPE\0"
+ "UNKNOWN_KEY_EXCHANGE_TYPE\0"
+ "UNKNOWN_PROTOCOL\0"
+ "UNKNOWN_SSL_VERSION\0"
+ "UNKNOWN_STATE\0"
+ "UNSAFE_LEGACY_RENEGOTIATION_DISABLED\0"
+ "UNSUPPORTED_COMPRESSION_ALGORITHM\0"
+ "UNSUPPORTED_ELLIPTIC_CURVE\0"
+ "UNSUPPORTED_PROTOCOL\0"
+ "WRONG_CERTIFICATE_TYPE\0"
+ "WRONG_CIPHER_RETURNED\0"
+ "WRONG_CURVE\0"
+ "WRONG_MESSAGE_TYPE\0"
+ "WRONG_SIGNATURE_TYPE\0"
+ "WRONG_SSL_VERSION\0"
+ "WRONG_VERSION_NUMBER\0"
+ "X509_LIB\0"
+ "X509_VERIFICATION_SETUP_PROBLEMS\0"
+ "AKID_MISMATCH\0"
+ "BAD_PKCS7_VERSION\0"
+ "BAD_X509_FILETYPE\0"
+ "BASE64_DECODE_ERROR\0"
+ "CANT_CHECK_DH_KEY\0"
+ "CERT_ALREADY_IN_HASH_TABLE\0"
+ "CRL_ALREADY_DELTA\0"
+ "CRL_VERIFY_FAILURE\0"
+ "IDP_MISMATCH\0"
+ "INVALID_DIRECTORY\0"
+ "INVALID_FIELD_NAME\0"
+ "INVALID_TRUST\0"
+ "ISSUER_MISMATCH\0"
+ "KEY_TYPE_MISMATCH\0"
+ "KEY_VALUES_MISMATCH\0"
+ "LOADING_CERT_DIR\0"
+ "LOADING_DEFAULTS\0"
+ "NEWER_CRL_NOT_NEWER\0"
+ "NOT_PKCS7_SIGNED_DATA\0"
+ "NO_CERTIFICATES_INCLUDED\0"
+ "NO_CERT_SET_FOR_US_TO_VERIFY\0"
+ "NO_CRLS_INCLUDED\0"
+ "NO_CRL_NUMBER\0"
+ "PUBLIC_KEY_DECODE_ERROR\0"
+ "PUBLIC_KEY_ENCODE_ERROR\0"
+ "SHOULD_RETRY\0"
+ "UNABLE_TO_FIND_PARAMETERS_IN_CHAIN\0"
+ "UNABLE_TO_GET_CERTS_PUBLIC_KEY\0"
+ "UNKNOWN_KEY_TYPE\0"
+ "UNKNOWN_PURPOSE_ID\0"
+ "UNKNOWN_TRUST_ID\0"
+ "WRONG_LOOKUP_TYPE\0"
+ "BAD_IP_ADDRESS\0"
+ "BAD_OBJECT\0"
+ "BN_DEC2BN_ERROR\0"
+ "BN_TO_ASN1_INTEGER_ERROR\0"
+ "CANNOT_FIND_FREE_FUNCTION\0"
+ "DIRNAME_ERROR\0"
+ "DISTPOINT_ALREADY_SET\0"
+ "DUPLICATE_ZONE_ID\0"
+ "ERROR_CONVERTING_ZONE\0"
+ "ERROR_CREATING_EXTENSION\0"
+ "ERROR_IN_EXTENSION\0"
+ "EXPECTED_A_SECTION_NAME\0"
+ "EXTENSION_EXISTS\0"
+ "EXTENSION_NAME_ERROR\0"
+ "EXTENSION_NOT_FOUND\0"
+ "EXTENSION_SETTING_NOT_SUPPORTED\0"
+ "EXTENSION_VALUE_ERROR\0"
+ "ILLEGAL_EMPTY_EXTENSION\0"
+ "ILLEGAL_HEX_DIGIT\0"
+ "INCORRECT_POLICY_SYNTAX_TAG\0"
+ "INVALID_BOOLEAN_STRING\0"
+ "INVALID_EXTENSION_STRING\0"
+ "INVALID_MULTIPLE_RDNS\0"
+ "INVALID_NAME\0"
+ "INVALID_NULL_ARGUMENT\0"
+ "INVALID_NULL_NAME\0"
+ "INVALID_NULL_VALUE\0"
+ "INVALID_NUMBERS\0"
+ "INVALID_OBJECT_IDENTIFIER\0"
+ "INVALID_OPTION\0"
+ "INVALID_POLICY_IDENTIFIER\0"
+ "INVALID_PROXY_POLICY_SETTING\0"
+ "INVALID_PURPOSE\0"
+ "INVALID_SECTION\0"
+ "INVALID_SYNTAX\0"
+ "ISSUER_DECODE_ERROR\0"
+ "NEED_ORGANIZATION_AND_NUMBERS\0"
+ "NO_CONFIG_DATABASE\0"
+ "NO_ISSUER_CERTIFICATE\0"
+ "NO_ISSUER_DETAILS\0"
+ "NO_POLICY_IDENTIFIER\0"
+ "NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED\0"
+ "NO_PUBLIC_KEY\0"
+ "NO_SUBJECT_DETAILS\0"
+ "ODD_NUMBER_OF_DIGITS\0"
+ "OPERATION_NOT_DEFINED\0"
+ "OTHERNAME_ERROR\0"
+ "POLICY_LANGUAGE_ALREADY_DEFINED\0"
+ "POLICY_PATH_LENGTH\0"
+ "POLICY_PATH_LENGTH_ALREADY_DEFINED\0"
+ "POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY\0"
+ "SECTION_NOT_FOUND\0"
+ "UNABLE_TO_GET_ISSUER_DETAILS\0"
+ "UNABLE_TO_GET_ISSUER_KEYID\0"
+ "UNKNOWN_BIT_STRING_ARGUMENT\0"
+ "UNKNOWN_EXTENSION\0"
+ "UNKNOWN_EXTENSION_NAME\0"
+ "UNKNOWN_OPTION\0"
+ "UNSUPPORTED_OPTION\0"
+ "USER_TOO_LONG\0"
+ "";
+
diff --git a/src/boringssl/gen_build_yaml.py b/src/boringssl/gen_build_yaml.py
new file mode 100755
index 0000000000..424912ba70
--- /dev/null
+++ b/src/boringssl/gen_build_yaml.py
@@ -0,0 +1,160 @@
+#!/usr/bin/env python2.7
+# Copyright 2015-2016, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import shutil
+import sys
+import os
+import yaml
+
+boring_ssl_root = os.path.abspath(os.path.join(
+ os.path.dirname(sys.argv[0]),
+ '../../third_party/boringssl'))
+sys.path.append(os.path.join(boring_ssl_root, 'util'))
+
+try:
+ import generate_build_files
+except ImportError:
+ print yaml.dump({})
+ sys.exit()
+
+def map_dir(filename):
+ if filename[0:4] == 'src/':
+ return 'third_party/boringssl/' + filename[4:]
+ else:
+ return 'src/boringssl/' + filename
+
+def map_testarg(arg):
+ if '/' in arg:
+ return 'third_party/boringssl/' + arg
+ else:
+ return arg
+
+class Grpc(object):
+
+ yaml = None
+
+ def WriteFiles(self, files, asm_outputs):
+ self.yaml = {
+ '#': 'generated with tools/buildgen/gen_boring_ssl_build_yaml.py',
+ 'raw_boringssl_build_output_for_debugging': {
+ 'files': files,
+ 'asm_outputs': asm_outputs,
+ },
+ 'libs': [
+ {
+ 'name': 'boringssl',
+ 'build': 'private',
+ 'language': 'c',
+ 'secure': 'no',
+ 'src': sorted(
+ map_dir(f)
+ for f in files['ssl'] + files['crypto']
+ ),
+ 'headers': sorted(
+ map_dir(f)
+ for f in files['ssl_headers'] + files['ssl_internal_headers'] + files['crypto_headers'] + files['crypto_internal_headers']
+ ),
+ 'boringssl': True,
+ },
+ {
+ 'name': 'boringssl_test_util',
+ 'build': 'private',
+ 'language': 'c++',
+ 'secure': 'no',
+ 'boringssl': True,
+ 'src': [
+ map_dir(f)
+ for f in sorted(files['test_support'])
+ ],
+ }
+ ] + [
+ {
+ 'name': 'boringssl_%s_lib' % os.path.splitext(os.path.basename(test))[0],
+ 'build': 'private',
+ 'secure': 'no',
+ 'language': 'c' if os.path.splitext(test)[1] == '.c' else 'c++',
+ 'src': [map_dir(test)],
+ 'vs_proj_dir': 'test/boringssl',
+ 'boringssl': True,
+ 'deps': [
+ 'boringssl_test_util',
+ 'boringssl',
+ ]
+ }
+ for test in sorted(files['test'])
+ ],
+ 'targets': [
+ {
+ 'name': 'boringssl_%s' % os.path.splitext(os.path.basename(test))[0],
+ 'build': 'test',
+ 'run': False,
+ 'secure': 'no',
+ 'language': 'c++',
+ 'src': [],
+ 'vs_proj_dir': 'test/boringssl',
+ 'boringssl': True,
+ 'deps': [
+ 'boringssl_%s_lib' % os.path.splitext(os.path.basename(test))[0],
+ 'boringssl_test_util',
+ 'boringssl',
+ ]
+ }
+ for test in sorted(files['test'])
+ ],
+ 'tests': [
+ {
+ 'name': 'boringssl_%s' % os.path.basename(test[0]),
+ 'args': [map_testarg(arg) for arg in test[1:]],
+ 'exclude_configs': ['asan'],
+ 'ci_platforms': ['linux', 'mac', 'posix', 'windows'],
+ 'platforms': ['linux', 'mac', 'posix', 'windows'],
+ 'flaky': False,
+ 'language': 'c++',
+ 'boringssl': True
+ }
+ for test in files['tests']
+ ]
+ }
+
+
+os.chdir(os.path.dirname(sys.argv[0]))
+os.mkdir('src')
+try:
+ for f in os.listdir(boring_ssl_root):
+ os.symlink(os.path.join(boring_ssl_root, f),
+ os.path.join('src', f))
+
+ g = Grpc()
+ generate_build_files.main([g])
+
+ print yaml.dump(g.yaml)
+
+finally:
+ shutil.rmtree('src')
diff --git a/src/core/census/grpc_filter.c b/src/core/census/grpc_filter.c
index 4529ae9bd7..ee1f62f8c2 100644
--- a/src/core/census/grpc_filter.c
+++ b/src/core/census/grpc_filter.c
@@ -59,7 +59,7 @@ typedef struct call_data {
grpc_closure finish_recv;
} call_data;
-typedef struct channel_data { gpr_uint8 unused; } channel_data;
+typedef struct channel_data { uint8_t unused; } channel_data;
static void extract_and_annotate_method_tag(grpc_metadata_batch *md,
call_data *calld,
diff --git a/src/core/census/operation.c b/src/core/census/operation.c
index 118eb0a47a..5c58704372 100644
--- a/src/core/census/operation.c
+++ b/src/core/census/operation.c
@@ -42,14 +42,14 @@ census_timestamp census_start_rpc_op_timestamp(void) {
}
census_context *census_start_client_rpc_op(
- const census_context *context, gpr_int64 rpc_name_id,
+ const census_context *context, int64_t rpc_name_id,
const census_rpc_name_info *rpc_name_info, const char *peer, int trace_mask,
const census_timestamp *start_time) {
return NULL;
}
census_context *census_start_server_rpc_op(
- const char *buffer, gpr_int64 rpc_name_id,
+ const char *buffer, int64_t rpc_name_id,
const census_rpc_name_info *rpc_name_info, const char *peer, int trace_mask,
census_timestamp *start_time) {
return NULL;
diff --git a/src/core/census/rpc_metric_id.h b/src/core/census/rpc_metric_id.h
index 1d8e8806f5..f199839511 100644
--- a/src/core/census/rpc_metric_id.h
+++ b/src/core/census/rpc_metric_id.h
@@ -36,16 +36,16 @@
/* Metric ID's used for RPC measurements. */
/* Count of client requests sent. */
-#define CENSUS_METRIC_RPC_CLIENT_REQUESTS ((gpr_uint32)0)
+#define CENSUS_METRIC_RPC_CLIENT_REQUESTS ((uint32_t)0)
/* Count of server requests sent. */
-#define CENSUS_METRIC_RPC_SERVER_REQUESTS ((gpr_uint32)1)
+#define CENSUS_METRIC_RPC_SERVER_REQUESTS ((uint32_t)1)
/* Client error counts. */
-#define CENSUS_METRIC_RPC_CLIENT_ERRORS ((gpr_uint32)2)
+#define CENSUS_METRIC_RPC_CLIENT_ERRORS ((uint32_t)2)
/* Server error counts. */
-#define CENSUS_METRIC_RPC_SERVER_ERRORS ((gpr_uint32)3)
+#define CENSUS_METRIC_RPC_SERVER_ERRORS ((uint32_t)3)
/* Client side request latency. */
-#define CENSUS_METRIC_RPC_CLIENT_LATENCY ((gpr_uint32)4)
+#define CENSUS_METRIC_RPC_CLIENT_LATENCY ((uint32_t)4)
/* Server side request latency. */
-#define CENSUS_METRIC_RPC_SERVER_LATENCY ((gpr_uint32)5)
+#define CENSUS_METRIC_RPC_SERVER_LATENCY ((uint32_t)5)
#endif /* CENSUS_RPC_METRIC_ID_H */
diff --git a/src/core/census/tracing.c b/src/core/census/tracing.c
index ae38773c0a..3b5d6dab2b 100644
--- a/src/core/census/tracing.c
+++ b/src/core/census/tracing.c
@@ -41,5 +41,5 @@ int census_trace_mask(const census_context *context) {
void census_set_trace_mask(int trace_mask) {}
-void census_trace_print(census_context *context, gpr_uint32 type,
+void census_trace_print(census_context *context, uint32_t type,
const char *buffer, size_t n) {}
diff --git a/src/core/channel/channel_stack.c b/src/core/channel/channel_stack.c
index 5e09a050ee..3e61688364 100644
--- a/src/core/channel/channel_stack.c
+++ b/src/core/channel/channel_stack.c
@@ -137,7 +137,7 @@ void grpc_channel_stack_init(grpc_exec_ctx *exec_ctx, int initial_refs,
}
GPR_ASSERT(user_data > (char *)stack);
- GPR_ASSERT((gpr_uintptr)(user_data - (char *)stack) ==
+ GPR_ASSERT((uintptr_t)(user_data - (char *)stack) ==
grpc_channel_stack_size(filters, filter_count));
stack->call_stack_size = call_size;
diff --git a/src/core/channel/compress_filter.c b/src/core/channel/compress_filter.c
index cc8e191628..3de1ef8a35 100644
--- a/src/core/channel/compress_filter.c
+++ b/src/core/channel/compress_filter.c
@@ -51,7 +51,7 @@ typedef struct call_data {
gpr_slice_buffer slices; /**< Buffers up input slices to be compressed */
grpc_linked_mdelem compression_algorithm_storage;
grpc_linked_mdelem accept_encoding_storage;
- gpr_uint32 remaining_slice_bytes;
+ uint32_t remaining_slice_bytes;
/** Compression algorithm we'll try to use. It may be given by incoming
* metadata, or by the channel's default compression settings. */
grpc_compression_algorithm compression_algorithm;
@@ -59,8 +59,8 @@ typedef struct call_data {
int has_compression_algorithm;
grpc_transport_stream_op send_op;
- gpr_uint32 send_length;
- gpr_uint32 send_flags;
+ uint32_t send_length;
+ uint32_t send_flags;
gpr_slice incoming_slice;
grpc_slice_buffer_stream replacement_stream;
grpc_closure *post_send;
@@ -74,7 +74,7 @@ typedef struct channel_data {
/** Compression options for the channel */
grpc_compression_options compression_options;
/** Supported compression algorithms */
- gpr_uint32 supported_compression_algorithms;
+ uint32_t supported_compression_algorithms;
} channel_data;
/** For each \a md element from the incoming metadata, filter out the entry for
@@ -262,7 +262,7 @@ static void init_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_compression_options_init(&channeld->compression_options);
channeld->compression_options.enabled_algorithms_bitset =
- (gpr_uint32)grpc_channel_args_compression_algorithm_get_states(
+ (uint32_t)grpc_channel_args_compression_algorithm_get_states(
args->channel_args);
channeld->default_compression_algorithm =
diff --git a/src/core/channel/http_server_filter.c b/src/core/channel/http_server_filter.c
index ae8660da92..a10b105494 100644
--- a/src/core/channel/http_server_filter.c
+++ b/src/core/channel/http_server_filter.c
@@ -40,12 +40,12 @@
#include "src/core/transport/static_metadata.h"
typedef struct call_data {
- gpr_uint8 seen_path;
- gpr_uint8 seen_post;
- gpr_uint8 sent_status;
- gpr_uint8 seen_scheme;
- gpr_uint8 seen_te_trailers;
- gpr_uint8 seen_authority;
+ uint8_t seen_path;
+ uint8_t seen_post;
+ uint8_t sent_status;
+ uint8_t seen_scheme;
+ uint8_t seen_te_trailers;
+ uint8_t seen_authority;
grpc_linked_mdelem status;
grpc_linked_mdelem content_type;
@@ -58,7 +58,7 @@ typedef struct call_data {
grpc_closure hs_on_recv;
} call_data;
-typedef struct channel_data { gpr_uint8 unused; } channel_data;
+typedef struct channel_data { uint8_t unused; } channel_data;
typedef struct {
grpc_call_element *elem;
diff --git a/src/core/channel/subchannel_call_holder.c b/src/core/channel/subchannel_call_holder.c
index f5da41f3cd..1e8f4ba1b6 100644
--- a/src/core/channel/subchannel_call_holder.c
+++ b/src/core/channel/subchannel_call_holder.c
@@ -155,7 +155,7 @@ retry:
holder->connected_subchannel != NULL) {
gpr_atm_rel_store(
&holder->subchannel_call,
- (gpr_atm)(gpr_uintptr)grpc_connected_subchannel_create_call(
+ (gpr_atm)(uintptr_t)grpc_connected_subchannel_create_call(
exec_ctx, holder->connected_subchannel, holder->pollset));
retry_waiting_locked(exec_ctx, holder);
goto retry;
@@ -180,7 +180,7 @@ static void subchannel_ready(grpc_exec_ctx *exec_ctx, void *arg, int success) {
} else {
gpr_atm_rel_store(
&holder->subchannel_call,
- (gpr_atm)(gpr_uintptr)grpc_connected_subchannel_create_call(
+ (gpr_atm)(uintptr_t)grpc_connected_subchannel_create_call(
exec_ctx, holder->connected_subchannel, holder->pollset));
retry_waiting_locked(exec_ctx, holder);
}
diff --git a/src/core/client_config/resolvers/sockaddr_resolver.c b/src/core/client_config/resolvers/sockaddr_resolver.c
index 81d6627ecc..6343259246 100644
--- a/src/core/client_config/resolvers/sockaddr_resolver.c
+++ b/src/core/client_config/resolvers/sockaddr_resolver.c
@@ -230,7 +230,7 @@ static int parse_ipv4(grpc_uri *uri, struct sockaddr_storage *addr,
gpr_log(GPR_ERROR, "invalid ipv4 port: '%s'", port);
goto done;
}
- in->sin_port = htons((gpr_uint16)port_num);
+ in->sin_port = htons((uint16_t)port_num);
} else {
gpr_log(GPR_ERROR, "no port given for ipv4 scheme");
goto done;
@@ -271,7 +271,7 @@ static int parse_ipv6(grpc_uri *uri, struct sockaddr_storage *addr,
gpr_log(GPR_ERROR, "invalid ipv6 port: '%s'", port);
goto done;
}
- in6->sin6_port = htons((gpr_uint16)port_num);
+ in6->sin6_port = htons((uint16_t)port_num);
} else {
gpr_log(GPR_ERROR, "no port given for ipv6 scheme");
goto done;
diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c
index 9a332c4d67..2992da8b79 100644
--- a/src/core/client_config/subchannel.c
+++ b/src/core/client_config/subchannel.c
@@ -131,7 +131,7 @@ struct grpc_subchannel {
/** our alarm */
grpc_timer alarm;
/** current random value */
- gpr_uint32 random;
+ uint32_t random;
};
struct grpc_subchannel_call {
@@ -272,8 +272,8 @@ void grpc_subchannel_weak_unref(grpc_exec_ctx *exec_ctx,
}
}
-static gpr_uint32 random_seed() {
- return (gpr_uint32)(gpr_time_to_millis(gpr_now(GPR_CLOCK_MONOTONIC)));
+static uint32_t random_seed() {
+ return (uint32_t)(gpr_time_to_millis(gpr_now(GPR_CLOCK_MONOTONIC)));
}
grpc_subchannel *grpc_subchannel_create(grpc_connector *connector,
@@ -541,15 +541,15 @@ static void publish_transport(grpc_exec_ctx *exec_ctx, grpc_subchannel *c) {
/* Generate a random number between 0 and 1. */
static double generate_uniform_random_number(grpc_subchannel *c) {
- c->random = (1103515245 * c->random + 12345) % ((gpr_uint32)1 << 31);
- return c->random / (double)((gpr_uint32)1 << 31);
+ c->random = (1103515245 * c->random + 12345) % ((uint32_t)1 << 31);
+ return c->random / (double)((uint32_t)1 << 31);
}
/* Update backoff_delta and next_attempt in subchannel */
static void update_reconnect_parameters(grpc_subchannel *c) {
size_t i;
- gpr_int32 backoff_delta_millis, jitter;
- gpr_int32 max_backoff_millis =
+ int32_t backoff_delta_millis, jitter;
+ int32_t max_backoff_millis =
GRPC_SUBCHANNEL_RECONNECT_MAX_BACKOFF_SECONDS * 1000;
double jitter_range;
@@ -567,8 +567,8 @@ static void update_reconnect_parameters(grpc_subchannel *c) {
}
backoff_delta_millis =
- (gpr_int32)(gpr_time_to_millis(c->backoff_delta) *
- GRPC_SUBCHANNEL_RECONNECT_BACKOFF_MULTIPLIER);
+ (int32_t)(gpr_time_to_millis(c->backoff_delta) *
+ GRPC_SUBCHANNEL_RECONNECT_BACKOFF_MULTIPLIER);
if (backoff_delta_millis > max_backoff_millis) {
backoff_delta_millis = max_backoff_millis;
}
@@ -578,7 +578,7 @@ static void update_reconnect_parameters(grpc_subchannel *c) {
jitter_range = GRPC_SUBCHANNEL_RECONNECT_JITTER * backoff_delta_millis;
jitter =
- (gpr_int32)((2 * generate_uniform_random_number(c) - 1) * jitter_range);
+ (int32_t)((2 * generate_uniform_random_number(c) - 1) * jitter_range);
c->next_attempt =
gpr_time_add(c->next_attempt, gpr_time_from_millis(jitter, GPR_TIMESPAN));
}
diff --git a/src/core/compression/algorithm.c b/src/core/compression/algorithm.c
index 8e4e5c91d4..6f3a8eb28e 100644
--- a/src/core/compression/algorithm.c
+++ b/src/core/compression/algorithm.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -139,9 +139,9 @@ grpc_compression_algorithm grpc_compression_algorithm_for_level(
case GRPC_COMPRESS_LEVEL_HIGH:
return GRPC_COMPRESS_DEFLATE;
default:
- break;
+ gpr_log(GPR_ERROR, "Unknown compression level %d.", (int)level);
+ abort();
}
- GPR_UNREACHABLE_CODE(return GRPC_COMPRESS_NONE);
}
void grpc_compression_options_init(grpc_compression_options *opts) {
diff --git a/src/core/httpcli/format_request.c b/src/core/httpcli/format_request.c
index 6189fce86b..04f2a2d99a 100644
--- a/src/core/httpcli/format_request.c
+++ b/src/core/httpcli/format_request.c
@@ -93,7 +93,7 @@ gpr_slice grpc_httpcli_format_post_request(const grpc_httpcli_request *request,
gpr_strvec_add(&out, gpr_strdup("POST "));
fill_common_header(request, &out);
if (body_bytes) {
- gpr_uint8 has_content_type = 0;
+ uint8_t has_content_type = 0;
for (i = 0; i < request->hdr_count; i++) {
if (strcmp(request->hdrs[i].key, "Content-Type") == 0) {
has_content_type = 1;
diff --git a/src/core/httpcli/httpcli_security_connector.c b/src/core/httpcli/httpcli_security_connector.c
index ba7cba25f9..41ad1de6c0 100644
--- a/src/core/httpcli/httpcli_security_connector.c
+++ b/src/core/httpcli/httpcli_security_connector.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -84,8 +84,7 @@ static void httpcli_ssl_do_handshake(grpc_exec_ctx *exec_ctx,
}
static void httpcli_ssl_check_peer(grpc_exec_ctx *exec_ctx,
- grpc_security_connector *sc,
- tsi_peer peer,
+ grpc_security_connector *sc, tsi_peer peer,
grpc_security_peer_check_cb cb,
void *user_data) {
grpc_httpcli_ssl_channel_security_connector *c =
diff --git a/src/core/httpcli/parser.c b/src/core/httpcli/parser.c
index 046770c094..c314f025a0 100644
--- a/src/core/httpcli/parser.c
+++ b/src/core/httpcli/parser.c
@@ -40,9 +40,9 @@
#include <grpc/support/useful.h>
static int handle_response_line(grpc_httpcli_parser *parser) {
- gpr_uint8 *beg = parser->cur_line;
- gpr_uint8 *cur = beg;
- gpr_uint8 *end = beg + parser->cur_line_length;
+ uint8_t *beg = parser->cur_line;
+ uint8_t *cur = beg;
+ uint8_t *end = beg + parser->cur_line_length;
if (cur == end || *cur++ != 'H') goto error;
if (cur == end || *cur++ != 'T') goto error;
@@ -77,9 +77,9 @@ static char *buf2str(void *buffer, size_t length) {
}
static int add_header(grpc_httpcli_parser *parser) {
- gpr_uint8 *beg = parser->cur_line;
- gpr_uint8 *cur = beg;
- gpr_uint8 *end = beg + parser->cur_line_length;
+ uint8_t *beg = parser->cur_line;
+ uint8_t *cur = beg;
+ uint8_t *end = beg + parser->cur_line_length;
grpc_httpcli_header hdr = {NULL, NULL};
GPR_ASSERT(cur != end);
@@ -146,7 +146,7 @@ static int finish_line(grpc_httpcli_parser *parser) {
return 1;
}
-static int addbyte(grpc_httpcli_parser *parser, gpr_uint8 byte) {
+static int addbyte(grpc_httpcli_parser *parser, uint8_t byte) {
switch (parser->state) {
case GRPC_HTTPCLI_INITIAL_RESPONSE:
case GRPC_HTTPCLI_HEADERS:
diff --git a/src/core/httpcli/parser.h b/src/core/httpcli/parser.h
index 40b28f0ee8..cd0383637f 100644
--- a/src/core/httpcli/parser.h
+++ b/src/core/httpcli/parser.h
@@ -51,7 +51,7 @@ typedef struct {
size_t body_capacity;
size_t hdr_capacity;
- gpr_uint8 cur_line[GRPC_HTTPCLI_MAX_HEADER_LENGTH];
+ uint8_t cur_line[GRPC_HTTPCLI_MAX_HEADER_LENGTH];
size_t cur_line_length;
} grpc_httpcli_parser;
diff --git a/src/core/iomgr/closure.c b/src/core/iomgr/closure.c
index 4aae52a454..7646a88ac5 100644
--- a/src/core/iomgr/closure.c
+++ b/src/core/iomgr/closure.c
@@ -49,7 +49,7 @@ void grpc_closure_list_add(grpc_closure_list *closure_list,
if (closure_list->head == NULL) {
closure_list->head = closure;
} else {
- closure_list->tail->final_data |= (gpr_uintptr)closure;
+ closure_list->tail->final_data |= (uintptr_t)closure;
}
closure_list->tail = closure;
}
@@ -65,7 +65,7 @@ void grpc_closure_list_move(grpc_closure_list *src, grpc_closure_list *dst) {
if (dst->head == NULL) {
*dst = *src;
} else {
- dst->tail->final_data |= (gpr_uintptr)src->head;
+ dst->tail->final_data |= (uintptr_t)src->head;
dst->tail = src->tail;
}
src->head = src->tail = NULL;
@@ -94,5 +94,5 @@ grpc_closure *grpc_closure_create(grpc_iomgr_cb_func cb, void *cb_arg) {
}
grpc_closure *grpc_closure_next(grpc_closure *closure) {
- return (grpc_closure *)(closure->final_data & ~(gpr_uintptr)1);
+ return (grpc_closure *)(closure->final_data & ~(uintptr_t)1);
}
diff --git a/src/core/iomgr/closure.h b/src/core/iomgr/closure.h
index a1d738bf5a..98ef91e1db 100644
--- a/src/core/iomgr/closure.h
+++ b/src/core/iomgr/closure.h
@@ -67,7 +67,7 @@ struct grpc_closure {
/** Once enqueued, contains in the lower bit the success of the closure,
and in the upper bits the pointer to the next closure in the list.
Before enqueing for execution, this is usable for scratch data. */
- gpr_uintptr final_data;
+ uintptr_t final_data;
};
/** Initializes \a closure with \a cb and \a cb_arg. */
diff --git a/src/core/iomgr/exec_ctx.c b/src/core/iomgr/exec_ctx.c
index e95eaf267a..6059a6031c 100644
--- a/src/core/iomgr/exec_ctx.c
+++ b/src/core/iomgr/exec_ctx.c
@@ -45,7 +45,7 @@ int grpc_exec_ctx_flush(grpc_exec_ctx *exec_ctx) {
exec_ctx->closure_list.head = exec_ctx->closure_list.tail = NULL;
while (c != NULL) {
int success = (int)(c->final_data & 1);
- grpc_closure *next = (grpc_closure *)(c->final_data & ~(gpr_uintptr)1);
+ grpc_closure *next = (grpc_closure *)(c->final_data & ~(uintptr_t)1);
did_something++;
GPR_TIMER_BEGIN("grpc_exec_ctx_flush.cb", 0);
c->cb(exec_ctx, c->cb_arg, success);
diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c
index 00710d83bd..917307a4c0 100644
--- a/src/core/iomgr/fd_posix.c
+++ b/src/core/iomgr/fd_posix.c
@@ -101,6 +101,7 @@ static grpc_fd *alloc_fd(int fd) {
r->read_watcher = r->write_watcher = NULL;
r->on_done_closure = NULL;
r->closed = 0;
+ r->released = 0;
return r;
}
@@ -210,6 +211,14 @@ static int has_watchers(grpc_fd *fd) {
fd->inactive_watcher_root.next != &fd->inactive_watcher_root;
}
+int grpc_fd_wrapped_fd(grpc_fd *fd) {
+ if (fd->released || fd->closed) {
+ return -1;
+ } else {
+ return fd->fd;
+ }
+}
+
void grpc_fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_closure *on_done,
int *release_fd, const char *reason) {
fd->on_done_closure = on_done;
@@ -318,10 +327,10 @@ void grpc_fd_notify_on_write(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
gpr_mu_unlock(&fd->mu);
}
-gpr_uint32 grpc_fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset,
- grpc_pollset_worker *worker, gpr_uint32 read_mask,
- gpr_uint32 write_mask, grpc_fd_watcher *watcher) {
- gpr_uint32 mask = 0;
+uint32_t grpc_fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset,
+ grpc_pollset_worker *worker, uint32_t read_mask,
+ uint32_t write_mask, grpc_fd_watcher *watcher) {
+ uint32_t mask = 0;
grpc_closure *cur;
int requested;
/* keep track of pollers that have requested our events, in case they change
diff --git a/src/core/iomgr/fd_posix.h b/src/core/iomgr/fd_posix.h
index df4eb64d4c..8062dd01db 100644
--- a/src/core/iomgr/fd_posix.h
+++ b/src/core/iomgr/fd_posix.h
@@ -105,6 +105,9 @@ struct grpc_fd {
This takes ownership of closing fd. */
grpc_fd *grpc_fd_create(int fd, const char *name);
+/* Return the wrapped fd, or -1 if it has been released or closed. */
+int grpc_fd_wrapped_fd(grpc_fd *fd);
+
/* Releases fd to be asynchronously destroyed.
on_done is called when the underlying file descriptor is definitely close()d.
If on_done is NULL, no callback will be made.
@@ -126,9 +129,9 @@ void grpc_fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_closure *on_done,
Polling strategies that do not need to alter their behavior depending on the
fd's current interest (such as epoll) do not need to call this function.
MUST NOT be called with a pollset lock taken */
-gpr_uint32 grpc_fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset,
- grpc_pollset_worker *worker, gpr_uint32 read_mask,
- gpr_uint32 write_mask, grpc_fd_watcher *rec);
+uint32_t grpc_fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset,
+ grpc_pollset_worker *worker, uint32_t read_mask,
+ uint32_t write_mask, grpc_fd_watcher *rec);
/* Complete polling previously started with grpc_fd_begin_poll
MUST NOT be called with a pollset lock taken
if got_read or got_write are 1, also does the become_{readable,writable} as
diff --git a/src/core/iomgr/iocp_windows.c b/src/core/iomgr/iocp_windows.c
index 65da3a9d2d..d3868ce62c 100644
--- a/src/core/iomgr/iocp_windows.c
+++ b/src/core/iomgr/iocp_windows.c
@@ -160,7 +160,7 @@ void grpc_iocp_add_socket(grpc_winsocket *socket) {
HANDLE ret;
if (socket->added_to_iocp) return;
ret = CreateIoCompletionPort((HANDLE)socket->socket, g_iocp,
- (gpr_uintptr)socket, 0);
+ (uintptr_t)socket, 0);
if (!ret) {
char *utf8_message = gpr_format_message(WSAGetLastError());
gpr_log(GPR_ERROR, "Unable to add socket to iocp: %s", utf8_message);
diff --git a/src/core/iomgr/pollset_multipoller_with_poll_posix.c b/src/core/iomgr/pollset_multipoller_with_poll_posix.c
index b619b8c3db..a7282b9896 100644
--- a/src/core/iomgr/pollset_multipoller_with_poll_posix.c
+++ b/src/core/iomgr/pollset_multipoller_with_poll_posix.c
@@ -144,7 +144,9 @@ static void multipoll_with_poll_pollset_maybe_work_and_unlock(
GRPC_SCHEDULING_END_BLOCKING_REGION;
if (r < 0) {
- gpr_log(GPR_ERROR, "poll() failed: %s", strerror(errno));
+ if (errno != EINTR) {
+ gpr_log(GPR_ERROR, "poll() failed: %s", strerror(errno));
+ }
for (i = 2; i < pfd_count; i++) {
grpc_fd_end_poll(exec_ctx, &watchers[i], 0, 0);
}
diff --git a/src/core/iomgr/pollset_posix.c b/src/core/iomgr/pollset_posix.c
index 9195344758..c325b634ae 100644
--- a/src/core/iomgr/pollset_posix.c
+++ b/src/core/iomgr/pollset_posix.c
@@ -100,7 +100,7 @@ static void push_front_worker(grpc_pollset *p, grpc_pollset_worker *worker) {
void grpc_pollset_kick_ext(grpc_pollset *p,
grpc_pollset_worker *specific_worker,
- gpr_uint32 flags) {
+ uint32_t flags) {
GPR_TIMER_BEGIN("grpc_pollset_kick_ext", 0);
/* pollset->mu already held */
@@ -116,7 +116,7 @@ void grpc_pollset_kick_ext(grpc_pollset *p,
p->kicked_without_pollers = 1;
GPR_TIMER_END("grpc_pollset_kick_ext.broadcast", 0);
} else if (gpr_tls_get(&g_current_thread_worker) !=
- (gpr_intptr)specific_worker) {
+ (intptr_t)specific_worker) {
GPR_TIMER_MARK("different_thread_worker", 0);
if ((flags & GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) != 0) {
specific_worker->reevaluate_polling_on_wakeup = 1;
@@ -131,19 +131,18 @@ void grpc_pollset_kick_ext(grpc_pollset *p,
specific_worker->kicked_specifically = 1;
grpc_wakeup_fd_wakeup(&specific_worker->wakeup_fd->fd);
}
- } else if (gpr_tls_get(&g_current_thread_poller) != (gpr_intptr)p) {
+ } else if (gpr_tls_get(&g_current_thread_poller) != (intptr_t)p) {
GPR_ASSERT((flags & GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) == 0);
GPR_TIMER_MARK("kick_anonymous", 0);
specific_worker = pop_front_worker(p);
if (specific_worker != NULL) {
- if (gpr_tls_get(&g_current_thread_worker) ==
- (gpr_intptr)specific_worker) {
+ if (gpr_tls_get(&g_current_thread_worker) == (intptr_t)specific_worker) {
GPR_TIMER_MARK("kick_anonymous_not_self", 0);
push_back_worker(p, specific_worker);
specific_worker = pop_front_worker(p);
if ((flags & GRPC_POLLSET_CAN_KICK_SELF) == 0 &&
gpr_tls_get(&g_current_thread_worker) ==
- (gpr_intptr)specific_worker) {
+ (intptr_t)specific_worker) {
push_back_worker(p, specific_worker);
specific_worker = NULL;
}
@@ -307,9 +306,9 @@ void grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
if (!added_worker) {
push_front_worker(pollset, worker);
added_worker = 1;
- gpr_tls_set(&g_current_thread_worker, (gpr_intptr)worker);
+ gpr_tls_set(&g_current_thread_worker, (intptr_t)worker);
}
- gpr_tls_set(&g_current_thread_poller, (gpr_intptr)pollset);
+ gpr_tls_set(&g_current_thread_poller, (intptr_t)pollset);
GPR_TIMER_BEGIN("maybe_work_and_unlock", 0);
pollset->vtable->maybe_work_and_unlock(exec_ctx, pollset, worker,
deadline, now);
diff --git a/src/core/iomgr/pollset_posix.h b/src/core/iomgr/pollset_posix.h
index 29de4a2026..78fc27d2b3 100644
--- a/src/core/iomgr/pollset_posix.h
+++ b/src/core/iomgr/pollset_posix.h
@@ -122,7 +122,7 @@ int grpc_poll_deadline_to_millis_timeout(gpr_timespec deadline,
-- mostly for fd_posix's use. */
void grpc_pollset_kick_ext(grpc_pollset *p,
grpc_pollset_worker *specific_worker,
- gpr_uint32 flags);
+ uint32_t flags);
/* turn a pollset into a multipoller: platform specific */
typedef void (*grpc_platform_become_multipoller_type)(grpc_exec_ctx *exec_ctx,
diff --git a/src/core/iomgr/sockaddr_utils.c b/src/core/iomgr/sockaddr_utils.c
index 511a5d5c59..61006d7a7a 100644
--- a/src/core/iomgr/sockaddr_utils.c
+++ b/src/core/iomgr/sockaddr_utils.c
@@ -48,8 +48,8 @@
#include "src/core/support/string.h"
-static const gpr_uint8 kV4MappedPrefix[] = {0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xff, 0xff};
+static const uint8_t kV4MappedPrefix[] = {0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xff, 0xff};
int grpc_sockaddr_is_v4mapped(const struct sockaddr *addr,
struct sockaddr_in *addr4_out) {
@@ -126,14 +126,14 @@ void grpc_sockaddr_make_wildcard4(int port, struct sockaddr_in *wild_out) {
GPR_ASSERT(port >= 0 && port < 65536);
memset(wild_out, 0, sizeof(*wild_out));
wild_out->sin_family = AF_INET;
- wild_out->sin_port = htons((gpr_uint16)port);
+ wild_out->sin_port = htons((uint16_t)port);
}
void grpc_sockaddr_make_wildcard6(int port, struct sockaddr_in6 *wild_out) {
GPR_ASSERT(port >= 0 && port < 65536);
memset(wild_out, 0, sizeof(*wild_out));
wild_out->sin6_family = AF_INET6;
- wild_out->sin6_port = htons((gpr_uint16)port);
+ wild_out->sin6_port = htons((uint16_t)port);
}
int grpc_sockaddr_to_string(char **out, const struct sockaddr *addr,
@@ -220,11 +220,11 @@ int grpc_sockaddr_set_port(const struct sockaddr *addr, int port) {
switch (addr->sa_family) {
case AF_INET:
GPR_ASSERT(port >= 0 && port < 65536);
- ((struct sockaddr_in *)addr)->sin_port = htons((gpr_uint16)port);
+ ((struct sockaddr_in *)addr)->sin_port = htons((uint16_t)port);
return 1;
case AF_INET6:
GPR_ASSERT(port >= 0 && port < 65536);
- ((struct sockaddr_in6 *)addr)->sin6_port = htons((gpr_uint16)port);
+ ((struct sockaddr_in6 *)addr)->sin6_port = htons((uint16_t)port);
return 1;
default:
gpr_log(GPR_ERROR, "Unknown socket family %d in grpc_sockaddr_set_port",
diff --git a/src/core/iomgr/tcp_posix.c b/src/core/iomgr/tcp_posix.c
index f3be41aa57..65783a7afa 100644
--- a/src/core/iomgr/tcp_posix.c
+++ b/src/core/iomgr/tcp_posix.c
@@ -473,6 +473,12 @@ grpc_endpoint *grpc_tcp_create(grpc_fd *em_fd, size_t slice_size,
return &tcp->base;
}
+int grpc_tcp_fd(grpc_endpoint *ep) {
+ grpc_tcp *tcp = (grpc_tcp *)ep;
+ GPR_ASSERT(ep->vtable == &vtable);
+ return grpc_fd_wrapped_fd(tcp->em_fd);
+}
+
void grpc_tcp_destroy_and_release_fd(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
int *fd, grpc_closure *done) {
grpc_tcp *tcp = (grpc_tcp *)ep;
diff --git a/src/core/iomgr/tcp_posix.h b/src/core/iomgr/tcp_posix.h
index b554983ae1..495ed009c8 100644
--- a/src/core/iomgr/tcp_posix.h
+++ b/src/core/iomgr/tcp_posix.h
@@ -56,6 +56,12 @@ extern int grpc_tcp_trace;
grpc_endpoint *grpc_tcp_create(grpc_fd *fd, size_t read_slice_size,
const char *peer_string);
+/* Return the tcp endpoint's fd, or -1 if this is not available. Does not
+ release the fd.
+ Requires: ep must be a tcp endpoint.
+ */
+int grpc_tcp_fd(grpc_endpoint *ep);
+
/* Destroy the tcp endpoint without closing its fd. *fd will be set and done
* will be called when the endpoint is destroyed.
* Requires: ep must be a tcp endpoint and fd must not be NULL. */
diff --git a/src/core/iomgr/tcp_server_posix.c b/src/core/iomgr/tcp_server_posix.c
index 835675c390..49e83cf6ae 100644
--- a/src/core/iomgr/tcp_server_posix.c
+++ b/src/core/iomgr/tcp_server_posix.c
@@ -78,7 +78,7 @@ struct grpc_tcp_listener {
grpc_fd *emfd;
grpc_tcp_server *server;
union {
- gpr_uint8 untyped[GRPC_MAX_SOCKADDR_SIZE];
+ uint8_t untyped[GRPC_MAX_SOCKADDR_SIZE];
struct sockaddr sockaddr;
struct sockaddr_un un;
} addr;
diff --git a/src/core/iomgr/tcp_server_windows.c b/src/core/iomgr/tcp_server_windows.c
index 583cab4890..d38fd8860a 100644
--- a/src/core/iomgr/tcp_server_windows.c
+++ b/src/core/iomgr/tcp_server_windows.c
@@ -58,7 +58,7 @@
struct grpc_tcp_listener {
/* This seemingly magic number comes from AcceptEx's documentation. each
address buffer needs to have at least 16 more bytes at their end. */
- gpr_uint8 addresses[(sizeof(struct sockaddr_in6) + 16) * 2];
+ uint8_t addresses[(sizeof(struct sockaddr_in6) + 16) * 2];
/* This will hold the socket for the next accept. */
SOCKET new_socket;
/* The listener winsocket. */
diff --git a/src/core/iomgr/timer.c b/src/core/iomgr/timer.c
index bbf9800049..24d6204e07 100644
--- a/src/core/iomgr/timer.c
+++ b/src/core/iomgr/timer.c
@@ -55,7 +55,7 @@ typedef struct {
gpr_timespec queue_deadline_cap;
gpr_timespec min_deadline;
/* Index in the g_shard_queue */
- gpr_uint32 shard_queue_index;
+ uint32_t shard_queue_index;
/* This holds all timers with deadlines < queue_deadline_cap. Timers in this
list have the top bit of their deadline set to 0. */
grpc_timer_heap heap;
@@ -82,7 +82,7 @@ static gpr_timespec compute_min_deadline(shard_type *shard) {
}
void grpc_timer_list_init(gpr_timespec now) {
- gpr_uint32 i;
+ uint32_t i;
gpr_mu_init(&g_mu);
gpr_mu_init(&g_checker_mu);
@@ -126,8 +126,8 @@ static double ts_to_dbl(gpr_timespec ts) {
static gpr_timespec dbl_to_ts(double d) {
gpr_timespec ts;
- ts.tv_sec = (gpr_int64)d;
- ts.tv_nsec = (gpr_int32)(1e9 * (d - (double)ts.tv_sec));
+ ts.tv_sec = (int64_t)d;
+ ts.tv_nsec = (int32_t)(1e9 * (d - (double)ts.tv_sec));
ts.clock_type = GPR_TIMESPAN;
return ts;
}
@@ -143,7 +143,7 @@ static void list_remove(grpc_timer *timer) {
timer->prev->next = timer->next;
}
-static void swap_adjacent_shards_in_queue(gpr_uint32 first_shard_queue_index) {
+static void swap_adjacent_shards_in_queue(uint32_t first_shard_queue_index) {
shard_type *temp;
temp = g_shard_queue[first_shard_queue_index];
g_shard_queue[first_shard_queue_index] =
diff --git a/src/core/iomgr/timer.h b/src/core/iomgr/timer.h
index 9abe58133d..720c9d5ab9 100644
--- a/src/core/iomgr/timer.h
+++ b/src/core/iomgr/timer.h
@@ -41,7 +41,7 @@
typedef struct grpc_timer {
gpr_timespec deadline;
- gpr_uint32 heap_index; /* INVALID_HEAP_INDEX if not in heap */
+ uint32_t heap_index; /* INVALID_HEAP_INDEX if not in heap */
int triggered;
struct grpc_timer *next;
struct grpc_timer *prev;
diff --git a/src/core/iomgr/timer_heap.c b/src/core/iomgr/timer_heap.c
index 31d41d6750..9d8be5c1fc 100644
--- a/src/core/iomgr/timer_heap.c
+++ b/src/core/iomgr/timer_heap.c
@@ -43,9 +43,9 @@
position. This functor is called each time immediately after modifying a
value in the underlying container, with the offset of the modified element as
its argument. */
-static void adjust_upwards(grpc_timer **first, gpr_uint32 i, grpc_timer *t) {
+static void adjust_upwards(grpc_timer **first, uint32_t i, grpc_timer *t) {
while (i > 0) {
- gpr_uint32 parent = (gpr_uint32)(((int)i - 1) / 2);
+ uint32_t parent = (uint32_t)(((int)i - 1) / 2);
if (gpr_time_cmp(first[parent]->deadline, t->deadline) >= 0) break;
first[i] = first[parent];
first[i]->heap_index = i;
@@ -58,12 +58,12 @@ static void adjust_upwards(grpc_timer **first, gpr_uint32 i, grpc_timer *t) {
/* Adjusts a heap so as to move a hole at position i farther away from the root,
until a suitable position is found for element t. Then, copies t into that
position. */
-static void adjust_downwards(grpc_timer **first, gpr_uint32 i,
- gpr_uint32 length, grpc_timer *t) {
+static void adjust_downwards(grpc_timer **first, uint32_t i, uint32_t length,
+ grpc_timer *t) {
for (;;) {
- gpr_uint32 left_child = 1u + 2u * i;
- gpr_uint32 right_child;
- gpr_uint32 next_i;
+ uint32_t left_child = 1u + 2u * i;
+ uint32_t right_child;
+ uint32_t next_i;
if (left_child >= length) break;
right_child = left_child + 1;
next_i = right_child < length &&
@@ -93,8 +93,8 @@ static void maybe_shrink(grpc_timer_heap *heap) {
}
static void note_changed_priority(grpc_timer_heap *heap, grpc_timer *timer) {
- gpr_uint32 i = timer->heap_index;
- gpr_uint32 parent = (gpr_uint32)(((int)i - 1) / 2);
+ uint32_t i = timer->heap_index;
+ uint32_t parent = (uint32_t)(((int)i - 1) / 2);
if (gpr_time_cmp(heap->timers[parent]->deadline, timer->deadline) < 0) {
adjust_upwards(heap->timers, i, timer);
} else {
@@ -122,7 +122,7 @@ int grpc_timer_heap_add(grpc_timer_heap *heap, grpc_timer *timer) {
}
void grpc_timer_heap_remove(grpc_timer_heap *heap, grpc_timer *timer) {
- gpr_uint32 i = timer->heap_index;
+ uint32_t i = timer->heap_index;
if (i == heap->timer_count - 1) {
heap->timer_count--;
maybe_shrink(heap);
diff --git a/src/core/iomgr/timer_heap.h b/src/core/iomgr/timer_heap.h
index cd5258f93e..2d220f1677 100644
--- a/src/core/iomgr/timer_heap.h
+++ b/src/core/iomgr/timer_heap.h
@@ -38,8 +38,8 @@
typedef struct {
grpc_timer **timers;
- gpr_uint32 timer_count;
- gpr_uint32 timer_capacity;
+ uint32_t timer_count;
+ uint32_t timer_capacity;
} grpc_timer_heap;
/* return 1 if the new timer is the first timer in the heap */
diff --git a/src/core/iomgr/udp_server.c b/src/core/iomgr/udp_server.c
index 28f1bfae26..a1a6b04cad 100644
--- a/src/core/iomgr/udp_server.c
+++ b/src/core/iomgr/udp_server.c
@@ -75,7 +75,7 @@ typedef struct {
grpc_fd *emfd;
grpc_udp_server *server;
union {
- gpr_uint8 untyped[GRPC_MAX_SOCKADDR_SIZE];
+ uint8_t untyped[GRPC_MAX_SOCKADDR_SIZE];
struct sockaddr sockaddr;
struct sockaddr_un un;
} addr;
diff --git a/src/core/json/json_reader.c b/src/core/json/json_reader.c
index 256995240a..30da6f28f3 100644
--- a/src/core/json/json_reader.c
+++ b/src/core/json/json_reader.c
@@ -43,17 +43,16 @@ static void json_reader_string_clear(grpc_json_reader *reader) {
reader->vtable->string_clear(reader->userdata);
}
-static void json_reader_string_add_char(grpc_json_reader *reader,
- gpr_uint32 c) {
+static void json_reader_string_add_char(grpc_json_reader *reader, uint32_t c) {
reader->vtable->string_add_char(reader->userdata, c);
}
static void json_reader_string_add_utf32(grpc_json_reader *reader,
- gpr_uint32 utf32) {
+ uint32_t utf32) {
reader->vtable->string_add_utf32(reader->userdata, utf32);
}
-static gpr_uint32 grpc_json_reader_read_char(grpc_json_reader *reader) {
+static uint32_t grpc_json_reader_read_char(grpc_json_reader *reader) {
return reader->vtable->read_char(reader->userdata);
}
@@ -108,7 +107,7 @@ int grpc_json_reader_is_complete(grpc_json_reader *reader) {
}
grpc_json_reader_status grpc_json_reader_run(grpc_json_reader *reader) {
- gpr_uint32 c, success;
+ uint32_t c, success;
/* This state-machine is a strict implementation of ECMA-404 */
for (;;) {
@@ -154,7 +153,7 @@ grpc_json_reader_status grpc_json_reader_run(grpc_json_reader *reader) {
case GRPC_JSON_STATE_VALUE_NUMBER_WITH_DECIMAL:
case GRPC_JSON_STATE_VALUE_NUMBER_ZERO:
case GRPC_JSON_STATE_VALUE_NUMBER_EPM:
- success = (gpr_uint32)json_reader_set_number(reader);
+ success = (uint32_t)json_reader_set_number(reader);
if (!success) return GRPC_JSON_PARSE_ERROR;
json_reader_string_clear(reader);
reader->state = GRPC_JSON_STATE_VALUE_END;
@@ -181,7 +180,7 @@ grpc_json_reader_status grpc_json_reader_run(grpc_json_reader *reader) {
case GRPC_JSON_STATE_VALUE_NUMBER_WITH_DECIMAL:
case GRPC_JSON_STATE_VALUE_NUMBER_ZERO:
case GRPC_JSON_STATE_VALUE_NUMBER_EPM:
- success = (gpr_uint32)json_reader_set_number(reader);
+ success = (uint32_t)json_reader_set_number(reader);
if (!success) return GRPC_JSON_PARSE_ERROR;
json_reader_string_clear(reader);
reader->state = GRPC_JSON_STATE_VALUE_END;
@@ -416,8 +415,8 @@ grpc_json_reader_status grpc_json_reader_run(grpc_json_reader *reader) {
} else {
return GRPC_JSON_PARSE_ERROR;
}
- reader->unicode_char = (gpr_uint16)(reader->unicode_char << 4);
- reader->unicode_char = (gpr_uint16)(reader->unicode_char | c);
+ reader->unicode_char = (uint16_t)(reader->unicode_char << 4);
+ reader->unicode_char = (uint16_t)(reader->unicode_char | c);
switch (reader->state) {
case GRPC_JSON_STATE_STRING_ESCAPE_U1:
@@ -440,13 +439,13 @@ grpc_json_reader_status grpc_json_reader_run(grpc_json_reader *reader) {
reader->unicode_high_surrogate = reader->unicode_char;
} else if ((reader->unicode_char & 0xfc00) == 0xdc00) {
/* low surrogate utf-16 */
- gpr_uint32 utf32;
+ uint32_t utf32;
if (reader->unicode_high_surrogate == 0)
return GRPC_JSON_PARSE_ERROR;
utf32 = 0x10000;
- utf32 += (gpr_uint32)(
+ utf32 += (uint32_t)(
(reader->unicode_high_surrogate - 0xd800) * 0x400);
- utf32 += (gpr_uint32)(reader->unicode_char - 0xdc00);
+ utf32 += (uint32_t)(reader->unicode_char - 0xdc00);
json_reader_string_add_utf32(reader, utf32);
reader->unicode_high_surrogate = 0;
} else {
diff --git a/src/core/json/json_reader.h b/src/core/json/json_reader.h
index 417db110cf..90b9f1f9fe 100644
--- a/src/core/json/json_reader.h
+++ b/src/core/json/json_reader.h
@@ -84,11 +84,11 @@ typedef struct grpc_json_reader_vtable {
/* Clears your internal string scratchpad. */
void (*string_clear)(void *userdata);
/* Adds a char to the string scratchpad. */
- void (*string_add_char)(void *userdata, gpr_uint32 c);
+ void (*string_add_char)(void *userdata, uint32_t c);
/* Adds a utf32 char to the string scratchpad. */
- void (*string_add_utf32)(void *userdata, gpr_uint32 c);
+ void (*string_add_utf32)(void *userdata, uint32_t c);
/* Reads a character from your input. May be utf-8, 16 or 32. */
- gpr_uint32 (*read_char)(void *userdata);
+ uint32_t (*read_char)(void *userdata);
/* Starts a container of type GRPC_JSON_ARRAY or GRPC_JSON_OBJECT. */
void (*container_begins)(void *userdata, grpc_json_type type);
/* Ends the current container. Must return the type of its parent. */
@@ -117,7 +117,7 @@ typedef struct grpc_json_reader {
int in_array;
int escaped_string_was_key;
int container_just_begun;
- gpr_uint16 unicode_char, unicode_high_surrogate;
+ uint16_t unicode_char, unicode_high_surrogate;
grpc_json_reader_state state;
} grpc_json_reader;
diff --git a/src/core/json/json_string.c b/src/core/json/json_string.c
index 06c157dc98..2bc0b513d5 100644
--- a/src/core/json/json_string.c
+++ b/src/core/json/json_string.c
@@ -56,10 +56,10 @@ typedef struct {
grpc_json *top;
grpc_json *current_container;
grpc_json *current_value;
- gpr_uint8 *input;
- gpr_uint8 *key;
- gpr_uint8 *string;
- gpr_uint8 *string_ptr;
+ uint8_t *input;
+ uint8_t *key;
+ uint8_t *string;
+ uint8_t *string_ptr;
size_t remaining_input;
} json_reader_userdata;
@@ -122,36 +122,36 @@ static void json_reader_string_clear(void *userdata) {
state->string = state->string_ptr;
}
-static void json_reader_string_add_char(void *userdata, gpr_uint32 c) {
+static void json_reader_string_add_char(void *userdata, uint32_t c) {
json_reader_userdata *state = userdata;
GPR_ASSERT(state->string_ptr < state->input);
GPR_ASSERT(c <= 0xff);
- *state->string_ptr++ = (gpr_uint8)c;
+ *state->string_ptr++ = (uint8_t)c;
}
/* We are converting a UTF-32 character into UTF-8 here,
* as described by RFC3629.
*/
-static void json_reader_string_add_utf32(void *userdata, gpr_uint32 c) {
+static void json_reader_string_add_utf32(void *userdata, uint32_t c) {
if (c <= 0x7f) {
json_reader_string_add_char(userdata, c);
} else if (c <= 0x7ff) {
- gpr_uint32 b1 = 0xc0 | ((c >> 6) & 0x1f);
- gpr_uint32 b2 = 0x80 | (c & 0x3f);
+ uint32_t b1 = 0xc0 | ((c >> 6) & 0x1f);
+ uint32_t b2 = 0x80 | (c & 0x3f);
json_reader_string_add_char(userdata, b1);
json_reader_string_add_char(userdata, b2);
} else if (c <= 0xffff) {
- gpr_uint32 b1 = 0xe0 | ((c >> 12) & 0x0f);
- gpr_uint32 b2 = 0x80 | ((c >> 6) & 0x3f);
- gpr_uint32 b3 = 0x80 | (c & 0x3f);
+ uint32_t b1 = 0xe0 | ((c >> 12) & 0x0f);
+ uint32_t b2 = 0x80 | ((c >> 6) & 0x3f);
+ uint32_t b3 = 0x80 | (c & 0x3f);
json_reader_string_add_char(userdata, b1);
json_reader_string_add_char(userdata, b2);
json_reader_string_add_char(userdata, b3);
} else if (c <= 0x1fffff) {
- gpr_uint32 b1 = 0xf0 | ((c >> 18) & 0x07);
- gpr_uint32 b2 = 0x80 | ((c >> 12) & 0x3f);
- gpr_uint32 b3 = 0x80 | ((c >> 6) & 0x3f);
- gpr_uint32 b4 = 0x80 | (c & 0x3f);
+ uint32_t b1 = 0xf0 | ((c >> 18) & 0x07);
+ uint32_t b2 = 0x80 | ((c >> 12) & 0x3f);
+ uint32_t b3 = 0x80 | ((c >> 6) & 0x3f);
+ uint32_t b4 = 0x80 | (c & 0x3f);
json_reader_string_add_char(userdata, b1);
json_reader_string_add_char(userdata, b2);
json_reader_string_add_char(userdata, b3);
@@ -162,8 +162,8 @@ static void json_reader_string_add_utf32(void *userdata, gpr_uint32 c) {
/* We consider that the input may be a zero-terminated string. So we
* can end up hitting eof before the end of the alleged string length.
*/
-static gpr_uint32 json_reader_read_char(void *userdata) {
- gpr_uint32 r;
+static uint32_t json_reader_read_char(void *userdata) {
+ uint32_t r;
json_reader_userdata *state = userdata;
if (state->remaining_input == 0) return GRPC_JSON_READ_CHAR_EOF;
@@ -302,7 +302,7 @@ grpc_json *grpc_json_parse_string_with_len(char *input, size_t size) {
state.top = state.current_container = state.current_value = NULL;
state.string = state.key = NULL;
- state.string_ptr = state.input = (gpr_uint8 *)input;
+ state.string_ptr = state.input = (uint8_t *)input;
state.remaining_input = size;
grpc_json_reader_init(&reader, &reader_vtable, &state);
diff --git a/src/core/json/json_writer.c b/src/core/json/json_writer.c
index e0d02f411e..326ec2d431 100644
--- a/src/core/json/json_writer.c
+++ b/src/core/json/json_writer.c
@@ -100,8 +100,7 @@ static void json_writer_value_end(grpc_json_writer *writer) {
}
}
-static void json_writer_escape_utf16(grpc_json_writer *writer,
- gpr_uint16 utf16) {
+static void json_writer_escape_utf16(grpc_json_writer *writer, uint16_t utf16) {
static const char hex[] = "0123456789abcdef";
json_writer_output_string_with_len(writer, "\\u", 2);
@@ -116,7 +115,7 @@ static void json_writer_escape_string(grpc_json_writer *writer,
json_writer_output_char(writer, '"');
for (;;) {
- gpr_uint8 c = (gpr_uint8)*string++;
+ uint8_t c = (uint8_t)*string++;
if (c == 0) {
break;
} else if ((c >= 32) && (c <= 126)) {
@@ -144,7 +143,7 @@ static void json_writer_escape_string(grpc_json_writer *writer,
break;
}
} else {
- gpr_uint32 utf32 = 0;
+ uint32_t utf32 = 0;
int extra = 0;
int i;
int valid = 1;
@@ -162,7 +161,7 @@ static void json_writer_escape_string(grpc_json_writer *writer,
}
for (i = 0; i < extra; i++) {
utf32 <<= 6;
- c = (gpr_uint8)(*string++);
+ c = (uint8_t)(*string++);
/* Breaks out and bail on any invalid UTF-8 sequence, including \0. */
if ((c & 0xc0) != 0x80) {
valid = 0;
@@ -195,11 +194,10 @@ static void json_writer_escape_string(grpc_json_writer *writer,
* That range is exactly 20 bits.
*/
utf32 -= 0x10000;
- json_writer_escape_utf16(writer, (gpr_uint16)(0xd800 | (utf32 >> 10)));
- json_writer_escape_utf16(writer,
- (gpr_uint16)(0xdc00 | (utf32 & 0x3ff)));
+ json_writer_escape_utf16(writer, (uint16_t)(0xd800 | (utf32 >> 10)));
+ json_writer_escape_utf16(writer, (uint16_t)(0xdc00 | (utf32 & 0x3ff)));
} else {
- json_writer_escape_utf16(writer, (gpr_uint16)utf32);
+ json_writer_escape_utf16(writer, (uint16_t)utf32);
}
}
}
diff --git a/src/core/profiling/basic_timers.c b/src/core/profiling/basic_timers.c
index eedd387ebc..df32472d1c 100644
--- a/src/core/profiling/basic_timers.c
+++ b/src/core/profiling/basic_timers.c
@@ -52,7 +52,7 @@ typedef struct gpr_timer_entry {
const char *file;
short line;
char type;
- gpr_uint8 important;
+ uint8_t important;
int thd;
} gpr_timer_entry;
diff --git a/src/core/security/base64.c b/src/core/security/base64.c
index 5226d2c578..e68359602e 100644
--- a/src/core/security/base64.c
+++ b/src/core/security/base64.c
@@ -114,7 +114,7 @@ char *grpc_base64_encode(const void *vdata, size_t data_size, int url_safe,
}
GPR_ASSERT(current >= result);
- GPR_ASSERT((gpr_uintptr)(current - result) < result_projected_size);
+ GPR_ASSERT((uintptr_t)(current - result) < result_projected_size);
result[current - result] = '\0';
return result;
}
@@ -125,14 +125,14 @@ gpr_slice grpc_base64_decode(const char *b64, int url_safe) {
static void decode_one_char(const unsigned char *codes, unsigned char *result,
size_t *result_offset) {
- gpr_uint32 packed = ((gpr_uint32)codes[0] << 2) | ((gpr_uint32)codes[1] >> 4);
+ uint32_t packed = ((uint32_t)codes[0] << 2) | ((uint32_t)codes[1] >> 4);
result[(*result_offset)++] = (unsigned char)packed;
}
static void decode_two_chars(const unsigned char *codes, unsigned char *result,
size_t *result_offset) {
- gpr_uint32 packed = ((gpr_uint32)codes[0] << 10) |
- ((gpr_uint32)codes[1] << 4) | ((gpr_uint32)codes[2] >> 2);
+ uint32_t packed = ((uint32_t)codes[0] << 10) | ((uint32_t)codes[1] << 4) |
+ ((uint32_t)codes[2] >> 2);
result[(*result_offset)++] = (unsigned char)(packed >> 8);
result[(*result_offset)++] = (unsigned char)(packed);
}
@@ -172,9 +172,8 @@ static int decode_group(const unsigned char *codes, size_t num_codes,
decode_two_chars(codes, result, result_offset);
} else {
/* No padding. */
- gpr_uint32 packed = ((gpr_uint32)codes[0] << 18) |
- ((gpr_uint32)codes[1] << 12) |
- ((gpr_uint32)codes[2] << 6) | codes[3];
+ uint32_t packed = ((uint32_t)codes[0] << 18) | ((uint32_t)codes[1] << 12) |
+ ((uint32_t)codes[2] << 6) | codes[3];
result[(*result_offset)++] = (unsigned char)(packed >> 16);
result[(*result_offset)++] = (unsigned char)(packed >> 8);
result[(*result_offset)++] = (unsigned char)(packed);
diff --git a/src/core/security/client_auth_filter.c b/src/core/security/client_auth_filter.c
index 1cb247d874..57b367d00f 100644
--- a/src/core/security/client_auth_filter.c
+++ b/src/core/security/client_auth_filter.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -60,7 +60,7 @@ typedef struct {
progress */
grpc_pollset *pollset;
grpc_transport_stream_op op;
- gpr_uint8 security_context_set;
+ uint8_t security_context_set;
grpc_linked_mdelem md_links[MAX_CREDENTIALS_METADATA_COUNT];
grpc_auth_metadata_context auth_md_context;
} call_data;
@@ -232,8 +232,8 @@ static void auth_start_transport_op(grpc_exec_ctx *exec_ctx,
}
sec_ctx = op->context[GRPC_CONTEXT_SECURITY].value;
GRPC_AUTH_CONTEXT_UNREF(sec_ctx->auth_context, "client auth filter");
- sec_ctx->auth_context = GRPC_AUTH_CONTEXT_REF(
- chand->auth_context, "client_auth_filter");
+ sec_ctx->auth_context =
+ GRPC_AUTH_CONTEXT_REF(chand->auth_context, "client_auth_filter");
}
if (op->send_initial_metadata != NULL) {
diff --git a/src/core/security/credentials.c b/src/core/security/credentials.c
index 866c4b792f..8b56c57645 100644
--- a/src/core/security/credentials.c
+++ b/src/core/security/credentials.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -179,8 +179,8 @@ void grpc_server_credentials_set_auth_metadata_processor(
GRPC_API_TRACE(
"grpc_server_credentials_set_auth_metadata_processor("
"creds=%p, "
- "processor=grpc_auth_metadata_processor { process: %lx, state: %p })",
- 3, (creds, (unsigned long)processor.process, processor.state));
+ "processor=grpc_auth_metadata_processor { process: %p, state: %p })",
+ 3, (creds, (void *)(intptr_t)processor.process, processor.state));
if (creds == NULL) return;
if (creds->processor.destroy != NULL && creds->processor.state != NULL) {
creds->processor.destroy(creds->processor.state);
diff --git a/src/core/security/json_token.c b/src/core/security/json_token.c
index 92775d885d..4d4bc4baad 100644
--- a/src/core/security/json_token.c
+++ b/src/core/security/json_token.c
@@ -215,8 +215,8 @@ static char *encoded_jwt_claim(const grpc_auth_json_key *json_key,
gpr_log(GPR_INFO, "Cropping token lifetime to maximum allowed value.");
expiration = gpr_time_add(now, grpc_max_auth_token_lifetime);
}
- gpr_int64toa(now.tv_sec, now_str);
- gpr_int64toa(expiration.tv_sec, expiration_str);
+ int64_ttoa(now.tv_sec, now_str);
+ int64_ttoa(expiration.tv_sec, expiration_str);
child =
create_child(NULL, json, "iss", json_key->client_email, GRPC_JSON_STRING);
@@ -251,7 +251,7 @@ static char *dot_concat_and_free_strings(char *str1, char *str2) {
memcpy(current, str2, str2_len);
current += str2_len;
GPR_ASSERT(current >= result);
- GPR_ASSERT((gpr_uintptr)(current - result) == result_len);
+ GPR_ASSERT((uintptr_t)(current - result) == result_len);
*current = '\0';
gpr_free(str1);
gpr_free(str2);
diff --git a/src/core/security/jwt_verifier.c b/src/core/security/jwt_verifier.c
index fafca661df..042a117f5d 100644
--- a/src/core/security/jwt_verifier.c
+++ b/src/core/security/jwt_verifier.c
@@ -38,6 +38,7 @@
#include "src/core/httpcli/httpcli.h"
#include "src/core/security/base64.h"
+#include "src/core/tsi/ssl_types.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@@ -442,8 +443,8 @@ static BIGNUM *bignum_from_base64(const char *b64) {
gpr_log(GPR_ERROR, "Invalid base64 for big num.");
return NULL;
}
- result =
- BN_bin2bn(GPR_SLICE_START_PTR(bin), (int)GPR_SLICE_LENGTH(bin), NULL);
+ result = BN_bin2bn(GPR_SLICE_START_PTR(bin),
+ TSI_SIZE_AS_SIZE(GPR_SLICE_LENGTH(bin)), NULL);
gpr_slice_unref(bin);
return result;
}
diff --git a/src/core/security/secure_endpoint.c b/src/core/security/secure_endpoint.c
index fd50abb773..9b87e268c6 100644
--- a/src/core/security/secure_endpoint.c
+++ b/src/core/security/secure_endpoint.c
@@ -117,8 +117,8 @@ static void secure_endpoint_unref(grpc_exec_ctx *exec_ctx,
static void secure_endpoint_ref(secure_endpoint *ep) { gpr_ref(&ep->ref); }
#endif
-static void flush_read_staging_buffer(secure_endpoint *ep, gpr_uint8 **cur,
- gpr_uint8 **end) {
+static void flush_read_staging_buffer(secure_endpoint *ep, uint8_t **cur,
+ uint8_t **end) {
gpr_slice_buffer_add(ep->read_buffer, ep->read_staging_buffer);
ep->read_staging_buffer = gpr_slice_malloc(STAGING_BUFFER_SIZE);
*cur = GPR_SLICE_START_PTR(ep->read_staging_buffer);
@@ -143,11 +143,11 @@ static void call_read_cb(grpc_exec_ctx *exec_ctx, secure_endpoint *ep,
static void on_read(grpc_exec_ctx *exec_ctx, void *user_data, int success) {
unsigned i;
- gpr_uint8 keep_looping = 0;
+ uint8_t keep_looping = 0;
tsi_result result = TSI_OK;
secure_endpoint *ep = (secure_endpoint *)user_data;
- gpr_uint8 *cur = GPR_SLICE_START_PTR(ep->read_staging_buffer);
- gpr_uint8 *end = GPR_SLICE_END_PTR(ep->read_staging_buffer);
+ uint8_t *cur = GPR_SLICE_START_PTR(ep->read_staging_buffer);
+ uint8_t *end = GPR_SLICE_END_PTR(ep->read_staging_buffer);
if (!success) {
gpr_slice_buffer_reset_and_unref(ep->read_buffer);
@@ -158,7 +158,7 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *user_data, int success) {
/* TODO(yangg) check error, maybe bail out early */
for (i = 0; i < ep->source_buffer.count; i++) {
gpr_slice encrypted = ep->source_buffer.slices[i];
- gpr_uint8 *message_bytes = GPR_SLICE_START_PTR(encrypted);
+ uint8_t *message_bytes = GPR_SLICE_START_PTR(encrypted);
size_t message_size = GPR_SLICE_LENGTH(encrypted);
while (message_size > 0 || keep_looping) {
@@ -234,8 +234,8 @@ static void endpoint_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep,
&ep->on_read);
}
-static void flush_write_staging_buffer(secure_endpoint *ep, gpr_uint8 **cur,
- gpr_uint8 **end) {
+static void flush_write_staging_buffer(secure_endpoint *ep, uint8_t **cur,
+ uint8_t **end) {
gpr_slice_buffer_add(&ep->output_buffer, ep->write_staging_buffer);
ep->write_staging_buffer = gpr_slice_malloc(STAGING_BUFFER_SIZE);
*cur = GPR_SLICE_START_PTR(ep->write_staging_buffer);
@@ -247,8 +247,8 @@ static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep,
unsigned i;
tsi_result result = TSI_OK;
secure_endpoint *ep = (secure_endpoint *)secure_ep;
- gpr_uint8 *cur = GPR_SLICE_START_PTR(ep->write_staging_buffer);
- gpr_uint8 *end = GPR_SLICE_END_PTR(ep->write_staging_buffer);
+ uint8_t *cur = GPR_SLICE_START_PTR(ep->write_staging_buffer);
+ uint8_t *end = GPR_SLICE_END_PTR(ep->write_staging_buffer);
gpr_slice_buffer_reset_and_unref(&ep->output_buffer);
@@ -263,7 +263,7 @@ static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep,
for (i = 0; i < slices->count; i++) {
gpr_slice plain = slices->slices[i];
- gpr_uint8 *message_bytes = GPR_SLICE_START_PTR(plain);
+ uint8_t *message_bytes = GPR_SLICE_START_PTR(plain);
size_t message_size = GPR_SLICE_LENGTH(plain);
while (message_size > 0) {
size_t protected_buffer_size_to_send = (size_t)(end - cur);
diff --git a/src/core/security/security_connector.c b/src/core/security/security_connector.c
index 204cd324f6..f25d9aab3f 100644
--- a/src/core/security/security_connector.c
+++ b/src/core/security/security_connector.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -316,8 +316,12 @@ grpc_channel_security_connector *grpc_fake_channel_security_connector_create(
c->base.is_client_side = 1;
c->base.url_scheme = GRPC_FAKE_SECURITY_URL_SCHEME;
c->base.vtable = &fake_channel_vtable;
+<<<<<<< HEAD
c->request_metadata_creds =
grpc_call_credentials_ref(request_metadata_creds);
+=======
+ c->request_metadata_creds = grpc_call_credentials_ref(request_metadata_creds);
+>>>>>>> master
c->check_call_host = fake_channel_check_call_host;
return c;
}
@@ -500,9 +504,16 @@ static grpc_security_status ssl_check_peer(grpc_security_connector *sc,
return GRPC_SECURITY_OK;
}
+<<<<<<< HEAD
static void ssl_channel_check_peer(
grpc_exec_ctx *exec_ctx, grpc_security_connector *sc, tsi_peer peer,
grpc_security_peer_check_cb cb, void *user_data) {
+=======
+static void ssl_channel_check_peer(grpc_exec_ctx *exec_ctx,
+ grpc_security_connector *sc, tsi_peer peer,
+ grpc_security_peer_check_cb cb,
+ void *user_data) {
+>>>>>>> master
grpc_ssl_channel_security_connector *c =
(grpc_ssl_channel_security_connector *)sc;
grpc_security_status status;
@@ -516,9 +527,16 @@ static void ssl_channel_check_peer(
tsi_peer_destruct(&peer);
}
+<<<<<<< HEAD
static void ssl_server_check_peer(
grpc_exec_ctx *exec_ctx, grpc_security_connector *sc, tsi_peer peer,
grpc_security_peer_check_cb cb, void *user_data) {
+=======
+static void ssl_server_check_peer(grpc_exec_ctx *exec_ctx,
+ grpc_security_connector *sc, tsi_peer peer,
+ grpc_security_peer_check_cb cb,
+ void *user_data) {
+>>>>>>> master
grpc_auth_context *auth_context = NULL;
grpc_security_status status = ssl_check_peer(sc, NULL, &peer, &auth_context);
tsi_peer_destruct(&peer);
diff --git a/src/core/security/security_connector.h b/src/core/security/security_connector.h
index b5f3ff17f4..2b734109b3 100644
--- a/src/core/security/security_connector.h
+++ b/src/core/security/security_connector.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -40,10 +40,7 @@
/* --- status enum. --- */
-typedef enum {
- GRPC_SECURITY_OK = 0,
- GRPC_SECURITY_ERROR
-} grpc_security_status;
+typedef enum { GRPC_SECURITY_OK = 0, GRPC_SECURITY_ERROR } grpc_security_status;
/* --- URL schemes. --- */
diff --git a/src/core/security/server_auth_filter.c b/src/core/security/server_auth_filter.c
index 5cfee6d139..d5c8c54369 100644
--- a/src/core/security/server_auth_filter.c
+++ b/src/core/security/server_auth_filter.c
@@ -140,7 +140,7 @@ static void on_md_processing_done(
message = gpr_slice_from_copied_string(error_details);
calld->transport_op.send_initial_metadata = NULL;
if (calld->transport_op.send_message != NULL) {
- grpc_byte_stream_destroy(calld->transport_op.send_message);
+ grpc_byte_stream_destroy(&exec_ctx, calld->transport_op.send_message);
calld->transport_op.send_message = NULL;
}
calld->transport_op.send_trailing_metadata = NULL;
diff --git a/src/core/statistics/census_interface.h b/src/core/statistics/census_interface.h
index e870357276..c43acbd317 100644
--- a/src/core/statistics/census_interface.h
+++ b/src/core/statistics/census_interface.h
@@ -42,8 +42,8 @@
/* Structure of a census op id. Define as structure because 64bit integer is not
available on every platform for C89. */
typedef struct census_op_id {
- gpr_uint32 upper;
- gpr_uint32 lower;
+ uint32_t upper;
+ uint32_t lower;
} census_op_id;
typedef struct census_rpc_stats census_rpc_stats;
diff --git a/src/core/statistics/census_log.c b/src/core/statistics/census_log.c
index 88e338038d..257ba586a3 100644
--- a/src/core/statistics/census_log.c
+++ b/src/core/statistics/census_log.c
@@ -116,7 +116,7 @@ typedef struct census_log_block {
simultaneously by reader and writer. */
gpr_atm bytes_committed;
/* Bytes already read */
- gpr_int32 bytes_read;
+ int32_t bytes_read;
/* Links for list */
cl_block_list_struct link;
/* We want this structure to be cacheline aligned. We assume the following
@@ -124,7 +124,7 @@ typedef struct census_log_block {
type 32b size 64b size
char* 4 8
3x gpr_atm 12 24
- gpr_int32 4 8 (assumes padding)
+ int32_t 4 8 (assumes padding)
cl_block_list_struct 12 24
TOTAL 32 64
@@ -147,7 +147,7 @@ typedef struct census_log_block {
/* A list of cl_blocks, doubly-linked through cl_block::link. */
typedef struct census_log_block_list {
- gpr_int32 count; /* Number of items in list. */
+ int32_t count; /* Number of items in list. */
cl_block_list_struct ht; /* head/tail of linked list. */
} cl_block_list;
@@ -175,7 +175,7 @@ struct census_log {
/* Number of cores (aka hardware-contexts) */
unsigned num_cores;
/* number of CENSUS_LOG_2_MAX_RECORD_SIZE blocks in log */
- gpr_int32 num_blocks;
+ int32_t num_blocks;
cl_block *blocks; /* Block metadata. */
cl_core_local_block *core_local_blocks; /* Keeps core to block mappings. */
gpr_mu lock;
@@ -183,7 +183,7 @@ struct census_log {
/* Keeps the state of the reader iterator. A value of 0 indicates that
iterator has reached the end. census_log_init_reader() resets the
value to num_core to restart iteration. */
- gpr_uint32 read_iterator_state;
+ uint32_t read_iterator_state;
/* Points to the block being read. If non-NULL, the block is locked for
reading (block_being_read_->reader_lock is held). */
cl_block *block_being_read;
@@ -276,11 +276,11 @@ static void cl_block_initialize(cl_block *block, char *buffer) {
/* Guards against exposing partially written buffer to the reader. */
static void cl_block_set_bytes_committed(cl_block *block,
- gpr_int32 bytes_committed) {
+ int32_t bytes_committed) {
gpr_atm_rel_store(&block->bytes_committed, bytes_committed);
}
-static gpr_int32 cl_block_get_bytes_committed(cl_block *block) {
+static int32_t cl_block_get_bytes_committed(cl_block *block) {
return gpr_atm_acq_load(&block->bytes_committed);
}
@@ -317,7 +317,7 @@ static void cl_block_enable_access(cl_block *block) {
/* Returns with writer_lock held. */
static void *cl_block_start_write(cl_block *block, size_t size) {
- gpr_int32 bytes_committed;
+ int32_t bytes_committed;
if (!cl_try_lock(&block->writer_lock)) {
return NULL;
}
@@ -395,8 +395,7 @@ static cl_block *cl_allocate_block(void) {
- allocated a new block OR
- 'core_id' => 'old_block' mapping changed (another thread allocated a
block before lock was acquired). */
-static int cl_allocate_core_local_block(gpr_int32 core_id,
- cl_block *old_block) {
+static int cl_allocate_core_local_block(int32_t core_id, cl_block *old_block) {
/* Now that we have the lock, check if core-local mapping has changed. */
cl_core_local_block *core_local_block = &g_log.core_local_blocks[core_id];
cl_block *block = cl_core_local_block_get_block(core_local_block);
@@ -418,8 +417,8 @@ static int cl_allocate_core_local_block(gpr_int32 core_id,
}
static cl_block *cl_get_block(void *record) {
- gpr_uintptr p = (gpr_uintptr)((char *)record - g_log.buffer);
- gpr_uintptr index = p >> CENSUS_LOG_2_MAX_RECORD_SIZE;
+ uintptr_t p = (uintptr_t)((char *)record - g_log.buffer);
+ uintptr_t index = p >> CENSUS_LOG_2_MAX_RECORD_SIZE;
return &g_log.blocks[index];
}
@@ -460,7 +459,7 @@ static cl_block *cl_next_block_to_read(cl_block *prev) {
/* External functions: primary stats_log interface */
void census_log_initialize(size_t size_in_mb, int discard_old_records) {
- gpr_int32 ix;
+ int32_t ix;
/* Check cacheline alignment. */
GPR_ASSERT(sizeof(cl_block) % GPR_CACHELINE_SIZE == 0);
GPR_ASSERT(sizeof(cl_core_local_block) % GPR_CACHELINE_SIZE == 0);
@@ -510,9 +509,9 @@ void census_log_shutdown(void) {
void *census_log_start_write(size_t size) {
/* Used to bound number of times block allocation is attempted. */
- gpr_int32 attempts_remaining = g_log.num_blocks;
+ int32_t attempts_remaining = g_log.num_blocks;
/* TODO(aveitch): move this inside the do loop when current_cpu is fixed */
- gpr_int32 core_id = gpr_cpu_current_cpu();
+ int32_t core_id = gpr_cpu_current_cpu();
GPR_ASSERT(g_log.initialized);
if (size > CENSUS_LOG_MAX_RECORD_SIZE) {
return NULL;
diff --git a/src/core/statistics/census_rpc_stats.c b/src/core/statistics/census_rpc_stats.c
index d6638ed641..524a60793a 100644
--- a/src/core/statistics/census_rpc_stats.c
+++ b/src/core/statistics/census_rpc_stats.c
@@ -70,9 +70,9 @@ static int cmp_str_keys(const void *k1, const void *k2) {
}
/* TODO(hongyu): replace it with cityhash64 */
-static gpr_uint64 simple_hash(const void *k) {
+static uint64_t simple_hash(const void *k) {
size_t len = strlen(k);
- gpr_uint64 higher = gpr_murmur_hash3((const char *)k, len / 2, 0);
+ uint64_t higher = gpr_murmur_hash3((const char *)k, len / 2, 0);
return higher << 32 |
gpr_murmur_hash3((const char *)k + len / 2, len - len / 2, 0);
}
diff --git a/src/core/statistics/census_rpc_stats.h b/src/core/statistics/census_rpc_stats.h
index 5edbe9f478..8bdbc49490 100644
--- a/src/core/statistics/census_rpc_stats.h
+++ b/src/core/statistics/census_rpc_stats.h
@@ -42,9 +42,9 @@ extern "C" {
#endif
struct census_rpc_stats {
- gpr_uint64 cnt;
- gpr_uint64 rpc_error_cnt;
- gpr_uint64 app_error_cnt;
+ uint64_t cnt;
+ uint64_t rpc_error_cnt;
+ uint64_t app_error_cnt;
double elapsed_time_ms;
double api_request_bytes;
double wire_request_bytes;
diff --git a/src/core/statistics/census_tracing.c b/src/core/statistics/census_tracing.c
index ecbe27e536..dc0f8a26f5 100644
--- a/src/core/statistics/census_tracing.c
+++ b/src/core/statistics/census_tracing.c
@@ -68,14 +68,14 @@ static const census_ht_option ht_opt = {
static gpr_once g_init_mutex_once = GPR_ONCE_INIT;
static gpr_mu g_mu; /* Guards following two static variables. */
static census_ht *g_trace_store = NULL;
-static gpr_uint64 g_id = 0;
+static uint64_t g_id = 0;
static census_ht_key op_id_as_key(census_op_id *id) {
return *(census_ht_key *)id;
}
-static gpr_uint64 op_id_2_uint64(census_op_id *id) {
- gpr_uint64 ret;
+static uint64_t op_id_2_uint64(census_op_id *id) {
+ uint64_t ret;
memcpy(&ret, id, sizeof(census_op_id));
return ret;
}
diff --git a/src/core/statistics/hash_table.c b/src/core/statistics/hash_table.c
index 39b760f0e0..0cadcd4740 100644
--- a/src/core/statistics/hash_table.c
+++ b/src/core/statistics/hash_table.c
@@ -54,29 +54,29 @@ typedef struct bucket {
/* NULL if bucket is empty */
ht_entry *next;
/* -1 if all buckets are empty. */
- gpr_int32 prev_non_empty_bucket;
+ int32_t prev_non_empty_bucket;
/* -1 if all buckets are empty. */
- gpr_int32 next_non_empty_bucket;
+ int32_t next_non_empty_bucket;
} bucket;
struct unresizable_hash_table {
/* Number of entries in the table */
size_t size;
/* Number of buckets */
- gpr_uint32 num_buckets;
+ uint32_t num_buckets;
/* Array of buckets initialized at creation time. Memory consumption is
16 bytes per bucket on a 64-bit platform. */
bucket *buckets;
/* Index of the first non-empty bucket. -1 iff size == 0. */
- gpr_int32 first_non_empty_bucket;
+ int32_t first_non_empty_bucket;
/* Index of the last non_empty bucket. -1 iff size == 0. */
- gpr_int32 last_non_empty_bucket;
+ int32_t last_non_empty_bucket;
/* Immutable options of this hash table, initialized at creation time. */
census_ht_option options;
};
typedef struct entry_locator {
- gpr_int32 bucket_idx;
+ int32_t bucket_idx;
int is_first_in_chain;
int found;
ht_entry *prev_entry;
@@ -113,7 +113,7 @@ static void delete_entry(const census_ht_option *opt, ht_entry *p) {
gpr_free(p);
}
-static gpr_uint64 hash(const census_ht_option *opt, census_ht_key key) {
+static uint64_t hash(const census_ht_option *opt, census_ht_key key) {
return opt->key_type == CENSUS_HT_UINT64 ? key.val : opt->hash(key.ptr);
}
@@ -135,7 +135,7 @@ census_ht *census_ht_create(const census_ht_option *option) {
return ret;
}
-static gpr_int32 find_bucket_idx(const census_ht *ht, census_ht_key key) {
+static int32_t find_bucket_idx(const census_ht *ht, census_ht_key key) {
return hash(&ht->options, key) % ht->num_buckets;
}
@@ -149,7 +149,7 @@ static int keys_match(const census_ht_option *opt, const ht_entry *p,
static entry_locator ht_find(const census_ht *ht, census_ht_key key) {
entry_locator loc = {0, 0, 0, NULL};
- gpr_int32 idx = 0;
+ int32_t idx = 0;
ht_entry *ptr = NULL;
GPR_ASSERT(ht != NULL);
idx = find_bucket_idx(ht, key);
@@ -188,7 +188,7 @@ void *census_ht_find(const census_ht *ht, census_ht_key key) {
}
void census_ht_insert(census_ht *ht, census_ht_key key, void *data) {
- gpr_int32 idx = find_bucket_idx(ht, key);
+ int32_t idx = find_bucket_idx(ht, key);
ht_entry *ptr = NULL;
entry_locator loc = ht_find(ht, key);
if (loc.found) {
@@ -259,7 +259,7 @@ void census_ht_erase(census_ht *ht, census_ht_key key) {
census_ht_kv *census_ht_get_all_elements(const census_ht *ht, size_t *num) {
census_ht_kv *ret = NULL;
int i = 0;
- gpr_int32 idx = -1;
+ int32_t idx = -1;
GPR_ASSERT(ht != NULL && num != NULL);
*num = ht->size;
if (*num == 0) {
diff --git a/src/core/statistics/hash_table.h b/src/core/statistics/hash_table.h
index 8b39f536fd..d9860a909f 100644
--- a/src/core/statistics/hash_table.h
+++ b/src/core/statistics/hash_table.h
@@ -60,7 +60,7 @@ typedef struct unresizable_hash_table census_ht;
/* Currently, the hash_table can take two types of keys. (uint64 for trace
store and const char* for stats store). */
typedef union {
- gpr_uint64 val;
+ uint64_t val;
void *ptr;
} census_ht_key;
@@ -73,10 +73,10 @@ typedef struct census_ht_option {
/* Type of hash key */
census_ht_key_type key_type;
/* Desired number of buckets, preferably a prime number */
- gpr_int32 num_buckets;
+ int32_t num_buckets;
/* Fucntion to calculate uint64 hash value of the key. Only takes effect if
key_type is POINTER. */
- gpr_uint64 (*hash)(const void *);
+ uint64_t (*hash)(const void *);
/* Function to compare two keys, returns 0 iff equal. Only takes effect if
key_type is POINTER */
int (*compare_keys)(const void *k1, const void *k2);
@@ -126,6 +126,6 @@ typedef void (*census_ht_itr_cb)(census_ht_key key, const void *val_ptr,
/* Iterates through all key-value pairs in the hash_table. The callback function
should not invalidate data entries. */
-gpr_uint64 census_ht_for_all(const census_ht *ht, census_ht_itr_cb);
+uint64_t census_ht_for_all(const census_ht *ht, census_ht_itr_cb);
#endif /* GRPC_INTERNAL_CORE_STATISTICS_HASH_TABLE_H */
diff --git a/src/core/statistics/window_stats.c b/src/core/statistics/window_stats.c
index e744006bb5..3f2940853a 100644
--- a/src/core/statistics/window_stats.c
+++ b/src/core/statistics/window_stats.c
@@ -47,7 +47,7 @@ typedef struct census_window_stats_sum cws_sum;
/* Each interval is composed of a number of buckets, which hold a count of
entries and a single statistic */
typedef struct census_window_stats_bucket {
- gpr_int64 count;
+ int64_t count;
void *statistic;
} cws_bucket;
@@ -59,11 +59,11 @@ typedef struct census_window_stats_interval_stats {
/* Index of the bucket containing the smallest time interval. */
int bottom_bucket;
/* The smallest time storable in the current window. */
- gpr_int64 bottom;
+ int64_t bottom;
/* The largest time storable in the current window + 1ns */
- gpr_int64 top;
+ int64_t top;
/* The width of each bucket in ns. */
- gpr_int64 width;
+ int64_t width;
} cws_interval_stats;
typedef struct census_window_stats {
@@ -76,7 +76,7 @@ typedef struct census_window_stats {
/* Stats for each interval. */
cws_interval_stats *interval_stats;
/* The time the newset stat was recorded. */
- gpr_int64 newest_time;
+ int64_t newest_time;
} window_stats;
/* Calculate an actual bucket index from a logical index 'IDX'. Other
@@ -87,10 +87,9 @@ typedef struct census_window_stats {
/* The maximum seconds value we can have in a valid timespec. More than this
will result in overflow in timespec_to_ns(). This works out to ~292 years.
TODO: consider using doubles instead of int64. */
-static gpr_int64 max_seconds =
- (GPR_INT64_MAX - GPR_NS_PER_SEC) / GPR_NS_PER_SEC;
+static int64_t max_seconds = (GPR_INT64_MAX - GPR_NS_PER_SEC) / GPR_NS_PER_SEC;
-static gpr_int64 timespec_to_ns(const gpr_timespec ts) {
+static int64_t timespec_to_ns(const gpr_timespec ts) {
if (ts.tv_sec > max_seconds) {
return GPR_INT64_MAX - 1;
}
@@ -123,7 +122,7 @@ window_stats *census_window_stats_create(int nintervals,
GPR_ASSERT(nintervals > 0 && granularity > 2 && intervals != NULL &&
stat_info != NULL);
for (i = 0; i < nintervals; i++) {
- gpr_int64 ns = timespec_to_ns(intervals[i]);
+ int64_t ns = timespec_to_ns(intervals[i]);
GPR_ASSERT(intervals[i].tv_sec >= 0 && intervals[i].tv_nsec >= 0 &&
intervals[i].tv_nsec < GPR_NS_PER_SEC && ns >= 100 &&
granularity * 10 <= ns);
@@ -136,7 +135,7 @@ window_stats *census_window_stats_create(int nintervals,
ret->interval_stats =
(cws_interval_stats *)gpr_malloc(nintervals * sizeof(cws_interval_stats));
for (i = 0; i < nintervals; i++) {
- gpr_int64 size_ns = timespec_to_ns(intervals[i]);
+ int64_t size_ns = timespec_to_ns(intervals[i]);
cws_interval_stats *is = ret->interval_stats + i;
cws_bucket *buckets = is->buckets =
(cws_bucket *)gpr_malloc(ret->nbuckets * sizeof(cws_bucket));
@@ -169,7 +168,7 @@ window_stats *census_window_stats_create(int nintervals,
/* When we try adding a measurement above the current interval range, we
need to "shift" the buckets sufficiently to cover the new range. */
static void cws_shift_buckets(const window_stats *wstats,
- cws_interval_stats *is, gpr_int64 when_ns) {
+ cws_interval_stats *is, int64_t when_ns) {
int i;
/* number of bucket time widths to "shift" */
int shift;
@@ -194,7 +193,7 @@ static void cws_shift_buckets(const window_stats *wstats,
void census_window_stats_add(window_stats *wstats, const gpr_timespec when,
const void *stat_value) {
int i;
- gpr_int64 when_ns = timespec_to_ns(when);
+ int64_t when_ns = timespec_to_ns(when);
GPR_ASSERT(wstats->interval_stats != NULL);
for (i = 0; i < wstats->nintervals; i++) {
cws_interval_stats *is = wstats->interval_stats + i;
@@ -235,7 +234,7 @@ static void cws_add_proportion_to_sum(double p, cws_sum *sum,
void census_window_stats_get_sums(const window_stats *wstats,
const gpr_timespec when, cws_sum sums[]) {
int i;
- gpr_int64 when_ns = timespec_to_ns(when);
+ int64_t when_ns = timespec_to_ns(when);
GPR_ASSERT(wstats->interval_stats != NULL);
for (i = 0; i < wstats->nintervals; i++) {
int when_bucket;
@@ -264,7 +263,7 @@ void census_window_stats_get_sums(const window_stats *wstats,
when_bucket = (when_ns - is->bottom) / is->width;
new_bucket = (wstats->newest_time - is->bottom) / is->width;
if (new_bucket == when_bucket) {
- gpr_int64 bottom_bucket_time = is->bottom + when_bucket * is->width;
+ int64_t bottom_bucket_time = is->bottom + when_bucket * is->width;
if (when_ns < wstats->newest_time) {
last_proportion = (double)(when_ns - bottom_bucket_time) /
(double)(wstats->newest_time - bottom_bucket_time);
diff --git a/src/core/support/alloc.c b/src/core/support/alloc.c
index ca72379b1d..0a064b2c18 100644
--- a/src/core/support/alloc.c
+++ b/src/core/support/alloc.c
@@ -82,7 +82,7 @@ void *gpr_malloc_aligned(size_t size, size_t alignment_log) {
size_t alignment = ((size_t)1) << alignment_log;
size_t extra = alignment - 1 + sizeof(void *);
void *p = gpr_malloc(size + extra);
- void **ret = (void **)(((gpr_uintptr)p + extra) & ~(alignment - 1));
+ void **ret = (void **)(((uintptr_t)p + extra) & ~(alignment - 1));
ret[-1] = p;
return (void *)ret;
}
diff --git a/src/core/support/cpu_posix.c b/src/core/support/cpu_posix.c
index 55d92c0555..5edb87d67f 100644
--- a/src/core/support/cpu_posix.c
+++ b/src/core/support/cpu_posix.c
@@ -48,7 +48,7 @@ static long ncpus = 0;
static void init_ncpus() {
ncpus = sysconf(_SC_NPROCESSORS_ONLN);
- if (ncpus < 1 || ncpus > GPR_UINT32_MAX) {
+ if (ncpus < 1 || ncpus > UINT32_MAX) {
gpr_log(GPR_ERROR, "Cannot determine number of CPUs: assuming 1");
ncpus = 1;
}
diff --git a/src/core/support/histogram.c b/src/core/support/histogram.c
index 77b48af996..20ed2b14b1 100644
--- a/src/core/support/histogram.c
+++ b/src/core/support/histogram.c
@@ -66,7 +66,7 @@ struct gpr_histogram {
/* number of buckets */
size_t num_buckets;
/* the buckets themselves */
- gpr_uint32 *buckets;
+ uint32_t *buckets;
};
/* determine a bucket index given a value - does no bounds checking */
@@ -102,8 +102,8 @@ gpr_histogram *gpr_histogram_create(double resolution,
h->num_buckets = bucket_for_unchecked(h, max_bucket_start) + 1;
GPR_ASSERT(h->num_buckets > 1);
GPR_ASSERT(h->num_buckets < 100000000);
- h->buckets = gpr_malloc(sizeof(gpr_uint32) * h->num_buckets);
- memset(h->buckets, 0, sizeof(gpr_uint32) * h->num_buckets);
+ h->buckets = gpr_malloc(sizeof(uint32_t) * h->num_buckets);
+ memset(h->buckets, 0, sizeof(uint32_t) * h->num_buckets);
return h;
}
@@ -137,7 +137,7 @@ int gpr_histogram_merge(gpr_histogram *dst, const gpr_histogram *src) {
return 1;
}
-void gpr_histogram_merge_contents(gpr_histogram *dst, const gpr_uint32 *data,
+void gpr_histogram_merge_contents(gpr_histogram *dst, const uint32_t *data,
size_t data_count, double min_seen,
double max_seen, double sum,
double sum_of_squares, double count) {
@@ -238,7 +238,7 @@ double gpr_histogram_sum_of_squares(gpr_histogram *h) {
return h->sum_of_squares;
}
-const gpr_uint32 *gpr_histogram_get_contents(gpr_histogram *h, size_t *size) {
+const uint32_t *gpr_histogram_get_contents(gpr_histogram *h, size_t *size) {
*size = h->num_buckets;
return h->buckets;
}
diff --git a/src/core/support/log_posix.c b/src/core/support/log_posix.c
index 8986254e4e..3ff171f99c 100644
--- a/src/core/support/log_posix.c
+++ b/src/core/support/log_posix.c
@@ -45,7 +45,7 @@
#include <time.h>
#include <pthread.h>
-static gpr_intptr gettid(void) { return (gpr_intptr)pthread_self(); }
+static intptr_t gettid(void) { return (intptr_t)pthread_self(); }
void gpr_log(const char *file, int line, gpr_log_severity severity,
const char *format, ...) {
diff --git a/src/core/support/log_win32.c b/src/core/support/log_win32.c
index 28e7768f80..40adcd1b50 100644
--- a/src/core/support/log_win32.c
+++ b/src/core/support/log_win32.c
@@ -106,6 +106,7 @@ void gpr_default_log(gpr_log_func_args *args) {
gpr_log_severity_string(args->severity), time_buffer,
(int)(now.tv_nsec), GetCurrentThreadId(), display_file, args->line,
args->message);
+ fflush(stderr);
}
char *gpr_format_message(DWORD messageid) {
diff --git a/src/core/support/murmur_hash.c b/src/core/support/murmur_hash.c
index 37fdca82ba..a5261c0cc0 100644
--- a/src/core/support/murmur_hash.c
+++ b/src/core/support/murmur_hash.c
@@ -46,19 +46,19 @@
handle aligned reads, do the conversion here */
#define GETBLOCK32(p, i) (p)[(i)]
-gpr_uint32 gpr_murmur_hash3(const void *key, size_t len, gpr_uint32 seed) {
- const gpr_uint8 *data = (const gpr_uint8 *)key;
+uint32_t gpr_murmur_hash3(const void *key, size_t len, uint32_t seed) {
+ const uint8_t *data = (const uint8_t *)key;
const size_t nblocks = len / 4;
int i;
- gpr_uint32 h1 = seed;
- gpr_uint32 k1;
+ uint32_t h1 = seed;
+ uint32_t k1;
- const gpr_uint32 c1 = 0xcc9e2d51;
- const gpr_uint32 c2 = 0x1b873593;
+ const uint32_t c1 = 0xcc9e2d51;
+ const uint32_t c2 = 0x1b873593;
- const gpr_uint32 *blocks = ((const gpr_uint32 *)key) + nblocks;
- const gpr_uint8 *tail = (const gpr_uint8 *)(data + nblocks * 4);
+ const uint32_t *blocks = ((const uint32_t *)key) + nblocks;
+ const uint8_t *tail = (const uint8_t *)(data + nblocks * 4);
/* body */
for (i = -(int)nblocks; i; i++) {
@@ -78,9 +78,9 @@ gpr_uint32 gpr_murmur_hash3(const void *key, size_t len, gpr_uint32 seed) {
/* tail */
switch (len & 3) {
case 3:
- k1 ^= ((gpr_uint32)tail[2]) << 16;
+ k1 ^= ((uint32_t)tail[2]) << 16;
case 2:
- k1 ^= ((gpr_uint32)tail[1]) << 8;
+ k1 ^= ((uint32_t)tail[1]) << 8;
case 1:
k1 ^= tail[0];
k1 *= c1;
@@ -90,7 +90,7 @@ gpr_uint32 gpr_murmur_hash3(const void *key, size_t len, gpr_uint32 seed) {
};
/* finalization */
- h1 ^= (gpr_uint32)len;
+ h1 ^= (uint32_t)len;
FMIX32(h1);
return h1;
}
diff --git a/src/core/support/murmur_hash.h b/src/core/support/murmur_hash.h
index 343fcb99f7..0bf04f731a 100644
--- a/src/core/support/murmur_hash.h
+++ b/src/core/support/murmur_hash.h
@@ -39,6 +39,6 @@
#include <stddef.h>
/* compute the hash of key (length len) */
-gpr_uint32 gpr_murmur_hash3(const void *key, size_t len, gpr_uint32 seed);
+uint32_t gpr_murmur_hash3(const void *key, size_t len, uint32_t seed);
#endif /* GRPC_INTERNAL_CORE_SUPPORT_MURMUR_HASH_H */
diff --git a/src/core/support/slice.c b/src/core/support/slice.c
index 9f0ded4932..b9a7c77bda 100644
--- a/src/core/support/slice.c
+++ b/src/core/support/slice.c
@@ -67,7 +67,7 @@ static gpr_slice_refcount noop_refcount = {noop_ref_or_unref,
gpr_slice gpr_slice_from_static_string(const char *s) {
gpr_slice slice;
slice.refcount = &noop_refcount;
- slice.data.refcounted.bytes = (gpr_uint8 *)s;
+ slice.data.refcounted.bytes = (uint8_t *)s;
slice.data.refcounted.length = strlen(s);
return slice;
}
@@ -203,13 +203,13 @@ gpr_slice gpr_slice_malloc(size_t length) {
/* The slices refcount points back to the allocated block. */
slice.refcount = &rc->base;
/* The data bytes are placed immediately after the refcount struct */
- slice.data.refcounted.bytes = (gpr_uint8 *)(rc + 1);
+ slice.data.refcounted.bytes = (uint8_t *)(rc + 1);
/* And the length of the block is set to the requested length */
slice.data.refcounted.length = length;
} else {
/* small slice: just inline the data */
slice.refcount = NULL;
- slice.data.inlined.length = (gpr_uint8)length;
+ slice.data.inlined.length = (uint8_t)length;
}
return slice;
}
@@ -232,7 +232,7 @@ gpr_slice gpr_slice_sub_no_ref(gpr_slice source, size_t begin, size_t end) {
/* Enforce preconditions */
GPR_ASSERT(source.data.inlined.length >= end);
subset.refcount = NULL;
- subset.data.inlined.length = (gpr_uint8)(end - begin);
+ subset.data.inlined.length = (uint8_t)(end - begin);
memcpy(subset.data.inlined.bytes, source.data.inlined.bytes + begin,
end - begin);
}
@@ -244,7 +244,7 @@ gpr_slice gpr_slice_sub(gpr_slice source, size_t begin, size_t end) {
if (end - begin <= sizeof(subset.data.inlined.bytes)) {
subset.refcount = NULL;
- subset.data.inlined.length = (gpr_uint8)(end - begin);
+ subset.data.inlined.length = (uint8_t)(end - begin);
memcpy(subset.data.inlined.bytes, GPR_SLICE_START_PTR(source) + begin,
end - begin);
} else {
@@ -262,17 +262,17 @@ gpr_slice gpr_slice_split_tail(gpr_slice *source, size_t split) {
/* inlined data, copy it out */
GPR_ASSERT(source->data.inlined.length >= split);
tail.refcount = NULL;
- tail.data.inlined.length = (gpr_uint8)(source->data.inlined.length - split);
+ tail.data.inlined.length = (uint8_t)(source->data.inlined.length - split);
memcpy(tail.data.inlined.bytes, source->data.inlined.bytes + split,
tail.data.inlined.length);
- source->data.inlined.length = (gpr_uint8)split;
+ source->data.inlined.length = (uint8_t)split;
} else {
size_t tail_length = source->data.refcounted.length - split;
GPR_ASSERT(source->data.refcounted.length >= split);
if (tail_length < sizeof(tail.data.inlined.bytes)) {
/* Copy out the bytes - it'll be cheaper than refcounting */
tail.refcount = NULL;
- tail.data.inlined.length = (gpr_uint8)tail_length;
+ tail.data.inlined.length = (uint8_t)tail_length;
memcpy(tail.data.inlined.bytes, source->data.refcounted.bytes + split,
tail_length);
} else {
@@ -297,17 +297,17 @@ gpr_slice gpr_slice_split_head(gpr_slice *source, size_t split) {
GPR_ASSERT(source->data.inlined.length >= split);
head.refcount = NULL;
- head.data.inlined.length = (gpr_uint8)split;
+ head.data.inlined.length = (uint8_t)split;
memcpy(head.data.inlined.bytes, source->data.inlined.bytes, split);
source->data.inlined.length =
- (gpr_uint8)(source->data.inlined.length - split);
+ (uint8_t)(source->data.inlined.length - split);
memmove(source->data.inlined.bytes, source->data.inlined.bytes + split,
source->data.inlined.length);
} else if (split < sizeof(head.data.inlined.bytes)) {
GPR_ASSERT(source->data.refcounted.length >= split);
head.refcount = NULL;
- head.data.inlined.length = (gpr_uint8)split;
+ head.data.inlined.length = (uint8_t)split;
memcpy(head.data.inlined.bytes, source->data.refcounted.bytes, split);
source->data.refcounted.bytes += split;
source->data.refcounted.length -= split;
diff --git a/src/core/support/slice_buffer.c b/src/core/support/slice_buffer.c
index 856d3a2439..66f111d767 100644
--- a/src/core/support/slice_buffer.c
+++ b/src/core/support/slice_buffer.c
@@ -70,9 +70,9 @@ void gpr_slice_buffer_destroy(gpr_slice_buffer *sb) {
}
}
-gpr_uint8 *gpr_slice_buffer_tiny_add(gpr_slice_buffer *sb, size_t n) {
+uint8_t *gpr_slice_buffer_tiny_add(gpr_slice_buffer *sb, size_t n) {
gpr_slice *back;
- gpr_uint8 *out;
+ uint8_t *out;
sb->length += n;
@@ -82,7 +82,7 @@ gpr_uint8 *gpr_slice_buffer_tiny_add(gpr_slice_buffer *sb, size_t n) {
if ((back->data.inlined.length + n) > sizeof(back->data.inlined.bytes))
goto add_new;
out = back->data.inlined.bytes + back->data.inlined.length;
- back->data.inlined.length = (gpr_uint8)(back->data.inlined.length + n);
+ back->data.inlined.length = (uint8_t)(back->data.inlined.length + n);
return out;
add_new:
@@ -90,7 +90,7 @@ add_new:
back = &sb->slices[sb->count];
sb->count++;
back->refcount = NULL;
- back->data.inlined.length = (gpr_uint8)n;
+ back->data.inlined.length = (uint8_t)n;
return back->data.inlined.bytes;
}
@@ -118,7 +118,7 @@ void gpr_slice_buffer_add(gpr_slice_buffer *sb, gpr_slice s) {
memcpy(back->data.inlined.bytes + back->data.inlined.length,
s.data.inlined.bytes, s.data.inlined.length);
back->data.inlined.length =
- (gpr_uint8)(back->data.inlined.length + s.data.inlined.length);
+ (uint8_t)(back->data.inlined.length + s.data.inlined.length);
} else {
size_t cp1 = GPR_SLICE_INLINED_SIZE - back->data.inlined.length;
memcpy(back->data.inlined.bytes + back->data.inlined.length,
@@ -128,7 +128,7 @@ void gpr_slice_buffer_add(gpr_slice_buffer *sb, gpr_slice s) {
back = &sb->slices[n];
sb->count = n + 1;
back->refcount = NULL;
- back->data.inlined.length = (gpr_uint8)(s.data.inlined.length - cp1);
+ back->data.inlined.length = (uint8_t)(s.data.inlined.length - cp1);
memcpy(back->data.inlined.bytes, s.data.inlined.bytes + cp1,
s.data.inlined.length - cp1);
}
diff --git a/src/core/support/stack_lockfree.c b/src/core/support/stack_lockfree.c
index df9a09894c..cd0afddf9d 100644
--- a/src/core/support/stack_lockfree.c
+++ b/src/core/support/stack_lockfree.c
@@ -45,13 +45,13 @@
word that allows for an atomic CAS to set it up. */
struct lockfree_node_contents {
/* next thing to look at. Actual index for head, next index otherwise */
- gpr_uint16 index;
+ uint16_t index;
#ifdef GPR_ARCH_64
- gpr_uint16 pad;
- gpr_uint32 aba_ctr;
+ uint16_t pad;
+ uint32_t aba_ctr;
#else
#ifdef GPR_ARCH_32
- gpr_uint16 aba_ctr;
+ uint16_t aba_ctr;
#else
#error Unsupported bit width architecture
#endif
@@ -114,7 +114,7 @@ int gpr_stack_lockfree_push(gpr_stack_lockfree *stack, int entry) {
lockfree_node newent;
/* First fill in the entry's index and aba ctr for new head */
- newhead.contents.index = (gpr_uint16)entry;
+ newhead.contents.index = (uint16_t)entry;
/* Also post-increment the aba_ctr */
curent.atm = gpr_atm_no_barrier_load(&stack->entries[entry].atm);
newhead.contents.aba_ctr = ++curent.contents.aba_ctr;
@@ -128,8 +128,8 @@ int gpr_stack_lockfree_push(gpr_stack_lockfree *stack, int entry) {
gpr_atm old_val;
old_val = gpr_atm_no_barrier_fetch_add(&stack->pushed[pushed_index],
- (gpr_atm)(1UL << pushed_bit));
- GPR_ASSERT((old_val & (gpr_atm)(1UL << pushed_bit)) == 0);
+ ((gpr_atm)1 << pushed_bit));
+ GPR_ASSERT((old_val & (((gpr_atm)1) << pushed_bit)) == 0);
}
#endif
@@ -166,8 +166,8 @@ int gpr_stack_lockfree_pop(gpr_stack_lockfree *stack) {
gpr_atm old_val;
old_val = gpr_atm_no_barrier_fetch_add(&stack->pushed[pushed_index],
- -(gpr_atm)(1UL << pushed_bit));
- GPR_ASSERT((old_val & (gpr_atm)(1UL << pushed_bit)) != 0);
+ -((gpr_atm)1 << pushed_bit));
+ GPR_ASSERT((old_val & (((gpr_atm)1) << pushed_bit)) != 0);
}
#endif
diff --git a/src/core/support/string.c b/src/core/support/string.c
index 46a7ca3d46..1f541de40f 100644
--- a/src/core/support/string.c
+++ b/src/core/support/string.c
@@ -80,9 +80,9 @@ static void dump_out_append(dump_out *out, char c) {
static void hexdump(dump_out *out, const char *buf, size_t len) {
static const char hex[16] = "0123456789abcdef";
- const gpr_uint8 *const beg = (const gpr_uint8 *)buf;
- const gpr_uint8 *const end = beg + len;
- const gpr_uint8 *cur;
+ const uint8_t *const beg = (const uint8_t *)buf;
+ const uint8_t *const end = beg + len;
+ const uint8_t *cur;
for (cur = beg; cur != end; ++cur) {
if (cur != beg) dump_out_append(out, ' ');
@@ -92,9 +92,9 @@ static void hexdump(dump_out *out, const char *buf, size_t len) {
}
static void asciidump(dump_out *out, const char *buf, size_t len) {
- const gpr_uint8 *const beg = (const gpr_uint8 *)buf;
- const gpr_uint8 *const end = beg + len;
- const gpr_uint8 *cur;
+ const uint8_t *const beg = (const uint8_t *)buf;
+ const uint8_t *const end = beg + len;
+ const uint8_t *cur;
int out_was_empty = (out->length == 0);
if (!out_was_empty) {
dump_out_append(out, ' ');
@@ -108,7 +108,7 @@ static void asciidump(dump_out *out, const char *buf, size_t len) {
}
}
-char *gpr_dump(const char *buf, size_t len, gpr_uint32 flags) {
+char *gpr_dump(const char *buf, size_t len, uint32_t flags) {
dump_out out = dump_out_create();
if (flags & GPR_DUMP_HEX) {
hexdump(&out, buf, len);
@@ -120,21 +120,21 @@ char *gpr_dump(const char *buf, size_t len, gpr_uint32 flags) {
return out.data;
}
-char *gpr_dump_slice(gpr_slice s, gpr_uint32 flags) {
+char *gpr_dump_slice(gpr_slice s, uint32_t flags) {
return gpr_dump((const char *)GPR_SLICE_START_PTR(s), GPR_SLICE_LENGTH(s),
flags);
}
-int gpr_parse_bytes_to_uint32(const char *buf, size_t len, gpr_uint32 *result) {
- gpr_uint32 out = 0;
- gpr_uint32 new;
+int gpr_parse_bytes_to_uint32(const char *buf, size_t len, uint32_t *result) {
+ uint32_t out = 0;
+ uint32_t new;
size_t i;
if (len == 0) return 0; /* must have some bytes */
for (i = 0; i < len; i++) {
if (buf[i] < '0' || buf[i] > '9') return 0; /* bad char */
- new = 10 * out + (gpr_uint32)(buf[i] - '0');
+ new = 10 * out + (uint32_t)(buf[i] - '0');
if (new < out) return 0; /* overflow */
out = new;
}
@@ -173,8 +173,8 @@ int gpr_ltoa(long value, char *string) {
return i;
}
-int gpr_int64toa(gpr_int64 value, char *string) {
- gpr_int64 sign;
+int int64_ttoa(int64_t value, char *string) {
+ int64_t sign;
int i = 0;
if (value == 0) {
@@ -238,7 +238,7 @@ static int slice_find_separator_offset(const gpr_slice str, const char *sep,
const size_t read_offset, size_t *begin,
size_t *end) {
size_t i;
- const gpr_uint8 *str_ptr = GPR_SLICE_START_PTR(str) + read_offset;
+ const uint8_t *str_ptr = GPR_SLICE_START_PTR(str) + read_offset;
const size_t str_len = GPR_SLICE_LENGTH(str) - read_offset;
const size_t sep_len = strlen(sep);
if (str_len < sep_len) {
diff --git a/src/core/support/string.h b/src/core/support/string.h
index 9b604ac5bf..e6755de106 100644
--- a/src/core/support/string.h
+++ b/src/core/support/string.h
@@ -52,15 +52,15 @@ extern "C" {
/* Converts array buf, of length len, into a C string according to the flags.
Result should be freed with gpr_free() */
-char *gpr_dump(const char *buf, size_t len, gpr_uint32 flags);
+char *gpr_dump(const char *buf, size_t len, uint32_t flags);
/* Calls gpr_dump on a slice. */
-char *gpr_dump_slice(gpr_slice slice, gpr_uint32 flags);
+char *gpr_dump_slice(gpr_slice slice, uint32_t flags);
/* Parses an array of bytes into an integer (base 10). Returns 1 on success,
0 on failure. */
int gpr_parse_bytes_to_uint32(const char *data, size_t length,
- gpr_uint32 *result);
+ uint32_t *result);
/* Minimum buffer size for calling ltoa */
#define GPR_LTOA_MIN_BUFSIZE (3 * sizeof(long))
@@ -71,14 +71,14 @@ int gpr_parse_bytes_to_uint32(const char *data, size_t length,
int gpr_ltoa(long value, char *output);
/* Minimum buffer size for calling int64toa */
-#define GPR_INT64TOA_MIN_BUFSIZE (3 * sizeof(gpr_int64))
+#define GPR_INT64TOA_MIN_BUFSIZE (3 * sizeof(int64_t))
/* Convert an int64 to a string in base 10; returns the length of the
output string (or 0 on failure).
output must be at least GPR_INT64TOA_MIN_BUFSIZE bytes long.
NOTE: This function ensures sufficient bit width even on Win x64,
where long is 32bit is size.*/
-int gpr_int64toa(gpr_int64 value, char *output);
+int int64_ttoa(int64_t value, char *output);
/* Reverse a run of bytes */
void gpr_reverse_bytes(char *str, int len);
diff --git a/src/core/support/sync.c b/src/core/support/sync.c
index d3cf77faea..d368422d9e 100644
--- a/src/core/support/sync.c
+++ b/src/core/support/sync.c
@@ -59,7 +59,7 @@ static void event_initialize(void) {
/* Hash ev into an element of sync_array[]. */
static struct sync_array_s *hash(gpr_event *ev) {
- return &sync_array[((gpr_uintptr)ev) % event_sync_partitions];
+ return &sync_array[((uintptr_t)ev) % event_sync_partitions];
}
void gpr_event_init(gpr_event *ev) {
@@ -108,15 +108,15 @@ int gpr_unref(gpr_refcount *r) {
return prior == 1;
}
-void gpr_stats_init(gpr_stats_counter *c, gpr_intptr n) {
+void gpr_stats_init(gpr_stats_counter *c, intptr_t n) {
gpr_atm_rel_store(&c->value, n);
}
-void gpr_stats_inc(gpr_stats_counter *c, gpr_intptr inc) {
+void gpr_stats_inc(gpr_stats_counter *c, intptr_t inc) {
gpr_atm_no_barrier_fetch_add(&c->value, inc);
}
-gpr_intptr gpr_stats_read(const gpr_stats_counter *c) {
+intptr_t gpr_stats_read(const gpr_stats_counter *c) {
/* don't need acquire-load, but we have no no-barrier load yet */
return gpr_atm_acq_load(&c->value);
}
diff --git a/src/core/support/sync_posix.c b/src/core/support/sync_posix.c
index d6a0f7c325..4d59a10002 100644
--- a/src/core/support/sync_posix.c
+++ b/src/core/support/sync_posix.c
@@ -81,7 +81,7 @@ int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu, gpr_timespec abs_deadline) {
} else {
struct timespec abs_deadline_ts;
abs_deadline = gpr_convert_clock_type(abs_deadline, GPR_CLOCK_REALTIME);
- abs_deadline_ts.tv_sec = abs_deadline.tv_sec;
+ abs_deadline_ts.tv_sec = (time_t)abs_deadline.tv_sec;
abs_deadline_ts.tv_nsec = abs_deadline.tv_nsec;
err = pthread_cond_timedwait(cv, mu, &abs_deadline_ts);
}
diff --git a/src/core/support/sync_win32.c b/src/core/support/sync_win32.c
index 69dd46399a..51a082b29e 100644
--- a/src/core/support/sync_win32.c
+++ b/src/core/support/sync_win32.c
@@ -88,9 +88,9 @@ int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline) {
SleepConditionVariableCS(cv, &mu->cs, INFINITE);
} else {
gpr_timespec now = gpr_now(abs_deadline.clock_type);
- gpr_int64 now_ms = (gpr_int64)now.tv_sec * 1000 + now.tv_nsec / 1000000;
- gpr_int64 deadline_ms =
- (gpr_int64)abs_deadline.tv_sec * 1000 + abs_deadline.tv_nsec / 1000000;
+ int64_t now_ms = (int64_t)now.tv_sec * 1000 + now.tv_nsec / 1000000;
+ int64_t deadline_ms =
+ (int64_t)abs_deadline.tv_sec * 1000 + abs_deadline.tv_nsec / 1000000;
if (now_ms >= deadline_ms) {
timeout = 1;
} else {
diff --git a/src/core/support/time.c b/src/core/support/time.c
index 197fa9ad44..ac8c3bcde5 100644
--- a/src/core/support/time.c
+++ b/src/core/support/time.c
@@ -92,11 +92,11 @@ gpr_timespec gpr_time_from_nanos(long ns, gpr_clock_type type) {
result = gpr_inf_past(type);
} else if (ns >= 0) {
result.tv_sec = ns / GPR_NS_PER_SEC;
- result.tv_nsec = (gpr_int32)(ns - result.tv_sec * GPR_NS_PER_SEC);
+ result.tv_nsec = (int32_t)(ns - result.tv_sec * GPR_NS_PER_SEC);
} else {
/* Calculation carefully formulated to avoid any possible under/overflow. */
result.tv_sec = (-(999999999 - (ns + GPR_NS_PER_SEC)) / GPR_NS_PER_SEC) - 1;
- result.tv_nsec = (gpr_int32)(ns - result.tv_sec * GPR_NS_PER_SEC);
+ result.tv_nsec = (int32_t)(ns - result.tv_sec * GPR_NS_PER_SEC);
}
return result;
}
@@ -110,11 +110,11 @@ gpr_timespec gpr_time_from_micros(long us, gpr_clock_type type) {
result = gpr_inf_past(type);
} else if (us >= 0) {
result.tv_sec = us / 1000000;
- result.tv_nsec = (gpr_int32)((us - result.tv_sec * 1000000) * 1000);
+ result.tv_nsec = (int32_t)((us - result.tv_sec * 1000000) * 1000);
} else {
/* Calculation carefully formulated to avoid any possible under/overflow. */
result.tv_sec = (-(999999 - (us + 1000000)) / 1000000) - 1;
- result.tv_nsec = (gpr_int32)((us - result.tv_sec * 1000000) * 1000);
+ result.tv_nsec = (int32_t)((us - result.tv_sec * 1000000) * 1000);
}
return result;
}
@@ -128,11 +128,11 @@ gpr_timespec gpr_time_from_millis(long ms, gpr_clock_type type) {
result = gpr_inf_past(type);
} else if (ms >= 0) {
result.tv_sec = ms / 1000;
- result.tv_nsec = (gpr_int32)((ms - result.tv_sec * 1000) * 1000000);
+ result.tv_nsec = (int32_t)((ms - result.tv_sec * 1000) * 1000000);
} else {
/* Calculation carefully formulated to avoid any possible under/overflow. */
result.tv_sec = (-(999 - (ms + 1000)) / 1000) - 1;
- result.tv_nsec = (gpr_int32)((ms - result.tv_sec * 1000) * 1000000);
+ result.tv_nsec = (int32_t)((ms - result.tv_sec * 1000) * 1000000);
}
return result;
}
@@ -181,7 +181,7 @@ gpr_timespec gpr_time_from_hours(long h, gpr_clock_type type) {
gpr_timespec gpr_time_add(gpr_timespec a, gpr_timespec b) {
gpr_timespec sum;
- gpr_int64 inc = 0;
+ int64_t inc = 0;
GPR_ASSERT(b.clock_type == GPR_TIMESPAN);
sum.clock_type = a.clock_type;
sum.tv_nsec = a.tv_nsec + b.tv_nsec;
@@ -210,7 +210,7 @@ gpr_timespec gpr_time_add(gpr_timespec a, gpr_timespec b) {
gpr_timespec gpr_time_sub(gpr_timespec a, gpr_timespec b) {
gpr_timespec diff;
- gpr_int64 dec = 0;
+ int64_t dec = 0;
if (b.clock_type == GPR_TIMESPAN) {
diff.clock_type = a.clock_type;
} else {
@@ -256,7 +256,7 @@ int gpr_time_similar(gpr_timespec a, gpr_timespec b, gpr_timespec threshold) {
}
}
-gpr_int32 gpr_time_to_millis(gpr_timespec t) {
+int32_t gpr_time_to_millis(gpr_timespec t) {
if (t.tv_sec >= 2147483) {
if (t.tv_sec == 2147483 && t.tv_nsec < 648 * GPR_NS_PER_MS) {
return 2147483 * GPR_MS_PER_SEC + t.tv_nsec / GPR_NS_PER_MS;
@@ -267,7 +267,7 @@ gpr_int32 gpr_time_to_millis(gpr_timespec t) {
care?) */
return -2147483647;
} else {
- return (gpr_int32)(t.tv_sec * GPR_MS_PER_SEC + t.tv_nsec / GPR_NS_PER_MS);
+ return (int32_t)(t.tv_sec * GPR_MS_PER_SEC + t.tv_nsec / GPR_NS_PER_MS);
}
}
diff --git a/src/core/support/time_posix.c b/src/core/support/time_posix.c
index ba72572e05..06bb78c913 100644
--- a/src/core/support/time_posix.c
+++ b/src/core/support/time_posix.c
@@ -45,7 +45,7 @@
static struct timespec timespec_from_gpr(gpr_timespec gts) {
struct timespec rv;
- if (sizeof(time_t) < sizeof(gpr_int64)) {
+ if (sizeof(time_t) < sizeof(int64_t)) {
/* fine to assert, as this is only used in gpr_sleep_until */
GPR_ASSERT(gts.tv_sec <= INT32_MAX && gts.tv_sec >= INT32_MIN);
}
@@ -64,7 +64,7 @@ static gpr_timespec gpr_from_timespec(struct timespec ts,
*/
gpr_timespec rv;
rv.tv_sec = ts.tv_sec;
- rv.tv_nsec = (gpr_int32)ts.tv_nsec;
+ rv.tv_nsec = (int32_t)ts.tv_nsec;
rv.clock_type = clock_type;
return rv;
}
@@ -119,8 +119,8 @@ gpr_timespec gpr_now(gpr_clock_type clock) {
break;
case GPR_CLOCK_MONOTONIC:
now_dbl = (mach_absolute_time() - g_time_start) * g_time_scale;
- now.tv_sec = (gpr_int64)(now_dbl * 1e-9);
- now.tv_nsec = (gpr_int32)(now_dbl - ((double)now.tv_sec) * 1e9);
+ now.tv_sec = (int64_t)(now_dbl * 1e-9);
+ now.tv_nsec = (int32_t)(now_dbl - ((double)now.tv_sec) * 1e9);
break;
case GPR_CLOCK_PRECISE:
gpr_precise_clock_now(&now);
diff --git a/src/core/support/time_precise.c b/src/core/support/time_precise.c
index 4de1d9b071..a2cf74bc84 100644
--- a/src/core/support/time_precise.c
+++ b/src/core/support/time_precise.c
@@ -75,8 +75,8 @@ void gpr_precise_clock_now(gpr_timespec *clk) {
gpr_get_cycle_counter(&counter);
secs = (double)(counter - start_cycle) / cycles_per_second;
clk->clock_type = GPR_CLOCK_PRECISE;
- clk->tv_sec = (gpr_int64)secs;
- clk->tv_nsec = (gpr_int32)(1e9 * (secs - (double)clk->tv_sec));
+ clk->tv_sec = (int64_t)secs;
+ clk->tv_nsec = (int32_t)(1e9 * (secs - (double)clk->tv_sec));
}
#else /* GRPC_TIMERS_RDTSC */
diff --git a/src/core/support/time_win32.c b/src/core/support/time_win32.c
index 7ccaaa248d..2bed0f6a9c 100644
--- a/src/core/support/time_win32.c
+++ b/src/core/support/time_win32.c
@@ -62,15 +62,15 @@ gpr_timespec gpr_now(gpr_clock_type clock) {
switch (clock) {
case GPR_CLOCK_REALTIME:
_ftime_s(&now_tb);
- now_tv.tv_sec = (gpr_int64)now_tb.time;
+ now_tv.tv_sec = (int64_t)now_tb.time;
now_tv.tv_nsec = now_tb.millitm * 1000000;
break;
case GPR_CLOCK_MONOTONIC:
case GPR_CLOCK_PRECISE:
QueryPerformanceCounter(&timestamp);
now_dbl = (timestamp.QuadPart - g_start_time.QuadPart) * g_time_scale;
- now_tv.tv_sec = (gpr_int64)now_dbl;
- now_tv.tv_nsec = (gpr_int32)((now_dbl - (double)now_tv.tv_sec) * 1e9);
+ now_tv.tv_sec = (int64_t)now_dbl;
+ now_tv.tv_nsec = (int32_t)((now_dbl - (double)now_tv.tv_sec) * 1e9);
break;
}
return now_tv;
diff --git a/src/core/support/tls_pthread.c b/src/core/support/tls_pthread.c
index 2d28226fc4..9683a6e547 100644
--- a/src/core/support/tls_pthread.c
+++ b/src/core/support/tls_pthread.c
@@ -37,7 +37,7 @@
#include <grpc/support/tls.h>
-gpr_intptr gpr_tls_set(struct gpr_pthread_thread_local *tls, gpr_intptr value) {
+intptr_t gpr_tls_set(struct gpr_pthread_thread_local *tls, intptr_t value) {
GPR_ASSERT(0 == pthread_setspecific(tls->key, (void *)value));
return value;
}
diff --git a/src/core/surface/byte_buffer_reader.c b/src/core/surface/byte_buffer_reader.c
index 57417f41b0..4679854227 100644
--- a/src/core/surface/byte_buffer_reader.c
+++ b/src/core/surface/byte_buffer_reader.c
@@ -110,7 +110,7 @@ gpr_slice grpc_byte_buffer_reader_readall(grpc_byte_buffer_reader *reader) {
size_t bytes_read = 0;
const size_t input_size = grpc_byte_buffer_length(reader->buffer_out);
gpr_slice out_slice = gpr_slice_malloc(input_size);
- gpr_uint8 *const outbuf = GPR_SLICE_START_PTR(out_slice); /* just an alias */
+ uint8_t *const outbuf = GPR_SLICE_START_PTR(out_slice); /* just an alias */
while (grpc_byte_buffer_reader_next(reader, &in_slice) != 0) {
const size_t slice_length = GPR_SLICE_LENGTH(in_slice);
diff --git a/src/core/surface/call.c b/src/core/surface/call.c
index 2782c1a4dd..880666bb38 100644
--- a/src/core/surface/call.c
+++ b/src/core/surface/call.c
@@ -92,7 +92,7 @@ typedef enum {
} status_source;
typedef struct {
- gpr_uint8 is_set;
+ uint8_t is_set;
grpc_status_code code;
grpc_mdstr *details;
} received_status;
@@ -123,14 +123,14 @@ typedef struct batch_control {
void *notify_tag;
gpr_refcount steps_to_complete;
- gpr_uint8 send_initial_metadata;
- gpr_uint8 send_message;
- gpr_uint8 send_final_op;
- gpr_uint8 recv_initial_metadata;
- gpr_uint8 recv_message;
- gpr_uint8 recv_final_op;
- gpr_uint8 is_notify_tag_closure;
- gpr_uint8 success;
+ uint8_t send_initial_metadata;
+ uint8_t send_message;
+ uint8_t send_final_op;
+ uint8_t recv_initial_metadata;
+ uint8_t recv_message;
+ uint8_t recv_final_op;
+ uint8_t is_notify_tag_closure;
+ uint8_t success;
} batch_control;
struct grpc_call {
@@ -142,22 +142,22 @@ struct grpc_call {
gpr_mu mu;
/* client or server call */
- gpr_uint8 is_client;
+ uint8_t is_client;
/* is the alarm set */
- gpr_uint8 have_alarm;
+ uint8_t have_alarm;
/** has grpc_call_destroy been called */
- gpr_uint8 destroy_called;
+ uint8_t destroy_called;
/** flag indicating that cancellation is inherited */
- gpr_uint8 cancellation_is_inherited;
+ uint8_t cancellation_is_inherited;
/** bitmask of live batches */
- gpr_uint8 used_batches;
+ uint8_t used_batches;
/** which ops are in-flight */
- gpr_uint8 sent_initial_metadata;
- gpr_uint8 sending_message;
- gpr_uint8 sent_final_op;
- gpr_uint8 received_initial_metadata;
- gpr_uint8 receiving_message;
- gpr_uint8 received_final_op;
+ uint8_t sent_initial_metadata;
+ uint8_t sending_message;
+ uint8_t sent_final_op;
+ uint8_t received_initial_metadata;
+ uint8_t receiving_message;
+ uint8_t received_final_op;
batch_control active_batches[MAX_CONCURRENT_BATCHES];
@@ -174,7 +174,7 @@ struct grpc_call {
/* Compression algorithm for the call */
grpc_compression_algorithm compression_algorithm;
/* Supported encodings (compression algorithms), a bitset */
- gpr_uint32 encodings_accepted_by_peer;
+ uint32_t encodings_accepted_by_peer;
/* Contexts for various subsystems (security, tracing, ...). */
grpc_call_context_element context[GRPC_CONTEXT_COUNT];
@@ -200,7 +200,7 @@ struct grpc_call {
gpr_slice receiving_slice;
grpc_closure receiving_slice_ready;
grpc_closure receiving_stream_ready;
- gpr_uint32 test_only_last_message_flags;
+ uint32_t test_only_last_message_flags;
union {
struct {
@@ -234,7 +234,7 @@ static void receiving_slice_ready(grpc_exec_ctx *exec_ctx, void *bctlp,
int success);
grpc_call *grpc_call_create(grpc_channel *channel, grpc_call *parent_call,
- gpr_uint32 propagation_mask,
+ uint32_t propagation_mask,
grpc_completion_queue *cq,
const void *server_transport_data,
grpc_mdelem **add_initial_metadata,
@@ -361,7 +361,7 @@ static void destroy_call(grpc_exec_ctx *exec_ctx, void *call, int success) {
&c->metadata_batch[1 /* is_receiving */][i /* is_initial */]);
}
if (c->receiving_stream != NULL) {
- grpc_byte_stream_destroy(c->receiving_stream);
+ grpc_byte_stream_destroy(exec_ctx, c->receiving_stream);
}
grpc_call_stack_destroy(exec_ctx, CALL_STACK_FROM_CALL(c));
GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, c->channel, "call");
@@ -387,7 +387,7 @@ static void destroy_call(grpc_exec_ctx *exec_ctx, void *call, int success) {
}
static void set_status_code(grpc_call *call, status_source source,
- gpr_uint32 status) {
+ uint32_t status) {
if (call->status[source].is_set) return;
call->status[source].is_set = 1;
@@ -410,8 +410,8 @@ grpc_compression_algorithm grpc_call_test_only_get_compression_algorithm(
return algorithm;
}
-gpr_uint32 grpc_call_test_only_get_message_flags(grpc_call *call) {
- gpr_uint32 flags;
+uint32_t grpc_call_test_only_get_message_flags(grpc_call *call) {
+ uint32_t flags;
gpr_mu_lock(&call->mu);
flags = call->test_only_last_message_flags;
gpr_mu_unlock(&call->mu);
@@ -431,7 +431,7 @@ static void set_encodings_accepted_by_peer(grpc_call *call, grpc_mdelem *mdel) {
grpc_mdelem_get_user_data(mdel, destroy_encodings_accepted_by_peer);
if (accepted_user_data != NULL) {
call->encodings_accepted_by_peer =
- (gpr_uint32)(((gpr_uintptr)accepted_user_data) - 1);
+ (uint32_t)(((uintptr_t)accepted_user_data) - 1);
return;
}
@@ -464,11 +464,11 @@ static void set_encodings_accepted_by_peer(grpc_call *call, grpc_mdelem *mdel) {
grpc_mdelem_set_user_data(
mdel, destroy_encodings_accepted_by_peer,
- (void *)(((gpr_uintptr)call->encodings_accepted_by_peer) + 1));
+ (void *)(((uintptr_t)call->encodings_accepted_by_peer) + 1));
}
-gpr_uint32 grpc_call_test_only_get_encodings_accepted_by_peer(grpc_call *call) {
- gpr_uint32 encodings_accepted_by_peer;
+uint32_t grpc_call_test_only_get_encodings_accepted_by_peer(grpc_call *call) {
+ uint32_t encodings_accepted_by_peer;
gpr_mu_lock(&call->mu);
encodings_accepted_by_peer = call->encodings_accepted_by_peer;
gpr_mu_unlock(&call->mu);
@@ -562,7 +562,7 @@ static int prepare_application_metadata(grpc_call *call, int count,
grpc_linked_mdelem *l = (grpc_linked_mdelem *)&md->internal_data;
GPR_ASSERT(sizeof(grpc_linked_mdelem) == sizeof(md->internal_data));
l->md = grpc_mdelem_from_string_and_buffer(
- md->key, (const gpr_uint8 *)md->value, md->value_length);
+ md->key, (const uint8_t *)md->value, md->value_length);
if (!grpc_header_key_is_legal(grpc_mdstr_as_c_string(l->md->key),
GRPC_MDSTR_LENGTH(l->md->key))) {
gpr_log(GPR_ERROR, "attempt to send invalid metadata key: %s",
@@ -714,7 +714,7 @@ static grpc_call_error cancel_with_status(grpc_exec_ctx *exec_ctx, grpc_call *c,
GPR_ASSERT(status != GRPC_STATUS_OK);
- set_status_code(c, STATUS_FROM_API_OVERRIDE, (gpr_uint32)status);
+ set_status_code(c, STATUS_FROM_API_OVERRIDE, (uint32_t)status);
set_status_details(c, STATUS_FROM_API_OVERRIDE, details);
grpc_closure_init(&cc->closure, send_cancel, cc);
@@ -789,15 +789,15 @@ static void set_deadline_alarm(grpc_exec_ctx *exec_ctx, grpc_call *call,
#define STATUS_OFFSET 1
static void destroy_status(void *ignored) {}
-static gpr_uint32 decode_status(grpc_mdelem *md) {
- gpr_uint32 status;
+static uint32_t decode_status(grpc_mdelem *md) {
+ uint32_t status;
void *user_data;
if (md == GRPC_MDELEM_GRPC_STATUS_0) return 0;
if (md == GRPC_MDELEM_GRPC_STATUS_1) return 1;
if (md == GRPC_MDELEM_GRPC_STATUS_2) return 2;
user_data = grpc_mdelem_get_user_data(md, destroy_status);
if (user_data != NULL) {
- status = ((gpr_uint32)(gpr_intptr)user_data) - STATUS_OFFSET;
+ status = ((uint32_t)(intptr_t)user_data) - STATUS_OFFSET;
} else {
if (!gpr_parse_bytes_to_uint32(grpc_mdstr_as_c_string(md->value),
GPR_SLICE_LENGTH(md->value->slice),
@@ -805,12 +805,12 @@ static gpr_uint32 decode_status(grpc_mdelem *md) {
status = GRPC_STATUS_UNKNOWN; /* could not parse status code */
}
grpc_mdelem_set_user_data(md, destroy_status,
- (void *)(gpr_intptr)(status + STATUS_OFFSET));
+ (void *)(intptr_t)(status + STATUS_OFFSET));
}
return status;
}
-static gpr_uint32 decode_compression(grpc_mdelem *md) {
+static uint32_t decode_compression(grpc_mdelem *md) {
grpc_compression_algorithm algorithm =
grpc_compression_algorithm_from_mdstr(md->value);
if (algorithm == GRPC_COMPRESS_ALGORITHMS_COUNT) {
@@ -900,11 +900,11 @@ static void set_cancelled_value(grpc_status_code status, void *dest) {
*(int *)dest = (status != GRPC_STATUS_OK);
}
-static int are_write_flags_valid(gpr_uint32 flags) {
+static int are_write_flags_valid(uint32_t flags) {
/* check that only bits in GRPC_WRITE_(INTERNAL?)_USED_MASK are set */
- const gpr_uint32 allowed_write_positions =
+ const uint32_t allowed_write_positions =
(GRPC_WRITE_USED_MASK | GRPC_WRITE_INTERNAL_USED_MASK);
- const gpr_uint32 invalid_positions = ~allowed_write_positions;
+ const uint32_t invalid_positions = ~allowed_write_positions;
return !(flags & invalid_positions);
}
@@ -912,8 +912,7 @@ static batch_control *allocate_batch_control(grpc_call *call) {
size_t i;
for (i = 0; i < MAX_CONCURRENT_BATCHES; i++) {
if ((call->used_batches & (1 << i)) == 0) {
- call->used_batches =
- (gpr_uint8)(call->used_batches | (gpr_uint8)(1 << i));
+ call->used_batches = (uint8_t)(call->used_batches | (uint8_t)(1 << i));
return &call->active_batches[i];
}
}
@@ -925,8 +924,8 @@ static void finish_batch_completion(grpc_exec_ctx *exec_ctx, void *user_data,
batch_control *bctl = user_data;
grpc_call *call = bctl->call;
gpr_mu_lock(&call->mu);
- call->used_batches = (gpr_uint8)(
- call->used_batches & ~(gpr_uint8)(1 << (bctl - call->active_batches)));
+ call->used_batches = (uint8_t)(
+ call->used_batches & ~(uint8_t)(1 << (bctl - call->active_batches)));
gpr_mu_unlock(&call->mu);
GRPC_CALL_INTERNAL_UNREF(exec_ctx, call, "completion");
}
@@ -938,8 +937,8 @@ static void post_batch_completion(grpc_exec_ctx *exec_ctx,
grpc_exec_ctx_enqueue(exec_ctx, bctl->notify_tag, bctl->success);
gpr_mu_lock(&call->mu);
bctl->call->used_batches =
- (gpr_uint8)(bctl->call->used_batches &
- ~(gpr_uint8)(1 << (bctl - bctl->call->active_batches)));
+ (uint8_t)(bctl->call->used_batches &
+ ~(uint8_t)(1 << (bctl - bctl->call->active_batches)));
gpr_mu_unlock(&call->mu);
GRPC_CALL_INTERNAL_UNREF(exec_ctx, call, "completion");
} else {
@@ -956,7 +955,7 @@ static void continue_receiving_slices(grpc_exec_ctx *exec_ctx,
(*call->receiving_buffer)->data.raw.slice_buffer.length;
if (remaining == 0) {
call->receiving_message = 0;
- grpc_byte_stream_destroy(call->receiving_stream);
+ grpc_byte_stream_destroy(exec_ctx, call->receiving_stream);
call->receiving_stream = NULL;
if (gpr_unref(&bctl->steps_to_complete)) {
post_batch_completion(exec_ctx, bctl);
@@ -979,11 +978,19 @@ static void receiving_slice_ready(grpc_exec_ctx *exec_ctx, void *bctlp,
batch_control *bctl = bctlp;
grpc_call *call = bctl->call;
- GPR_ASSERT(success);
- gpr_slice_buffer_add(&(*call->receiving_buffer)->data.raw.slice_buffer,
- call->receiving_slice);
-
- continue_receiving_slices(exec_ctx, bctl);
+ if (success) {
+ gpr_slice_buffer_add(&(*call->receiving_buffer)->data.raw.slice_buffer,
+ call->receiving_slice);
+ continue_receiving_slices(exec_ctx, bctl);
+ } else {
+ grpc_byte_stream_destroy(exec_ctx, call->receiving_stream);
+ call->receiving_stream = NULL;
+ grpc_byte_buffer_destroy(*call->receiving_buffer);
+ *call->receiving_buffer = NULL;
+ if (gpr_unref(&bctl->steps_to_complete)) {
+ post_batch_completion(exec_ctx, bctl);
+ }
+ }
}
static void finish_batch(grpc_exec_ctx *exec_ctx, void *bctlp, int success) {
@@ -1065,6 +1072,7 @@ static void receiving_stream_ready(grpc_exec_ctx *exec_ctx, void *bctlp,
if (call->receiving_stream == NULL) {
*call->receiving_buffer = NULL;
+ call->receiving_message = 0;
if (gpr_unref(&bctl->steps_to_complete)) {
post_batch_completion(exec_ctx, bctl);
}
@@ -1072,9 +1080,10 @@ static void receiving_stream_ready(grpc_exec_ctx *exec_ctx, void *bctlp,
grpc_channel_get_max_message_length(call->channel)) {
cancel_with_status(exec_ctx, call, GRPC_STATUS_INTERNAL,
"Max message size exceeded");
- grpc_byte_stream_destroy(call->receiving_stream);
+ grpc_byte_stream_destroy(exec_ctx, call->receiving_stream);
call->receiving_stream = NULL;
*call->receiving_buffer = NULL;
+ call->receiving_message = 0;
if (gpr_unref(&bctl->steps_to_complete)) {
post_batch_completion(exec_ctx, bctl);
}
@@ -1118,7 +1127,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx,
memset(bctl, 0, sizeof(*bctl));
bctl->call = call;
bctl->notify_tag = notify_tag;
- bctl->is_notify_tag_closure = (gpr_uint8)(is_notify_tag_closure != 0);
+ bctl->is_notify_tag_closure = (uint8_t)(is_notify_tag_closure != 0);
if (nops == 0) {
GRPC_CALL_INTERNAL_REF(call, "completion");
@@ -1241,7 +1250,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx,
GRPC_MDSTR_REF(call->send_extra_metadata[1].md->value));
}
set_status_code(call, STATUS_FROM_API_OVERRIDE,
- (gpr_uint32)op->data.send_status_from_server.status);
+ (uint32_t)op->data.send_status_from_server.status);
if (!prepare_application_metadata(
call,
(int)op->data.send_status_from_server.trailing_metadata_count,
@@ -1362,7 +1371,7 @@ done_with_error:
}
if (bctl->send_message) {
call->sending_message = 0;
- grpc_byte_stream_destroy(&call->sending_stream.base);
+ grpc_byte_stream_destroy(exec_ctx, &call->sending_stream.base);
}
if (bctl->send_final_op) {
call->sent_final_op = 0;
@@ -1421,4 +1430,4 @@ void *grpc_call_context_get(grpc_call *call, grpc_context_index elem) {
return call->context[elem].value;
}
-gpr_uint8 grpc_call_is_client(grpc_call *call) { return call->is_client; }
+uint8_t grpc_call_is_client(grpc_call *call) { return call->is_client; }
diff --git a/src/core/surface/call.h b/src/core/surface/call.h
index b53340df8e..0bbffb98ae 100644
--- a/src/core/surface/call.h
+++ b/src/core/surface/call.h
@@ -49,7 +49,7 @@ typedef void (*grpc_ioreq_completion_func)(grpc_exec_ctx *exec_ctx,
void *user_data);
grpc_call *grpc_call_create(grpc_channel *channel, grpc_call *parent_call,
- gpr_uint32 propagation_mask,
+ uint32_t propagation_mask,
grpc_completion_queue *cq,
const void *server_transport_data,
grpc_mdelem **add_initial_metadata,
@@ -100,7 +100,7 @@ void *grpc_call_context_get(grpc_call *call, grpc_context_index elem);
#define GRPC_CALL_LOG_BATCH(sev, call, ops, nops, tag) \
if (grpc_api_trace) grpc_call_log_batch(sev, call, ops, nops, tag)
-gpr_uint8 grpc_call_is_client(grpc_call *call);
+uint8_t grpc_call_is_client(grpc_call *call);
#ifdef __cplusplus
}
diff --git a/src/core/surface/call_test_only.h b/src/core/surface/call_test_only.h
index b3a2bbd6f1..b57c95c64a 100644
--- a/src/core/surface/call_test_only.h
+++ b/src/core/surface/call_test_only.h
@@ -49,13 +49,13 @@ grpc_compression_algorithm grpc_call_test_only_get_compression_algorithm(
/** Return the message flags from \a call.
*
* \warning This function should \b only be used in test code. */
-gpr_uint32 grpc_call_test_only_get_message_flags(grpc_call *call);
+uint32_t grpc_call_test_only_get_message_flags(grpc_call *call);
/** Returns a bitset for the encodings (compression algorithms) supported by \a
* call's peer.
*
* To be indexed by grpc_compression_algorithm enum values. */
-gpr_uint32 grpc_call_test_only_get_encodings_accepted_by_peer(grpc_call *call);
+uint32_t grpc_call_test_only_get_encodings_accepted_by_peer(grpc_call *call);
#ifdef __cplusplus
}
diff --git a/src/core/surface/channel.c b/src/core/surface/channel.c
index d0a8b0be09..001692376f 100644
--- a/src/core/surface/channel.c
+++ b/src/core/surface/channel.c
@@ -63,7 +63,7 @@ typedef struct registered_call {
struct grpc_channel {
int is_client;
- gpr_uint32 max_message_length;
+ uint32_t max_message_length;
grpc_mdelem *default_authority;
gpr_mu registered_call_mu;
@@ -108,7 +108,7 @@ grpc_channel *grpc_channel_create_from_filters(
gpr_log(GPR_ERROR, "%s ignored: it must be >= 0",
GRPC_ARG_MAX_MESSAGE_LENGTH);
} else {
- channel->max_message_length = (gpr_uint32)args->args[i].value.integer;
+ channel->max_message_length = (uint32_t)args->args[i].value.integer;
}
} else if (0 == strcmp(args->args[i].key, GRPC_ARG_DEFAULT_AUTHORITY)) {
if (args->args[i].type != GRPC_ARG_STRING) {
@@ -166,7 +166,7 @@ char *grpc_channel_get_target(grpc_channel *channel) {
}
static grpc_call *grpc_channel_create_call_internal(
- grpc_channel *channel, grpc_call *parent_call, gpr_uint32 propagation_mask,
+ grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask,
grpc_completion_queue *cq, grpc_mdelem *path_mdelem,
grpc_mdelem *authority_mdelem, gpr_timespec deadline) {
grpc_mdelem *send_metadata[2];
@@ -187,7 +187,7 @@ static grpc_call *grpc_channel_create_call_internal(
grpc_call *grpc_channel_create_call(grpc_channel *channel,
grpc_call *parent_call,
- gpr_uint32 propagation_mask,
+ uint32_t propagation_mask,
grpc_completion_queue *cq,
const char *method, const char *host,
gpr_timespec deadline, void *reserved) {
@@ -231,7 +231,7 @@ void *grpc_channel_register_call(grpc_channel *channel, const char *method,
}
grpc_call *grpc_channel_create_registered_call(
- grpc_channel *channel, grpc_call *parent_call, gpr_uint32 propagation_mask,
+ grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask,
grpc_completion_queue *completion_queue, void *registered_call_handle,
gpr_timespec deadline, void *reserved) {
registered_call *rc = registered_call_handle;
@@ -322,6 +322,6 @@ grpc_mdelem *grpc_channel_get_reffed_status_elem(grpc_channel *channel, int i) {
grpc_mdstr_from_string(tmp));
}
-gpr_uint32 grpc_channel_get_max_message_length(grpc_channel *channel) {
+uint32_t grpc_channel_get_max_message_length(grpc_channel *channel) {
return channel->max_message_length;
}
diff --git a/src/core/surface/channel.h b/src/core/surface/channel.h
index 3d2ff23542..00240c637f 100644
--- a/src/core/surface/channel.h
+++ b/src/core/surface/channel.h
@@ -51,7 +51,7 @@ grpc_channel_stack *grpc_channel_get_channel_stack(grpc_channel *channel);
The returned elem is owned by the caller. */
grpc_mdelem *grpc_channel_get_reffed_status_elem(grpc_channel *channel,
int status_code);
-gpr_uint32 grpc_channel_get_max_message_length(grpc_channel *channel);
+uint32_t grpc_channel_get_max_message_length(grpc_channel *channel);
#ifdef GRPC_STREAM_REFCOUNT_DEBUG
void grpc_channel_internal_ref(grpc_channel *channel, const char *reason);
diff --git a/src/core/surface/completion_queue.c b/src/core/surface/completion_queue.c
index 848a33adc3..c0db9c508a 100644
--- a/src/core/surface/completion_queue.c
+++ b/src/core/surface/completion_queue.c
@@ -142,7 +142,7 @@ grpc_completion_queue *grpc_completion_queue_create(void *reserved) {
/* One for destroy(), one for pollset_shutdown */
gpr_ref_init(&cc->owning_refs, 2);
cc->completed_tail = &cc->completed_head;
- cc->completed_head.next = (gpr_uintptr)cc->completed_tail;
+ cc->completed_head.next = (uintptr_t)cc->completed_tail;
cc->shutdown = 0;
cc->shutdown_called = 0;
cc->is_server_cq = 0;
@@ -183,7 +183,7 @@ void grpc_cq_internal_unref(grpc_completion_queue *cc, const char *reason,
void grpc_cq_internal_unref(grpc_completion_queue *cc) {
#endif
if (gpr_unref(&cc->owning_refs)) {
- GPR_ASSERT(cc->completed_head.next == (gpr_uintptr)&cc->completed_head);
+ GPR_ASSERT(cc->completed_head.next == (uintptr_t)&cc->completed_head);
grpc_pollset_reset(&cc->pollset);
gpr_mu_lock(&g_freelist_mu);
cc->next_free = g_freelist;
@@ -229,7 +229,7 @@ void grpc_cq_end_op(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cc,
storage->done = done;
storage->done_arg = done_arg;
storage->next =
- ((gpr_uintptr)&cc->completed_head) | ((gpr_uintptr)(success != 0));
+ ((uintptr_t)&cc->completed_head) | ((uintptr_t)(success != 0));
gpr_mu_lock(GRPC_POLLSET_MU(&cc->pollset));
#ifndef NDEBUG
@@ -247,7 +247,7 @@ void grpc_cq_end_op(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cc,
shutdown = gpr_unref(&cc->pending_events);
if (!shutdown) {
cc->completed_tail->next =
- ((gpr_uintptr)storage) | (1u & (gpr_uintptr)cc->completed_tail->next);
+ ((uintptr_t)storage) | (1u & (uintptr_t)cc->completed_tail->next);
cc->completed_tail = storage;
pluck_worker = NULL;
for (i = 0; i < cc->num_pluckers; i++) {
@@ -260,7 +260,7 @@ void grpc_cq_end_op(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cc,
gpr_mu_unlock(GRPC_POLLSET_MU(&cc->pollset));
} else {
cc->completed_tail->next =
- ((gpr_uintptr)storage) | (1u & (gpr_uintptr)cc->completed_tail->next);
+ ((uintptr_t)storage) | (1u & (uintptr_t)cc->completed_tail->next);
cc->completed_tail = storage;
GPR_ASSERT(!cc->shutdown);
GPR_ASSERT(cc->shutdown_called);
@@ -298,7 +298,7 @@ grpc_event grpc_completion_queue_next(grpc_completion_queue *cc,
for (;;) {
if (cc->completed_tail != &cc->completed_head) {
grpc_cq_completion *c = (grpc_cq_completion *)cc->completed_head.next;
- cc->completed_head.next = c->next & ~(gpr_uintptr)1;
+ cc->completed_head.next = c->next & ~(uintptr_t)1;
if (c == cc->completed_tail) {
cc->completed_tail = &cc->completed_head;
}
@@ -385,11 +385,10 @@ grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cc, void *tag,
gpr_mu_lock(GRPC_POLLSET_MU(&cc->pollset));
for (;;) {
prev = &cc->completed_head;
- while ((c = (grpc_cq_completion *)(prev->next & ~(gpr_uintptr)1)) !=
+ while ((c = (grpc_cq_completion *)(prev->next & ~(uintptr_t)1)) !=
&cc->completed_head) {
if (c->tag == tag) {
- prev->next =
- (prev->next & (gpr_uintptr)1) | (c->next & ~(gpr_uintptr)1);
+ prev->next = (prev->next & (uintptr_t)1) | (c->next & ~(uintptr_t)1);
if (c == cc->completed_tail) {
cc->completed_tail = prev;
}
diff --git a/src/core/surface/completion_queue.h b/src/core/surface/completion_queue.h
index 1e40c48bea..27ef90f2d5 100644
--- a/src/core/surface/completion_queue.h
+++ b/src/core/surface/completion_queue.h
@@ -48,7 +48,7 @@ typedef struct grpc_cq_completion {
struct grpc_cq_completion *c);
void *done_arg;
/** next pointer; low bit is used to indicate success or not */
- gpr_uintptr next;
+ uintptr_t next;
} grpc_cq_completion;
#ifdef GRPC_CQ_REF_COUNT_DEBUG
diff --git a/src/core/surface/init.c b/src/core/surface/init.c
index 82027af651..19cea4c4f6 100644
--- a/src/core/surface/init.c
+++ b/src/core/surface/init.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -82,8 +82,8 @@ static grpc_plugin g_all_of_the_plugins[MAX_PLUGINS];
static int g_number_of_plugins = 0;
void grpc_register_plugin(void (*init)(void), void (*destroy)(void)) {
- GRPC_API_TRACE("grpc_register_plugin(init=%lx, destroy=%lx)", 2,
- ((unsigned long)init, (unsigned long)destroy));
+ GRPC_API_TRACE("grpc_register_plugin(init=%p, destroy=%p)", 2,
+ ((void*)(intptr_t)init, (void*)(intptr_t)destroy));
GPR_ASSERT(g_number_of_plugins != MAX_PLUGINS);
g_all_of_the_plugins[g_number_of_plugins].init = init;
g_all_of_the_plugins[g_number_of_plugins].destroy = destroy;
diff --git a/src/core/surface/server.c b/src/core/surface/server.c
index 1e1cde3648..79db13810a 100644
--- a/src/core/surface/server.c
+++ b/src/core/surface/server.c
@@ -113,8 +113,8 @@ struct channel_data {
channel_data *next;
channel_data *prev;
channel_registered_method *registered_methods;
- gpr_uint32 registered_method_slots;
- gpr_uint32 registered_method_max_probes;
+ uint32_t registered_method_slots;
+ uint32_t registered_method_max_probes;
grpc_closure finish_destroy_channel_closure;
grpc_closure channel_connectivity_changed;
};
@@ -209,7 +209,7 @@ struct grpc_server {
size_t max_requested_calls;
gpr_atm shutdown_flag;
- gpr_uint8 shutdown_published;
+ uint8_t shutdown_published;
size_t num_shutdown_tags;
shutdown_tag *shutdown_tags;
@@ -450,8 +450,8 @@ static void start_new_rpc(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) {
channel_data *chand = elem->channel_data;
call_data *calld = elem->call_data;
grpc_server *server = chand->server;
- gpr_uint32 i;
- gpr_uint32 hash;
+ uint32_t i;
+ uint32_t hash;
channel_registered_method *rm;
if (chand->registered_methods && calld->path && calld->host) {
@@ -901,10 +901,10 @@ void grpc_server_setup_transport(grpc_exec_ctx *exec_ctx, grpc_server *s,
channel_data *chand;
grpc_mdstr *host;
grpc_mdstr *method;
- gpr_uint32 hash;
+ uint32_t hash;
size_t slots;
- gpr_uint32 probes;
- gpr_uint32 max_probes = 0;
+ uint32_t probes;
+ uint32_t max_probes = 0;
grpc_transport_op op;
for (i = 0; i < s->channel_filter_count; i++) {
@@ -954,8 +954,8 @@ void grpc_server_setup_transport(grpc_exec_ctx *exec_ctx, grpc_server *s,
crm->host = host;
crm->method = method;
}
- GPR_ASSERT(slots <= GPR_UINT32_MAX);
- chand->registered_method_slots = (gpr_uint32)slots;
+ GPR_ASSERT(slots <= UINT32_MAX);
+ chand->registered_method_slots = (uint32_t)slots;
chand->registered_method_max_probes = max_probes;
}
diff --git a/src/core/transport/byte_stream.c b/src/core/transport/byte_stream.c
index 81e8e77ccb..8e6fb2cbef 100644
--- a/src/core/transport/byte_stream.c
+++ b/src/core/transport/byte_stream.c
@@ -44,8 +44,9 @@ int grpc_byte_stream_next(grpc_exec_ctx *exec_ctx,
on_complete);
}
-void grpc_byte_stream_destroy(grpc_byte_stream *byte_stream) {
- byte_stream->destroy(byte_stream);
+void grpc_byte_stream_destroy(grpc_exec_ctx *exec_ctx,
+ grpc_byte_stream *byte_stream) {
+ byte_stream->destroy(exec_ctx, byte_stream);
}
/* slice_buffer_stream */
@@ -61,13 +62,14 @@ static int slice_buffer_stream_next(grpc_exec_ctx *exec_ctx,
return 1;
}
-static void slice_buffer_stream_destroy(grpc_byte_stream *byte_stream) {}
+static void slice_buffer_stream_destroy(grpc_exec_ctx *exec_ctx,
+ grpc_byte_stream *byte_stream) {}
void grpc_slice_buffer_stream_init(grpc_slice_buffer_stream *stream,
gpr_slice_buffer *slice_buffer,
- gpr_uint32 flags) {
- GPR_ASSERT(slice_buffer->length <= GPR_UINT32_MAX);
- stream->base.length = (gpr_uint32)slice_buffer->length;
+ uint32_t flags) {
+ GPR_ASSERT(slice_buffer->length <= UINT32_MAX);
+ stream->base.length = (uint32_t)slice_buffer->length;
stream->base.flags = flags;
stream->base.next = slice_buffer_stream_next;
stream->base.destroy = slice_buffer_stream_destroy;
diff --git a/src/core/transport/byte_stream.h b/src/core/transport/byte_stream.h
index c94d8ff275..d2e51e7b45 100644
--- a/src/core/transport/byte_stream.h
+++ b/src/core/transport/byte_stream.h
@@ -47,12 +47,12 @@ struct grpc_byte_stream;
typedef struct grpc_byte_stream grpc_byte_stream;
struct grpc_byte_stream {
- gpr_uint32 length;
- gpr_uint32 flags;
+ uint32_t length;
+ uint32_t flags;
int (*next)(grpc_exec_ctx *exec_ctx, grpc_byte_stream *byte_stream,
gpr_slice *slice, size_t max_size_hint,
grpc_closure *on_complete);
- void (*destroy)(grpc_byte_stream *byte_stream);
+ void (*destroy)(grpc_exec_ctx *exec_ctx, grpc_byte_stream *byte_stream);
};
/* returns 1 if the bytes are available immediately (in which case
@@ -72,7 +72,8 @@ int grpc_byte_stream_next(grpc_exec_ctx *exec_ctx,
grpc_byte_stream *byte_stream, gpr_slice *slice,
size_t max_size_hint, grpc_closure *on_complete);
-void grpc_byte_stream_destroy(grpc_byte_stream *byte_stream);
+void grpc_byte_stream_destroy(grpc_exec_ctx *exec_ctx,
+ grpc_byte_stream *byte_stream);
/* grpc_byte_stream that wraps a slice buffer */
typedef struct grpc_slice_buffer_stream {
@@ -83,6 +84,6 @@ typedef struct grpc_slice_buffer_stream {
void grpc_slice_buffer_stream_init(grpc_slice_buffer_stream *stream,
gpr_slice_buffer *slice_buffer,
- gpr_uint32 flags);
+ uint32_t flags);
#endif /* GRPC_INTERNAL_CORE_TRANSPORT_BYTE_STREAM_H */
diff --git a/src/core/transport/chttp2/bin_encoder.c b/src/core/transport/chttp2/bin_encoder.c
index 53ea9ac609..f26bc7e29b 100644
--- a/src/core/transport/chttp2/bin_encoder.c
+++ b/src/core/transport/chttp2/bin_encoder.c
@@ -42,8 +42,8 @@ static const char alphabet[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
typedef struct {
- gpr_uint16 bits;
- gpr_uint8 length;
+ uint16_t bits;
+ uint8_t length;
} b64_huff_sym;
static const b64_huff_sym huff_alphabet[64] = {{0x21, 6},
@@ -111,7 +111,7 @@ static const b64_huff_sym huff_alphabet[64] = {{0x21, 6},
{0x7fb, 11},
{0x18, 6}};
-static const gpr_uint8 tail_xtra[3] = {0, 2, 3};
+static const uint8_t tail_xtra[3] = {0, 2, 3};
gpr_slice grpc_chttp2_base64_encode(gpr_slice input) {
size_t input_length = GPR_SLICE_LENGTH(input);
@@ -119,7 +119,7 @@ gpr_slice grpc_chttp2_base64_encode(gpr_slice input) {
size_t tail_case = input_length % 3;
size_t output_length = input_triplets * 4 + tail_xtra[tail_case];
gpr_slice output = gpr_slice_malloc(output_length);
- gpr_uint8 *in = GPR_SLICE_START_PTR(input);
+ uint8_t *in = GPR_SLICE_START_PTR(input);
char *out = (char *)GPR_SLICE_START_PTR(output);
size_t i;
@@ -159,11 +159,11 @@ gpr_slice grpc_chttp2_base64_encode(gpr_slice input) {
gpr_slice grpc_chttp2_huffman_compress(gpr_slice input) {
size_t nbits;
- gpr_uint8 *in;
- gpr_uint8 *out;
+ uint8_t *in;
+ uint8_t *out;
gpr_slice output;
- gpr_uint32 temp = 0;
- gpr_uint32 temp_length = 0;
+ uint32_t temp = 0;
+ uint32_t temp_length = 0;
nbits = 0;
for (in = GPR_SLICE_START_PTR(input); in != GPR_SLICE_END_PTR(input); ++in) {
@@ -180,7 +180,7 @@ gpr_slice grpc_chttp2_huffman_compress(gpr_slice input) {
while (temp_length > 8) {
temp_length -= 8;
- *out++ = (gpr_uint8)(temp >> temp_length);
+ *out++ = (uint8_t)(temp >> temp_length);
}
}
@@ -189,8 +189,8 @@ gpr_slice grpc_chttp2_huffman_compress(gpr_slice input) {
* expanded form due to the "integral promotion" performed (see section
* 3.2.1.1 of the C89 draft standard). A cast to the smaller container type
* is then required to avoid the compiler warning */
- *out++ = (gpr_uint8)((gpr_uint8)(temp << (8u - temp_length)) |
- (gpr_uint8)(0xffu >> temp_length));
+ *out++ = (uint8_t)((uint8_t)(temp << (8u - temp_length)) |
+ (uint8_t)(0xffu >> temp_length));
}
GPR_ASSERT(out == GPR_SLICE_END_PTR(output));
@@ -199,28 +199,28 @@ gpr_slice grpc_chttp2_huffman_compress(gpr_slice input) {
}
typedef struct {
- gpr_uint32 temp;
- gpr_uint32 temp_length;
- gpr_uint8 *out;
+ uint32_t temp;
+ uint32_t temp_length;
+ uint8_t *out;
} huff_out;
static void enc_flush_some(huff_out *out) {
while (out->temp_length > 8) {
out->temp_length -= 8;
- *out->out++ = (gpr_uint8)(out->temp >> out->temp_length);
+ *out->out++ = (uint8_t)(out->temp >> out->temp_length);
}
}
-static void enc_add2(huff_out *out, gpr_uint8 a, gpr_uint8 b) {
+static void enc_add2(huff_out *out, uint8_t a, uint8_t b) {
b64_huff_sym sa = huff_alphabet[a];
b64_huff_sym sb = huff_alphabet[b];
out->temp = (out->temp << (sa.length + sb.length)) |
- ((gpr_uint32)sa.bits << sb.length) | sb.bits;
- out->temp_length += (gpr_uint32)sa.length + (gpr_uint32)sb.length;
+ ((uint32_t)sa.bits << sb.length) | sb.bits;
+ out->temp_length += (uint32_t)sa.length + (uint32_t)sb.length;
enc_flush_some(out);
}
-static void enc_add1(huff_out *out, gpr_uint8 a) {
+static void enc_add1(huff_out *out, uint8_t a) {
b64_huff_sym sa = huff_alphabet[a];
out->temp = (out->temp << sa.length) | sa.bits;
out->temp_length += sa.length;
@@ -235,8 +235,8 @@ gpr_slice grpc_chttp2_base64_encode_and_huffman_compress(gpr_slice input) {
size_t max_output_bits = 11 * output_syms;
size_t max_output_length = max_output_bits / 8 + (max_output_bits % 8 != 0);
gpr_slice output = gpr_slice_malloc(max_output_length);
- gpr_uint8 *in = GPR_SLICE_START_PTR(input);
- gpr_uint8 *start_out = GPR_SLICE_START_PTR(output);
+ uint8_t *in = GPR_SLICE_START_PTR(input);
+ uint8_t *start_out = GPR_SLICE_START_PTR(output);
huff_out out;
size_t i;
@@ -246,9 +246,9 @@ gpr_slice grpc_chttp2_base64_encode_and_huffman_compress(gpr_slice input) {
/* encode full triplets */
for (i = 0; i < input_triplets; i++) {
- enc_add2(&out, in[0] >> 2, (gpr_uint8)((in[0] & 0x3) << 4) | (in[1] >> 4));
- enc_add2(&out, (gpr_uint8)((in[1] & 0xf) << 2) | (in[2] >> 6),
- (gpr_uint8)(in[2] & 0x3f));
+ enc_add2(&out, in[0] >> 2, (uint8_t)((in[0] & 0x3) << 4) | (in[1] >> 4));
+ enc_add2(&out, (uint8_t)((in[1] & 0xf) << 2) | (in[2] >> 6),
+ (uint8_t)(in[2] & 0x3f));
in += 3;
}
@@ -257,13 +257,13 @@ gpr_slice grpc_chttp2_base64_encode_and_huffman_compress(gpr_slice input) {
case 0:
break;
case 1:
- enc_add2(&out, in[0] >> 2, (gpr_uint8)((in[0] & 0x3) << 4));
+ enc_add2(&out, in[0] >> 2, (uint8_t)((in[0] & 0x3) << 4));
in += 1;
break;
case 2:
enc_add2(&out, in[0] >> 2,
- (gpr_uint8)((in[0] & 0x3) << 4) | (gpr_uint8)(in[1] >> 4));
- enc_add1(&out, (gpr_uint8)((in[1] & 0xf) << 2));
+ (uint8_t)((in[0] & 0x3) << 4) | (uint8_t)(in[1] >> 4));
+ enc_add1(&out, (uint8_t)((in[1] & 0xf) << 2));
in += 2;
break;
}
@@ -273,8 +273,8 @@ gpr_slice grpc_chttp2_base64_encode_and_huffman_compress(gpr_slice input) {
* expanded form due to the "integral promotion" performed (see section
* 3.2.1.1 of the C89 draft standard). A cast to the smaller container type
* is then required to avoid the compiler warning */
- *out.out++ = (gpr_uint8)((gpr_uint8)(out.temp << (8u - out.temp_length)) |
- (gpr_uint8)(0xffu >> out.temp_length));
+ *out.out++ = (uint8_t)((uint8_t)(out.temp << (8u - out.temp_length)) |
+ (uint8_t)(0xffu >> out.temp_length));
}
GPR_ASSERT(out.out <= GPR_SLICE_END_PTR(output));
diff --git a/src/core/transport/chttp2/frame_data.c b/src/core/transport/chttp2/frame_data.c
index 732124b7c9..f9a1af8873 100644
--- a/src/core/transport/chttp2/frame_data.c
+++ b/src/core/transport/chttp2/frame_data.c
@@ -53,16 +53,17 @@ void grpc_chttp2_data_parser_destroy(grpc_exec_ctx *exec_ctx,
grpc_chttp2_data_parser *parser) {
grpc_byte_stream *bs;
if (parser->parsing_frame) {
- grpc_chttp2_incoming_byte_stream_finished(exec_ctx, parser->parsing_frame);
+ grpc_chttp2_incoming_byte_stream_finished(exec_ctx, parser->parsing_frame,
+ 0, 1);
}
while (
(bs = grpc_chttp2_incoming_frame_queue_pop(&parser->incoming_frames))) {
- grpc_byte_stream_destroy(bs);
+ grpc_byte_stream_destroy(exec_ctx, bs);
}
}
grpc_chttp2_parse_error grpc_chttp2_data_parser_begin_frame(
- grpc_chttp2_data_parser *parser, gpr_uint8 flags) {
+ grpc_chttp2_data_parser *parser, uint8_t flags) {
if (flags & ~GRPC_CHTTP2_DATA_FLAG_END_STREAM) {
gpr_log(GPR_ERROR, "unsupported data flags: 0x%02x", flags);
return GRPC_CHTTP2_STREAM_ERROR;
@@ -110,24 +111,24 @@ grpc_byte_stream *grpc_chttp2_incoming_frame_queue_pop(
return out;
}
-void grpc_chttp2_encode_data(gpr_uint32 id, gpr_slice_buffer *inbuf,
- gpr_uint32 write_bytes, int is_eof,
+void grpc_chttp2_encode_data(uint32_t id, gpr_slice_buffer *inbuf,
+ uint32_t write_bytes, int is_eof,
gpr_slice_buffer *outbuf) {
gpr_slice hdr;
- gpr_uint8 *p;
+ uint8_t *p;
hdr = gpr_slice_malloc(9);
p = GPR_SLICE_START_PTR(hdr);
GPR_ASSERT(write_bytes < (1 << 24));
- *p++ = (gpr_uint8)(write_bytes >> 16);
- *p++ = (gpr_uint8)(write_bytes >> 8);
- *p++ = (gpr_uint8)(write_bytes);
+ *p++ = (uint8_t)(write_bytes >> 16);
+ *p++ = (uint8_t)(write_bytes >> 8);
+ *p++ = (uint8_t)(write_bytes);
*p++ = GRPC_CHTTP2_FRAME_DATA;
*p++ = is_eof ? GRPC_CHTTP2_DATA_FLAG_END_STREAM : 0;
- *p++ = (gpr_uint8)(id >> 24);
- *p++ = (gpr_uint8)(id >> 16);
- *p++ = (gpr_uint8)(id >> 8);
- *p++ = (gpr_uint8)(id);
+ *p++ = (uint8_t)(id >> 24);
+ *p++ = (uint8_t)(id >> 16);
+ *p++ = (uint8_t)(id >> 8);
+ *p++ = (uint8_t)(id);
gpr_slice_buffer_add(outbuf, hdr);
gpr_slice_buffer_move_first(inbuf, write_bytes, outbuf);
@@ -137,11 +138,11 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
grpc_exec_ctx *exec_ctx, void *parser,
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last) {
- gpr_uint8 *const beg = GPR_SLICE_START_PTR(slice);
- gpr_uint8 *const end = GPR_SLICE_END_PTR(slice);
- gpr_uint8 *cur = beg;
+ uint8_t *const beg = GPR_SLICE_START_PTR(slice);
+ uint8_t *const end = GPR_SLICE_END_PTR(slice);
+ uint8_t *cur = beg;
grpc_chttp2_data_parser *p = parser;
- gpr_uint32 message_flags;
+ uint32_t message_flags;
grpc_chttp2_incoming_byte_stream *incoming_byte_stream;
if (is_last && p->is_last_frame) {
@@ -173,28 +174,28 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
}
/* fallthrough */
case GRPC_CHTTP2_DATA_FH_1:
- p->frame_size = ((gpr_uint32)*cur) << 24;
+ p->frame_size = ((uint32_t)*cur) << 24;
if (++cur == end) {
p->state = GRPC_CHTTP2_DATA_FH_2;
return GRPC_CHTTP2_PARSE_OK;
}
/* fallthrough */
case GRPC_CHTTP2_DATA_FH_2:
- p->frame_size |= ((gpr_uint32)*cur) << 16;
+ p->frame_size |= ((uint32_t)*cur) << 16;
if (++cur == end) {
p->state = GRPC_CHTTP2_DATA_FH_3;
return GRPC_CHTTP2_PARSE_OK;
}
/* fallthrough */
case GRPC_CHTTP2_DATA_FH_3:
- p->frame_size |= ((gpr_uint32)*cur) << 8;
+ p->frame_size |= ((uint32_t)*cur) << 8;
if (++cur == end) {
p->state = GRPC_CHTTP2_DATA_FH_4;
return GRPC_CHTTP2_PARSE_OK;
}
/* fallthrough */
case GRPC_CHTTP2_DATA_FH_4:
- p->frame_size |= ((gpr_uint32)*cur);
+ p->frame_size |= ((uint32_t)*cur);
p->state = GRPC_CHTTP2_DATA_FRAME;
++cur;
message_flags = 0;
@@ -214,20 +215,22 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
}
grpc_chttp2_list_add_parsing_seen_stream(transport_parsing,
stream_parsing);
- if ((gpr_uint32)(end - cur) == p->frame_size) {
+ if ((uint32_t)(end - cur) == p->frame_size) {
grpc_chttp2_incoming_byte_stream_push(
exec_ctx, p->parsing_frame,
gpr_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg)));
- grpc_chttp2_incoming_byte_stream_finished(exec_ctx, p->parsing_frame);
+ grpc_chttp2_incoming_byte_stream_finished(exec_ctx, p->parsing_frame, 1,
+ 1);
p->parsing_frame = NULL;
p->state = GRPC_CHTTP2_DATA_FH_0;
return GRPC_CHTTP2_PARSE_OK;
- } else if ((gpr_uint32)(end - cur) > p->frame_size) {
+ } else if ((uint32_t)(end - cur) > p->frame_size) {
grpc_chttp2_incoming_byte_stream_push(
exec_ctx, p->parsing_frame,
gpr_slice_sub(slice, (size_t)(cur - beg),
(size_t)(cur + p->frame_size - beg)));
- grpc_chttp2_incoming_byte_stream_finished(exec_ctx, p->parsing_frame);
+ grpc_chttp2_incoming_byte_stream_finished(exec_ctx, p->parsing_frame, 1,
+ 1);
p->parsing_frame = NULL;
cur += p->frame_size;
goto fh_0; /* loop */
@@ -236,7 +239,7 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
exec_ctx, p->parsing_frame,
gpr_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg)));
GPR_ASSERT((size_t)(end - cur) <= p->frame_size);
- p->frame_size -= (gpr_uint32)(end - cur);
+ p->frame_size -= (uint32_t)(end - cur);
return GRPC_CHTTP2_PARSE_OK;
}
}
diff --git a/src/core/transport/chttp2/frame_data.h b/src/core/transport/chttp2/frame_data.h
index 27d4d0043b..936b7a2589 100644
--- a/src/core/transport/chttp2/frame_data.h
+++ b/src/core/transport/chttp2/frame_data.h
@@ -61,9 +61,9 @@ typedef struct grpc_chttp2_incoming_frame_queue {
typedef struct {
grpc_chttp2_stream_state state;
- gpr_uint8 is_last_frame;
- gpr_uint8 frame_type;
- gpr_uint32 frame_size;
+ uint8_t is_last_frame;
+ uint8_t frame_type;
+ uint32_t frame_size;
int is_frame_compressed;
grpc_chttp2_incoming_frame_queue incoming_frames;
@@ -85,7 +85,7 @@ void grpc_chttp2_data_parser_destroy(grpc_exec_ctx *exec_ctx,
/* start processing a new data frame */
grpc_chttp2_parse_error grpc_chttp2_data_parser_begin_frame(
- grpc_chttp2_data_parser *parser, gpr_uint8 flags);
+ grpc_chttp2_data_parser *parser, uint8_t flags);
/* handle a slice of a data frame - is_last indicates the last slice of a
frame */
@@ -94,8 +94,8 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last);
-void grpc_chttp2_encode_data(gpr_uint32 id, gpr_slice_buffer *inbuf,
- gpr_uint32 write_bytes, int is_eof,
+void grpc_chttp2_encode_data(uint32_t id, gpr_slice_buffer *inbuf,
+ uint32_t write_bytes, int is_eof,
gpr_slice_buffer *outbuf);
#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_DATA_H */
diff --git a/src/core/transport/chttp2/frame_goaway.c b/src/core/transport/chttp2/frame_goaway.c
index c5758bcb71..2fa525e989 100644
--- a/src/core/transport/chttp2/frame_goaway.c
+++ b/src/core/transport/chttp2/frame_goaway.c
@@ -48,7 +48,7 @@ void grpc_chttp2_goaway_parser_destroy(grpc_chttp2_goaway_parser *p) {
}
grpc_chttp2_parse_error grpc_chttp2_goaway_parser_begin_frame(
- grpc_chttp2_goaway_parser *p, gpr_uint32 length, gpr_uint8 flags) {
+ grpc_chttp2_goaway_parser *p, uint32_t length, uint8_t flags) {
if (length < 8) {
gpr_log(GPR_ERROR, "goaway frame too short (%d bytes)", length);
return GRPC_CHTTP2_CONNECTION_ERROR;
@@ -66,9 +66,9 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
grpc_exec_ctx *exec_ctx, void *parser,
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last) {
- gpr_uint8 *const beg = GPR_SLICE_START_PTR(slice);
- gpr_uint8 *const end = GPR_SLICE_END_PTR(slice);
- gpr_uint8 *cur = beg;
+ uint8_t *const beg = GPR_SLICE_START_PTR(slice);
+ uint8_t *const end = GPR_SLICE_END_PTR(slice);
+ uint8_t *cur = beg;
grpc_chttp2_goaway_parser *p = parser;
switch (p->state) {
@@ -77,7 +77,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
p->state = GRPC_CHTTP2_GOAWAY_LSI0;
return GRPC_CHTTP2_PARSE_OK;
}
- p->last_stream_id = ((gpr_uint32)*cur) << 24;
+ p->last_stream_id = ((uint32_t)*cur) << 24;
++cur;
/* fallthrough */
case GRPC_CHTTP2_GOAWAY_LSI1:
@@ -85,7 +85,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
p->state = GRPC_CHTTP2_GOAWAY_LSI1;
return GRPC_CHTTP2_PARSE_OK;
}
- p->last_stream_id |= ((gpr_uint32)*cur) << 16;
+ p->last_stream_id |= ((uint32_t)*cur) << 16;
++cur;
/* fallthrough */
case GRPC_CHTTP2_GOAWAY_LSI2:
@@ -93,7 +93,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
p->state = GRPC_CHTTP2_GOAWAY_LSI2;
return GRPC_CHTTP2_PARSE_OK;
}
- p->last_stream_id |= ((gpr_uint32)*cur) << 8;
+ p->last_stream_id |= ((uint32_t)*cur) << 8;
++cur;
/* fallthrough */
case GRPC_CHTTP2_GOAWAY_LSI3:
@@ -101,7 +101,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
p->state = GRPC_CHTTP2_GOAWAY_LSI3;
return GRPC_CHTTP2_PARSE_OK;
}
- p->last_stream_id |= ((gpr_uint32)*cur);
+ p->last_stream_id |= ((uint32_t)*cur);
++cur;
/* fallthrough */
case GRPC_CHTTP2_GOAWAY_ERR0:
@@ -109,7 +109,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
p->state = GRPC_CHTTP2_GOAWAY_ERR0;
return GRPC_CHTTP2_PARSE_OK;
}
- p->error_code = ((gpr_uint32)*cur) << 24;
+ p->error_code = ((uint32_t)*cur) << 24;
++cur;
/* fallthrough */
case GRPC_CHTTP2_GOAWAY_ERR1:
@@ -117,7 +117,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
p->state = GRPC_CHTTP2_GOAWAY_ERR1;
return GRPC_CHTTP2_PARSE_OK;
}
- p->error_code |= ((gpr_uint32)*cur) << 16;
+ p->error_code |= ((uint32_t)*cur) << 16;
++cur;
/* fallthrough */
case GRPC_CHTTP2_GOAWAY_ERR2:
@@ -125,7 +125,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
p->state = GRPC_CHTTP2_GOAWAY_ERR2;
return GRPC_CHTTP2_PARSE_OK;
}
- p->error_code |= ((gpr_uint32)*cur) << 8;
+ p->error_code |= ((uint32_t)*cur) << 8;
++cur;
/* fallthrough */
case GRPC_CHTTP2_GOAWAY_ERR3:
@@ -133,13 +133,13 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
p->state = GRPC_CHTTP2_GOAWAY_ERR3;
return GRPC_CHTTP2_PARSE_OK;
}
- p->error_code |= ((gpr_uint32)*cur);
+ p->error_code |= ((uint32_t)*cur);
++cur;
/* fallthrough */
case GRPC_CHTTP2_GOAWAY_DEBUG:
memcpy(p->debug_data + p->debug_pos, cur, (size_t)(end - cur));
- GPR_ASSERT((size_t)(end - cur) < GPR_UINT32_MAX - p->debug_pos);
- p->debug_pos += (gpr_uint32)(end - cur);
+ GPR_ASSERT((size_t)(end - cur) < UINT32_MAX - p->debug_pos);
+ p->debug_pos += (uint32_t)(end - cur);
p->state = GRPC_CHTTP2_GOAWAY_DEBUG;
if (is_last) {
transport_parsing->goaway_received = 1;
@@ -155,19 +155,19 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
GPR_UNREACHABLE_CODE(return GRPC_CHTTP2_CONNECTION_ERROR);
}
-void grpc_chttp2_goaway_append(gpr_uint32 last_stream_id, gpr_uint32 error_code,
+void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code,
gpr_slice debug_data,
gpr_slice_buffer *slice_buffer) {
gpr_slice header = gpr_slice_malloc(9 + 4 + 4);
- gpr_uint8 *p = GPR_SLICE_START_PTR(header);
- gpr_uint32 frame_length;
- GPR_ASSERT(GPR_SLICE_LENGTH(debug_data) < GPR_UINT32_MAX - 4 - 4);
- frame_length = 4 + 4 + (gpr_uint32)GPR_SLICE_LENGTH(debug_data);
+ uint8_t *p = GPR_SLICE_START_PTR(header);
+ uint32_t frame_length;
+ GPR_ASSERT(GPR_SLICE_LENGTH(debug_data) < UINT32_MAX - 4 - 4);
+ frame_length = 4 + 4 + (uint32_t)GPR_SLICE_LENGTH(debug_data);
/* frame header: length */
- *p++ = (gpr_uint8)(frame_length >> 16);
- *p++ = (gpr_uint8)(frame_length >> 8);
- *p++ = (gpr_uint8)(frame_length);
+ *p++ = (uint8_t)(frame_length >> 16);
+ *p++ = (uint8_t)(frame_length >> 8);
+ *p++ = (uint8_t)(frame_length);
/* frame header: type */
*p++ = GRPC_CHTTP2_FRAME_GOAWAY;
/* frame header: flags */
@@ -178,15 +178,15 @@ void grpc_chttp2_goaway_append(gpr_uint32 last_stream_id, gpr_uint32 error_code,
*p++ = 0;
*p++ = 0;
/* payload: last stream id */
- *p++ = (gpr_uint8)(last_stream_id >> 24);
- *p++ = (gpr_uint8)(last_stream_id >> 16);
- *p++ = (gpr_uint8)(last_stream_id >> 8);
- *p++ = (gpr_uint8)(last_stream_id);
+ *p++ = (uint8_t)(last_stream_id >> 24);
+ *p++ = (uint8_t)(last_stream_id >> 16);
+ *p++ = (uint8_t)(last_stream_id >> 8);
+ *p++ = (uint8_t)(last_stream_id);
/* payload: error code */
- *p++ = (gpr_uint8)(error_code >> 24);
- *p++ = (gpr_uint8)(error_code >> 16);
- *p++ = (gpr_uint8)(error_code >> 8);
- *p++ = (gpr_uint8)(error_code);
+ *p++ = (uint8_t)(error_code >> 24);
+ *p++ = (uint8_t)(error_code >> 16);
+ *p++ = (uint8_t)(error_code >> 8);
+ *p++ = (uint8_t)(error_code);
GPR_ASSERT(p == GPR_SLICE_END_PTR(header));
gpr_slice_buffer_add(slice_buffer, header);
gpr_slice_buffer_add(slice_buffer, debug_data);
diff --git a/src/core/transport/chttp2/frame_goaway.h b/src/core/transport/chttp2/frame_goaway.h
index 06aaa92f07..e1a72b4013 100644
--- a/src/core/transport/chttp2/frame_goaway.h
+++ b/src/core/transport/chttp2/frame_goaway.h
@@ -54,23 +54,23 @@ typedef enum {
typedef struct {
grpc_chttp2_goaway_parse_state state;
- gpr_uint32 last_stream_id;
- gpr_uint32 error_code;
+ uint32_t last_stream_id;
+ uint32_t error_code;
char *debug_data;
- gpr_uint32 debug_length;
- gpr_uint32 debug_pos;
+ uint32_t debug_length;
+ uint32_t debug_pos;
} grpc_chttp2_goaway_parser;
void grpc_chttp2_goaway_parser_init(grpc_chttp2_goaway_parser *p);
void grpc_chttp2_goaway_parser_destroy(grpc_chttp2_goaway_parser *p);
grpc_chttp2_parse_error grpc_chttp2_goaway_parser_begin_frame(
- grpc_chttp2_goaway_parser *parser, gpr_uint32 length, gpr_uint8 flags);
+ grpc_chttp2_goaway_parser *parser, uint32_t length, uint8_t flags);
grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
grpc_exec_ctx *exec_ctx, void *parser,
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last);
-void grpc_chttp2_goaway_append(gpr_uint32 last_stream_id, gpr_uint32 error_code,
+void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code,
gpr_slice debug_data,
gpr_slice_buffer *slice_buffer);
diff --git a/src/core/transport/chttp2/frame_ping.c b/src/core/transport/chttp2/frame_ping.c
index 8e763278ff..c6ab522283 100644
--- a/src/core/transport/chttp2/frame_ping.c
+++ b/src/core/transport/chttp2/frame_ping.c
@@ -39,9 +39,9 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-gpr_slice grpc_chttp2_ping_create(gpr_uint8 ack, gpr_uint8 *opaque_8bytes) {
+gpr_slice grpc_chttp2_ping_create(uint8_t ack, uint8_t *opaque_8bytes) {
gpr_slice slice = gpr_slice_malloc(9 + 8);
- gpr_uint8 *p = GPR_SLICE_START_PTR(slice);
+ uint8_t *p = GPR_SLICE_START_PTR(slice);
*p++ = 0;
*p++ = 0;
@@ -58,7 +58,7 @@ gpr_slice grpc_chttp2_ping_create(gpr_uint8 ack, gpr_uint8 *opaque_8bytes) {
}
grpc_chttp2_parse_error grpc_chttp2_ping_parser_begin_frame(
- grpc_chttp2_ping_parser *parser, gpr_uint32 length, gpr_uint8 flags) {
+ grpc_chttp2_ping_parser *parser, uint32_t length, uint8_t flags) {
if (flags & 0xfe || length != 8) {
gpr_log(GPR_ERROR, "invalid ping: length=%d, flags=%02x", length, flags);
return GRPC_CHTTP2_CONNECTION_ERROR;
@@ -72,9 +72,9 @@ grpc_chttp2_parse_error grpc_chttp2_ping_parser_parse(
grpc_exec_ctx *exec_ctx, void *parser,
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last) {
- gpr_uint8 *const beg = GPR_SLICE_START_PTR(slice);
- gpr_uint8 *const end = GPR_SLICE_END_PTR(slice);
- gpr_uint8 *cur = beg;
+ uint8_t *const beg = GPR_SLICE_START_PTR(slice);
+ uint8_t *const end = GPR_SLICE_END_PTR(slice);
+ uint8_t *cur = beg;
grpc_chttp2_ping_parser *p = parser;
while (p->byte != 8 && cur != end) {
diff --git a/src/core/transport/chttp2/frame_ping.h b/src/core/transport/chttp2/frame_ping.h
index 2c71d0d491..16d7a72618 100644
--- a/src/core/transport/chttp2/frame_ping.h
+++ b/src/core/transport/chttp2/frame_ping.h
@@ -39,15 +39,15 @@
#include "src/core/transport/chttp2/frame.h"
typedef struct {
- gpr_uint8 byte;
- gpr_uint8 is_ack;
- gpr_uint8 opaque_8bytes[8];
+ uint8_t byte;
+ uint8_t is_ack;
+ uint8_t opaque_8bytes[8];
} grpc_chttp2_ping_parser;
-gpr_slice grpc_chttp2_ping_create(gpr_uint8 ack, gpr_uint8 *opaque_8bytes);
+gpr_slice grpc_chttp2_ping_create(uint8_t ack, uint8_t *opaque_8bytes);
grpc_chttp2_parse_error grpc_chttp2_ping_parser_begin_frame(
- grpc_chttp2_ping_parser *parser, gpr_uint32 length, gpr_uint8 flags);
+ grpc_chttp2_ping_parser *parser, uint32_t length, uint8_t flags);
grpc_chttp2_parse_error grpc_chttp2_ping_parser_parse(
grpc_exec_ctx *exec_ctx, void *parser,
grpc_chttp2_transport_parsing *transport_parsing,
diff --git a/src/core/transport/chttp2/frame_rst_stream.c b/src/core/transport/chttp2/frame_rst_stream.c
index 3cd5bcfc39..754529e4b9 100644
--- a/src/core/transport/chttp2/frame_rst_stream.c
+++ b/src/core/transport/chttp2/frame_rst_stream.c
@@ -38,29 +38,29 @@
#include "src/core/transport/chttp2/frame.h"
-gpr_slice grpc_chttp2_rst_stream_create(gpr_uint32 id, gpr_uint32 code) {
+gpr_slice grpc_chttp2_rst_stream_create(uint32_t id, uint32_t code) {
gpr_slice slice = gpr_slice_malloc(13);
- gpr_uint8 *p = GPR_SLICE_START_PTR(slice);
+ uint8_t *p = GPR_SLICE_START_PTR(slice);
*p++ = 0;
*p++ = 0;
*p++ = 4;
*p++ = GRPC_CHTTP2_FRAME_RST_STREAM;
*p++ = 0;
- *p++ = (gpr_uint8)(id >> 24);
- *p++ = (gpr_uint8)(id >> 16);
- *p++ = (gpr_uint8)(id >> 8);
- *p++ = (gpr_uint8)(id);
- *p++ = (gpr_uint8)(code >> 24);
- *p++ = (gpr_uint8)(code >> 16);
- *p++ = (gpr_uint8)(code >> 8);
- *p++ = (gpr_uint8)(code);
+ *p++ = (uint8_t)(id >> 24);
+ *p++ = (uint8_t)(id >> 16);
+ *p++ = (uint8_t)(id >> 8);
+ *p++ = (uint8_t)(id);
+ *p++ = (uint8_t)(code >> 24);
+ *p++ = (uint8_t)(code >> 16);
+ *p++ = (uint8_t)(code >> 8);
+ *p++ = (uint8_t)(code);
return slice;
}
grpc_chttp2_parse_error grpc_chttp2_rst_stream_parser_begin_frame(
- grpc_chttp2_rst_stream_parser *parser, gpr_uint32 length, gpr_uint8 flags) {
+ grpc_chttp2_rst_stream_parser *parser, uint32_t length, uint8_t flags) {
if (length != 4) {
gpr_log(GPR_ERROR, "invalid rst_stream: length=%d, flags=%02x", length,
flags);
@@ -74,9 +74,9 @@ grpc_chttp2_parse_error grpc_chttp2_rst_stream_parser_parse(
grpc_exec_ctx *exec_ctx, void *parser,
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last) {
- gpr_uint8 *const beg = GPR_SLICE_START_PTR(slice);
- gpr_uint8 *const end = GPR_SLICE_END_PTR(slice);
- gpr_uint8 *cur = beg;
+ uint8_t *const beg = GPR_SLICE_START_PTR(slice);
+ uint8_t *const end = GPR_SLICE_END_PTR(slice);
+ uint8_t *cur = beg;
grpc_chttp2_rst_stream_parser *p = parser;
while (p->byte != 4 && cur != end) {
@@ -89,11 +89,10 @@ grpc_chttp2_parse_error grpc_chttp2_rst_stream_parser_parse(
GPR_ASSERT(is_last);
stream_parsing->received_close = 1;
stream_parsing->saw_rst_stream = 1;
- stream_parsing->rst_stream_reason =
- (((gpr_uint32)p->reason_bytes[0]) << 24) |
- (((gpr_uint32)p->reason_bytes[1]) << 16) |
- (((gpr_uint32)p->reason_bytes[2]) << 8) |
- (((gpr_uint32)p->reason_bytes[3]));
+ stream_parsing->rst_stream_reason = (((uint32_t)p->reason_bytes[0]) << 24) |
+ (((uint32_t)p->reason_bytes[1]) << 16) |
+ (((uint32_t)p->reason_bytes[2]) << 8) |
+ (((uint32_t)p->reason_bytes[3]));
}
return GRPC_CHTTP2_PARSE_OK;
diff --git a/src/core/transport/chttp2/frame_rst_stream.h b/src/core/transport/chttp2/frame_rst_stream.h
index 92cb77c971..72ca654c32 100644
--- a/src/core/transport/chttp2/frame_rst_stream.h
+++ b/src/core/transport/chttp2/frame_rst_stream.h
@@ -39,14 +39,14 @@
#include "src/core/iomgr/exec_ctx.h"
typedef struct {
- gpr_uint8 byte;
- gpr_uint8 reason_bytes[4];
+ uint8_t byte;
+ uint8_t reason_bytes[4];
} grpc_chttp2_rst_stream_parser;
-gpr_slice grpc_chttp2_rst_stream_create(gpr_uint32 stream_id, gpr_uint32 code);
+gpr_slice grpc_chttp2_rst_stream_create(uint32_t stream_id, uint32_t code);
grpc_chttp2_parse_error grpc_chttp2_rst_stream_parser_begin_frame(
- grpc_chttp2_rst_stream_parser *parser, gpr_uint32 length, gpr_uint8 flags);
+ grpc_chttp2_rst_stream_parser *parser, uint32_t length, uint8_t flags);
grpc_chttp2_parse_error grpc_chttp2_rst_stream_parser_parse(
grpc_exec_ctx *exec_ctx, void *parser,
grpc_chttp2_transport_parsing *transport_parsing,
diff --git a/src/core/transport/chttp2/frame_settings.c b/src/core/transport/chttp2/frame_settings.c
index 383b6e7f93..cc49dd4f69 100644
--- a/src/core/transport/chttp2/frame_settings.c
+++ b/src/core/transport/chttp2/frame_settings.c
@@ -67,11 +67,10 @@ const grpc_chttp2_setting_parameters
GRPC_CHTTP2_PROTOCOL_ERROR},
};
-static gpr_uint8 *fill_header(gpr_uint8 *out, gpr_uint32 length,
- gpr_uint8 flags) {
- *out++ = (gpr_uint8)(length >> 16);
- *out++ = (gpr_uint8)(length >> 8);
- *out++ = (gpr_uint8)(length);
+static uint8_t *fill_header(uint8_t *out, uint32_t length, uint8_t flags) {
+ *out++ = (uint8_t)(length >> 16);
+ *out++ = (uint8_t)(length >> 8);
+ *out++ = (uint8_t)(length);
*out++ = GRPC_CHTTP2_FRAME_SETTINGS;
*out++ = flags;
*out++ = 0;
@@ -81,12 +80,12 @@ static gpr_uint8 *fill_header(gpr_uint8 *out, gpr_uint32 length,
return out;
}
-gpr_slice grpc_chttp2_settings_create(gpr_uint32 *old, const gpr_uint32 *new,
- gpr_uint32 force_mask, size_t count) {
+gpr_slice grpc_chttp2_settings_create(uint32_t *old, const uint32_t *new,
+ uint32_t force_mask, size_t count) {
size_t i;
- gpr_uint32 n = 0;
+ uint32_t n = 0;
gpr_slice output;
- gpr_uint8 *p;
+ uint8_t *p;
for (i = 0; i < count; i++) {
n += (new[i] != old[i] || (force_mask & (1u << i)) != 0);
@@ -98,12 +97,12 @@ gpr_slice grpc_chttp2_settings_create(gpr_uint32 *old, const gpr_uint32 *new,
for (i = 0; i < count; i++) {
if (new[i] != old[i] || (force_mask & (1u << i)) != 0) {
GPR_ASSERT(i);
- *p++ = (gpr_uint8)(i >> 8);
- *p++ = (gpr_uint8)(i);
- *p++ = (gpr_uint8)(new[i] >> 24);
- *p++ = (gpr_uint8)(new[i] >> 16);
- *p++ = (gpr_uint8)(new[i] >> 8);
- *p++ = (gpr_uint8)(new[i]);
+ *p++ = (uint8_t)(i >> 8);
+ *p++ = (uint8_t)(i);
+ *p++ = (uint8_t)(new[i] >> 24);
+ *p++ = (uint8_t)(new[i] >> 16);
+ *p++ = (uint8_t)(new[i] >> 8);
+ *p++ = (uint8_t)(new[i]);
old[i] = new[i];
}
}
@@ -120,11 +119,11 @@ gpr_slice grpc_chttp2_settings_ack_create(void) {
}
grpc_chttp2_parse_error grpc_chttp2_settings_parser_begin_frame(
- grpc_chttp2_settings_parser *parser, gpr_uint32 length, gpr_uint8 flags,
- gpr_uint32 *settings) {
+ grpc_chttp2_settings_parser *parser, uint32_t length, uint8_t flags,
+ uint32_t *settings) {
parser->target_settings = settings;
memcpy(parser->incoming_settings, settings,
- GRPC_CHTTP2_NUM_SETTINGS * sizeof(gpr_uint32));
+ GRPC_CHTTP2_NUM_SETTINGS * sizeof(uint32_t));
parser->is_ack = 0;
parser->state = GRPC_CHTTP2_SPS_ID0;
if (flags == GRPC_CHTTP2_FLAG_ACK) {
@@ -150,8 +149,8 @@ grpc_chttp2_parse_error grpc_chttp2_settings_parser_parse(
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last) {
grpc_chttp2_settings_parser *parser = p;
- const gpr_uint8 *cur = GPR_SLICE_START_PTR(slice);
- const gpr_uint8 *end = GPR_SLICE_END_PTR(slice);
+ const uint8_t *cur = GPR_SLICE_START_PTR(slice);
+ const uint8_t *end = GPR_SLICE_END_PTR(slice);
if (parser->is_ack) {
return GRPC_CHTTP2_PARSE_OK;
@@ -165,13 +164,13 @@ grpc_chttp2_parse_error grpc_chttp2_settings_parser_parse(
if (is_last) {
transport_parsing->settings_updated = 1;
memcpy(parser->target_settings, parser->incoming_settings,
- GRPC_CHTTP2_NUM_SETTINGS * sizeof(gpr_uint32));
+ GRPC_CHTTP2_NUM_SETTINGS * sizeof(uint32_t));
gpr_slice_buffer_add(&transport_parsing->qbuf,
grpc_chttp2_settings_ack_create());
}
return GRPC_CHTTP2_PARSE_OK;
}
- parser->id = (gpr_uint16)(((gpr_uint16)*cur) << 8);
+ parser->id = (uint16_t)(((uint16_t)*cur) << 8);
cur++;
/* fallthrough */
case GRPC_CHTTP2_SPS_ID1:
@@ -179,7 +178,7 @@ grpc_chttp2_parse_error grpc_chttp2_settings_parser_parse(
parser->state = GRPC_CHTTP2_SPS_ID1;
return GRPC_CHTTP2_PARSE_OK;
}
- parser->id = (gpr_uint16)(parser->id | (*cur));
+ parser->id = (uint16_t)(parser->id | (*cur));
cur++;
/* fallthrough */
case GRPC_CHTTP2_SPS_VAL0:
@@ -187,7 +186,7 @@ grpc_chttp2_parse_error grpc_chttp2_settings_parser_parse(
parser->state = GRPC_CHTTP2_SPS_VAL0;
return GRPC_CHTTP2_PARSE_OK;
}
- parser->value = ((gpr_uint32)*cur) << 24;
+ parser->value = ((uint32_t)*cur) << 24;
cur++;
/* fallthrough */
case GRPC_CHTTP2_SPS_VAL1:
@@ -195,7 +194,7 @@ grpc_chttp2_parse_error grpc_chttp2_settings_parser_parse(
parser->state = GRPC_CHTTP2_SPS_VAL1;
return GRPC_CHTTP2_PARSE_OK;
}
- parser->value |= ((gpr_uint32)*cur) << 16;
+ parser->value |= ((uint32_t)*cur) << 16;
cur++;
/* fallthrough */
case GRPC_CHTTP2_SPS_VAL2:
@@ -203,7 +202,7 @@ grpc_chttp2_parse_error grpc_chttp2_settings_parser_parse(
parser->state = GRPC_CHTTP2_SPS_VAL2;
return GRPC_CHTTP2_PARSE_OK;
}
- parser->value |= ((gpr_uint32)*cur) << 8;
+ parser->value |= ((uint32_t)*cur) << 8;
cur++;
/* fallthrough */
case GRPC_CHTTP2_SPS_VAL3:
@@ -238,10 +237,11 @@ grpc_chttp2_parse_error grpc_chttp2_settings_parser_parse(
if (parser->id == GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE &&
parser->incoming_settings[parser->id] != parser->value) {
transport_parsing->initial_window_update =
- (gpr_int64)parser->value -
- parser->incoming_settings[parser->id];
- gpr_log(GPR_DEBUG, "adding %d for initial_window change",
- (int)transport_parsing->initial_window_update);
+ (int64_t)parser->value - parser->incoming_settings[parser->id];
+ if (grpc_http_trace) {
+ gpr_log(GPR_DEBUG, "adding %d for initial_window change",
+ (int)transport_parsing->initial_window_update);
+ }
}
parser->incoming_settings[parser->id] = parser->value;
if (grpc_http_trace) {
diff --git a/src/core/transport/chttp2/frame_settings.h b/src/core/transport/chttp2/frame_settings.h
index e9c3c440b5..3c918e3a2a 100644
--- a/src/core/transport/chttp2/frame_settings.h
+++ b/src/core/transport/chttp2/frame_settings.h
@@ -61,11 +61,11 @@ typedef enum {
typedef struct {
grpc_chttp2_settings_parse_state state;
- gpr_uint32 *target_settings;
- gpr_uint8 is_ack;
- gpr_uint16 id;
- gpr_uint32 value;
- gpr_uint32 incoming_settings[GRPC_CHTTP2_NUM_SETTINGS];
+ uint32_t *target_settings;
+ uint8_t is_ack;
+ uint16_t id;
+ uint32_t value;
+ uint32_t incoming_settings[GRPC_CHTTP2_NUM_SETTINGS];
} grpc_chttp2_settings_parser;
typedef enum {
@@ -75,11 +75,11 @@ typedef enum {
typedef struct {
const char *name;
- gpr_uint32 default_value;
- gpr_uint32 min_value;
- gpr_uint32 max_value;
+ uint32_t default_value;
+ uint32_t min_value;
+ uint32_t max_value;
grpc_chttp2_invalid_value_behavior invalid_value_behavior;
- gpr_uint32 error_value;
+ uint32_t error_value;
} grpc_chttp2_setting_parameters;
/* HTTP/2 mandated connection setting parameters */
@@ -87,14 +87,14 @@ extern const grpc_chttp2_setting_parameters
grpc_chttp2_settings_parameters[GRPC_CHTTP2_NUM_SETTINGS];
/* Create a settings frame by diffing old & new, and updating old to be new */
-gpr_slice grpc_chttp2_settings_create(gpr_uint32 *old, const gpr_uint32 *new,
- gpr_uint32 force_mask, size_t count);
+gpr_slice grpc_chttp2_settings_create(uint32_t *old, const uint32_t *new,
+ uint32_t force_mask, size_t count);
/* Create an ack settings frame */
gpr_slice grpc_chttp2_settings_ack_create(void);
grpc_chttp2_parse_error grpc_chttp2_settings_parser_begin_frame(
- grpc_chttp2_settings_parser *parser, gpr_uint32 length, gpr_uint8 flags,
- gpr_uint32 *settings);
+ grpc_chttp2_settings_parser *parser, uint32_t length, uint8_t flags,
+ uint32_t *settings);
grpc_chttp2_parse_error grpc_chttp2_settings_parser_parse(
grpc_exec_ctx *exec_ctx, void *parser,
grpc_chttp2_transport_parsing *transport_parsing,
diff --git a/src/core/transport/chttp2/frame_window_update.c b/src/core/transport/chttp2/frame_window_update.c
index 74ca29baf9..62d9bac117 100644
--- a/src/core/transport/chttp2/frame_window_update.c
+++ b/src/core/transport/chttp2/frame_window_update.c
@@ -36,10 +36,10 @@
#include <grpc/support/log.h>
-gpr_slice grpc_chttp2_window_update_create(gpr_uint32 id,
- gpr_uint32 window_update) {
+gpr_slice grpc_chttp2_window_update_create(uint32_t id,
+ uint32_t window_update) {
gpr_slice slice = gpr_slice_malloc(13);
- gpr_uint8 *p = GPR_SLICE_START_PTR(slice);
+ uint8_t *p = GPR_SLICE_START_PTR(slice);
GPR_ASSERT(window_update);
@@ -48,21 +48,20 @@ gpr_slice grpc_chttp2_window_update_create(gpr_uint32 id,
*p++ = 4;
*p++ = GRPC_CHTTP2_FRAME_WINDOW_UPDATE;
*p++ = 0;
- *p++ = (gpr_uint8)(id >> 24);
- *p++ = (gpr_uint8)(id >> 16);
- *p++ = (gpr_uint8)(id >> 8);
- *p++ = (gpr_uint8)(id);
- *p++ = (gpr_uint8)(window_update >> 24);
- *p++ = (gpr_uint8)(window_update >> 16);
- *p++ = (gpr_uint8)(window_update >> 8);
- *p++ = (gpr_uint8)(window_update);
+ *p++ = (uint8_t)(id >> 24);
+ *p++ = (uint8_t)(id >> 16);
+ *p++ = (uint8_t)(id >> 8);
+ *p++ = (uint8_t)(id);
+ *p++ = (uint8_t)(window_update >> 24);
+ *p++ = (uint8_t)(window_update >> 16);
+ *p++ = (uint8_t)(window_update >> 8);
+ *p++ = (uint8_t)(window_update);
return slice;
}
grpc_chttp2_parse_error grpc_chttp2_window_update_parser_begin_frame(
- grpc_chttp2_window_update_parser *parser, gpr_uint32 length,
- gpr_uint8 flags) {
+ grpc_chttp2_window_update_parser *parser, uint32_t length, uint8_t flags) {
if (flags || length != 4) {
gpr_log(GPR_ERROR, "invalid window update: length=%d, flags=%02x", length,
flags);
@@ -77,19 +76,19 @@ grpc_chttp2_parse_error grpc_chttp2_window_update_parser_parse(
grpc_exec_ctx *exec_ctx, void *parser,
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last) {
- gpr_uint8 *const beg = GPR_SLICE_START_PTR(slice);
- gpr_uint8 *const end = GPR_SLICE_END_PTR(slice);
- gpr_uint8 *cur = beg;
+ uint8_t *const beg = GPR_SLICE_START_PTR(slice);
+ uint8_t *const end = GPR_SLICE_END_PTR(slice);
+ uint8_t *cur = beg;
grpc_chttp2_window_update_parser *p = parser;
while (p->byte != 4 && cur != end) {
- p->amount |= ((gpr_uint32)*cur) << (8 * (3 - p->byte));
+ p->amount |= ((uint32_t)*cur) << (8 * (3 - p->byte));
cur++;
p->byte++;
}
if (p->byte == 4) {
- gpr_uint32 received_update = p->amount;
+ uint32_t received_update = p->amount;
if (received_update == 0 || (received_update & 0x80000000u)) {
gpr_log(GPR_ERROR, "invalid window update bytes: %d", p->amount);
return GRPC_CHTTP2_CONNECTION_ERROR;
diff --git a/src/core/transport/chttp2/frame_window_update.h b/src/core/transport/chttp2/frame_window_update.h
index fc074092ff..89d835c079 100644
--- a/src/core/transport/chttp2/frame_window_update.h
+++ b/src/core/transport/chttp2/frame_window_update.h
@@ -39,17 +39,15 @@
#include "src/core/transport/chttp2/frame.h"
typedef struct {
- gpr_uint8 byte;
- gpr_uint8 is_connection_update;
- gpr_uint32 amount;
+ uint8_t byte;
+ uint8_t is_connection_update;
+ uint32_t amount;
} grpc_chttp2_window_update_parser;
-gpr_slice grpc_chttp2_window_update_create(gpr_uint32 id,
- gpr_uint32 window_delta);
+gpr_slice grpc_chttp2_window_update_create(uint32_t id, uint32_t window_delta);
grpc_chttp2_parse_error grpc_chttp2_window_update_parser_begin_frame(
- grpc_chttp2_window_update_parser *parser, gpr_uint32 length,
- gpr_uint8 flags);
+ grpc_chttp2_window_update_parser *parser, uint32_t length, uint8_t flags);
grpc_chttp2_parse_error grpc_chttp2_window_update_parser_parse(
grpc_exec_ctx *exec_ctx, void *parser,
grpc_chttp2_transport_parsing *transport_parsing,
diff --git a/src/core/transport/chttp2/hpack_encoder.c b/src/core/transport/chttp2/hpack_encoder.c
index 303b8f332a..89a80d896c 100644
--- a/src/core/transport/chttp2/hpack_encoder.c
+++ b/src/core/transport/chttp2/hpack_encoder.c
@@ -70,39 +70,38 @@ typedef struct {
/* index (in output) of the header for the current frame */
size_t header_idx;
/* have we seen a regular (non-colon-prefixed) header yet? */
- gpr_uint8 seen_regular_header;
+ uint8_t seen_regular_header;
/* output stream id */
- gpr_uint32 stream_id;
+ uint32_t stream_id;
gpr_slice_buffer *output;
} framer_state;
/* fills p (which is expected to be 9 bytes long) with a data frame header */
-static void fill_header(gpr_uint8 *p, gpr_uint8 type, gpr_uint32 id, size_t len,
- gpr_uint8 flags) {
+static void fill_header(uint8_t *p, uint8_t type, uint32_t id, size_t len,
+ uint8_t flags) {
GPR_ASSERT(len < 16777316);
- *p++ = (gpr_uint8)(len >> 16);
- *p++ = (gpr_uint8)(len >> 8);
- *p++ = (gpr_uint8)(len);
+ *p++ = (uint8_t)(len >> 16);
+ *p++ = (uint8_t)(len >> 8);
+ *p++ = (uint8_t)(len);
*p++ = type;
*p++ = flags;
- *p++ = (gpr_uint8)(id >> 24);
- *p++ = (gpr_uint8)(id >> 16);
- *p++ = (gpr_uint8)(id >> 8);
- *p++ = (gpr_uint8)(id);
+ *p++ = (uint8_t)(id >> 24);
+ *p++ = (uint8_t)(id >> 16);
+ *p++ = (uint8_t)(id >> 8);
+ *p++ = (uint8_t)(id);
}
/* finish a frame - fill in the previously reserved header */
static void finish_frame(framer_state *st, int is_header_boundary,
int is_last_in_stream) {
- gpr_uint8 type = 0xff;
+ uint8_t type = 0xff;
type = st->is_first_frame ? GRPC_CHTTP2_FRAME_HEADER
: GRPC_CHTTP2_FRAME_CONTINUATION;
fill_header(
GPR_SLICE_START_PTR(st->output->slices[st->header_idx]), type,
st->stream_id, st->output->length - st->output_length_at_start_of_frame,
- (gpr_uint8)(
- (is_last_in_stream ? GRPC_CHTTP2_DATA_FLAG_END_STREAM : 0) |
- (is_header_boundary ? GRPC_CHTTP2_DATA_FLAG_END_HEADERS : 0)));
+ (uint8_t)((is_last_in_stream ? GRPC_CHTTP2_DATA_FLAG_END_STREAM : 0) |
+ (is_header_boundary ? GRPC_CHTTP2_DATA_FLAG_END_HEADERS : 0)));
st->is_first_frame = 0;
}
@@ -127,7 +126,7 @@ static void ensure_space(framer_state *st, size_t need_bytes) {
}
/* increment a filter count, halve all counts if one element reaches max */
-static void inc_filter(gpr_uint8 idx, gpr_uint32 *sum, gpr_uint8 *elems) {
+static void inc_filter(uint8_t idx, uint32_t *sum, uint8_t *elems) {
elems[idx]++;
if (elems[idx] < 255) {
(*sum)++;
@@ -157,7 +156,7 @@ static void add_header_data(framer_state *st, gpr_slice slice) {
}
}
-static gpr_uint8 *add_tiny_header_data(framer_state *st, size_t len) {
+static uint8_t *add_tiny_header_data(framer_state *st, size_t len) {
ensure_space(st, len);
return gpr_slice_buffer_tiny_add(st->output, len);
}
@@ -168,17 +167,17 @@ static void evict_entry(grpc_chttp2_hpack_compressor *c) {
GPR_ASSERT(c->table_size >=
c->table_elem_size[c->tail_remote_index % c->cap_table_elems]);
GPR_ASSERT(c->table_elems > 0);
- c->table_size = (gpr_uint16)(
- c->table_size -
- c->table_elem_size[c->tail_remote_index % c->cap_table_elems]);
+ c->table_size =
+ (uint16_t)(c->table_size -
+ c->table_elem_size[c->tail_remote_index % c->cap_table_elems]);
c->table_elems--;
}
/* add an element to the decoder table */
static void add_elem(grpc_chttp2_hpack_compressor *c, grpc_mdelem *elem) {
- gpr_uint32 key_hash = elem->key->hash;
- gpr_uint32 elem_hash = GRPC_MDSTR_KV_HASH(key_hash, elem->value->hash);
- gpr_uint32 new_index = c->tail_remote_index + c->table_elems + 1;
+ uint32_t key_hash = elem->key->hash;
+ uint32_t elem_hash = GRPC_MDSTR_KV_HASH(key_hash, elem->value->hash);
+ uint32_t new_index = c->tail_remote_index + c->table_elems + 1;
size_t elem_size = 32 + GPR_SLICE_LENGTH(elem->key->slice) +
GPR_SLICE_LENGTH(elem->value->slice);
@@ -198,8 +197,8 @@ static void add_elem(grpc_chttp2_hpack_compressor *c, grpc_mdelem *elem) {
evict_entry(c);
}
GPR_ASSERT(c->table_elems < c->max_table_size);
- c->table_elem_size[new_index % c->cap_table_elems] = (gpr_uint16)elem_size;
- c->table_size = (gpr_uint16)(c->table_size + elem_size);
+ c->table_elem_size[new_index % c->cap_table_elems] = (uint16_t)elem_size;
+ c->table_size = (uint16_t)(c->table_size + elem_size);
c->table_elems++;
/* Store this element into {entries,indices}_elem */
@@ -254,14 +253,14 @@ static void add_elem(grpc_chttp2_hpack_compressor *c, grpc_mdelem *elem) {
}
}
-static void emit_indexed(grpc_chttp2_hpack_compressor *c, gpr_uint32 elem_index,
+static void emit_indexed(grpc_chttp2_hpack_compressor *c, uint32_t elem_index,
framer_state *st) {
- gpr_uint32 len = GRPC_CHTTP2_VARINT_LENGTH(elem_index, 1);
+ uint32_t len = GRPC_CHTTP2_VARINT_LENGTH(elem_index, 1);
GRPC_CHTTP2_WRITE_VARINT(elem_index, 1, 0x80, add_tiny_header_data(st, len),
len);
}
-static gpr_slice get_wire_value(grpc_mdelem *elem, gpr_uint8 *huffman_prefix) {
+static gpr_slice get_wire_value(grpc_mdelem *elem, uint8_t *huffman_prefix) {
if (grpc_is_binary_header((const char *)GPR_SLICE_START_PTR(elem->key->slice),
GPR_SLICE_LENGTH(elem->key->slice))) {
*huffman_prefix = 0x80;
@@ -273,49 +272,49 @@ static gpr_slice get_wire_value(grpc_mdelem *elem, gpr_uint8 *huffman_prefix) {
}
static void emit_lithdr_incidx(grpc_chttp2_hpack_compressor *c,
- gpr_uint32 key_index, grpc_mdelem *elem,
+ uint32_t key_index, grpc_mdelem *elem,
framer_state *st) {
- gpr_uint32 len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 2);
- gpr_uint8 huffman_prefix;
+ uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 2);
+ uint8_t huffman_prefix;
gpr_slice value_slice = get_wire_value(elem, &huffman_prefix);
size_t len_val = GPR_SLICE_LENGTH(value_slice);
- gpr_uint32 len_val_len;
- GPR_ASSERT(len_val <= GPR_UINT32_MAX);
- len_val_len = GRPC_CHTTP2_VARINT_LENGTH((gpr_uint32)len_val, 1);
+ uint32_t len_val_len;
+ GPR_ASSERT(len_val <= UINT32_MAX);
+ len_val_len = GRPC_CHTTP2_VARINT_LENGTH((uint32_t)len_val, 1);
GRPC_CHTTP2_WRITE_VARINT(key_index, 2, 0x40,
add_tiny_header_data(st, len_pfx), len_pfx);
- GRPC_CHTTP2_WRITE_VARINT((gpr_uint32)len_val, 1, 0x00,
+ GRPC_CHTTP2_WRITE_VARINT((uint32_t)len_val, 1, 0x00,
add_tiny_header_data(st, len_val_len), len_val_len);
add_header_data(st, gpr_slice_ref(value_slice));
}
static void emit_lithdr_noidx(grpc_chttp2_hpack_compressor *c,
- gpr_uint32 key_index, grpc_mdelem *elem,
+ uint32_t key_index, grpc_mdelem *elem,
framer_state *st) {
- gpr_uint32 len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 4);
- gpr_uint8 huffman_prefix;
+ uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 4);
+ uint8_t huffman_prefix;
gpr_slice value_slice = get_wire_value(elem, &huffman_prefix);
size_t len_val = GPR_SLICE_LENGTH(value_slice);
- gpr_uint32 len_val_len;
- GPR_ASSERT(len_val <= GPR_UINT32_MAX);
- len_val_len = GRPC_CHTTP2_VARINT_LENGTH((gpr_uint32)len_val, 1);
+ uint32_t len_val_len;
+ GPR_ASSERT(len_val <= UINT32_MAX);
+ len_val_len = GRPC_CHTTP2_VARINT_LENGTH((uint32_t)len_val, 1);
GRPC_CHTTP2_WRITE_VARINT(key_index, 4, 0x00,
add_tiny_header_data(st, len_pfx), len_pfx);
- GRPC_CHTTP2_WRITE_VARINT((gpr_uint32)len_val, 1, 0x00,
+ GRPC_CHTTP2_WRITE_VARINT((uint32_t)len_val, 1, 0x00,
add_tiny_header_data(st, len_val_len), len_val_len);
add_header_data(st, gpr_slice_ref(value_slice));
}
static void emit_lithdr_incidx_v(grpc_chttp2_hpack_compressor *c,
grpc_mdelem *elem, framer_state *st) {
- gpr_uint32 len_key = (gpr_uint32)GPR_SLICE_LENGTH(elem->key->slice);
- gpr_uint8 huffman_prefix;
+ uint32_t len_key = (uint32_t)GPR_SLICE_LENGTH(elem->key->slice);
+ uint8_t huffman_prefix;
gpr_slice value_slice = get_wire_value(elem, &huffman_prefix);
- gpr_uint32 len_val = (gpr_uint32)GPR_SLICE_LENGTH(value_slice);
- gpr_uint32 len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1);
- gpr_uint32 len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
- GPR_ASSERT(len_key <= GPR_UINT32_MAX);
- GPR_ASSERT(GPR_SLICE_LENGTH(value_slice) <= GPR_UINT32_MAX);
+ uint32_t len_val = (uint32_t)GPR_SLICE_LENGTH(value_slice);
+ uint32_t len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1);
+ uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
+ GPR_ASSERT(len_key <= UINT32_MAX);
+ GPR_ASSERT(GPR_SLICE_LENGTH(value_slice) <= UINT32_MAX);
*add_tiny_header_data(st, 1) = 0x40;
GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00,
add_tiny_header_data(st, len_key_len), len_key_len);
@@ -327,14 +326,14 @@ static void emit_lithdr_incidx_v(grpc_chttp2_hpack_compressor *c,
static void emit_lithdr_noidx_v(grpc_chttp2_hpack_compressor *c,
grpc_mdelem *elem, framer_state *st) {
- gpr_uint32 len_key = (gpr_uint32)GPR_SLICE_LENGTH(elem->key->slice);
- gpr_uint8 huffman_prefix;
+ uint32_t len_key = (uint32_t)GPR_SLICE_LENGTH(elem->key->slice);
+ uint8_t huffman_prefix;
gpr_slice value_slice = get_wire_value(elem, &huffman_prefix);
- gpr_uint32 len_val = (gpr_uint32)GPR_SLICE_LENGTH(value_slice);
- gpr_uint32 len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1);
- gpr_uint32 len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
- GPR_ASSERT(len_key <= GPR_UINT32_MAX);
- GPR_ASSERT(GPR_SLICE_LENGTH(value_slice) <= GPR_UINT32_MAX);
+ uint32_t len_val = (uint32_t)GPR_SLICE_LENGTH(value_slice);
+ uint32_t len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1);
+ uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
+ GPR_ASSERT(len_key <= UINT32_MAX);
+ GPR_ASSERT(GPR_SLICE_LENGTH(value_slice) <= UINT32_MAX);
*add_tiny_header_data(st, 1) = 0x00;
GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00,
add_tiny_header_data(st, len_key_len), len_key_len);
@@ -346,14 +345,13 @@ static void emit_lithdr_noidx_v(grpc_chttp2_hpack_compressor *c,
static void emit_advertise_table_size_change(grpc_chttp2_hpack_compressor *c,
framer_state *st) {
- gpr_uint32 len = GRPC_CHTTP2_VARINT_LENGTH(c->max_table_size, 3);
+ uint32_t len = GRPC_CHTTP2_VARINT_LENGTH(c->max_table_size, 3);
GRPC_CHTTP2_WRITE_VARINT(c->max_table_size, 3, 0x20,
add_tiny_header_data(st, len), len);
c->advertise_table_size_change = 0;
}
-static gpr_uint32 dynidx(grpc_chttp2_hpack_compressor *c,
- gpr_uint32 elem_index) {
+static uint32_t dynidx(grpc_chttp2_hpack_compressor *c, uint32_t elem_index) {
return 1 + GRPC_CHTTP2_LAST_STATIC_ENTRY + c->tail_remote_index +
c->table_elems - elem_index;
}
@@ -361,10 +359,10 @@ static gpr_uint32 dynidx(grpc_chttp2_hpack_compressor *c,
/* encode an mdelem */
static void hpack_enc(grpc_chttp2_hpack_compressor *c, grpc_mdelem *elem,
framer_state *st) {
- gpr_uint32 key_hash = elem->key->hash;
- gpr_uint32 elem_hash = GRPC_MDSTR_KV_HASH(key_hash, elem->value->hash);
+ uint32_t key_hash = elem->key->hash;
+ uint32_t elem_hash = GRPC_MDSTR_KV_HASH(key_hash, elem->value->hash);
size_t decoder_space_usage;
- gpr_uint32 indices_key;
+ uint32_t indices_key;
int should_add_elem;
GPR_ASSERT(GPR_SLICE_LENGTH(elem->key->slice) > 0);
@@ -463,9 +461,7 @@ static void deadline_enc(grpc_chttp2_hpack_compressor *c, gpr_timespec deadline,
GRPC_MDELEM_UNREF(mdelem);
}
-static gpr_uint32 elems_for_bytes(gpr_uint32 bytes) {
- return (bytes + 31) / 32;
-}
+static uint32_t elems_for_bytes(uint32_t bytes) { return (bytes + 31) / 32; }
void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor *c) {
memset(c, 0, sizeof(*c));
@@ -489,21 +485,21 @@ void grpc_chttp2_hpack_compressor_destroy(grpc_chttp2_hpack_compressor *c) {
}
void grpc_chttp2_hpack_compressor_set_max_usable_size(
- grpc_chttp2_hpack_compressor *c, gpr_uint32 max_table_size) {
+ grpc_chttp2_hpack_compressor *c, uint32_t max_table_size) {
c->max_usable_size = max_table_size;
grpc_chttp2_hpack_compressor_set_max_table_size(
c, GPR_MIN(c->max_table_size, max_table_size));
}
-static void rebuild_elems(grpc_chttp2_hpack_compressor *c, gpr_uint32 new_cap) {
- gpr_uint16 *table_elem_size = gpr_malloc(sizeof(*table_elem_size) * new_cap);
- gpr_uint32 i;
+static void rebuild_elems(grpc_chttp2_hpack_compressor *c, uint32_t new_cap) {
+ uint16_t *table_elem_size = gpr_malloc(sizeof(*table_elem_size) * new_cap);
+ uint32_t i;
memset(table_elem_size, 0, sizeof(*table_elem_size) * new_cap);
GPR_ASSERT(c->table_elems <= new_cap);
for (i = 0; i < c->table_elems; i++) {
- gpr_uint32 ofs = c->tail_remote_index + i + 1;
+ uint32_t ofs = c->tail_remote_index + i + 1;
table_elem_size[ofs % new_cap] =
c->table_elem_size[ofs % c->cap_table_elems];
}
@@ -514,7 +510,7 @@ static void rebuild_elems(grpc_chttp2_hpack_compressor *c, gpr_uint32 new_cap) {
}
void grpc_chttp2_hpack_compressor_set_max_table_size(
- grpc_chttp2_hpack_compressor *c, gpr_uint32 max_table_size) {
+ grpc_chttp2_hpack_compressor *c, uint32_t max_table_size) {
max_table_size = GPR_MIN(max_table_size, c->max_usable_size);
if (max_table_size == c->max_table_size) {
return;
@@ -527,7 +523,7 @@ void grpc_chttp2_hpack_compressor_set_max_table_size(
if (c->max_table_elems > c->cap_table_elems) {
rebuild_elems(c, GPR_MAX(c->max_table_elems, 2 * c->cap_table_elems));
} else if (c->max_table_elems < c->cap_table_elems / 3) {
- gpr_uint32 new_cap = GPR_MAX(c->max_table_elems, 16);
+ uint32_t new_cap = GPR_MAX(c->max_table_elems, 16);
if (new_cap != c->cap_table_elems) {
rebuild_elems(c, new_cap);
}
@@ -537,7 +533,7 @@ void grpc_chttp2_hpack_compressor_set_max_table_size(
}
void grpc_chttp2_encode_header(grpc_chttp2_hpack_compressor *c,
- gpr_uint32 stream_id,
+ uint32_t stream_id,
grpc_metadata_batch *metadata, int is_eof,
gpr_slice_buffer *outbuf) {
framer_state st;
diff --git a/src/core/transport/chttp2/hpack_encoder.h b/src/core/transport/chttp2/hpack_encoder.h
index a3600436e9..19b5cb72ae 100644
--- a/src/core/transport/chttp2/hpack_encoder.h
+++ b/src/core/transport/chttp2/hpack_encoder.h
@@ -49,46 +49,46 @@
#define GRPC_CHTTP2_HPACKC_MAX_TABLE_SIZE (1024 * 1024)
typedef struct {
- gpr_uint32 filter_elems_sum;
- gpr_uint32 max_table_size;
- gpr_uint32 max_table_elems;
- gpr_uint32 cap_table_elems;
+ uint32_t filter_elems_sum;
+ uint32_t max_table_size;
+ uint32_t max_table_elems;
+ uint32_t cap_table_elems;
/** if non-zero, advertise to the decoder that we'll start using a table
of this size */
- gpr_uint8 advertise_table_size_change;
+ uint8_t advertise_table_size_change;
/** maximum number of bytes we'll use for the decode table (to guard against
peers ooming us by setting decode table size high) */
- gpr_uint32 max_usable_size;
+ uint32_t max_usable_size;
/* one before the lowest usable table index */
- gpr_uint32 tail_remote_index;
- gpr_uint32 table_size;
- gpr_uint32 table_elems;
+ uint32_t tail_remote_index;
+ uint32_t table_size;
+ uint32_t table_elems;
/* filter tables for elems: this tables provides an approximate
popularity count for particular hashes, and are used to determine whether
a new literal should be added to the compression table or not.
They track a single integer that counts how often a particular value has
been seen. When that count reaches max (255), all values are halved. */
- gpr_uint8 filter_elems[GRPC_CHTTP2_HPACKC_NUM_FILTERS];
+ uint8_t filter_elems[GRPC_CHTTP2_HPACKC_NUM_FILTERS];
/* entry tables for keys & elems: these tables track values that have been
seen and *may* be in the decompressor table */
grpc_mdstr *entries_keys[GRPC_CHTTP2_HPACKC_NUM_VALUES];
grpc_mdelem *entries_elems[GRPC_CHTTP2_HPACKC_NUM_VALUES];
- gpr_uint32 indices_keys[GRPC_CHTTP2_HPACKC_NUM_VALUES];
- gpr_uint32 indices_elems[GRPC_CHTTP2_HPACKC_NUM_VALUES];
+ uint32_t indices_keys[GRPC_CHTTP2_HPACKC_NUM_VALUES];
+ uint32_t indices_elems[GRPC_CHTTP2_HPACKC_NUM_VALUES];
- gpr_uint16 *table_elem_size;
+ uint16_t *table_elem_size;
} grpc_chttp2_hpack_compressor;
void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor *c);
void grpc_chttp2_hpack_compressor_destroy(grpc_chttp2_hpack_compressor *c);
void grpc_chttp2_hpack_compressor_set_max_table_size(
- grpc_chttp2_hpack_compressor *c, gpr_uint32 max_table_size);
+ grpc_chttp2_hpack_compressor *c, uint32_t max_table_size);
void grpc_chttp2_hpack_compressor_set_max_usable_size(
- grpc_chttp2_hpack_compressor *c, gpr_uint32 max_table_size);
+ grpc_chttp2_hpack_compressor *c, uint32_t max_table_size);
-void grpc_chttp2_encode_header(grpc_chttp2_hpack_compressor *c, gpr_uint32 id,
+void grpc_chttp2_encode_header(grpc_chttp2_hpack_compressor *c, uint32_t id,
grpc_metadata_batch *metadata, int is_eof,
gpr_slice_buffer *outbuf);
diff --git a/src/core/transport/chttp2/hpack_parser.c b/src/core/transport/chttp2/hpack_parser.c
index 48790c2ef2..a63c7db1f6 100644
--- a/src/core/transport/chttp2/hpack_parser.c
+++ b/src/core/transport/chttp2/hpack_parser.c
@@ -75,63 +75,63 @@ typedef enum {
a set of indirect jumps, and so not waste stack space. */
/* forward declarations for parsing states */
-static int parse_begin(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end);
-static int parse_error(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end);
-static int parse_illegal_op(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end);
-
-static int parse_string_prefix(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end);
-static int parse_key_string(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end);
+static int parse_begin(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
+static int parse_error(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
+static int parse_illegal_op(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
+
+static int parse_string_prefix(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
+static int parse_key_string(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
static int parse_value_string_with_indexed_key(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur,
- const gpr_uint8 *end);
+ const uint8_t *cur,
+ const uint8_t *end);
static int parse_value_string_with_literal_key(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur,
- const gpr_uint8 *end);
-
-static int parse_value0(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end);
-static int parse_value1(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end);
-static int parse_value2(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end);
-static int parse_value3(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end);
-static int parse_value4(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end);
-static int parse_value5up(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end);
-
-static int parse_indexed_field(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end);
+ const uint8_t *cur,
+ const uint8_t *end);
+
+static int parse_value0(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
+static int parse_value1(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
+static int parse_value2(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
+static int parse_value3(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
+static int parse_value4(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
+static int parse_value5up(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
+
+static int parse_indexed_field(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
static int parse_indexed_field_x(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end);
-static int parse_lithdr_incidx(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end);
+ const uint8_t *cur, const uint8_t *end);
+static int parse_lithdr_incidx(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
static int parse_lithdr_incidx_x(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end);
+ const uint8_t *cur, const uint8_t *end);
static int parse_lithdr_incidx_v(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end);
-static int parse_lithdr_notidx(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end);
+ const uint8_t *cur, const uint8_t *end);
+static int parse_lithdr_notidx(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
static int parse_lithdr_notidx_x(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end);
+ const uint8_t *cur, const uint8_t *end);
static int parse_lithdr_notidx_v(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end);
-static int parse_lithdr_nvridx(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end);
+ const uint8_t *cur, const uint8_t *end);
+static int parse_lithdr_nvridx(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
static int parse_lithdr_nvridx_x(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end);
+ const uint8_t *cur, const uint8_t *end);
static int parse_lithdr_nvridx_v(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end);
-static int parse_max_tbl_size(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end);
-static int parse_max_tbl_size_x(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end);
+ const uint8_t *cur, const uint8_t *end);
+static int parse_max_tbl_size(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
+static int parse_max_tbl_size_x(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
/* we translate the first byte of a hpack field into one of these decoding
cases, then use a lookup table to jump directly to the appropriate parser.
@@ -167,7 +167,7 @@ static const grpc_chttp2_hpack_parser_state first_byte_action[] = {
/* indexes the first byte to a parse state function - generated by
gen_hpack_tables.c */
-static const gpr_uint8 first_byte_lut[256] = {
+static const uint8_t first_byte_lut[256] = {
LITHDR_NOTIDX_V, LITHDR_NOTIDX, LITHDR_NOTIDX, LITHDR_NOTIDX,
LITHDR_NOTIDX, LITHDR_NOTIDX, LITHDR_NOTIDX, LITHDR_NOTIDX,
LITHDR_NOTIDX, LITHDR_NOTIDX, LITHDR_NOTIDX, LITHDR_NOTIDX,
@@ -239,7 +239,7 @@ static const gpr_uint8 first_byte_lut[256] = {
considered returns the next state.
generated by gen_hpack_tables.c */
-static const gpr_uint8 next_tbl[256] = {
+static const uint8_t next_tbl[256] = {
0, 1, 2, 3, 4, 1, 2, 5, 6, 1, 7, 8, 1, 3, 3, 9, 10, 11, 1, 1,
1, 12, 1, 2, 13, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
14, 1, 15, 16, 1, 17, 1, 15, 2, 7, 3, 18, 19, 1, 1, 1, 1, 20, 1, 1,
@@ -257,7 +257,7 @@ static const gpr_uint8 next_tbl[256] = {
/* next state, based upon current state and the current nibble: see above.
generated by gen_hpack_tables.c */
-static const gpr_int16 next_sub_tbl[48 * 16] = {
+static const int16_t next_sub_tbl[48 * 16] = {
1, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217,
218, 2, 6, 10, 13, 14, 15, 16, 17, 2, 6, 10, 13, 14, 15,
16, 17, 3, 7, 11, 24, 3, 7, 11, 24, 3, 7, 11, 24, 3,
@@ -316,7 +316,7 @@ static const gpr_int16 next_sub_tbl[48 * 16] = {
emitted, or -1 for no byte, or 256 for end of stream
generated by gen_hpack_tables.c */
-static const gpr_uint16 emit_tbl[256] = {
+static const uint16_t emit_tbl[256] = {
0, 1, 2, 3, 4, 5, 6, 7, 0, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19, 20, 21, 22, 0, 23, 24, 25, 26, 27,
28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
@@ -338,7 +338,7 @@ static const gpr_uint16 emit_tbl[256] = {
};
/* generated by gen_hpack_tables.c */
-static const gpr_int16 emit_sub_tbl[249 * 16] = {
+static const int16_t emit_sub_tbl[249 * 16] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 48, 48, 48, 48, 48, 48, 48, 48, 49, 49, 49, 49, 49, 49,
49, 49, 48, 48, 48, 48, 49, 49, 49, 49, 50, 50, 50, 50, 97,
@@ -607,7 +607,7 @@ static const gpr_int16 emit_sub_tbl[249 * 16] = {
13, 22, 22, 22, 22, 256, 256, 256, 256,
};
-static const gpr_uint8 inverse_base64[256] = {
+static const uint8_t inverse_base64[256] = {
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 255,
@@ -642,22 +642,22 @@ static int on_hdr(grpc_chttp2_hpack_parser *p, grpc_mdelem *md,
static grpc_mdstr *take_string(grpc_chttp2_hpack_parser *p,
grpc_chttp2_hpack_parser_string *str) {
- grpc_mdstr *s = grpc_mdstr_from_buffer((gpr_uint8 *)str->str, str->length);
+ grpc_mdstr *s = grpc_mdstr_from_buffer((uint8_t *)str->str, str->length);
str->length = 0;
return s;
}
/* jump to the next state */
-static int parse_next(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_next(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
p->state = *p->next_state++;
return p->state(p, cur, end);
}
/* begin parsing a header: all functionality is encoded into lookup tables
above */
-static int parse_begin(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_begin(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
if (cur == end) {
p->state = parse_begin;
return 1;
@@ -667,8 +667,8 @@ static int parse_begin(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
}
/* stream dependency and prioritization data: we just skip it */
-static int parse_stream_weight(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+static int parse_stream_weight(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
if (cur == end) {
p->state = parse_stream_weight;
return 1;
@@ -677,8 +677,8 @@ static int parse_stream_weight(grpc_chttp2_hpack_parser *p,
return p->after_prioritization(p, cur + 1, end);
}
-static int parse_stream_dep3(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_stream_dep3(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
if (cur == end) {
p->state = parse_stream_dep3;
return 1;
@@ -687,8 +687,8 @@ static int parse_stream_dep3(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
return parse_stream_weight(p, cur + 1, end);
}
-static int parse_stream_dep2(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_stream_dep2(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
if (cur == end) {
p->state = parse_stream_dep2;
return 1;
@@ -697,8 +697,8 @@ static int parse_stream_dep2(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
return parse_stream_dep3(p, cur + 1, end);
}
-static int parse_stream_dep1(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_stream_dep1(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
if (cur == end) {
p->state = parse_stream_dep1;
return 1;
@@ -707,8 +707,8 @@ static int parse_stream_dep1(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
return parse_stream_dep2(p, cur + 1, end);
}
-static int parse_stream_dep0(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_stream_dep0(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
if (cur == end) {
p->state = parse_stream_dep0;
return 1;
@@ -719,8 +719,8 @@ static int parse_stream_dep0(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
/* emit an indexed field; for now just logs it to console; jumps to
begin the next field on completion */
-static int finish_indexed_field(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+static int finish_indexed_field(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
grpc_mdelem *md = grpc_chttp2_hptbl_lookup(&p->table, p->index);
if (md == NULL) {
gpr_log(GPR_ERROR, "Invalid HPACK index received: %d", p->index);
@@ -731,8 +731,8 @@ static int finish_indexed_field(grpc_chttp2_hpack_parser *p,
}
/* parse an indexed field with index < 127 */
-static int parse_indexed_field(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+static int parse_indexed_field(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
p->dynamic_table_update_allowed = 0;
p->index = (*cur) & 0x7f;
return finish_indexed_field(p, cur + 1, end);
@@ -740,7 +740,7 @@ static int parse_indexed_field(grpc_chttp2_hpack_parser *p,
/* parse an indexed field with index >= 127 */
static int parse_indexed_field_x(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+ const uint8_t *cur, const uint8_t *end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
finish_indexed_field};
p->dynamic_table_update_allowed = 0;
@@ -752,8 +752,8 @@ static int parse_indexed_field_x(grpc_chttp2_hpack_parser *p,
/* finish a literal header with incremental indexing: just log, and jump to '
begin */
-static int finish_lithdr_incidx(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+static int finish_lithdr_incidx(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
grpc_mdelem *md = grpc_chttp2_hptbl_lookup(&p->table, p->index);
GPR_ASSERT(md != NULL); /* handled in string parsing */
return on_hdr(p, grpc_mdelem_from_metadata_strings(GRPC_MDSTR_REF(md->key),
@@ -764,7 +764,7 @@ static int finish_lithdr_incidx(grpc_chttp2_hpack_parser *p,
/* finish a literal header with incremental indexing with no index */
static int finish_lithdr_incidx_v(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+ const uint8_t *cur, const uint8_t *end) {
return on_hdr(p, grpc_mdelem_from_metadata_strings(take_string(p, &p->key),
take_string(p, &p->value)),
1) &&
@@ -772,8 +772,8 @@ static int finish_lithdr_incidx_v(grpc_chttp2_hpack_parser *p,
}
/* parse a literal header with incremental indexing; index < 63 */
-static int parse_lithdr_incidx(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+static int parse_lithdr_incidx(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_value_string_with_indexed_key, finish_lithdr_incidx};
p->dynamic_table_update_allowed = 0;
@@ -784,7 +784,7 @@ static int parse_lithdr_incidx(grpc_chttp2_hpack_parser *p,
/* parse a literal header with incremental indexing; index >= 63 */
static int parse_lithdr_incidx_x(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+ const uint8_t *cur, const uint8_t *end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_string_prefix, parse_value_string_with_indexed_key,
finish_lithdr_incidx};
@@ -797,7 +797,7 @@ static int parse_lithdr_incidx_x(grpc_chttp2_hpack_parser *p,
/* parse a literal header with incremental indexing; index = 0 */
static int parse_lithdr_incidx_v(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+ const uint8_t *cur, const uint8_t *end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_key_string, parse_string_prefix,
parse_value_string_with_literal_key, finish_lithdr_incidx_v};
@@ -807,8 +807,8 @@ static int parse_lithdr_incidx_v(grpc_chttp2_hpack_parser *p,
}
/* finish a literal header without incremental indexing */
-static int finish_lithdr_notidx(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+static int finish_lithdr_notidx(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
grpc_mdelem *md = grpc_chttp2_hptbl_lookup(&p->table, p->index);
GPR_ASSERT(md != NULL); /* handled in string parsing */
return on_hdr(p, grpc_mdelem_from_metadata_strings(GRPC_MDSTR_REF(md->key),
@@ -819,7 +819,7 @@ static int finish_lithdr_notidx(grpc_chttp2_hpack_parser *p,
/* finish a literal header without incremental indexing with index = 0 */
static int finish_lithdr_notidx_v(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+ const uint8_t *cur, const uint8_t *end) {
return on_hdr(p, grpc_mdelem_from_metadata_strings(take_string(p, &p->key),
take_string(p, &p->value)),
0) &&
@@ -827,8 +827,8 @@ static int finish_lithdr_notidx_v(grpc_chttp2_hpack_parser *p,
}
/* parse a literal header without incremental indexing; index < 15 */
-static int parse_lithdr_notidx(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+static int parse_lithdr_notidx(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_value_string_with_indexed_key, finish_lithdr_notidx};
p->dynamic_table_update_allowed = 0;
@@ -839,7 +839,7 @@ static int parse_lithdr_notidx(grpc_chttp2_hpack_parser *p,
/* parse a literal header without incremental indexing; index >= 15 */
static int parse_lithdr_notidx_x(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+ const uint8_t *cur, const uint8_t *end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_string_prefix, parse_value_string_with_indexed_key,
finish_lithdr_notidx};
@@ -852,7 +852,7 @@ static int parse_lithdr_notidx_x(grpc_chttp2_hpack_parser *p,
/* parse a literal header without incremental indexing; index == 0 */
static int parse_lithdr_notidx_v(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+ const uint8_t *cur, const uint8_t *end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_key_string, parse_string_prefix,
parse_value_string_with_literal_key, finish_lithdr_notidx_v};
@@ -862,8 +862,8 @@ static int parse_lithdr_notidx_v(grpc_chttp2_hpack_parser *p,
}
/* finish a literal header that is never indexed */
-static int finish_lithdr_nvridx(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+static int finish_lithdr_nvridx(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
grpc_mdelem *md = grpc_chttp2_hptbl_lookup(&p->table, p->index);
GPR_ASSERT(md != NULL); /* handled in string parsing */
return on_hdr(p, grpc_mdelem_from_metadata_strings(GRPC_MDSTR_REF(md->key),
@@ -874,7 +874,7 @@ static int finish_lithdr_nvridx(grpc_chttp2_hpack_parser *p,
/* finish a literal header that is never indexed with an extra value */
static int finish_lithdr_nvridx_v(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+ const uint8_t *cur, const uint8_t *end) {
return on_hdr(p, grpc_mdelem_from_metadata_strings(take_string(p, &p->key),
take_string(p, &p->value)),
0) &&
@@ -882,8 +882,8 @@ static int finish_lithdr_nvridx_v(grpc_chttp2_hpack_parser *p,
}
/* parse a literal header that is never indexed; index < 15 */
-static int parse_lithdr_nvridx(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+static int parse_lithdr_nvridx(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_value_string_with_indexed_key, finish_lithdr_nvridx};
p->dynamic_table_update_allowed = 0;
@@ -894,7 +894,7 @@ static int parse_lithdr_nvridx(grpc_chttp2_hpack_parser *p,
/* parse a literal header that is never indexed; index >= 15 */
static int parse_lithdr_nvridx_x(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+ const uint8_t *cur, const uint8_t *end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_string_prefix, parse_value_string_with_indexed_key,
finish_lithdr_nvridx};
@@ -907,7 +907,7 @@ static int parse_lithdr_nvridx_x(grpc_chttp2_hpack_parser *p,
/* parse a literal header that is never indexed; index == 0 */
static int parse_lithdr_nvridx_v(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+ const uint8_t *cur, const uint8_t *end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_key_string, parse_string_prefix,
parse_value_string_with_literal_key, finish_lithdr_nvridx_v};
@@ -917,16 +917,16 @@ static int parse_lithdr_nvridx_v(grpc_chttp2_hpack_parser *p,
}
/* finish parsing a max table size change */
-static int finish_max_tbl_size(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+static int finish_max_tbl_size(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
gpr_log(GPR_INFO, "MAX TABLE SIZE: %d", p->index);
return grpc_chttp2_hptbl_set_current_table_size(&p->table, p->index) &&
parse_begin(p, cur, end);
}
/* parse a max table size change, max size < 15 */
-static int parse_max_tbl_size(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_max_tbl_size(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
if (p->dynamic_table_update_allowed == 0) {
return 0;
}
@@ -936,8 +936,8 @@ static int parse_max_tbl_size(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
}
/* parse a max table size change, max size >= 15 */
-static int parse_max_tbl_size_x(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+static int parse_max_tbl_size_x(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
finish_max_tbl_size};
if (p->dynamic_table_update_allowed == 0) {
@@ -951,14 +951,14 @@ static int parse_max_tbl_size_x(grpc_chttp2_hpack_parser *p,
}
/* a parse error: jam the parse state into parse_error, and return error */
-static int parse_error(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_error(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
p->state = parse_error;
return 0;
}
-static int parse_illegal_op(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_illegal_op(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
GPR_ASSERT(cur != end);
gpr_log(GPR_DEBUG, "Illegal hpack op code %d", *cur);
return parse_error(p, cur, end);
@@ -966,8 +966,8 @@ static int parse_illegal_op(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
/* parse the 1st byte of a varint into p->parsing.value
no overflow is possible */
-static int parse_value0(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_value0(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
if (cur == end) {
p->state = parse_value0;
return 1;
@@ -984,14 +984,14 @@ static int parse_value0(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
/* parse the 2nd byte of a varint into p->parsing.value
no overflow is possible */
-static int parse_value1(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_value1(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
if (cur == end) {
p->state = parse_value1;
return 1;
}
- *p->parsing.value += (((gpr_uint32)*cur) & 0x7f) << 7;
+ *p->parsing.value += (((uint32_t)*cur) & 0x7f) << 7;
if ((*cur) & 0x80) {
return parse_value2(p, cur + 1, end);
@@ -1002,14 +1002,14 @@ static int parse_value1(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
/* parse the 3rd byte of a varint into p->parsing.value
no overflow is possible */
-static int parse_value2(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_value2(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
if (cur == end) {
p->state = parse_value2;
return 1;
}
- *p->parsing.value += (((gpr_uint32)*cur) & 0x7f) << 14;
+ *p->parsing.value += (((uint32_t)*cur) & 0x7f) << 14;
if ((*cur) & 0x80) {
return parse_value3(p, cur + 1, end);
@@ -1020,14 +1020,14 @@ static int parse_value2(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
/* parse the 4th byte of a varint into p->parsing.value
no overflow is possible */
-static int parse_value3(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_value3(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
if (cur == end) {
p->state = parse_value3;
return 1;
}
- *p->parsing.value += (((gpr_uint32)*cur) & 0x7f) << 21;
+ *p->parsing.value += (((uint32_t)*cur) & 0x7f) << 21;
if ((*cur) & 0x80) {
return parse_value4(p, cur + 1, end);
@@ -1038,11 +1038,11 @@ static int parse_value3(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
/* parse the 5th byte of a varint into p->parsing.value
depending on the byte, we may overflow, and care must be taken */
-static int parse_value4(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
- gpr_uint8 c;
- gpr_uint32 cur_value;
- gpr_uint32 add_value;
+static int parse_value4(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
+ uint8_t c;
+ uint32_t cur_value;
+ uint32_t add_value;
if (cur == end) {
p->state = parse_value4;
@@ -1055,7 +1055,7 @@ static int parse_value4(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
}
cur_value = *p->parsing.value;
- add_value = ((gpr_uint32)c) << 28;
+ add_value = ((uint32_t)c) << 28;
if (add_value > 0xffffffffu - cur_value) {
goto error;
}
@@ -1079,8 +1079,8 @@ error:
/* parse any trailing bytes in a varint: it's possible to append an arbitrary
number of 0x80's and not affect the value - a zero will terminate - and
anything else will overflow */
-static int parse_value5up(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_value5up(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
while (cur != end && *cur == 0x80) {
++cur;
}
@@ -1102,8 +1102,8 @@ static int parse_value5up(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
}
/* parse a string prefix */
-static int parse_string_prefix(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+static int parse_string_prefix(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
if (cur == end) {
p->state = parse_string_prefix;
return 1;
@@ -1121,22 +1121,22 @@ static int parse_string_prefix(grpc_chttp2_hpack_parser *p,
/* append some bytes to a string */
static void append_bytes(grpc_chttp2_hpack_parser_string *str,
- const gpr_uint8 *data, size_t length) {
+ const uint8_t *data, size_t length) {
if (length + str->length > str->capacity) {
- GPR_ASSERT(str->length + length <= GPR_UINT32_MAX);
- str->capacity = (gpr_uint32)(str->length + length);
+ GPR_ASSERT(str->length + length <= UINT32_MAX);
+ str->capacity = (uint32_t)(str->length + length);
str->str = gpr_realloc(str->str, str->capacity);
}
memcpy(str->str + str->length, data, length);
- GPR_ASSERT(length <= GPR_UINT32_MAX - str->length);
- str->length += (gpr_uint32)length;
+ GPR_ASSERT(length <= UINT32_MAX - str->length);
+ str->length += (uint32_t)length;
}
-static int append_string(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int append_string(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
grpc_chttp2_hpack_parser_string *str = p->parsing.str;
- gpr_uint32 bits;
- gpr_uint8 decoded[3];
+ uint32_t bits;
+ uint8_t decoded[3];
switch ((binary_state)p->binary) {
case NOT_BINARY:
append_bytes(str, cur, (size_t)(end - cur));
@@ -1197,9 +1197,9 @@ static int append_string(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
goto b64_byte3;
p->base64_buffer |= bits;
bits = p->base64_buffer;
- decoded[0] = (gpr_uint8)(bits >> 16);
- decoded[1] = (gpr_uint8)(bits >> 8);
- decoded[2] = (gpr_uint8)(bits);
+ decoded[0] = (uint8_t)(bits >> 16);
+ decoded[1] = (uint8_t)(bits >> 8);
+ decoded[2] = (uint8_t)(bits);
append_bytes(str, decoded, 3);
goto b64_byte0;
}
@@ -1208,9 +1208,9 @@ static int append_string(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
/* append a null terminator to a string */
static int finish_str(grpc_chttp2_hpack_parser *p) {
- gpr_uint8 terminator = 0;
- gpr_uint8 decoded[2];
- gpr_uint32 bits;
+ uint8_t terminator = 0;
+ uint8_t decoded[2];
+ uint32_t bits;
grpc_chttp2_hpack_parser_string *str = p->parsing.str;
switch ((binary_state)p->binary) {
case NOT_BINARY:
@@ -1227,7 +1227,7 @@ static int finish_str(grpc_chttp2_hpack_parser *p) {
bits & 0xffff);
return 0;
}
- decoded[0] = (gpr_uint8)(bits >> 16);
+ decoded[0] = (uint8_t)(bits >> 16);
append_bytes(str, decoded, 1);
break;
case B64_BYTE3:
@@ -1237,8 +1237,8 @@ static int finish_str(grpc_chttp2_hpack_parser *p) {
bits & 0xff);
return 0;
}
- decoded[0] = (gpr_uint8)(bits >> 16);
- decoded[1] = (gpr_uint8)(bits >> 8);
+ decoded[0] = (uint8_t)(bits >> 16);
+ decoded[1] = (uint8_t)(bits >> 8);
append_bytes(str, decoded, 2);
break;
}
@@ -1248,12 +1248,12 @@ static int finish_str(grpc_chttp2_hpack_parser *p) {
}
/* decode a nibble from a huffman encoded stream */
-static int huff_nibble(grpc_chttp2_hpack_parser *p, gpr_uint8 nibble) {
- gpr_int16 emit = emit_sub_tbl[16 * emit_tbl[p->huff_state] + nibble];
- gpr_int16 next = next_sub_tbl[16 * next_tbl[p->huff_state] + nibble];
+static int huff_nibble(grpc_chttp2_hpack_parser *p, uint8_t nibble) {
+ int16_t emit = emit_sub_tbl[16 * emit_tbl[p->huff_state] + nibble];
+ int16_t next = next_sub_tbl[16 * next_tbl[p->huff_state] + nibble];
if (emit != -1) {
if (emit >= 0 && emit < 256) {
- gpr_uint8 c = (gpr_uint8)emit;
+ uint8_t c = (uint8_t)emit;
if (!append_string(p, &c, (&c) + 1)) return 0;
} else {
assert(emit == 256);
@@ -1264,8 +1264,8 @@ static int huff_nibble(grpc_chttp2_hpack_parser *p, gpr_uint8 nibble) {
}
/* decode full bytes from a huffman encoded stream */
-static int add_huff_bytes(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int add_huff_bytes(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
for (; cur != end; ++cur) {
if (!huff_nibble(p, *cur >> 4) || !huff_nibble(p, *cur & 0xf)) return 0;
}
@@ -1274,8 +1274,8 @@ static int add_huff_bytes(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
/* decode some string bytes based on the current decoding mode
(huffman or not) */
-static int add_str_bytes(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int add_str_bytes(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
if (p->huff) {
return add_huff_bytes(p, cur, end);
} else {
@@ -1284,8 +1284,8 @@ static int add_str_bytes(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
}
/* parse a string - tries to do large chunks at a time */
-static int parse_string(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_string(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
size_t remaining = p->strlen - p->strgot;
size_t given = (size_t)(end - cur);
if (remaining <= given) {
@@ -1293,16 +1293,16 @@ static int parse_string(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
parse_next(p, cur + remaining, end);
} else {
if (!add_str_bytes(p, cur, cur + given)) return 0;
- GPR_ASSERT(given <= GPR_UINT32_MAX - p->strgot);
- p->strgot += (gpr_uint32)given;
+ GPR_ASSERT(given <= UINT32_MAX - p->strgot);
+ p->strgot += (uint32_t)given;
p->state = parse_string;
return 1;
}
}
/* begin parsing a string - performs setup, calls parse_string */
-static int begin_parse_string(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end, gpr_uint8 binary,
+static int begin_parse_string(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end, uint8_t binary,
grpc_chttp2_hpack_parser_string *str) {
p->strgot = 0;
str->length = 0;
@@ -1313,8 +1313,8 @@ static int begin_parse_string(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
}
/* parse the key string */
-static int parse_key_string(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_key_string(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
return begin_parse_string(p, cur, end, NOT_BINARY, &p->key);
}
@@ -1340,8 +1340,8 @@ static is_binary_header is_binary_indexed_header(grpc_chttp2_hpack_parser *p) {
}
/* parse the value string */
-static int parse_value_string(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end, is_binary_header type) {
+static int parse_value_string(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end, is_binary_header type) {
switch (type) {
case BINARY_HEADER:
return begin_parse_string(p, cur, end, B64_BYTE0, &p->value);
@@ -1355,14 +1355,14 @@ static int parse_value_string(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
}
static int parse_value_string_with_indexed_key(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+ const uint8_t *cur,
+ const uint8_t *end) {
return parse_value_string(p, cur, end, is_binary_indexed_header(p));
}
static int parse_value_string_with_literal_key(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+ const uint8_t *cur,
+ const uint8_t *end) {
return parse_value_string(p, cur, end, is_binary_literal_header(p));
}
@@ -1398,7 +1398,7 @@ void grpc_chttp2_hpack_parser_destroy(grpc_chttp2_hpack_parser *p) {
}
int grpc_chttp2_hpack_parser_parse(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *beg, const gpr_uint8 *end) {
+ const uint8_t *beg, const uint8_t *end) {
/* TODO(ctiller): limit the distance of end from beg, and perform multiple
steps in the event of a large chunk of data to limit
stack space usage when no tail call optimization is
diff --git a/src/core/transport/chttp2/hpack_parser.h b/src/core/transport/chttp2/hpack_parser.h
index bd36357124..1ad0c64fb9 100644
--- a/src/core/transport/chttp2/hpack_parser.h
+++ b/src/core/transport/chttp2/hpack_parser.h
@@ -45,13 +45,13 @@
typedef struct grpc_chttp2_hpack_parser grpc_chttp2_hpack_parser;
typedef int (*grpc_chttp2_hpack_parser_state)(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *beg,
- const gpr_uint8 *end);
+ const uint8_t *beg,
+ const uint8_t *end);
typedef struct {
char *str;
- gpr_uint32 length;
- gpr_uint32 capacity;
+ uint32_t length;
+ uint32_t capacity;
} grpc_chttp2_hpack_parser_string;
struct grpc_chttp2_hpack_parser {
@@ -67,31 +67,31 @@ struct grpc_chttp2_hpack_parser {
grpc_chttp2_hpack_parser_state after_prioritization;
/* the value we're currently parsing */
union {
- gpr_uint32 *value;
+ uint32_t *value;
grpc_chttp2_hpack_parser_string *str;
} parsing;
/* string parameters for each chunk */
grpc_chttp2_hpack_parser_string key;
grpc_chttp2_hpack_parser_string value;
/* parsed index */
- gpr_uint32 index;
+ uint32_t index;
/* length of source bytes for the currently parsing string */
- gpr_uint32 strlen;
+ uint32_t strlen;
/* number of source bytes read for the currently parsing string */
- gpr_uint32 strgot;
+ uint32_t strgot;
/* huffman decoding state */
- gpr_int16 huff_state;
+ int16_t huff_state;
/* is the string being decoded binary? */
- gpr_uint8 binary;
+ uint8_t binary;
/* is the current string huffman encoded? */
- gpr_uint8 huff;
+ uint8_t huff;
/* is a dynamic table update allowed? */
- gpr_uint8 dynamic_table_update_allowed;
+ uint8_t dynamic_table_update_allowed;
/* set by higher layers, used by grpc_chttp2_header_parser_parse to signal
it should append a metadata boundary at the end of frame */
- gpr_uint8 is_boundary;
- gpr_uint8 is_eof;
- gpr_uint32 base64_buffer;
+ uint8_t is_boundary;
+ uint8_t is_eof;
+ uint32_t base64_buffer;
/* hpack table */
grpc_chttp2_hptbl table;
@@ -104,7 +104,7 @@ void grpc_chttp2_hpack_parser_set_has_priority(grpc_chttp2_hpack_parser *p);
/* returns 1 on success, 0 on error */
int grpc_chttp2_hpack_parser_parse(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *beg, const gpr_uint8 *end);
+ const uint8_t *beg, const uint8_t *end);
/* wraps grpc_chttp2_hpack_parser_parse to provide a frame level parser for
the transport */
diff --git a/src/core/transport/chttp2/hpack_table.c b/src/core/transport/chttp2/hpack_table.c
index 59060daad3..f1ce3b84fd 100644
--- a/src/core/transport/chttp2/hpack_table.c
+++ b/src/core/transport/chttp2/hpack_table.c
@@ -171,7 +171,7 @@ static struct {
{"www-authenticate", ""},
};
-static gpr_uint32 entries_for_bytes(gpr_uint32 bytes) {
+static uint32_t entries_for_bytes(uint32_t bytes) {
return (bytes + GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD - 1) /
GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD;
}
@@ -204,7 +204,7 @@ void grpc_chttp2_hptbl_destroy(grpc_chttp2_hptbl *tbl) {
}
grpc_mdelem *grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl *tbl,
- gpr_uint32 tbl_index) {
+ uint32_t tbl_index) {
/* Static table comes first, just return an entry from it */
if (tbl_index <= GRPC_CHTTP2_LAST_STATIC_ENTRY) {
return tbl->static_ents[tbl_index - 1];
@@ -212,7 +212,7 @@ grpc_mdelem *grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl *tbl,
/* Otherwise, find the value in the list of valid entries */
tbl_index -= (GRPC_CHTTP2_LAST_STATIC_ENTRY + 1);
if (tbl_index < tbl->num_ents) {
- gpr_uint32 offset =
+ uint32_t offset =
(tbl->num_ents - 1u - tbl_index + tbl->first_ent) % tbl->cap_entries;
return tbl->ents[offset];
}
@@ -227,15 +227,15 @@ static void evict1(grpc_chttp2_hptbl *tbl) {
GPR_SLICE_LENGTH(first_ent->value->slice) +
GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD;
GPR_ASSERT(elem_bytes <= tbl->mem_used);
- tbl->mem_used -= (gpr_uint32)elem_bytes;
+ tbl->mem_used -= (uint32_t)elem_bytes;
tbl->first_ent = ((tbl->first_ent + 1) % tbl->cap_entries);
tbl->num_ents--;
GRPC_MDELEM_UNREF(first_ent);
}
-static void rebuild_ents(grpc_chttp2_hptbl *tbl, gpr_uint32 new_cap) {
+static void rebuild_ents(grpc_chttp2_hptbl *tbl, uint32_t new_cap) {
grpc_mdelem **ents = gpr_malloc(sizeof(*ents) * new_cap);
- gpr_uint32 i;
+ uint32_t i;
for (i = 0; i < tbl->num_ents; i++) {
ents[i] = tbl->ents[(tbl->first_ent + i) % tbl->cap_entries];
@@ -247,7 +247,7 @@ static void rebuild_ents(grpc_chttp2_hptbl *tbl, gpr_uint32 new_cap) {
}
void grpc_chttp2_hptbl_set_max_bytes(grpc_chttp2_hptbl *tbl,
- gpr_uint32 max_bytes) {
+ uint32_t max_bytes) {
if (tbl->max_bytes == max_bytes) {
return;
}
@@ -259,7 +259,7 @@ void grpc_chttp2_hptbl_set_max_bytes(grpc_chttp2_hptbl *tbl,
}
int grpc_chttp2_hptbl_set_current_table_size(grpc_chttp2_hptbl *tbl,
- gpr_uint32 bytes) {
+ uint32_t bytes) {
if (tbl->current_table_bytes == bytes) {
return 1;
}
@@ -278,7 +278,7 @@ int grpc_chttp2_hptbl_set_current_table_size(grpc_chttp2_hptbl *tbl,
if (tbl->max_entries > tbl->cap_entries) {
rebuild_ents(tbl, GPR_MAX(tbl->max_entries, 2 * tbl->cap_entries));
} else if (tbl->max_entries < tbl->cap_entries / 3) {
- gpr_uint32 new_cap = GPR_MAX(tbl->max_entries, 16u);
+ uint32_t new_cap = GPR_MAX(tbl->max_entries, 16u);
if (new_cap != tbl->cap_entries) {
rebuild_ents(tbl, new_cap);
}
@@ -328,14 +328,14 @@ int grpc_chttp2_hptbl_add(grpc_chttp2_hptbl *tbl, grpc_mdelem *md) {
/* update accounting values */
tbl->num_ents++;
- tbl->mem_used += (gpr_uint32)elem_bytes;
+ tbl->mem_used += (uint32_t)elem_bytes;
return 1;
}
grpc_chttp2_hptbl_find_result grpc_chttp2_hptbl_find(
const grpc_chttp2_hptbl *tbl, grpc_mdelem *md) {
grpc_chttp2_hptbl_find_result r = {0, 0};
- gpr_uint32 i;
+ uint32_t i;
/* See if the string is in the static table */
for (i = 0; i < GRPC_CHTTP2_LAST_STATIC_ENTRY; i++) {
@@ -348,8 +348,8 @@ grpc_chttp2_hptbl_find_result grpc_chttp2_hptbl_find(
/* Scan the dynamic table */
for (i = 0; i < tbl->num_ents; i++) {
- gpr_uint32 idx =
- (gpr_uint32)(tbl->num_ents - i + GRPC_CHTTP2_LAST_STATIC_ENTRY);
+ uint32_t idx =
+ (uint32_t)(tbl->num_ents - i + GRPC_CHTTP2_LAST_STATIC_ENTRY);
grpc_mdelem *ent = tbl->ents[(tbl->first_ent + i) % tbl->cap_entries];
if (md->key != ent->key) continue;
r.index = idx;
diff --git a/src/core/transport/chttp2/hpack_table.h b/src/core/transport/chttp2/hpack_table.h
index a173eec30c..e7431255fc 100644
--- a/src/core/transport/chttp2/hpack_table.h
+++ b/src/core/transport/chttp2/hpack_table.h
@@ -60,21 +60,21 @@
/* hpack decoder table */
typedef struct {
/* the first used entry in ents */
- gpr_uint32 first_ent;
+ uint32_t first_ent;
/* how many entries are in the table */
- gpr_uint32 num_ents;
+ uint32_t num_ents;
/* the amount of memory used by the table, according to the hpack algorithm */
- gpr_uint32 mem_used;
+ uint32_t mem_used;
/* the max memory allowed to be used by the table, according to the hpack
algorithm */
- gpr_uint32 max_bytes;
+ uint32_t max_bytes;
/* the currently agreed size of the table, according to the hpack algorithm */
- gpr_uint32 current_table_bytes;
+ uint32_t current_table_bytes;
/* Maximum number of entries we could possibly fit in the table, given defined
overheads */
- gpr_uint32 max_entries;
+ uint32_t max_entries;
/* Number of entries allocated in ents */
- gpr_uint32 cap_entries;
+ uint32_t cap_entries;
/* a circular buffer of headers - this is stored in the opposite order to
what hpack specifies, in order to simplify table management a little...
meaning lookups need to SUBTRACT from the end position */
@@ -86,20 +86,20 @@ typedef struct {
void grpc_chttp2_hptbl_init(grpc_chttp2_hptbl *tbl);
void grpc_chttp2_hptbl_destroy(grpc_chttp2_hptbl *tbl);
void grpc_chttp2_hptbl_set_max_bytes(grpc_chttp2_hptbl *tbl,
- gpr_uint32 max_bytes);
+ uint32_t max_bytes);
int grpc_chttp2_hptbl_set_current_table_size(grpc_chttp2_hptbl *tbl,
- gpr_uint32 bytes);
+ uint32_t bytes);
/* lookup a table entry based on its hpack index */
grpc_mdelem *grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl *tbl,
- gpr_uint32 index);
+ uint32_t index);
/* add a table entry to the index */
int grpc_chttp2_hptbl_add(grpc_chttp2_hptbl *tbl,
grpc_mdelem *md) GRPC_MUST_USE_RESULT;
/* Find a key/value pair in the table... returns the index in the table of the
most similar entry, or 0 if the value was not found */
typedef struct {
- gpr_uint32 index;
+ uint32_t index;
int has_value;
} grpc_chttp2_hptbl_find_result;
grpc_chttp2_hptbl_find_result grpc_chttp2_hptbl_find(
diff --git a/src/core/transport/chttp2/internal.h b/src/core/transport/chttp2/internal.h
index 43b3adb9d3..0b0fccfcd4 100644
--- a/src/core/transport/chttp2/internal.h
+++ b/src/core/transport/chttp2/internal.h
@@ -141,7 +141,7 @@ typedef enum {
/* Outstanding ping request data */
typedef struct grpc_chttp2_outstanding_ping {
- gpr_uint8 id[8];
+ uint8_t id[8];
grpc_closure *on_recv;
struct grpc_chttp2_outstanding_ping *next;
struct grpc_chttp2_outstanding_ping *prev;
@@ -152,6 +152,7 @@ struct grpc_chttp2_incoming_byte_stream {
grpc_byte_stream base;
gpr_refcount refs;
struct grpc_chttp2_incoming_byte_stream *next_message;
+ int failed;
grpc_chttp2_transport *transport;
grpc_chttp2_stream *stream;
@@ -166,46 +167,46 @@ typedef struct {
gpr_slice_buffer qbuf;
/** window available for us to send to peer */
- gpr_int64 outgoing_window;
+ int64_t outgoing_window;
/** window available to announce to peer */
- gpr_int64 announce_incoming_window;
+ int64_t announce_incoming_window;
/** how much window would we like to have for incoming_window */
- gpr_uint32 connection_window_target;
+ uint32_t connection_window_target;
/** have we seen a goaway */
- gpr_uint8 seen_goaway;
+ uint8_t seen_goaway;
/** have we sent a goaway */
- gpr_uint8 sent_goaway;
+ uint8_t sent_goaway;
/** is this transport a client? */
- gpr_uint8 is_client;
+ uint8_t is_client;
/** are the local settings dirty and need to be sent? */
- gpr_uint8 dirtied_local_settings;
+ uint8_t dirtied_local_settings;
/** have local settings been sent? */
- gpr_uint8 sent_local_settings;
+ uint8_t sent_local_settings;
/** bitmask of setting indexes to send out */
- gpr_uint32 force_send_settings;
+ uint32_t force_send_settings;
/** settings values */
- gpr_uint32 settings[GRPC_NUM_SETTING_SETS][GRPC_CHTTP2_NUM_SETTINGS];
+ uint32_t settings[GRPC_NUM_SETTING_SETS][GRPC_CHTTP2_NUM_SETTINGS];
/** what is the next stream id to be allocated by this peer?
copied to next_stream_id in parsing when parsing commences */
- gpr_uint32 next_stream_id;
+ uint32_t next_stream_id;
/** how far to lookahead in a stream? */
- gpr_uint32 stream_lookahead;
+ uint32_t stream_lookahead;
/** last received stream id */
- gpr_uint32 last_incoming_stream_id;
+ uint32_t last_incoming_stream_id;
/** pings awaiting responses */
grpc_chttp2_outstanding_ping pings;
/** next payload for an outgoing ping */
- gpr_uint64 ping_counter;
+ uint64_t ping_counter;
/** concurrent stream count: updated when not parsing,
so this is a strict over-estimation on the client */
- gpr_uint32 concurrent_stream_count;
+ uint32_t concurrent_stream_count;
} grpc_chttp2_transport_global;
typedef struct {
@@ -213,29 +214,29 @@ typedef struct {
gpr_slice_buffer outbuf;
/** hpack encoding */
grpc_chttp2_hpack_compressor hpack_compressor;
- gpr_int64 outgoing_window;
+ int64_t outgoing_window;
/** is this a client? */
- gpr_uint8 is_client;
+ uint8_t is_client;
/** callback for when writing is done */
grpc_closure done_cb;
} grpc_chttp2_transport_writing;
struct grpc_chttp2_transport_parsing {
/** is this transport a client? (boolean) */
- gpr_uint8 is_client;
+ uint8_t is_client;
/** were settings updated? */
- gpr_uint8 settings_updated;
+ uint8_t settings_updated;
/** was a settings ack received? */
- gpr_uint8 settings_ack_received;
+ uint8_t settings_ack_received;
/** was a goaway frame received? */
- gpr_uint8 goaway_received;
+ uint8_t goaway_received;
/** the last sent max_table_size setting */
- gpr_uint32 last_sent_max_table_size;
+ uint32_t last_sent_max_table_size;
/** initial window change */
- gpr_int64 initial_window_update;
+ int64_t initial_window_update;
/** data to write later - after parsing */
gpr_slice_buffer qbuf;
@@ -252,20 +253,20 @@ struct grpc_chttp2_transport_parsing {
grpc_chttp2_goaway_parser goaway_parser;
/** window available for peer to send to us */
- gpr_int64 incoming_window;
+ int64_t incoming_window;
/** next stream id available at the time of beginning parsing */
- gpr_uint32 next_stream_id;
- gpr_uint32 last_incoming_stream_id;
+ uint32_t next_stream_id;
+ uint32_t last_incoming_stream_id;
/* deframing */
grpc_chttp2_deframe_transport_state deframe_state;
- gpr_uint8 incoming_frame_type;
- gpr_uint8 incoming_frame_flags;
- gpr_uint8 header_eof;
- gpr_uint32 expect_continuation_stream_id;
- gpr_uint32 incoming_frame_size;
- gpr_uint32 incoming_stream_id;
+ uint8_t incoming_frame_type;
+ uint8_t incoming_frame_flags;
+ uint8_t header_eof;
+ uint32_t expect_continuation_stream_id;
+ uint32_t incoming_frame_size;
+ uint32_t incoming_stream_id;
/* active parser */
void *parser_data;
@@ -276,14 +277,14 @@ struct grpc_chttp2_transport_parsing {
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last);
/* received settings */
- gpr_uint32 settings[GRPC_CHTTP2_NUM_SETTINGS];
+ uint32_t settings[GRPC_CHTTP2_NUM_SETTINGS];
/* goaway data */
grpc_status_code goaway_error;
- gpr_uint32 goaway_last_stream_index;
+ uint32_t goaway_last_stream_index;
gpr_slice goaway_text;
- gpr_int64 outgoing_window;
+ int64_t outgoing_window;
};
struct grpc_chttp2_transport {
@@ -298,17 +299,17 @@ struct grpc_chttp2_transport {
gpr_mu mu;
/** is the transport destroying itself? */
- gpr_uint8 destroying;
+ uint8_t destroying;
/** has the upper layer closed the transport? */
- gpr_uint8 closed;
+ uint8_t closed;
/** is a thread currently writing */
- gpr_uint8 writing_active;
+ uint8_t writing_active;
/** is a thread currently parsing */
- gpr_uint8 parsing_active;
+ uint8_t parsing_active;
/** is there a read request to the endpoint outstanding? */
- gpr_uint8 endpoint_reading;
+ uint8_t endpoint_reading;
/** various lists of streams */
grpc_chttp2_stream_list lists[STREAM_LIST_COUNT];
@@ -357,20 +358,20 @@ struct grpc_chttp2_transport {
typedef struct {
/** HTTP2 stream id for this stream, or zero if one has not been assigned */
- gpr_uint32 id;
+ uint32_t id;
/** window available for us to send to peer */
- gpr_int64 outgoing_window;
+ int64_t outgoing_window;
/** The number of bytes the upper layers have offered to receive.
As the upper layer offers more bytes, this value increases.
As bytes are read, this value decreases. */
- gpr_uint32 max_recv_bytes;
+ uint32_t max_recv_bytes;
/** The number of bytes the upper layer has offered to read but we have
not yet announced to HTTP2 flow control.
As the upper layers offer to read more bytes, this value increases.
As we advertise incoming flow control window, this value decreases. */
- gpr_uint32 unannounced_incoming_window_for_parse;
- gpr_uint32 unannounced_incoming_window_for_writing;
+ uint32_t unannounced_incoming_window_for_parse;
+ uint32_t unannounced_incoming_window_for_writing;
/** things the upper layers would like to send */
grpc_metadata_batch *send_initial_metadata;
grpc_closure *send_initial_metadata_finished;
@@ -389,18 +390,18 @@ typedef struct {
/** when the application requests writes be closed, the write_closed is
'queued'; when the close is flow controlled into the send path, we are
'sending' it; when the write has been performed it is 'sent' */
- gpr_uint8 write_closed;
+ uint8_t write_closed;
/** is this stream reading half-closed (boolean) */
- gpr_uint8 read_closed;
+ uint8_t read_closed;
/** is this stream in the stream map? (boolean) */
- gpr_uint8 in_stream_map;
+ uint8_t in_stream_map;
/** has this stream seen an error? if 1, then pending incoming frames
can be thrown away */
- gpr_uint8 seen_error;
+ uint8_t seen_error;
- gpr_uint8 published_initial_metadata;
- gpr_uint8 published_trailing_metadata;
- gpr_uint8 faked_trailing_metadata;
+ uint8_t published_initial_metadata;
+ uint8_t published_trailing_metadata;
+ uint8_t faked_trailing_metadata;
grpc_chttp2_incoming_metadata_buffer received_initial_metadata;
grpc_chttp2_incoming_metadata_buffer received_trailing_metadata;
@@ -410,19 +411,19 @@ typedef struct {
typedef struct {
/** HTTP2 stream id for this stream, or zero if one has not been assigned */
- gpr_uint32 id;
- gpr_uint8 fetching;
- gpr_uint8 sent_initial_metadata;
- gpr_uint8 sent_message;
- gpr_uint8 sent_trailing_metadata;
- gpr_uint8 read_closed;
+ uint32_t id;
+ uint8_t fetching;
+ uint8_t sent_initial_metadata;
+ uint8_t sent_message;
+ uint8_t sent_trailing_metadata;
+ uint8_t read_closed;
/** send this initial metadata */
grpc_metadata_batch *send_initial_metadata;
grpc_byte_stream *send_message;
grpc_metadata_batch *send_trailing_metadata;
- gpr_int64 outgoing_window;
+ int64_t outgoing_window;
/** how much window should we announce? */
- gpr_uint32 announce_window;
+ uint32_t announce_window;
gpr_slice_buffer flow_controlled_buffer;
gpr_slice fetching_slice;
size_t stream_fetched;
@@ -431,27 +432,27 @@ typedef struct {
struct grpc_chttp2_stream_parsing {
/** HTTP2 stream id for this stream, or zero if one has not been assigned */
- gpr_uint32 id;
+ uint32_t id;
/** has this stream received a close */
- gpr_uint8 received_close;
+ uint8_t received_close;
/** saw a rst_stream */
- gpr_uint8 saw_rst_stream;
+ uint8_t saw_rst_stream;
/** how many header frames have we received? */
- gpr_uint8 header_frames_received;
+ uint8_t header_frames_received;
/** which metadata did we get (on this parse) */
- gpr_uint8 got_metadata_on_parse[2];
+ uint8_t got_metadata_on_parse[2];
/** should we raise the seen_error flag in transport_global */
- gpr_uint8 seen_error;
+ uint8_t seen_error;
/** window available for peer to send to us */
- gpr_int64 incoming_window;
+ int64_t incoming_window;
/** parsing state for data frames */
grpc_chttp2_data_parser data_parser;
/** reason give to rst_stream */
- gpr_uint32 rst_stream_reason;
+ uint32_t rst_stream_reason;
/** amount of window given */
- gpr_int64 outgoing_window;
+ int64_t outgoing_window;
/** number of bytes received - reset at end of parse thread execution */
- gpr_int64 received_bytes;
+ int64_t received_bytes;
/** incoming metadata */
grpc_chttp2_incoming_metadata_buffer metadata_buffer[2];
@@ -464,7 +465,7 @@ struct grpc_chttp2_stream {
grpc_chttp2_stream_parsing parsing;
grpc_chttp2_stream_link links[STREAM_LIST_COUNT];
- gpr_uint8 included[STREAM_LIST_COUNT];
+ uint8_t included[STREAM_LIST_COUNT];
};
/** Transport writing call flow:
@@ -565,6 +566,9 @@ void grpc_chttp2_list_add_stalled_by_transport(
int grpc_chttp2_list_pop_stalled_by_transport(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global **stream_global);
+void grpc_chttp2_list_remove_stalled_by_transport(
+ grpc_chttp2_transport_global *transport_global,
+ grpc_chttp2_stream_global *stream_global);
void grpc_chttp2_list_add_unannounced_incoming_window_available(
grpc_chttp2_transport_global *transport_global,
@@ -593,14 +597,14 @@ int grpc_chttp2_list_pop_closed_waiting_for_writing(
grpc_chttp2_stream_global **stream_global);
grpc_chttp2_stream_parsing *grpc_chttp2_parsing_lookup_stream(
- grpc_chttp2_transport_parsing *transport_parsing, gpr_uint32 id);
+ grpc_chttp2_transport_parsing *transport_parsing, uint32_t id);
grpc_chttp2_stream_parsing *grpc_chttp2_parsing_accept_stream(
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing,
- gpr_uint32 id);
+ uint32_t id);
void grpc_chttp2_add_incoming_goaway(
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_global *transport_global,
- gpr_uint32 goaway_error, gpr_slice goaway_text);
+ uint32_t goaway_error, gpr_slice goaway_text);
void grpc_chttp2_register_stream(grpc_chttp2_transport *t,
grpc_chttp2_stream *s);
@@ -706,8 +710,7 @@ void grpc_chttp2_flowctl_trace(const char *file, int line, const char *phase,
grpc_chttp2_flowctl_op op, const char *context1,
const char *var1, const char *context2,
const char *var2, int is_client,
- gpr_uint32 stream_id, gpr_int64 val1,
- gpr_int64 val2);
+ uint32_t stream_id, int64_t val1, int64_t val2);
void grpc_chttp2_fake_status(grpc_exec_ctx *exec_ctx,
grpc_chttp2_transport_global *transport_global,
@@ -742,16 +745,17 @@ void grpc_chttp2_stream_unref(grpc_exec_ctx *exec_ctx,
grpc_chttp2_incoming_byte_stream *grpc_chttp2_incoming_byte_stream_create(
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing,
- grpc_chttp2_stream_parsing *stream_parsing, gpr_uint32 frame_size,
- gpr_uint32 flags, grpc_chttp2_incoming_frame_queue *add_to_queue);
+ grpc_chttp2_stream_parsing *stream_parsing, uint32_t frame_size,
+ uint32_t flags, grpc_chttp2_incoming_frame_queue *add_to_queue);
void grpc_chttp2_incoming_byte_stream_push(grpc_exec_ctx *exec_ctx,
grpc_chttp2_incoming_byte_stream *bs,
gpr_slice slice);
void grpc_chttp2_incoming_byte_stream_finished(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs);
+ grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs, int success,
+ int from_parsing_thread);
void grpc_chttp2_ack_ping(grpc_exec_ctx *exec_ctx,
grpc_chttp2_transport_parsing *parsing,
- const gpr_uint8 *opaque_8bytes);
+ const uint8_t *opaque_8bytes);
#endif
diff --git a/src/core/transport/chttp2/parsing.c b/src/core/transport/chttp2/parsing.c
index 7604e7b681..8fdebd7f13 100644
--- a/src/core/transport/chttp2/parsing.c
+++ b/src/core/transport/chttp2/parsing.c
@@ -126,7 +126,7 @@ void grpc_chttp2_publish_reads(
if (transport_parsing->settings_ack_received) {
memcpy(transport_global->settings[GRPC_ACKED_SETTINGS],
transport_global->settings[GRPC_SENT_SETTINGS],
- GRPC_CHTTP2_NUM_SETTINGS * sizeof(gpr_uint32));
+ GRPC_CHTTP2_NUM_SETTINGS * sizeof(uint32_t));
transport_parsing->settings_ack_received = 0;
transport_global->sent_local_settings = 0;
}
@@ -135,7 +135,7 @@ void grpc_chttp2_publish_reads(
published later */
if (transport_parsing->goaway_received) {
grpc_chttp2_add_incoming_goaway(exec_ctx, transport_global,
- (gpr_uint32)transport_parsing->goaway_error,
+ (uint32_t)transport_parsing->goaway_error,
transport_parsing->goaway_text);
transport_parsing->goaway_text = gpr_empty_slice();
transport_parsing->goaway_received = 0;
@@ -155,8 +155,8 @@ void grpc_chttp2_publish_reads(
if (transport_parsing->incoming_window <
transport_global->connection_window_target * 3 / 4) {
- gpr_int64 announce_bytes = transport_global->connection_window_target -
- transport_parsing->incoming_window;
+ int64_t announce_bytes = transport_global->connection_window_target -
+ transport_parsing->incoming_window;
GRPC_CHTTP2_FLOW_CREDIT_TRANSPORT("parsed", transport_global,
announce_incoming_window, announce_bytes);
GRPC_CHTTP2_FLOW_CREDIT_TRANSPORT("parsed", transport_parsing,
@@ -181,7 +181,7 @@ void grpc_chttp2_publish_reads(
grpc_chttp2_list_add_writable_stream(transport_global, stream_global);
}
- stream_global->max_recv_bytes -= (gpr_uint32)GPR_MIN(
+ stream_global->max_recv_bytes -= (uint32_t)GPR_MIN(
stream_global->max_recv_bytes, stream_parsing->received_bytes);
stream_parsing->received_bytes = 0;
@@ -245,9 +245,9 @@ void grpc_chttp2_publish_reads(
int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
grpc_chttp2_transport_parsing *transport_parsing,
gpr_slice slice) {
- gpr_uint8 *beg = GPR_SLICE_START_PTR(slice);
- gpr_uint8 *end = GPR_SLICE_END_PTR(slice);
- gpr_uint8 *cur = beg;
+ uint8_t *beg = GPR_SLICE_START_PTR(slice);
+ uint8_t *end = GPR_SLICE_END_PTR(slice);
+ uint8_t *cur = beg;
if (cur == end) return 1;
@@ -284,7 +284,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
"at byte %d",
GRPC_CHTTP2_CLIENT_CONNECT_STRING[transport_parsing
->deframe_state],
- (int)(gpr_uint8)GRPC_CHTTP2_CLIENT_CONNECT_STRING
+ (int)(uint8_t)GRPC_CHTTP2_CLIENT_CONNECT_STRING
[transport_parsing->deframe_state],
*cur, (int)*cur, transport_parsing->deframe_state);
return 0;
@@ -299,7 +299,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
dts_fh_0:
case GRPC_DTS_FH_0:
GPR_ASSERT(cur < end);
- transport_parsing->incoming_frame_size = ((gpr_uint32)*cur) << 16;
+ transport_parsing->incoming_frame_size = ((uint32_t)*cur) << 16;
if (++cur == end) {
transport_parsing->deframe_state = GRPC_DTS_FH_1;
return 1;
@@ -307,7 +307,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
/* fallthrough */
case GRPC_DTS_FH_1:
GPR_ASSERT(cur < end);
- transport_parsing->incoming_frame_size |= ((gpr_uint32)*cur) << 8;
+ transport_parsing->incoming_frame_size |= ((uint32_t)*cur) << 8;
if (++cur == end) {
transport_parsing->deframe_state = GRPC_DTS_FH_2;
return 1;
@@ -339,7 +339,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
/* fallthrough */
case GRPC_DTS_FH_5:
GPR_ASSERT(cur < end);
- transport_parsing->incoming_stream_id = (((gpr_uint32)*cur) & 0x7f) << 24;
+ transport_parsing->incoming_stream_id = (((uint32_t)*cur) & 0x7f) << 24;
if (++cur == end) {
transport_parsing->deframe_state = GRPC_DTS_FH_6;
return 1;
@@ -347,7 +347,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
/* fallthrough */
case GRPC_DTS_FH_6:
GPR_ASSERT(cur < end);
- transport_parsing->incoming_stream_id |= ((gpr_uint32)*cur) << 16;
+ transport_parsing->incoming_stream_id |= ((uint32_t)*cur) << 16;
if (++cur == end) {
transport_parsing->deframe_state = GRPC_DTS_FH_7;
return 1;
@@ -355,7 +355,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
/* fallthrough */
case GRPC_DTS_FH_7:
GPR_ASSERT(cur < end);
- transport_parsing->incoming_stream_id |= ((gpr_uint32)*cur) << 8;
+ transport_parsing->incoming_stream_id |= ((uint32_t)*cur) << 8;
if (++cur == end) {
transport_parsing->deframe_state = GRPC_DTS_FH_8;
return 1;
@@ -363,7 +363,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
/* fallthrough */
case GRPC_DTS_FH_8:
GPR_ASSERT(cur < end);
- transport_parsing->incoming_stream_id |= ((gpr_uint32)*cur);
+ transport_parsing->incoming_stream_id |= ((uint32_t)*cur);
transport_parsing->deframe_state = GRPC_DTS_FRAME;
if (!init_frame_parser(exec_ctx, transport_parsing)) {
return 0;
@@ -390,7 +390,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
/* fallthrough */
case GRPC_DTS_FRAME:
GPR_ASSERT(cur < end);
- if ((gpr_uint32)(end - cur) == transport_parsing->incoming_frame_size) {
+ if ((uint32_t)(end - cur) == transport_parsing->incoming_frame_size) {
if (!parse_frame_slice(exec_ctx, transport_parsing,
gpr_slice_sub_no_ref(slice, (size_t)(cur - beg),
(size_t)(end - beg)),
@@ -400,7 +400,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
transport_parsing->deframe_state = GRPC_DTS_FH_0;
transport_parsing->incoming_stream = NULL;
return 1;
- } else if ((gpr_uint32)(end - cur) >
+ } else if ((uint32_t)(end - cur) >
transport_parsing->incoming_frame_size) {
size_t cur_offset = (size_t)(cur - beg);
if (!parse_frame_slice(
@@ -421,7 +421,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
0)) {
return 0;
}
- transport_parsing->incoming_frame_size -= (gpr_uint32)(end - cur);
+ transport_parsing->incoming_frame_size -= (uint32_t)(end - cur);
return 1;
}
GPR_UNREACHABLE_CODE(return 0);
@@ -488,14 +488,14 @@ static int init_skip_frame_parser(
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing,
int is_header) {
if (is_header) {
- gpr_uint8 is_eoh = transport_parsing->expect_continuation_stream_id != 0;
+ uint8_t is_eoh = transport_parsing->expect_continuation_stream_id != 0;
transport_parsing->parser = grpc_chttp2_header_parser_parse;
transport_parsing->parser_data = &transport_parsing->hpack_parser;
transport_parsing->hpack_parser.on_header = skip_header;
transport_parsing->hpack_parser.on_header_user_data = NULL;
transport_parsing->hpack_parser.is_boundary = is_eoh;
transport_parsing->hpack_parser.is_eof =
- (gpr_uint8)(is_eoh ? transport_parsing->header_eof : 0);
+ (uint8_t)(is_eoh ? transport_parsing->header_eof : 0);
} else {
transport_parsing->parser = skip_parser;
}
@@ -512,7 +512,7 @@ void grpc_chttp2_parsing_become_skip_parser(
static grpc_chttp2_parse_error update_incoming_window(
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing) {
- gpr_uint32 incoming_frame_size = transport_parsing->incoming_frame_size;
+ uint32_t incoming_frame_size = transport_parsing->incoming_frame_size;
if (incoming_frame_size > transport_parsing->incoming_window) {
gpr_log(GPR_ERROR, "frame of size %d overflows incoming window of %d",
transport_parsing->incoming_frame_size,
@@ -652,8 +652,8 @@ static void on_trailing_header(void *tp, grpc_mdelem *md) {
static int init_header_frame_parser(
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing,
int is_continuation) {
- gpr_uint8 is_eoh = (transport_parsing->incoming_frame_flags &
- GRPC_CHTTP2_DATA_FLAG_END_HEADERS) != 0;
+ uint8_t is_eoh = (transport_parsing->incoming_frame_flags &
+ GRPC_CHTTP2_DATA_FLAG_END_HEADERS) != 0;
int via_accept = 0;
grpc_chttp2_stream_parsing *stream_parsing;
@@ -738,7 +738,7 @@ static int init_header_frame_parser(
transport_parsing->hpack_parser.on_header_user_data = transport_parsing;
transport_parsing->hpack_parser.is_boundary = is_eoh;
transport_parsing->hpack_parser.is_eof =
- (gpr_uint8)(is_eoh ? transport_parsing->header_eof : 0);
+ (uint8_t)(is_eoh ? transport_parsing->header_eof : 0);
if (!is_continuation && (transport_parsing->incoming_frame_flags &
GRPC_CHTTP2_FLAG_HAS_PRIORITY)) {
grpc_chttp2_hpack_parser_set_has_priority(&transport_parsing->hpack_parser);
@@ -829,7 +829,7 @@ static int init_settings_frame_parser(
}
/*
-static int is_window_update_legal(gpr_int64 window_update, gpr_int64 window) {
+static int is_window_update_legal(int64_t window_update, int64_t window) {
return window + window_update < MAX_WINDOW;
}
*/
diff --git a/src/core/transport/chttp2/stream_lists.c b/src/core/transport/chttp2/stream_lists.c
index 49f951d08b..273a513e2f 100644
--- a/src/core/transport/chttp2/stream_lists.c
+++ b/src/core/transport/chttp2/stream_lists.c
@@ -333,6 +333,14 @@ int grpc_chttp2_list_pop_stalled_by_transport(
return r;
}
+void grpc_chttp2_list_remove_stalled_by_transport(
+ grpc_chttp2_transport_global *transport_global,
+ grpc_chttp2_stream_global *stream_global) {
+ stream_list_maybe_remove(TRANSPORT_FROM_GLOBAL(transport_global),
+ STREAM_FROM_GLOBAL(stream_global),
+ GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT);
+}
+
void grpc_chttp2_list_add_closed_waiting_for_parsing(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global *stream_global) {
diff --git a/src/core/transport/chttp2/stream_map.c b/src/core/transport/chttp2/stream_map.c
index c983105abb..555a16fb72 100644
--- a/src/core/transport/chttp2/stream_map.c
+++ b/src/core/transport/chttp2/stream_map.c
@@ -42,7 +42,7 @@
void grpc_chttp2_stream_map_init(grpc_chttp2_stream_map *map,
size_t initial_capacity) {
GPR_ASSERT(initial_capacity > 1);
- map->keys = gpr_malloc(sizeof(gpr_uint32) * initial_capacity);
+ map->keys = gpr_malloc(sizeof(uint32_t) * initial_capacity);
map->values = gpr_malloc(sizeof(void *) * initial_capacity);
map->count = 0;
map->free = 0;
@@ -54,7 +54,7 @@ void grpc_chttp2_stream_map_destroy(grpc_chttp2_stream_map *map) {
gpr_free(map->values);
}
-static size_t compact(gpr_uint32 *keys, void **values, size_t count) {
+static size_t compact(uint32_t *keys, void **values, size_t count) {
size_t i, out;
for (i = 0, out = 0; i < count; i++) {
@@ -68,11 +68,11 @@ static size_t compact(gpr_uint32 *keys, void **values, size_t count) {
return out;
}
-void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map *map, gpr_uint32 key,
+void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map *map, uint32_t key,
void *value) {
size_t count = map->count;
size_t capacity = map->capacity;
- gpr_uint32 *keys = map->keys;
+ uint32_t *keys = map->keys;
void **values = map->values;
GPR_ASSERT(count == 0 || keys[count - 1] < key);
@@ -86,7 +86,7 @@ void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map *map, gpr_uint32 key,
/* resize when less than 25% of the table is free, because compaction
won't help much */
map->capacity = capacity = 3 * capacity / 2;
- map->keys = keys = gpr_realloc(keys, capacity * sizeof(gpr_uint32));
+ map->keys = keys = gpr_realloc(keys, capacity * sizeof(uint32_t));
map->values = values = gpr_realloc(values, capacity * sizeof(void *));
}
}
@@ -119,10 +119,10 @@ void grpc_chttp2_stream_map_move_into(grpc_chttp2_stream_map *src,
/* if dst doesn't have capacity, resize */
if (dst->count + src->count > dst->capacity) {
dst->capacity = GPR_MAX(dst->capacity * 3 / 2, dst->count + src->count);
- dst->keys = gpr_realloc(dst->keys, dst->capacity * sizeof(gpr_uint32));
+ dst->keys = gpr_realloc(dst->keys, dst->capacity * sizeof(uint32_t));
dst->values = gpr_realloc(dst->values, dst->capacity * sizeof(void *));
}
- memcpy(dst->keys + dst->count, src->keys, src->count * sizeof(gpr_uint32));
+ memcpy(dst->keys + dst->count, src->keys, src->count * sizeof(uint32_t));
memcpy(dst->values + dst->count, src->values, src->count * sizeof(void *));
dst->count += src->count;
dst->free += src->free;
@@ -130,13 +130,13 @@ void grpc_chttp2_stream_map_move_into(grpc_chttp2_stream_map *src,
src->free = 0;
}
-static void **find(grpc_chttp2_stream_map *map, gpr_uint32 key) {
+static void **find(grpc_chttp2_stream_map *map, uint32_t key) {
size_t min_idx = 0;
size_t max_idx = map->count;
size_t mid_idx;
- gpr_uint32 *keys = map->keys;
+ uint32_t *keys = map->keys;
void **values = map->values;
- gpr_uint32 mid_key;
+ uint32_t mid_key;
if (max_idx == 0) return NULL;
@@ -158,8 +158,7 @@ static void **find(grpc_chttp2_stream_map *map, gpr_uint32 key) {
return NULL;
}
-void *grpc_chttp2_stream_map_delete(grpc_chttp2_stream_map *map,
- gpr_uint32 key) {
+void *grpc_chttp2_stream_map_delete(grpc_chttp2_stream_map *map, uint32_t key) {
void **pvalue = find(map, key);
void *out = NULL;
if (pvalue != NULL) {
@@ -175,7 +174,7 @@ void *grpc_chttp2_stream_map_delete(grpc_chttp2_stream_map *map,
return out;
}
-void *grpc_chttp2_stream_map_find(grpc_chttp2_stream_map *map, gpr_uint32 key) {
+void *grpc_chttp2_stream_map_find(grpc_chttp2_stream_map *map, uint32_t key) {
void **pvalue = find(map, key);
return pvalue != NULL ? *pvalue : NULL;
}
@@ -185,7 +184,7 @@ size_t grpc_chttp2_stream_map_size(grpc_chttp2_stream_map *map) {
}
void grpc_chttp2_stream_map_for_each(grpc_chttp2_stream_map *map,
- void (*f)(void *user_data, gpr_uint32 key,
+ void (*f)(void *user_data, uint32_t key,
void *value),
void *user_data) {
size_t i;
diff --git a/src/core/transport/chttp2/stream_map.h b/src/core/transport/chttp2/stream_map.h
index 71b0582054..7a0e45fab2 100644
--- a/src/core/transport/chttp2/stream_map.h
+++ b/src/core/transport/chttp2/stream_map.h
@@ -38,14 +38,14 @@
#include <stddef.h>
-/* Data structure to map a gpr_uint32 to a data object (represented by a void*)
+/* Data structure to map a uint32_t to a data object (represented by a void*)
Represented as a sorted array of keys, and a corresponding array of values.
Lookups are performed with binary search.
Adds are restricted to strictly higher keys than previously seen (this is
guaranteed by http2). */
typedef struct {
- gpr_uint32 *keys;
+ uint32_t *keys;
void **values;
size_t count;
size_t free;
@@ -58,27 +58,26 @@ void grpc_chttp2_stream_map_destroy(grpc_chttp2_stream_map *map);
/* Add a new key: given http2 semantics, new keys must always be greater than
existing keys - this is asserted */
-void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map *map, gpr_uint32 key,
+void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map *map, uint32_t key,
void *value);
/* Delete an existing key - returns the previous value of the key if it existed,
or NULL otherwise */
-void *grpc_chttp2_stream_map_delete(grpc_chttp2_stream_map *map,
- gpr_uint32 key);
+void *grpc_chttp2_stream_map_delete(grpc_chttp2_stream_map *map, uint32_t key);
/* Move all elements of src into dst */
void grpc_chttp2_stream_map_move_into(grpc_chttp2_stream_map *src,
grpc_chttp2_stream_map *dst);
/* Return an existing key, or NULL if it does not exist */
-void *grpc_chttp2_stream_map_find(grpc_chttp2_stream_map *map, gpr_uint32 key);
+void *grpc_chttp2_stream_map_find(grpc_chttp2_stream_map *map, uint32_t key);
/* How many (populated) entries are in the stream map? */
size_t grpc_chttp2_stream_map_size(grpc_chttp2_stream_map *map);
/* Callback on each stream */
void grpc_chttp2_stream_map_for_each(grpc_chttp2_stream_map *map,
- void (*f)(void *user_data, gpr_uint32 key,
+ void (*f)(void *user_data, uint32_t key,
void *value),
void *user_data);
diff --git a/src/core/transport/chttp2/timeout_encoding.c b/src/core/transport/chttp2/timeout_encoding.c
index 7ec8b4e8bf..8cbf987a42 100644
--- a/src/core/transport/chttp2/timeout_encoding.c
+++ b/src/core/transport/chttp2/timeout_encoding.c
@@ -39,12 +39,12 @@
#include <grpc/support/port_platform.h>
#include "src/core/support/string.h"
-static gpr_int64 round_up(gpr_int64 x, gpr_int64 divisor) {
+static int64_t round_up(int64_t x, int64_t divisor) {
return (x / divisor + (x % divisor != 0)) * divisor;
}
/* round an integer up to the next value with three significant figures */
-static gpr_int64 round_up_to_three_sig_figs(gpr_int64 x) {
+static int64_t round_up_to_three_sig_figs(int64_t x) {
if (x < 1000) return x;
if (x < 10000) return round_up(x, 10);
if (x < 100000) return round_up(x, 100);
@@ -58,13 +58,13 @@ static gpr_int64 round_up_to_three_sig_figs(gpr_int64 x) {
/* encode our minimum viable timeout value */
static void enc_tiny(char *buffer) { memcpy(buffer, "1n", 3); }
-static void enc_ext(char *buffer, gpr_int64 value, char ext) {
- int n = gpr_int64toa(value, buffer);
+static void enc_ext(char *buffer, int64_t value, char ext) {
+ int n = int64_ttoa(value, buffer);
buffer[n] = ext;
buffer[n + 1] = 0;
}
-static void enc_seconds(char *buffer, gpr_int64 sec) {
+static void enc_seconds(char *buffer, int64_t sec) {
if (sec % 3600 == 0) {
enc_ext(buffer, sec / 3600, 'H');
} else if (sec % 60 == 0) {
@@ -74,7 +74,7 @@ static void enc_seconds(char *buffer, gpr_int64 sec) {
}
}
-static void enc_nanos(char *buffer, gpr_int64 x) {
+static void enc_nanos(char *buffer, int64_t x) {
x = round_up_to_three_sig_figs(x);
if (x < 100000) {
if (x % 1000 == 0) {
@@ -98,7 +98,7 @@ static void enc_nanos(char *buffer, gpr_int64 x) {
}
}
-static void enc_micros(char *buffer, gpr_int64 x) {
+static void enc_micros(char *buffer, int64_t x) {
x = round_up_to_three_sig_figs(x);
if (x < 100000) {
if (x % 1000 == 0) {
@@ -124,7 +124,7 @@ void grpc_chttp2_encode_timeout(gpr_timespec timeout, char *buffer) {
enc_nanos(buffer, timeout.tv_nsec);
} else if (timeout.tv_sec < 1000 && timeout.tv_nsec != 0) {
enc_micros(buffer,
- (gpr_int64)(timeout.tv_sec * 1000000) +
+ (int64_t)(timeout.tv_sec * 1000000) +
(timeout.tv_nsec / 1000 + (timeout.tv_nsec % 1000 != 0)));
} else {
enc_seconds(buffer, timeout.tv_sec + (timeout.tv_nsec != 0));
@@ -137,15 +137,15 @@ static int is_all_whitespace(const char *p) {
}
int grpc_chttp2_decode_timeout(const char *buffer, gpr_timespec *timeout) {
- gpr_uint32 x = 0;
- const gpr_uint8 *p = (const gpr_uint8 *)buffer;
+ uint32_t x = 0;
+ const uint8_t *p = (const uint8_t *)buffer;
int have_digit = 0;
/* skip whitespace */
for (; *p == ' '; p++)
;
/* decode numeric part */
for (; *p >= '0' && *p <= '9'; p++) {
- gpr_uint32 xp = x * 10u + (gpr_uint32)*p - (gpr_uint32)'0';
+ uint32_t xp = x * 10u + (uint32_t)*p - (uint32_t)'0';
have_digit = 1;
if (xp < x) {
*timeout = gpr_inf_future(GPR_CLOCK_REALTIME);
diff --git a/src/core/transport/chttp2/varint.c b/src/core/transport/chttp2/varint.c
index 056f68047b..1cc235e989 100644
--- a/src/core/transport/chttp2/varint.c
+++ b/src/core/transport/chttp2/varint.c
@@ -33,7 +33,7 @@
#include "src/core/transport/chttp2/varint.h"
-gpr_uint32 grpc_chttp2_hpack_varint_length(gpr_uint32 tail_value) {
+uint32_t grpc_chttp2_hpack_varint_length(uint32_t tail_value) {
if (tail_value < (1 << 7)) {
return 2;
} else if (tail_value < (1 << 14)) {
@@ -47,20 +47,19 @@ gpr_uint32 grpc_chttp2_hpack_varint_length(gpr_uint32 tail_value) {
}
}
-void grpc_chttp2_hpack_write_varint_tail(gpr_uint32 tail_value,
- gpr_uint8* target,
- gpr_uint32 tail_length) {
+void grpc_chttp2_hpack_write_varint_tail(uint32_t tail_value, uint8_t* target,
+ uint32_t tail_length) {
switch (tail_length) {
case 5:
- target[4] = (gpr_uint8)((tail_value >> 28) | 0x80);
+ target[4] = (uint8_t)((tail_value >> 28) | 0x80);
case 4:
- target[3] = (gpr_uint8)((tail_value >> 21) | 0x80);
+ target[3] = (uint8_t)((tail_value >> 21) | 0x80);
case 3:
- target[2] = (gpr_uint8)((tail_value >> 14) | 0x80);
+ target[2] = (uint8_t)((tail_value >> 14) | 0x80);
case 2:
- target[1] = (gpr_uint8)((tail_value >> 7) | 0x80);
+ target[1] = (uint8_t)((tail_value >> 7) | 0x80);
case 1:
- target[0] = (gpr_uint8)((tail_value) | 0x80);
+ target[0] = (uint8_t)((tail_value) | 0x80);
}
target[tail_length - 1] &= 0x7f;
}
diff --git a/src/core/transport/chttp2/varint.h b/src/core/transport/chttp2/varint.h
index 5acb15d032..2d92b6693e 100644
--- a/src/core/transport/chttp2/varint.h
+++ b/src/core/transport/chttp2/varint.h
@@ -41,17 +41,16 @@
/* length of a value that needs varint tail encoding (it's bigger than can be
bitpacked into the opcode byte) - returned value includes the length of the
opcode byte */
-gpr_uint32 grpc_chttp2_hpack_varint_length(gpr_uint32 tail_value);
+uint32_t grpc_chttp2_hpack_varint_length(uint32_t tail_value);
-void grpc_chttp2_hpack_write_varint_tail(gpr_uint32 tail_value,
- gpr_uint8* target,
- gpr_uint32 tail_length);
+void grpc_chttp2_hpack_write_varint_tail(uint32_t tail_value, uint8_t* target,
+ uint32_t tail_length);
/* maximum value that can be bitpacked with the opcode if the opcode has a
prefix
of length prefix_bits */
#define GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits) \
- ((gpr_uint32)((1 << (8 - (prefix_bits))) - 1))
+ ((uint32_t)((1 << (8 - (prefix_bits))) - 1))
/* length required to bitpack a value */
#define GRPC_CHTTP2_VARINT_LENGTH(n, prefix_bits) \
@@ -62,12 +61,12 @@ void grpc_chttp2_hpack_write_varint_tail(gpr_uint32 tail_value,
#define GRPC_CHTTP2_WRITE_VARINT(n, prefix_bits, prefix_or, target, length) \
do { \
- gpr_uint8* tgt = target; \
+ uint8_t* tgt = target; \
if ((length) == 1u) { \
- (tgt)[0] = (gpr_uint8)((prefix_or) | (n)); \
+ (tgt)[0] = (uint8_t)((prefix_or) | (n)); \
} else { \
(tgt)[0] = \
- (prefix_or) | (gpr_uint8)GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits); \
+ (prefix_or) | (uint8_t)GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits); \
grpc_chttp2_hpack_write_varint_tail( \
(n)-GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits), (tgt) + 1, (length)-1); \
} \
diff --git a/src/core/transport/chttp2/writing.c b/src/core/transport/chttp2/writing.c
index b5ca42d69c..fdad05b5fb 100644
--- a/src/core/transport/chttp2/writing.c
+++ b/src/core/transport/chttp2/writing.c
@@ -80,7 +80,7 @@ int grpc_chttp2_unlocking_check_writes(
(according to available window sizes) and add to the output buffer */
while (grpc_chttp2_list_pop_writable_stream(
transport_global, transport_writing, &stream_global, &stream_writing)) {
- gpr_uint8 sent_initial_metadata;
+ uint8_t sent_initial_metadata;
stream_writing->id = stream_global->id;
stream_writing->read_closed = stream_global->read_closed;
@@ -103,15 +103,15 @@ int grpc_chttp2_unlocking_check_writes(
if (sent_initial_metadata) {
if (stream_global->send_message != NULL) {
gpr_slice hdr = gpr_slice_malloc(5);
- gpr_uint8 *p = GPR_SLICE_START_PTR(hdr);
- gpr_uint32 len = stream_global->send_message->length;
+ uint8_t *p = GPR_SLICE_START_PTR(hdr);
+ uint32_t len = stream_global->send_message->length;
GPR_ASSERT(stream_writing->send_message == NULL);
p[0] = (stream_global->send_message->flags &
GRPC_WRITE_INTERNAL_COMPRESS) != 0;
- p[1] = (gpr_uint8)(len >> 24);
- p[2] = (gpr_uint8)(len >> 16);
- p[3] = (gpr_uint8)(len >> 8);
- p[4] = (gpr_uint8)(len);
+ p[1] = (uint8_t)(len >> 24);
+ p[2] = (uint8_t)(len >> 16);
+ p[3] = (uint8_t)(len >> 8);
+ p[4] = (uint8_t)(len);
gpr_slice_buffer_add(&stream_writing->flow_controlled_buffer, hdr);
if (stream_global->send_message->length > 0) {
stream_writing->send_message = stream_global->send_message;
@@ -160,8 +160,8 @@ int grpc_chttp2_unlocking_check_writes(
/* if the grpc_chttp2_transport is ready to send a window update, do so here
also; 3/4 is a magic number that will likely get tuned soon */
if (transport_global->announce_incoming_window > 0) {
- gpr_uint32 announced = (gpr_uint32)GPR_MIN(
- transport_global->announce_incoming_window, GPR_UINT32_MAX);
+ uint32_t announced = (uint32_t)GPR_MIN(
+ transport_global->announce_incoming_window, UINT32_MAX);
GRPC_CHTTP2_FLOW_DEBIT_TRANSPORT("write", transport_global,
announce_incoming_window, announced);
gpr_slice_buffer_add(&transport_writing->outbuf,
@@ -200,10 +200,10 @@ static void finalize_outbuf(grpc_exec_ctx *exec_ctx,
while (
grpc_chttp2_list_pop_writing_stream(transport_writing, &stream_writing)) {
- gpr_uint32 max_outgoing =
- (gpr_uint32)GPR_MIN(GRPC_CHTTP2_MAX_PAYLOAD_LENGTH,
- GPR_MIN(stream_writing->outgoing_window,
- transport_writing->outgoing_window));
+ uint32_t max_outgoing =
+ (uint32_t)GPR_MIN(GRPC_CHTTP2_MAX_PAYLOAD_LENGTH,
+ GPR_MIN(stream_writing->outgoing_window,
+ transport_writing->outgoing_window));
/* send initial metadata if it's available */
if (stream_writing->send_initial_metadata != NULL) {
grpc_chttp2_encode_header(
@@ -215,7 +215,7 @@ static void finalize_outbuf(grpc_exec_ctx *exec_ctx,
/* send any window updates */
if (stream_writing->announce_window > 0 &&
stream_writing->send_initial_metadata == NULL) {
- gpr_uint32 announce = stream_writing->announce_window;
+ uint32_t announce = stream_writing->announce_window;
gpr_slice_buffer_add(
&transport_writing->outbuf,
grpc_chttp2_window_update_create(stream_writing->id,
@@ -247,7 +247,7 @@ static void finalize_outbuf(grpc_exec_ctx *exec_ctx,
/* send any body bytes */
if (stream_writing->flow_controlled_buffer.length > 0) {
if (max_outgoing > 0) {
- gpr_uint32 send_bytes = (gpr_uint32)GPR_MIN(
+ uint32_t send_bytes = (uint32_t)GPR_MIN(
max_outgoing, stream_writing->flow_controlled_buffer.length);
int is_last_data_frame =
stream_writing->send_message == NULL &&
diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c
index 7793f7c9e4..c154c07772 100644
--- a/src/core/transport/chttp2_transport.c
+++ b/src/core/transport/chttp2_transport.c
@@ -90,7 +90,7 @@ static void writing_action(grpc_exec_ctx *exec_ctx, void *t,
/** Set a transport level setting, and push it to our peer */
static void push_setting(grpc_chttp2_transport *t, grpc_chttp2_setting_id id,
- gpr_uint32 value);
+ uint32_t value);
/** Endpoint callback to process incoming data */
static void recv_data(grpc_exec_ctx *exec_ctx, void *tp, int success);
@@ -134,7 +134,12 @@ static void connectivity_state_set(
static void check_read_ops(grpc_exec_ctx *exec_ctx,
grpc_chttp2_transport_global *transport_global);
-static void fail_pending_writes(grpc_exec_ctx *exec_ctx,
+static void incoming_byte_stream_update_flow_control(
+ grpc_chttp2_transport_global *transport_global,
+ grpc_chttp2_stream_global *stream_global, size_t max_size_hint,
+ size_t have_already);
+
+static void fail_pending_writes(grpc_exec_ctx *exec_ctx,
grpc_chttp2_stream_global *stream_global);
/*
@@ -218,7 +223,7 @@ static void ref_transport(grpc_chttp2_transport *t) { gpr_ref(&t->refs); }
static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
const grpc_channel_args *channel_args,
- grpc_endpoint *ep, gpr_uint8 is_client) {
+ grpc_endpoint *ep, uint8_t is_client) {
size_t i;
int j;
@@ -313,7 +318,7 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
GRPC_ARG_MAX_CONCURRENT_STREAMS);
} else {
push_setting(t, GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS,
- (gpr_uint32)channel_args->args[i].value.integer);
+ (uint32_t)channel_args->args[i].value.integer);
}
} else if (0 == strcmp(channel_args->args[i].key,
GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER)) {
@@ -328,7 +333,7 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
is_client ? "client" : "server");
} else {
t->global.next_stream_id =
- (gpr_uint32)channel_args->args[i].value.integer;
+ (uint32_t)channel_args->args[i].value.integer;
}
} else if (0 == strcmp(channel_args->args[i].key,
GRPC_ARG_HTTP2_STREAM_LOOKAHEAD_BYTES)) {
@@ -340,7 +345,7 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
GRPC_ARG_HTTP2_STREAM_LOOKAHEAD_BYTES);
} else {
t->global.stream_lookahead =
- (gpr_uint32)channel_args->args[i].value.integer;
+ (uint32_t)channel_args->args[i].value.integer;
}
} else if (0 == strcmp(channel_args->args[i].key,
GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_DECODER)) {
@@ -348,11 +353,11 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
gpr_log(GPR_ERROR, "%s: must be an integer",
GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_DECODER);
} else if (channel_args->args[i].value.integer < 0) {
- gpr_log(GPR_DEBUG, "%s: must be non-negative",
+ gpr_log(GPR_ERROR, "%s: must be non-negative",
GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_DECODER);
} else {
push_setting(t, GRPC_CHTTP2_SETTINGS_HEADER_TABLE_SIZE,
- (gpr_uint32)channel_args->args[i].value.integer);
+ (uint32_t)channel_args->args[i].value.integer);
}
} else if (0 == strcmp(channel_args->args[i].key,
GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_ENCODER)) {
@@ -360,12 +365,12 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
gpr_log(GPR_ERROR, "%s: must be an integer",
GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_ENCODER);
} else if (channel_args->args[i].value.integer < 0) {
- gpr_log(GPR_DEBUG, "%s: must be non-negative",
+ gpr_log(GPR_ERROR, "%s: must be non-negative",
GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_ENCODER);
} else {
grpc_chttp2_hpack_compressor_set_max_usable_size(
&t->writing.hpack_compressor,
- (gpr_uint32)channel_args->args[i].value.integer);
+ (uint32_t)channel_args->args[i].value.integer);
}
}
}
@@ -477,7 +482,7 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
grpc_chttp2_register_stream(t, s);
if (server_data) {
GPR_ASSERT(t->parsing_active);
- s->global.id = (gpr_uint32)(gpr_uintptr)server_data;
+ s->global.id = (uint32_t)(uintptr_t)server_data;
s->parsing.id = s->global.id;
s->global.outgoing_window =
t->global.settings[GRPC_PEER_SETTINGS]
@@ -519,6 +524,7 @@ static void destroy_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
grpc_chttp2_list_remove_writable_stream(&t->global, &s->global);
grpc_chttp2_list_remove_unannounced_incoming_window_available(&t->global,
&s->global);
+ grpc_chttp2_list_remove_stalled_by_transport(&t->global, &s->global);
gpr_mu_unlock(&t->mu);
@@ -532,7 +538,7 @@ static void destroy_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
while (
(bs = grpc_chttp2_incoming_frame_queue_pop(&s->global.incoming_frames))) {
- grpc_byte_stream_destroy(bs);
+ grpc_byte_stream_destroy(exec_ctx, bs);
}
GPR_ASSERT(s->global.send_initial_metadata_finished == NULL);
@@ -556,7 +562,7 @@ static void destroy_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
}
grpc_chttp2_stream_parsing *grpc_chttp2_parsing_lookup_stream(
- grpc_chttp2_transport_parsing *transport_parsing, gpr_uint32 id) {
+ grpc_chttp2_transport_parsing *transport_parsing, uint32_t id) {
grpc_chttp2_transport *t = TRANSPORT_FROM_PARSING(transport_parsing);
grpc_chttp2_stream *s =
grpc_chttp2_stream_map_find(&t->parsing_stream_map, id);
@@ -565,14 +571,14 @@ grpc_chttp2_stream_parsing *grpc_chttp2_parsing_lookup_stream(
grpc_chttp2_stream_parsing *grpc_chttp2_parsing_accept_stream(
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing,
- gpr_uint32 id) {
+ uint32_t id) {
grpc_chttp2_stream *accepting;
grpc_chttp2_transport *t = TRANSPORT_FROM_PARSING(transport_parsing);
GPR_ASSERT(t->accepting_stream == NULL);
t->accepting_stream = &accepting;
t->channel_callback.accept_stream(exec_ctx,
t->channel_callback.accept_stream_user_data,
- &t->base, (void *)(gpr_uintptr)id);
+ &t->base, (void *)(uintptr_t)id);
t->accepting_stream = NULL;
return &accepting->parsing;
}
@@ -610,10 +616,10 @@ static void unlock(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t) {
*/
static void push_setting(grpc_chttp2_transport *t, grpc_chttp2_setting_id id,
- gpr_uint32 value) {
+ uint32_t value) {
const grpc_chttp2_setting_parameters *sp =
&grpc_chttp2_settings_parameters[id];
- gpr_uint32 use_value = GPR_CLAMP(value, sp->min_value, sp->max_value);
+ uint32_t use_value = GPR_CLAMP(value, sp->min_value, sp->max_value);
if (use_value != value) {
gpr_log(GPR_INFO, "Requested parameter %s clamped from %d to %d", sp->name,
value, use_value);
@@ -642,7 +648,8 @@ void grpc_chttp2_terminate_writing(grpc_exec_ctx *exec_ctx,
grpc_chttp2_cleanup_writing(exec_ctx, &t->global, &t->writing);
- while (grpc_chttp2_list_pop_closed_waiting_for_writing(&t->global, &stream_global)) {
+ while (grpc_chttp2_list_pop_closed_waiting_for_writing(&t->global,
+ &stream_global)) {
fail_pending_writes(exec_ctx, stream_global);
GRPC_CHTTP2_STREAM_UNREF(exec_ctx, stream_global, "finish_writes");
}
@@ -671,7 +678,7 @@ static void writing_action(grpc_exec_ctx *exec_ctx, void *gt,
void grpc_chttp2_add_incoming_goaway(
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_global *transport_global,
- gpr_uint32 goaway_error, gpr_slice goaway_text) {
+ uint32_t goaway_error, gpr_slice goaway_text) {
char *msg = gpr_dump_slice(goaway_text, GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_DEBUG, "got goaway [%d]: %s", goaway_error, msg);
gpr_free(msg);
@@ -684,7 +691,7 @@ void grpc_chttp2_add_incoming_goaway(
static void maybe_start_some_streams(
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_global *transport_global) {
grpc_chttp2_stream_global *stream_global;
- gpr_uint32 stream_incoming_window;
+ uint32_t stream_incoming_window;
/* start streams where we have free grpc_chttp2_stream ids and free
* concurrency */
while (transport_global->next_stream_id <= MAX_CLIENT_STREAM_ID &&
@@ -867,6 +874,13 @@ static void perform_stream_op_locked(
GPR_ASSERT(stream_global->recv_message_ready == NULL);
stream_global->recv_message_ready = op->recv_message_ready;
stream_global->recv_message = op->recv_message;
+ if (stream_global->id != 0 &&
+ (stream_global->incoming_frames.head == NULL ||
+ stream_global->incoming_frames.head->is_tail)) {
+ incoming_byte_stream_update_flow_control(
+ transport_global, stream_global, transport_global->stream_lookahead,
+ 0);
+ }
grpc_chttp2_list_add_check_read_ops(transport_global, stream_global);
}
@@ -898,21 +912,21 @@ static void send_ping_locked(grpc_chttp2_transport *t, grpc_closure *on_recv) {
p->next = &t->global.pings;
p->prev = p->next->prev;
p->prev->next = p->next->prev = p;
- p->id[0] = (gpr_uint8)((t->global.ping_counter >> 56) & 0xff);
- p->id[1] = (gpr_uint8)((t->global.ping_counter >> 48) & 0xff);
- p->id[2] = (gpr_uint8)((t->global.ping_counter >> 40) & 0xff);
- p->id[3] = (gpr_uint8)((t->global.ping_counter >> 32) & 0xff);
- p->id[4] = (gpr_uint8)((t->global.ping_counter >> 24) & 0xff);
- p->id[5] = (gpr_uint8)((t->global.ping_counter >> 16) & 0xff);
- p->id[6] = (gpr_uint8)((t->global.ping_counter >> 8) & 0xff);
- p->id[7] = (gpr_uint8)(t->global.ping_counter & 0xff);
+ p->id[0] = (uint8_t)((t->global.ping_counter >> 56) & 0xff);
+ p->id[1] = (uint8_t)((t->global.ping_counter >> 48) & 0xff);
+ p->id[2] = (uint8_t)((t->global.ping_counter >> 40) & 0xff);
+ p->id[3] = (uint8_t)((t->global.ping_counter >> 32) & 0xff);
+ p->id[4] = (uint8_t)((t->global.ping_counter >> 24) & 0xff);
+ p->id[5] = (uint8_t)((t->global.ping_counter >> 16) & 0xff);
+ p->id[6] = (uint8_t)((t->global.ping_counter >> 8) & 0xff);
+ p->id[7] = (uint8_t)(t->global.ping_counter & 0xff);
p->on_recv = on_recv;
gpr_slice_buffer_add(&t->global.qbuf, grpc_chttp2_ping_create(0, p->id));
}
void grpc_chttp2_ack_ping(grpc_exec_ctx *exec_ctx,
grpc_chttp2_transport_parsing *transport_parsing,
- const gpr_uint8 *opaque_8bytes) {
+ const uint8_t *opaque_8bytes) {
grpc_chttp2_outstanding_ping *ping;
grpc_chttp2_transport *t = TRANSPORT_FROM_PARSING(transport_parsing);
grpc_chttp2_transport_global *transport_global = &t->global;
@@ -949,7 +963,7 @@ static void perform_transport_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
t->global.sent_goaway = 1;
grpc_chttp2_goaway_append(
t->global.last_incoming_stream_id,
- (gpr_uint32)grpc_chttp2_grpc_status_to_http2_error(op->goaway_status),
+ (uint32_t)grpc_chttp2_grpc_status_to_http2_error(op->goaway_status),
gpr_slice_ref(*op->goaway_message), &t->global.qbuf);
close_transport = !grpc_chttp2_has_streams(t);
}
@@ -1021,7 +1035,7 @@ static void check_read_ops(grpc_exec_ctx *exec_ctx,
while (stream_global->seen_error &&
(bs = grpc_chttp2_incoming_frame_queue_pop(
&stream_global->incoming_frames)) != NULL) {
- grpc_byte_stream_destroy(bs);
+ grpc_byte_stream_destroy(exec_ctx, bs);
}
if (stream_global->incoming_frames.head == NULL) {
grpc_chttp2_incoming_metadata_buffer_publish(
@@ -1035,7 +1049,7 @@ static void check_read_ops(grpc_exec_ctx *exec_ctx,
}
static void remove_stream(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- gpr_uint32 id) {
+ uint32_t id) {
size_t new_stream_count;
grpc_chttp2_stream *s =
grpc_chttp2_stream_map_delete(&t->parsing_stream_map, id);
@@ -1049,15 +1063,21 @@ static void remove_stream(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
t->parsing.incoming_stream = NULL;
grpc_chttp2_parsing_become_skip_parser(exec_ctx, &t->parsing);
}
+ if (s->parsing.data_parser.parsing_frame != NULL) {
+ grpc_chttp2_incoming_byte_stream_finished(
+ exec_ctx, s->parsing.data_parser.parsing_frame, 0, 0);
+ s->parsing.data_parser.parsing_frame = NULL;
+ }
+
if (grpc_chttp2_unregister_stream(t, s) && t->global.sent_goaway) {
close_transport_locked(exec_ctx, t);
}
new_stream_count = grpc_chttp2_stream_map_size(&t->parsing_stream_map) +
grpc_chttp2_stream_map_size(&t->new_stream_map);
- GPR_ASSERT(new_stream_count <= GPR_UINT32_MAX);
+ GPR_ASSERT(new_stream_count <= UINT32_MAX);
if (new_stream_count != t->global.concurrent_stream_count) {
- t->global.concurrent_stream_count = (gpr_uint32)new_stream_count;
+ t->global.concurrent_stream_count = (uint32_t)new_stream_count;
maybe_start_some_streams(exec_ctx, &t->global);
}
}
@@ -1071,7 +1091,7 @@ static void cancel_from_api(grpc_exec_ctx *exec_ctx,
&transport_global->qbuf,
grpc_chttp2_rst_stream_create(
stream_global->id,
- (gpr_uint32)grpc_chttp2_grpc_status_to_http2_error(status)));
+ (uint32_t)grpc_chttp2_grpc_status_to_http2_error(status)));
}
grpc_chttp2_fake_status(exec_ctx, transport_global, stream_global, status,
NULL);
@@ -1116,7 +1136,7 @@ void grpc_chttp2_fake_status(grpc_exec_ctx *exec_ctx,
}
}
-static void fail_pending_writes(grpc_exec_ctx *exec_ctx,
+static void fail_pending_writes(grpc_exec_ctx *exec_ctx,
grpc_chttp2_stream_global *stream_global) {
grpc_chttp2_complete_closure_step(
exec_ctx, &stream_global->send_initial_metadata_finished, 0);
@@ -1173,8 +1193,8 @@ static void close_from_api(grpc_exec_ctx *exec_ctx,
gpr_slice hdr;
gpr_slice status_hdr;
gpr_slice message_pfx;
- gpr_uint8 *p;
- gpr_uint32 len = 0;
+ uint8_t *p;
+ uint32_t len = 0;
GPR_ASSERT(status >= 0 && (int)status < 100);
@@ -1203,14 +1223,14 @@ static void close_from_api(grpc_exec_ctx *exec_ctx,
*p++ = 's';
if (status < 10) {
*p++ = 1;
- *p++ = (gpr_uint8)('0' + status);
+ *p++ = (uint8_t)('0' + status);
} else {
*p++ = 2;
- *p++ = (gpr_uint8)('0' + (status / 10));
- *p++ = (gpr_uint8)('0' + (status % 10));
+ *p++ = (uint8_t)('0' + (status / 10));
+ *p++ = (uint8_t)('0' + (status % 10));
}
GPR_ASSERT(p == GPR_SLICE_END_PTR(status_hdr));
- len += (gpr_uint32)GPR_SLICE_LENGTH(status_hdr);
+ len += (uint32_t)GPR_SLICE_LENGTH(status_hdr);
if (optional_message) {
GPR_ASSERT(GPR_SLICE_LENGTH(*optional_message) < 127);
@@ -1230,23 +1250,23 @@ static void close_from_api(grpc_exec_ctx *exec_ctx,
*p++ = 'a';
*p++ = 'g';
*p++ = 'e';
- *p++ = (gpr_uint8)GPR_SLICE_LENGTH(*optional_message);
+ *p++ = (uint8_t)GPR_SLICE_LENGTH(*optional_message);
GPR_ASSERT(p == GPR_SLICE_END_PTR(message_pfx));
- len += (gpr_uint32)GPR_SLICE_LENGTH(message_pfx);
- len += (gpr_uint32)GPR_SLICE_LENGTH(*optional_message);
+ len += (uint32_t)GPR_SLICE_LENGTH(message_pfx);
+ len += (uint32_t)GPR_SLICE_LENGTH(*optional_message);
}
hdr = gpr_slice_malloc(9);
p = GPR_SLICE_START_PTR(hdr);
- *p++ = (gpr_uint8)(len >> 16);
- *p++ = (gpr_uint8)(len >> 8);
- *p++ = (gpr_uint8)(len);
+ *p++ = (uint8_t)(len >> 16);
+ *p++ = (uint8_t)(len >> 8);
+ *p++ = (uint8_t)(len);
*p++ = GRPC_CHTTP2_FRAME_HEADER;
*p++ = GRPC_CHTTP2_DATA_FLAG_END_STREAM | GRPC_CHTTP2_DATA_FLAG_END_HEADERS;
- *p++ = (gpr_uint8)(stream_global->id >> 24);
- *p++ = (gpr_uint8)(stream_global->id >> 16);
- *p++ = (gpr_uint8)(stream_global->id >> 8);
- *p++ = (gpr_uint8)(stream_global->id);
+ *p++ = (uint8_t)(stream_global->id >> 24);
+ *p++ = (uint8_t)(stream_global->id >> 16);
+ *p++ = (uint8_t)(stream_global->id >> 8);
+ *p++ = (uint8_t)(stream_global->id);
GPR_ASSERT(p == GPR_SLICE_END_PTR(hdr));
gpr_slice_buffer_add(&transport_global->qbuf, hdr);
@@ -1288,14 +1308,14 @@ static void drop_connection(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t) {
}
/** update window from a settings change */
-static void update_global_window(void *args, gpr_uint32 id, void *stream) {
+static void update_global_window(void *args, uint32_t id, void *stream) {
grpc_chttp2_transport *t = args;
grpc_chttp2_stream *s = stream;
grpc_chttp2_transport_global *transport_global = &t->global;
grpc_chttp2_stream_global *stream_global = &s->global;
int was_zero;
int is_zero;
- gpr_int64 initial_window_update = t->parsing.initial_window_update;
+ int64_t initial_window_update = t->parsing.initial_window_update;
was_zero = stream_global->outgoing_window <= 0;
GRPC_CHTTP2_FLOW_CREDIT_STREAM("settings", transport_global, stream_global,
@@ -1355,7 +1375,7 @@ static void recv_data(grpc_exec_ctx *exec_ctx, void *tp, int success) {
grpc_chttp2_stream_map_move_into(&t->new_stream_map,
&t->parsing_stream_map);
transport_global->concurrent_stream_count =
- (gpr_uint32)grpc_chttp2_stream_map_size(&t->parsing_stream_map);
+ (uint32_t)grpc_chttp2_stream_map_size(&t->parsing_stream_map);
if (transport_parsing->initial_window_update != 0) {
grpc_chttp2_stream_map_for_each(&t->parsing_stream_map,
update_global_window, t);
@@ -1448,28 +1468,27 @@ static void incoming_byte_stream_update_flow_control(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global *stream_global, size_t max_size_hint,
size_t have_already) {
- gpr_uint32 max_recv_bytes;
+ uint32_t max_recv_bytes;
/* clamp max recv hint to an allowable size */
- if (max_size_hint >= GPR_UINT32_MAX - transport_global->stream_lookahead) {
- max_recv_bytes = GPR_UINT32_MAX - transport_global->stream_lookahead;
+ if (max_size_hint >= UINT32_MAX - transport_global->stream_lookahead) {
+ max_recv_bytes = UINT32_MAX - transport_global->stream_lookahead;
} else {
- max_recv_bytes = (gpr_uint32)max_size_hint;
+ max_recv_bytes = (uint32_t)max_size_hint;
}
/* account for bytes already received but unknown to higher layers */
if (max_recv_bytes >= have_already) {
- max_recv_bytes -= (gpr_uint32)have_already;
+ max_recv_bytes -= (uint32_t)have_already;
} else {
max_recv_bytes = 0;
}
/* add some small lookahead to keep pipelines flowing */
- GPR_ASSERT(max_recv_bytes <=
- GPR_UINT32_MAX - transport_global->stream_lookahead);
+ GPR_ASSERT(max_recv_bytes <= UINT32_MAX - transport_global->stream_lookahead);
max_recv_bytes += transport_global->stream_lookahead;
if (stream_global->max_recv_bytes < max_recv_bytes) {
- gpr_uint32 add_max_recv_bytes =
+ uint32_t add_max_recv_bytes =
max_recv_bytes - stream_global->max_recv_bytes;
GRPC_CHTTP2_FLOW_CREDIT_STREAM("op", transport_global, stream_global,
max_recv_bytes, add_max_recv_bytes);
@@ -1503,6 +1522,10 @@ static int incoming_byte_stream_next(grpc_exec_ctx *exec_ctx,
*slice = gpr_slice_buffer_take_first(&bs->slices);
unlock(exec_ctx, bs->transport);
return 1;
+ } else if (bs->failed) {
+ grpc_exec_ctx_enqueue(exec_ctx, on_complete, 0);
+ unlock(exec_ctx, bs->transport);
+ return 0;
} else {
bs->on_next = on_complete;
bs->next = slice;
@@ -1518,7 +1541,8 @@ static void incoming_byte_stream_unref(grpc_chttp2_incoming_byte_stream *bs) {
}
}
-static void incoming_byte_stream_destroy(grpc_byte_stream *byte_stream) {
+static void incoming_byte_stream_destroy(grpc_exec_ctx *exec_ctx,
+ grpc_byte_stream *byte_stream) {
incoming_byte_stream_unref((grpc_chttp2_incoming_byte_stream *)byte_stream);
}
@@ -1537,14 +1561,36 @@ void grpc_chttp2_incoming_byte_stream_push(grpc_exec_ctx *exec_ctx,
}
void grpc_chttp2_incoming_byte_stream_finished(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs) {
+ grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs, int success,
+ int from_parsing_thread) {
+ if (!success) {
+ if (from_parsing_thread) {
+ gpr_mu_lock(&bs->transport->mu);
+ }
+ grpc_exec_ctx_enqueue(exec_ctx, bs->on_next, 0);
+ bs->on_next = NULL;
+ bs->failed = 1;
+ if (from_parsing_thread) {
+ gpr_mu_unlock(&bs->transport->mu);
+ }
+ } else {
+#ifndef NDEBUG
+ if (from_parsing_thread) {
+ gpr_mu_lock(&bs->transport->mu);
+ }
+ GPR_ASSERT(bs->on_next == NULL);
+ if (from_parsing_thread) {
+ gpr_mu_unlock(&bs->transport->mu);
+ }
+#endif
+ }
incoming_byte_stream_unref(bs);
}
grpc_chttp2_incoming_byte_stream *grpc_chttp2_incoming_byte_stream_create(
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing,
- grpc_chttp2_stream_parsing *stream_parsing, gpr_uint32 frame_size,
- gpr_uint32 flags, grpc_chttp2_incoming_frame_queue *add_to_queue) {
+ grpc_chttp2_stream_parsing *stream_parsing, uint32_t frame_size,
+ uint32_t flags, grpc_chttp2_incoming_frame_queue *add_to_queue) {
grpc_chttp2_incoming_byte_stream *incoming_byte_stream =
gpr_malloc(sizeof(*incoming_byte_stream));
incoming_byte_stream->base.length = frame_size;
@@ -1558,6 +1604,7 @@ grpc_chttp2_incoming_byte_stream *grpc_chttp2_incoming_byte_stream_create(
gpr_slice_buffer_init(&incoming_byte_stream->slices);
incoming_byte_stream->on_next = NULL;
incoming_byte_stream->is_tail = 1;
+ incoming_byte_stream->failed = 0;
if (add_to_queue->head == NULL) {
add_to_queue->head = incoming_byte_stream;
} else {
@@ -1565,13 +1612,6 @@ grpc_chttp2_incoming_byte_stream *grpc_chttp2_incoming_byte_stream_create(
add_to_queue->tail->next_message = incoming_byte_stream;
}
add_to_queue->tail = incoming_byte_stream;
- if (frame_size == 0) {
- lock(TRANSPORT_FROM_PARSING(transport_parsing));
- incoming_byte_stream_update_flow_control(
- &TRANSPORT_FROM_PARSING(transport_parsing)->global,
- &STREAM_FROM_PARSING(stream_parsing)->global, 0, 0);
- unlock(exec_ctx, TRANSPORT_FROM_PARSING(transport_parsing));
- }
return incoming_byte_stream;
}
@@ -1580,7 +1620,7 @@ grpc_chttp2_incoming_byte_stream *grpc_chttp2_incoming_byte_stream_create(
*/
static char *format_flowctl_context_var(const char *context, const char *var,
- gpr_int64 val, gpr_uint32 id,
+ int64_t val, uint32_t id,
char **scope) {
char *underscore_pos;
char *result;
@@ -1615,8 +1655,7 @@ void grpc_chttp2_flowctl_trace(const char *file, int line, const char *phase,
grpc_chttp2_flowctl_op op, const char *context1,
const char *var1, const char *context2,
const char *var2, int is_client,
- gpr_uint32 stream_id, gpr_int64 val1,
- gpr_int64 val2) {
+ uint32_t stream_id, int64_t val1, int64_t val2) {
char *scope1;
char *scope2;
char *label1 =
diff --git a/src/core/transport/metadata.c b/src/core/transport/metadata.c
index e645ef9d8c..e241ad43bc 100644
--- a/src/core/transport/metadata.c
+++ b/src/core/transport/metadata.c
@@ -81,12 +81,12 @@ typedef void (*destroy_user_data_func)(void *user_data);
typedef struct internal_string {
/* must be byte compatible with grpc_mdstr */
gpr_slice slice;
- gpr_uint32 hash;
+ uint32_t hash;
/* private only data */
gpr_atm refcnt;
- gpr_uint8 has_base64_and_huffman_encoded;
+ uint8_t has_base64_and_huffman_encoded;
gpr_slice_refcount refcount;
gpr_slice base64_and_huffman;
@@ -131,7 +131,7 @@ typedef struct mdtab_shard {
#define MDTAB_SHARD_COUNT ((size_t)(1 << LOG2_MDTAB_SHARD_COUNT))
/* hash seed: decided at initialization time */
-static gpr_uint32 g_hash_seed;
+static uint32_t g_hash_seed;
static int g_forced_hash_seed = 0;
/* linearly probed hash tables for static element lookup */
@@ -145,7 +145,7 @@ static mdtab_shard g_mdtab_shard[MDTAB_SHARD_COUNT];
static void gc_mdtab(mdtab_shard *shard);
-void grpc_test_only_set_metadata_hash_seed(gpr_uint32 seed) {
+void grpc_test_only_set_metadata_hash_seed(uint32_t seed) {
g_hash_seed = seed;
g_forced_hash_seed = 1;
}
@@ -153,7 +153,7 @@ void grpc_test_only_set_metadata_hash_seed(gpr_uint32 seed) {
void grpc_mdctx_global_init(void) {
size_t i, j;
if (!g_forced_hash_seed) {
- g_hash_seed = (gpr_uint32)gpr_now(GPR_CLOCK_REALTIME).tv_nsec;
+ g_hash_seed = (uint32_t)gpr_now(GPR_CLOCK_REALTIME).tv_nsec;
}
g_static_strtab_maxprobe = 0;
g_static_mdtab_maxprobe = 0;
@@ -163,9 +163,9 @@ void grpc_mdctx_global_init(void) {
for (i = 0; i < GRPC_STATIC_MDSTR_COUNT; i++) {
grpc_mdstr *elem = &grpc_static_mdstr_table[i];
const char *str = grpc_static_metadata_strings[i];
- gpr_uint32 hash = gpr_murmur_hash3(str, strlen(str), g_hash_seed);
+ uint32_t hash = gpr_murmur_hash3(str, strlen(str), g_hash_seed);
*(gpr_slice *)&elem->slice = gpr_slice_from_static_string(str);
- *(gpr_uint32 *)&elem->hash = hash;
+ *(uint32_t *)&elem->hash = hash;
for (j = 0;; j++) {
size_t idx = (hash + j) % GPR_ARRAY_SIZE(g_static_strtab);
if (g_static_strtab[idx] == NULL) {
@@ -183,7 +183,7 @@ void grpc_mdctx_global_init(void) {
&grpc_static_mdstr_table[grpc_static_metadata_elem_indices[2 * i + 0]];
grpc_mdstr *value =
&grpc_static_mdstr_table[grpc_static_metadata_elem_indices[2 * i + 1]];
- gpr_uint32 hash = GRPC_MDSTR_KV_HASH(key->hash, value->hash);
+ uint32_t hash = GRPC_MDSTR_KV_HASH(key->hash, value->hash);
*(grpc_mdstr **)&elem->key = key;
*(grpc_mdstr **)&elem->value = value;
for (j = 0;; j++) {
@@ -327,7 +327,7 @@ static void slice_unref(void *p) {
}
grpc_mdstr *grpc_mdstr_from_string(const char *str) {
- return grpc_mdstr_from_buffer((const gpr_uint8 *)str, strlen(str));
+ return grpc_mdstr_from_buffer((const uint8_t *)str, strlen(str));
}
grpc_mdstr *grpc_mdstr_from_slice(gpr_slice slice) {
@@ -337,8 +337,8 @@ grpc_mdstr *grpc_mdstr_from_slice(gpr_slice slice) {
return result;
}
-grpc_mdstr *grpc_mdstr_from_buffer(const gpr_uint8 *buf, size_t length) {
- gpr_uint32 hash = gpr_murmur_hash3(buf, length, g_hash_seed);
+grpc_mdstr *grpc_mdstr_from_buffer(const uint8_t *buf, size_t length) {
+ uint32_t hash = gpr_murmur_hash3(buf, length, g_hash_seed);
internal_string *s;
strtab_shard *shard =
&g_strtab_shard[SHARD_IDX(hash, LOG2_STRTAB_SHARD_COUNT)];
@@ -382,7 +382,7 @@ grpc_mdstr *grpc_mdstr_from_buffer(const gpr_uint8 *buf, size_t length) {
s->slice.refcount = NULL;
memcpy(s->slice.data.inlined.bytes, buf, length);
s->slice.data.inlined.bytes[length] = 0;
- s->slice.data.inlined.length = (gpr_uint8)length;
+ s->slice.data.inlined.length = (uint8_t)length;
} else {
/* string data goes after the internal_string header, and we +1 for null
terminator */
@@ -391,7 +391,7 @@ grpc_mdstr *grpc_mdstr_from_buffer(const gpr_uint8 *buf, size_t length) {
s->refcount.ref = slice_ref;
s->refcount.unref = slice_unref;
s->slice.refcount = &s->refcount;
- s->slice.data.refcounted.bytes = (gpr_uint8 *)(s + 1);
+ s->slice.data.refcounted.bytes = (uint8_t *)(s + 1);
s->slice.data.refcounted.length = length;
memcpy(s->slice.data.refcounted.bytes, buf, length);
/* add a null terminator for cheap c string conversion when desired */
@@ -449,7 +449,7 @@ static void grow_mdtab(mdtab_shard *shard) {
size_t i;
internal_metadata **mdtab;
internal_metadata *md, *next;
- gpr_uint32 hash;
+ uint32_t hash;
GPR_TIMER_BEGIN("grow_mdtab", 0);
@@ -486,7 +486,7 @@ grpc_mdelem *grpc_mdelem_from_metadata_strings(grpc_mdstr *mkey,
grpc_mdstr *mvalue) {
internal_string *key = (internal_string *)mkey;
internal_string *value = (internal_string *)mvalue;
- gpr_uint32 hash = GRPC_MDSTR_KV_HASH(mkey->hash, mvalue->hash);
+ uint32_t hash = GRPC_MDSTR_KV_HASH(mkey->hash, mvalue->hash);
internal_metadata *md;
mdtab_shard *shard = &g_mdtab_shard[SHARD_IDX(hash, LOG2_MDTAB_SHARD_COUNT)];
size_t i;
@@ -562,7 +562,7 @@ grpc_mdelem *grpc_mdelem_from_slices(gpr_slice key, gpr_slice value) {
}
grpc_mdelem *grpc_mdelem_from_string_and_buffer(const char *key,
- const gpr_uint8 *value,
+ const uint8_t *value,
size_t value_length) {
return grpc_mdelem_from_metadata_strings(
grpc_mdstr_from_string(key), grpc_mdstr_from_buffer(value, value_length));
@@ -601,7 +601,7 @@ void grpc_mdelem_unref(grpc_mdelem *gmd DEBUG_ARGS) {
grpc_mdstr_as_c_string((grpc_mdstr *)md->value));
#endif
if (2 == gpr_atm_full_fetch_add(&md->refcnt, -1)) {
- gpr_uint32 hash = GRPC_MDSTR_KV_HASH(md->key->hash, md->value->hash);
+ uint32_t hash = GRPC_MDSTR_KV_HASH(md->key->hash, md->value->hash);
mdtab_shard *shard =
&g_mdtab_shard[SHARD_IDX(hash, LOG2_MDTAB_SHARD_COUNT)];
GPR_TIMER_BEGIN("grpc_mdelem_unref.to_zero", 0);
@@ -688,3 +688,40 @@ gpr_slice grpc_mdstr_as_base64_encoded_and_huffman_compressed(grpc_mdstr *gs) {
gpr_mu_unlock(&shard->mu);
return slice;
}
+<<<<<<< HEAD
+=======
+
+static int conforms_to(grpc_mdstr *s, const uint8_t *legal_bits) {
+ const uint8_t *p = GPR_SLICE_START_PTR(s->slice);
+ const uint8_t *e = GPR_SLICE_END_PTR(s->slice);
+ for (; p != e; p++) {
+ int idx = *p;
+ int byte = idx / 8;
+ int bit = idx % 8;
+ if ((legal_bits[byte] & (1 << bit)) == 0) return 0;
+ }
+ return 1;
+}
+
+int grpc_mdstr_is_legal_header(grpc_mdstr *s) {
+ static const uint8_t legal_header_bits[256 / 8] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xff, 0x03, 0x00, 0x00, 0x00,
+ 0x80, 0xfe, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+ return conforms_to(s, legal_header_bits);
+}
+
+int grpc_mdstr_is_legal_nonbin_header(grpc_mdstr *s) {
+ static const uint8_t legal_header_bits[256 / 8] = {
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+ return conforms_to(s, legal_header_bits);
+}
+
+int grpc_mdstr_is_bin_suffixed(grpc_mdstr *s) {
+ /* TODO(ctiller): consider caching this */
+ return grpc_is_binary_header((const char *)GPR_SLICE_START_PTR(s->slice),
+ GPR_SLICE_LENGTH(s->slice));
+}
+>>>>>>> master
diff --git a/src/core/transport/metadata.h b/src/core/transport/metadata.h
index 829c8a0873..9b8de9d882 100644
--- a/src/core/transport/metadata.h
+++ b/src/core/transport/metadata.h
@@ -74,7 +74,7 @@ typedef struct grpc_mdelem grpc_mdelem;
/* if changing this, make identical changes in internal_string in metadata.c */
struct grpc_mdstr {
const gpr_slice slice;
- const gpr_uint32 hash;
+ const uint32_t hash;
/* there is a private part to this in metadata.c */
};
@@ -86,14 +86,14 @@ struct grpc_mdelem {
/* there is a private part to this in metadata.c */
};
-void grpc_test_only_set_metadata_hash_seed(gpr_uint32 seed);
+void grpc_test_only_set_metadata_hash_seed(uint32_t seed);
/* Constructors for grpc_mdstr instances; take a variety of data types that
clients may have handy */
grpc_mdstr *grpc_mdstr_from_string(const char *str);
/* Unrefs the slice. */
grpc_mdstr *grpc_mdstr_from_slice(gpr_slice slice);
-grpc_mdstr *grpc_mdstr_from_buffer(const gpr_uint8 *str, size_t length);
+grpc_mdstr *grpc_mdstr_from_buffer(const uint8_t *str, size_t length);
/* Returns a borrowed slice from the mdstr with its contents base64 encoded
and huffman compressed */
@@ -107,7 +107,7 @@ grpc_mdelem *grpc_mdelem_from_strings(const char *key, const char *value);
/* Unrefs the slices. */
grpc_mdelem *grpc_mdelem_from_slices(gpr_slice key, gpr_slice value);
grpc_mdelem *grpc_mdelem_from_string_and_buffer(const char *key,
- const gpr_uint8 *value,
+ const uint8_t *value,
size_t value_length);
/* Mutator and accessor for grpc_mdelem user data. The destructor function
diff --git a/src/core/transport/static_metadata.c b/src/core/transport/static_metadata.c
index 361fe5ede6..233e5c0d92 100644
--- a/src/core/transport/static_metadata.c
+++ b/src/core/transport/static_metadata.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,7 +30,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
-
+
/*
* WARNING: Auto-generated code.
*
@@ -48,23 +48,22 @@
grpc_mdstr grpc_static_mdstr_table[GRPC_STATIC_MDSTR_COUNT];
grpc_mdelem grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];
-gpr_uintptr grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] = {
+uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 3, 7, 5, 2, 4, 8, 6, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-const gpr_uint8
- grpc_static_metadata_elem_indices[GRPC_STATIC_MDELEM_COUNT * 2] = {
- 11, 35, 10, 35, 12, 35, 12, 49, 13, 35, 14, 35, 15, 35, 16, 35, 17, 35,
- 19, 35, 20, 35, 21, 35, 24, 35, 25, 35, 26, 35, 27, 35, 28, 35, 29, 35,
- 30, 18, 30, 35, 31, 35, 32, 35, 36, 35, 37, 35, 38, 35, 39, 35, 42, 33,
- 42, 34, 42, 48, 42, 53, 42, 54, 42, 55, 42, 56, 43, 33, 43, 48, 43, 53,
- 46, 0, 46, 1, 46, 2, 50, 35, 57, 35, 58, 35, 59, 35, 60, 35, 61, 35,
- 62, 35, 63, 35, 64, 35, 65, 35, 66, 40, 66, 68, 67, 78, 67, 79, 69, 35,
- 70, 35, 71, 35, 72, 35, 73, 35, 74, 35, 75, 41, 75, 51, 75, 52, 76, 35,
- 77, 35, 80, 3, 80, 4, 80, 5, 80, 6, 80, 7, 80, 8, 80, 9, 81, 35,
- 82, 83, 84, 35, 85, 35, 86, 35, 87, 35, 88, 35};
+const uint8_t grpc_static_metadata_elem_indices[GRPC_STATIC_MDELEM_COUNT * 2] =
+ {11, 35, 10, 35, 12, 35, 12, 49, 13, 35, 14, 35, 15, 35, 16, 35, 17, 35,
+ 19, 35, 20, 35, 21, 35, 24, 35, 25, 35, 26, 35, 27, 35, 28, 35, 29, 35,
+ 30, 18, 30, 35, 31, 35, 32, 35, 36, 35, 37, 35, 38, 35, 39, 35, 42, 33,
+ 42, 34, 42, 48, 42, 53, 42, 54, 42, 55, 42, 56, 43, 33, 43, 48, 43, 53,
+ 46, 0, 46, 1, 46, 2, 50, 35, 57, 35, 58, 35, 59, 35, 60, 35, 61, 35,
+ 62, 35, 63, 35, 64, 35, 65, 35, 66, 40, 66, 68, 67, 78, 67, 79, 69, 35,
+ 70, 35, 71, 35, 72, 35, 73, 35, 74, 35, 75, 41, 75, 51, 75, 52, 76, 35,
+ 77, 35, 80, 3, 80, 4, 80, 5, 80, 6, 80, 7, 80, 8, 80, 9, 81, 35,
+ 82, 83, 84, 35, 85, 35, 86, 35, 87, 35, 88, 35};
const char *const grpc_static_metadata_strings[GRPC_STATIC_MDSTR_COUNT] = {
"0", "1", "2", "200", "204", "206", "304", "400", "404", "500", "accept",
@@ -86,5 +85,5 @@ const char *const grpc_static_metadata_strings[GRPC_STATIC_MDSTR_COUNT] = {
"te", "trailers", "transfer-encoding", "user-agent", "vary", "via",
"www-authenticate"};
-const gpr_uint8 grpc_static_accept_encoding_metadata[8] = {0, 29, 26, 30,
- 28, 32, 27, 31};
+const uint8_t grpc_static_accept_encoding_metadata[8] = {0, 29, 26, 30,
+ 28, 32, 27, 31};
diff --git a/src/core/transport/static_metadata.h b/src/core/transport/static_metadata.h
index d951293c84..3803a0488b 100644
--- a/src/core/transport/static_metadata.h
+++ b/src/core/transport/static_metadata.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,7 +30,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
-
+
/*
* WARNING: Auto-generated code.
*
@@ -232,7 +232,7 @@ extern grpc_mdstr grpc_static_mdstr_table[GRPC_STATIC_MDSTR_COUNT];
#define GRPC_STATIC_MDELEM_COUNT 78
extern grpc_mdelem grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];
-extern gpr_uintptr grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT];
+extern uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT];
/* "accept-charset": "" */
#define GRPC_MDELEM_ACCEPT_CHARSET_EMPTY (&grpc_static_mdelem_table[0])
/* "accept": "" */
@@ -399,10 +399,10 @@ extern gpr_uintptr grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT];
/* "www-authenticate": "" */
#define GRPC_MDELEM_WWW_AUTHENTICATE_EMPTY (&grpc_static_mdelem_table[77])
-extern const gpr_uint8
+extern const uint8_t
grpc_static_metadata_elem_indices[GRPC_STATIC_MDELEM_COUNT * 2];
extern const char *const grpc_static_metadata_strings[GRPC_STATIC_MDSTR_COUNT];
-extern const gpr_uint8 grpc_static_accept_encoding_metadata[8];
+extern const uint8_t grpc_static_accept_encoding_metadata[8];
#define GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(algs) \
(&grpc_static_mdelem_table[grpc_static_accept_encoding_metadata[(algs)]])
#endif /* GRPC_INTERNAL_CORE_TRANSPORT_STATIC_METADATA_H */
diff --git a/src/core/tsi/fake_transport_security.c b/src/core/tsi/fake_transport_security.c
index 99e28ab63b..72ac32a171 100644
--- a/src/core/tsi/fake_transport_security.c
+++ b/src/core/tsi/fake_transport_security.c
@@ -112,12 +112,12 @@ static tsi_result tsi_fake_handshake_message_from_string(
return TSI_DATA_CORRUPTED;
}
-static gpr_uint32 load32_little_endian(const unsigned char *buf) {
- return ((gpr_uint32)(buf[0]) | (gpr_uint32)(buf[1] << 8) |
- (gpr_uint32)(buf[2] << 16) | (gpr_uint32)(buf[3] << 24));
+static uint32_t load32_little_endian(const unsigned char *buf) {
+ return ((uint32_t)(buf[0]) | (uint32_t)(buf[1] << 8) |
+ (uint32_t)(buf[2] << 16) | (uint32_t)(buf[3] << 24));
}
-static void store32_little_endian(gpr_uint32 value, unsigned char *buf) {
+static void store32_little_endian(uint32_t value, unsigned char *buf) {
buf[3] = (unsigned char)((value >> 24) & 0xFF);
buf[2] = (unsigned char)((value >> 16) & 0xFF);
buf[1] = (unsigned char)((value >> 8) & 0xFF);
@@ -219,7 +219,7 @@ static tsi_result bytes_to_frame(unsigned char *bytes, size_t bytes_size,
frame->offset = 0;
frame->size = bytes_size + TSI_FAKE_FRAME_HEADER_SIZE;
if (!tsi_fake_frame_ensure_size(frame)) return TSI_OUT_OF_RESOURCES;
- store32_little_endian((gpr_uint32)frame->size, frame->data);
+ store32_little_endian((uint32_t)frame->size, frame->data);
memcpy(frame->data + TSI_FAKE_FRAME_HEADER_SIZE, bytes, bytes_size);
tsi_fake_frame_reset(frame, 1 /* needs draining */);
return TSI_OK;
@@ -266,7 +266,7 @@ static tsi_result fake_protector_protect(tsi_frame_protector *self,
if (frame->size == 0) {
/* New frame, create a header. */
size_t written_in_frame_size = 0;
- store32_little_endian((gpr_uint32)impl->max_frame_size, frame_header);
+ store32_little_endian((uint32_t)impl->max_frame_size, frame_header);
written_in_frame_size = TSI_FAKE_FRAME_HEADER_SIZE;
result = fill_frame_from_bytes(frame_header, &written_in_frame_size, frame);
if (result != TSI_INCOMPLETE_DATA) {
@@ -303,7 +303,7 @@ static tsi_result fake_protector_protect_flush(
frame->size = frame->offset;
frame->offset = 0;
frame->needs_draining = 1;
- store32_little_endian((gpr_uint32)frame->size,
+ store32_little_endian((uint32_t)frame->size,
frame->data); /* Overwrite header. */
}
result = drain_frame_to_bytes(protected_output_frames,
diff --git a/src/core/tsi/ssl_transport_security.c b/src/core/tsi/ssl_transport_security.c
index 22b57964cc..6adcaac9ed 100644
--- a/src/core/tsi/ssl_transport_security.c
+++ b/src/core/tsi/ssl_transport_security.c
@@ -40,7 +40,6 @@
#include <grpc/support/sync.h>
#include <grpc/support/thd.h>
#include <grpc/support/useful.h>
-#include "src/core/tsi/transport_security.h"
#include <openssl/bio.h>
#include <openssl/crypto.h> /* For OPENSSL_free */
@@ -49,6 +48,9 @@
#include <openssl/x509.h>
#include <openssl/x509v3.h>
+#include "src/core/tsi/ssl_types.h"
+#include "src/core/tsi/transport_security.h"
+
/* --- Constants. ---*/
#define TSI_SSL_MAX_PROTECTED_FRAME_SIZE_UPPER_BOUND 16384
@@ -291,7 +293,7 @@ static tsi_result add_subject_alt_names_properties_to_peer(
for (i = 0; i < subject_alt_name_count; i++) {
GENERAL_NAME *subject_alt_name =
- sk_GENERAL_NAME_value(subject_alt_names, (int)i);
+ sk_GENERAL_NAME_value(subject_alt_names, TSI_SIZE_AS_SIZE(i));
/* Filter out the non-dns entries names. */
if (subject_alt_name->type == GEN_DNS) {
unsigned char *dns_name = NULL;
@@ -649,7 +651,7 @@ static tsi_result build_alpn_protocol_name_list(
}
/* Safety check. */
if ((current < *protocol_name_list) ||
- ((gpr_uintptr)(current - *protocol_name_list) !=
+ ((uintptr_t)(current - *protocol_name_list) !=
*protocol_name_list_length)) {
return TSI_INTERNAL_ERROR;
}
@@ -1072,7 +1074,7 @@ static int select_protocol_list(const unsigned char **out,
unsigned char client_current_len = *(client_current++);
const unsigned char *server_current = server_list;
while ((server_current >= server_list) &&
- (gpr_uintptr)(server_current - server_list) < server_list_len) {
+ (uintptr_t)(server_current - server_list) < server_list_len) {
unsigned char server_current_len = *(server_current++);
if ((client_current_len == server_current_len) &&
!memcmp(client_current, server_current, server_current_len)) {
diff --git a/src/core/tsi/ssl_types.h b/src/core/tsi/ssl_types.h
new file mode 100644
index 0000000000..0d0225e9c7
--- /dev/null
+++ b/src/core/tsi/ssl_types.h
@@ -0,0 +1,55 @@
+/*
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef GRPC_INTERNAL_CORE_TSI_SSL_TYPES_H
+#define GRPC_INTERNAL_CORE_TSI_SSL_TYPES_H
+
+/* A collection of macros to cast between various integer types that are
+ * used differently between BoringSSL and OpenSSL:
+ * TSI_INT_AS_SIZE(x): convert 'int x' to a length parameter for an OpenSSL
+ * function
+ * TSI_SIZE_AS_SIZE(x): convert 'size_t x' to a length parameter for an OpenSSL
+ * function
+ */
+
+#include <openssl/ssl.h>
+
+#ifdef OPENSSL_IS_BORINGSSL
+#define TSI_INT_AS_SIZE(x) ((size_t)(x))
+#define TSI_SIZE_AS_SIZE(x) (x)
+#else
+#define TSI_INT_AS_SIZE(x) (x)
+#define TSI_SIZE_AS_SIZE(x) ((int)(x))
+#endif
+
+#endif
diff --git a/src/cpp/proto/proto_utils.cc b/src/cpp/proto/proto_utils.cc
index 898a1d4f58..79e7bf1801 100644
--- a/src/cpp/proto/proto_utils.cc
+++ b/src/cpp/proto/proto_utils.cc
@@ -96,7 +96,7 @@ class GrpcBufferWriter GRPC_FINAL
private:
const int block_size_;
- gpr_int64 byte_count_;
+ int64_t byte_count_;
gpr_slice_buffer* slice_buffer_;
bool have_backup_;
gpr_slice backup_slice_;
@@ -156,8 +156,8 @@ class GrpcBufferReader GRPC_FINAL
}
private:
- gpr_int64 byte_count_;
- gpr_int64 backup_count_;
+ int64_t byte_count_;
+ int64_t backup_count_;
grpc_byte_buffer_reader reader_;
gpr_slice slice_;
};
diff --git a/src/cpp/util/time.cc b/src/cpp/util/time.cc
index 9c38b34879..2685e31ee6 100644
--- a/src/cpp/util/time.cc
+++ b/src/cpp/util/time.cc
@@ -57,8 +57,8 @@ void Timepoint2Timespec(const system_clock::time_point& from,
return;
}
nanoseconds nsecs = duration_cast<nanoseconds>(deadline - secs);
- to->tv_sec = (gpr_int64)secs.count();
- to->tv_nsec = (gpr_int32)nsecs.count();
+ to->tv_sec = (int64_t)secs.count();
+ to->tv_nsec = (int32_t)nsecs.count();
to->clock_type = GPR_CLOCK_REALTIME;
}
@@ -73,8 +73,8 @@ void TimepointHR2Timespec(const high_resolution_clock::time_point& from,
return;
}
nanoseconds nsecs = duration_cast<nanoseconds>(deadline - secs);
- to->tv_sec = (gpr_int64)secs.count();
- to->tv_nsec = (gpr_int32)nsecs.count();
+ to->tv_sec = (int64_t)secs.count();
+ to->tv_nsec = (int32_t)nsecs.count();
to->clock_type = GPR_CLOCK_REALTIME;
}
diff --git a/src/csharp/Grpc.Core.Tests/ServerTest.cs b/src/csharp/Grpc.Core.Tests/ServerTest.cs
index e7193c843b..b40508accc 100644
--- a/src/csharp/Grpc.Core.Tests/ServerTest.cs
+++ b/src/csharp/Grpc.Core.Tests/ServerTest.cs
@@ -54,6 +54,17 @@ namespace Grpc.Core.Tests
}
[Test]
+ public void StartAndKillServer()
+ {
+ Server server = new Server
+ {
+ Ports = { new ServerPort("localhost", ServerPort.PickUnused, ServerCredentials.Insecure) }
+ };
+ server.Start();
+ server.KillAsync().Wait();
+ }
+
+ [Test]
public void PickUnusedPort()
{
Server server = new Server
diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs b/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs
index 46ca459349..0c805097f9 100644
--- a/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs
+++ b/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs
@@ -58,7 +58,7 @@ namespace Grpc.Core.Internal
public void Initialize(CallSafeHandle call)
{
- call.SetCompletionRegistry(environment.CompletionRegistry);
+ call.Initialize(environment.CompletionRegistry, environment.CompletionQueue);
server.AddCallReference(this);
InitializeInternal(call);
diff --git a/src/csharp/Grpc.Core/Internal/AtomicCounter.cs b/src/csharp/Grpc.Core/Internal/AtomicCounter.cs
index 7ccda225dc..63bea44e0e 100644
--- a/src/csharp/Grpc.Core/Internal/AtomicCounter.cs
+++ b/src/csharp/Grpc.Core/Internal/AtomicCounter.cs
@@ -40,14 +40,39 @@ namespace Grpc.Core.Internal
{
long counter = 0;
- public void Increment()
+ public AtomicCounter(long initialCount = 0)
{
- Interlocked.Increment(ref counter);
+ this.counter = initialCount;
}
- public void Decrement()
+ public long Increment()
{
- Interlocked.Decrement(ref counter);
+ return Interlocked.Increment(ref counter);
+ }
+
+ public void IncrementIfNonzero(ref bool success)
+ {
+ long origValue = counter;
+ while (true)
+ {
+ if (origValue == 0)
+ {
+ success = false;
+ return;
+ }
+ long result = Interlocked.CompareExchange(ref counter, origValue + 1, origValue);
+ if (result == origValue)
+ {
+ success = true;
+ return;
+ };
+ origValue = result;
+ }
+ }
+
+ public long Decrement()
+ {
+ return Interlocked.Decrement(ref counter);
}
public long Count
diff --git a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs
index ad2e2919b7..69dbdfea5e 100644
--- a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs
+++ b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs
@@ -47,6 +47,7 @@ namespace Grpc.Core.Internal
const uint GRPC_WRITE_BUFFER_HINT = 1;
CompletionRegistry completionRegistry;
+ CompletionQueueSafeHandle completionQueue;
[DllImport("grpc_csharp_ext.dll")]
static extern GRPCCallError grpcsharp_call_cancel(CallSafeHandle call);
@@ -112,9 +113,10 @@ namespace Grpc.Core.Internal
{
}
- public void SetCompletionRegistry(CompletionRegistry completionRegistry)
+ public void Initialize(CompletionRegistry completionRegistry, CompletionQueueSafeHandle completionQueue)
{
this.completionRegistry = completionRegistry;
+ this.completionQueue = completionQueue;
}
public void SetCredentials(CallCredentialsSafeHandle credentials)
@@ -124,10 +126,13 @@ namespace Grpc.Core.Internal
public void StartUnary(UnaryResponseClientHandler callback, byte[] payload, MetadataArraySafeHandle metadataArray, WriteFlags writeFlags)
{
- var ctx = BatchContextSafeHandle.Create();
- completionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success, context.GetReceivedStatusOnClient(), context.GetReceivedMessage(), context.GetReceivedInitialMetadata()));
- grpcsharp_call_start_unary(this, ctx, payload, new UIntPtr((ulong)payload.Length), metadataArray, writeFlags)
- .CheckOk();
+ using (completionQueue.NewScope())
+ {
+ var ctx = BatchContextSafeHandle.Create();
+ completionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success, context.GetReceivedStatusOnClient(), context.GetReceivedMessage(), context.GetReceivedInitialMetadata()));
+ grpcsharp_call_start_unary(this, ctx, payload, new UIntPtr((ulong)payload.Length), metadataArray, writeFlags)
+ .CheckOk();
+ }
}
public void StartUnary(BatchContextSafeHandle ctx, byte[] payload, MetadataArraySafeHandle metadataArray, WriteFlags writeFlags)
@@ -141,72 +146,102 @@ namespace Grpc.Core.Internal
public void StartClientStreaming(UnaryResponseClientHandler callback, MetadataArraySafeHandle metadataArray)
{
- var ctx = BatchContextSafeHandle.Create();
- completionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success, context.GetReceivedStatusOnClient(), context.GetReceivedMessage(), context.GetReceivedInitialMetadata()));
- grpcsharp_call_start_client_streaming(this, ctx, metadataArray).CheckOk();
+ using (completionQueue.NewScope())
+ {
+ var ctx = BatchContextSafeHandle.Create();
+ completionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success, context.GetReceivedStatusOnClient(), context.GetReceivedMessage(), context.GetReceivedInitialMetadata()));
+ grpcsharp_call_start_client_streaming(this, ctx, metadataArray).CheckOk();
+ }
}
public void StartServerStreaming(ReceivedStatusOnClientHandler callback, byte[] payload, MetadataArraySafeHandle metadataArray, WriteFlags writeFlags)
{
- var ctx = BatchContextSafeHandle.Create();
- completionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success, context.GetReceivedStatusOnClient()));
- grpcsharp_call_start_server_streaming(this, ctx, payload, new UIntPtr((ulong)payload.Length), metadataArray, writeFlags).CheckOk();
+ using (completionQueue.NewScope())
+ {
+ var ctx = BatchContextSafeHandle.Create();
+ completionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success, context.GetReceivedStatusOnClient()));
+ grpcsharp_call_start_server_streaming(this, ctx, payload, new UIntPtr((ulong)payload.Length), metadataArray, writeFlags).CheckOk();
+ }
}
public void StartDuplexStreaming(ReceivedStatusOnClientHandler callback, MetadataArraySafeHandle metadataArray)
{
- var ctx = BatchContextSafeHandle.Create();
- completionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success, context.GetReceivedStatusOnClient()));
- grpcsharp_call_start_duplex_streaming(this, ctx, metadataArray).CheckOk();
+ using (completionQueue.NewScope())
+ {
+ var ctx = BatchContextSafeHandle.Create();
+ completionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success, context.GetReceivedStatusOnClient()));
+ grpcsharp_call_start_duplex_streaming(this, ctx, metadataArray).CheckOk();
+ }
}
public void StartSendMessage(SendCompletionHandler callback, byte[] payload, WriteFlags writeFlags, bool sendEmptyInitialMetadata)
{
- var ctx = BatchContextSafeHandle.Create();
- completionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success));
- grpcsharp_call_send_message(this, ctx, payload, new UIntPtr((ulong)payload.Length), writeFlags, sendEmptyInitialMetadata).CheckOk();
+ using (completionQueue.NewScope())
+ {
+ var ctx = BatchContextSafeHandle.Create();
+ completionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success));
+ grpcsharp_call_send_message(this, ctx, payload, new UIntPtr((ulong)payload.Length), writeFlags, sendEmptyInitialMetadata).CheckOk();
+ }
}
public void StartSendCloseFromClient(SendCompletionHandler callback)
{
- var ctx = BatchContextSafeHandle.Create();
- completionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success));
- grpcsharp_call_send_close_from_client(this, ctx).CheckOk();
+ using (completionQueue.NewScope())
+ {
+ var ctx = BatchContextSafeHandle.Create();
+ completionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success));
+ grpcsharp_call_send_close_from_client(this, ctx).CheckOk();
+ }
}
public void StartSendStatusFromServer(SendCompletionHandler callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata)
{
- var ctx = BatchContextSafeHandle.Create();
- completionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success));
- grpcsharp_call_send_status_from_server(this, ctx, status.StatusCode, status.Detail, metadataArray, sendEmptyInitialMetadata).CheckOk();
+ using (completionQueue.NewScope())
+ {
+ var ctx = BatchContextSafeHandle.Create();
+ completionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success));
+ grpcsharp_call_send_status_from_server(this, ctx, status.StatusCode, status.Detail, metadataArray, sendEmptyInitialMetadata).CheckOk();
+ }
}
public void StartReceiveMessage(ReceivedMessageHandler callback)
{
- var ctx = BatchContextSafeHandle.Create();
- completionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success, context.GetReceivedMessage()));
- grpcsharp_call_recv_message(this, ctx).CheckOk();
+ using (completionQueue.NewScope())
+ {
+ var ctx = BatchContextSafeHandle.Create();
+ completionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success, context.GetReceivedMessage()));
+ grpcsharp_call_recv_message(this, ctx).CheckOk();
+ }
}
public void StartReceiveInitialMetadata(ReceivedResponseHeadersHandler callback)
{
- var ctx = BatchContextSafeHandle.Create();
- completionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success, context.GetReceivedInitialMetadata()));
- grpcsharp_call_recv_initial_metadata(this, ctx).CheckOk();
+ using (completionQueue.NewScope())
+ {
+ var ctx = BatchContextSafeHandle.Create();
+ completionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success, context.GetReceivedInitialMetadata()));
+ grpcsharp_call_recv_initial_metadata(this, ctx).CheckOk();
+ }
}
public void StartServerSide(ReceivedCloseOnServerHandler callback)
{
- var ctx = BatchContextSafeHandle.Create();
- completionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success, context.GetReceivedCloseOnServerCancelled()));
- grpcsharp_call_start_serverside(this, ctx).CheckOk();
+ using (completionQueue.NewScope())
+ {
+ var ctx = BatchContextSafeHandle.Create();
+ completionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success, context.GetReceivedCloseOnServerCancelled()));
+ grpcsharp_call_start_serverside(this, ctx).CheckOk();
+ }
}
public void StartSendInitialMetadata(SendCompletionHandler callback, MetadataArraySafeHandle metadataArray)
{
- var ctx = BatchContextSafeHandle.Create();
- completionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success));
- grpcsharp_call_send_initial_metadata(this, ctx, metadataArray).CheckOk();
+ using (completionQueue.NewScope())
+ {
+ var ctx = BatchContextSafeHandle.Create();
+ completionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success));
+ grpcsharp_call_send_initial_metadata(this, ctx, metadataArray).CheckOk();
+ }
}
public void Cancel()
diff --git a/src/csharp/Grpc.Core/Internal/ChannelSafeHandle.cs b/src/csharp/Grpc.Core/Internal/ChannelSafeHandle.cs
index b3aa27c40f..4a5584121e 100644
--- a/src/csharp/Grpc.Core/Internal/ChannelSafeHandle.cs
+++ b/src/csharp/Grpc.Core/Internal/ChannelSafeHandle.cs
@@ -92,7 +92,7 @@ namespace Grpc.Core.Internal
{
result.SetCredentials(credentials);
}
- result.SetCompletionRegistry(registry);
+ result.Initialize(registry, cq);
return result;
}
}
diff --git a/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs b/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs
index 9de2bc7950..3754ad382e 100644
--- a/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs
+++ b/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs
@@ -33,6 +33,8 @@ using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Grpc.Core.Profiling;
+using Grpc.Core.Utils;
+
namespace Grpc.Core.Internal
{
/// <summary>
@@ -40,6 +42,8 @@ namespace Grpc.Core.Internal
/// </summary>
internal class CompletionQueueSafeHandle : SafeHandleZeroIsInvalid
{
+ AtomicCounter shutdownRefcount = new AtomicCounter(1);
+
[DllImport("grpc_csharp_ext.dll")]
static extern CompletionQueueSafeHandle grpcsharp_completion_queue_create();
@@ -62,6 +66,7 @@ namespace Grpc.Core.Internal
public static CompletionQueueSafeHandle Create()
{
return grpcsharp_completion_queue_create();
+
}
public CompletionQueueEvent Next()
@@ -77,9 +82,18 @@ namespace Grpc.Core.Internal
}
}
+ /// <summary>
+ /// Creates a new usage scope for this completion queue. Once successfully created,
+ /// the completion queue won't be shutdown before scope.Dispose() is called.
+ /// </summary>
+ public UsageScope NewScope()
+ {
+ return new UsageScope(this);
+ }
+
public void Shutdown()
{
- grpcsharp_completion_queue_shutdown(this);
+ DecrementShutdownRefcount();
}
protected override bool ReleaseHandle()
@@ -87,5 +101,43 @@ namespace Grpc.Core.Internal
grpcsharp_completion_queue_destroy(handle);
return true;
}
+
+ private void DecrementShutdownRefcount()
+ {
+ if (shutdownRefcount.Decrement() == 0)
+ {
+ grpcsharp_completion_queue_shutdown(this);
+ }
+ }
+
+ private void BeginOp()
+ {
+ bool success = false;
+ shutdownRefcount.IncrementIfNonzero(ref success);
+ Preconditions.CheckState(success, "Shutdown has already been called");
+ }
+
+ private void EndOp()
+ {
+ DecrementShutdownRefcount();
+ }
+
+ // Allows declaring BeginOp and EndOp of a completion queue with a using statement.
+ // Declared as struct for better performance.
+ public struct UsageScope : IDisposable
+ {
+ readonly CompletionQueueSafeHandle cq;
+
+ public UsageScope(CompletionQueueSafeHandle cq)
+ {
+ this.cq = cq;
+ this.cq.BeginOp();
+ }
+
+ public void Dispose()
+ {
+ cq.EndOp();
+ }
+ }
}
}
diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c
index 0ef9be33a6..26f1537398 100644
--- a/src/csharp/ext/grpc_csharp_ext.c
+++ b/src/csharp/ext/grpc_csharp_ext.c
@@ -167,9 +167,9 @@ grpcsharp_metadata_array_add(grpc_metadata_array *array, const char *key,
array->count++;
}
-GPR_EXPORT gpr_intptr GPR_CALLTYPE
+GPR_EXPORT intptr_t GPR_CALLTYPE
grpcsharp_metadata_array_count(grpc_metadata_array *array) {
- return (gpr_intptr)array->count;
+ return (intptr_t)array->count;
}
GPR_EXPORT const char *GPR_CALLTYPE
@@ -184,10 +184,10 @@ grpcsharp_metadata_array_get_value(grpc_metadata_array *array, size_t index) {
return array->metadata[index].value;
}
-GPR_EXPORT gpr_intptr GPR_CALLTYPE grpcsharp_metadata_array_get_value_length(
+GPR_EXPORT intptr_t GPR_CALLTYPE grpcsharp_metadata_array_get_value_length(
grpc_metadata_array *array, size_t index) {
GPR_ASSERT(index < array->count);
- return (gpr_intptr)array->metadata[index].value_length;
+ return (intptr_t)array->metadata[index].value_length;
}
/* Move contents of metadata array */
@@ -247,12 +247,12 @@ grpcsharp_batch_context_recv_initial_metadata(
return &(ctx->recv_initial_metadata);
}
-GPR_EXPORT gpr_intptr GPR_CALLTYPE grpcsharp_batch_context_recv_message_length(
+GPR_EXPORT intptr_t GPR_CALLTYPE grpcsharp_batch_context_recv_message_length(
const grpcsharp_batch_context *ctx) {
if (!ctx->recv_message) {
return -1;
}
- return (gpr_intptr)grpc_byte_buffer_length(ctx->recv_message);
+ return (intptr_t)grpc_byte_buffer_length(ctx->recv_message);
}
/*
@@ -323,10 +323,10 @@ grpcsharp_batch_context_server_rpc_new_request_metadata(
return &(ctx->server_rpc_new.request_metadata);
}
-GPR_EXPORT gpr_int32 GPR_CALLTYPE
+GPR_EXPORT int32_t GPR_CALLTYPE
grpcsharp_batch_context_recv_close_on_server_cancelled(
const grpcsharp_batch_context *ctx) {
- return (gpr_int32) ctx->recv_close_on_server_cancelled;
+ return (int32_t) ctx->recv_close_on_server_cancelled;
}
/* Init & shutdown */
@@ -378,7 +378,7 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_channel_destroy(grpc_channel *channel) {
GPR_EXPORT grpc_call *GPR_CALLTYPE
grpcsharp_channel_create_call(grpc_channel *channel, grpc_call *parent_call,
- gpr_uint32 propagation_mask,
+ uint32_t propagation_mask,
grpc_completion_queue *cq,
const char *method, const char *host,
gpr_timespec deadline) {
@@ -387,7 +387,7 @@ grpcsharp_channel_create_call(grpc_channel *channel, grpc_call *parent_call,
}
GPR_EXPORT grpc_connectivity_state GPR_CALLTYPE
-grpcsharp_channel_check_connectivity_state(grpc_channel *channel, gpr_int32 try_to_connect) {
+grpcsharp_channel_check_connectivity_state(grpc_channel *channel, int32_t try_to_connect) {
return grpc_channel_check_connectivity_state(channel, try_to_connect);
}
@@ -469,7 +469,7 @@ GPR_EXPORT gpr_timespec GPR_CALLTYPE gprsharp_convert_clock_type(gpr_timespec t,
return gpr_convert_clock_type(t, target_clock);
}
-GPR_EXPORT gpr_int32 GPR_CALLTYPE gprsharp_sizeof_timespec(void) {
+GPR_EXPORT int32_t GPR_CALLTYPE gprsharp_sizeof_timespec(void) {
return sizeof(gpr_timespec);
}
@@ -500,7 +500,7 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_call_destroy(grpc_call *call) {
GPR_EXPORT grpc_call_error GPR_CALLTYPE
grpcsharp_call_start_unary(grpc_call *call, grpcsharp_batch_context *ctx,
const char *send_buffer, size_t send_buffer_len,
- grpc_metadata_array *initial_metadata, gpr_uint32 write_flags) {
+ grpc_metadata_array *initial_metadata, uint32_t write_flags) {
/* TODO: don't use magic number */
grpc_op ops[6];
ops[0].op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -593,7 +593,7 @@ grpcsharp_call_start_client_streaming(grpc_call *call,
GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_server_streaming(
grpc_call *call, grpcsharp_batch_context *ctx, const char *send_buffer,
- size_t send_buffer_len, grpc_metadata_array *initial_metadata, gpr_uint32 write_flags) {
+ size_t send_buffer_len, grpc_metadata_array *initial_metadata, uint32_t write_flags) {
/* TODO: don't use magic number */
grpc_op ops[4];
ops[0].op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -680,8 +680,8 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_recv_initial_metadata(
GPR_EXPORT grpc_call_error GPR_CALLTYPE
grpcsharp_call_send_message(grpc_call *call, grpcsharp_batch_context *ctx,
const char *send_buffer, size_t send_buffer_len,
- gpr_uint32 write_flags,
- gpr_int32 send_empty_initial_metadata) {
+ uint32_t write_flags,
+ int32_t send_empty_initial_metadata) {
/* TODO: don't use magic number */
grpc_op ops[2];
size_t nops = send_empty_initial_metadata ? 2 : 1;
@@ -715,7 +715,7 @@ grpcsharp_call_send_close_from_client(grpc_call *call,
GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_send_status_from_server(
grpc_call *call, grpcsharp_batch_context *ctx, grpc_status_code status_code,
const char *status_details, grpc_metadata_array *trailing_metadata,
- gpr_int32 send_empty_initial_metadata) {
+ int32_t send_empty_initial_metadata) {
/* TODO: don't use magic number */
grpc_op ops[2];
size_t nops = send_empty_initial_metadata ? 2 : 1;
@@ -801,7 +801,7 @@ grpcsharp_server_create(grpc_completion_queue *cq,
return server;
}
-GPR_EXPORT gpr_int32 GPR_CALLTYPE
+GPR_EXPORT int32_t GPR_CALLTYPE
grpcsharp_server_add_insecure_http2_port(grpc_server *server, const char *addr) {
return grpc_server_add_insecure_http2_port(server, addr);
}
@@ -899,7 +899,7 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_server_credentials_release(
grpc_server_credentials_release(creds);
}
-GPR_EXPORT gpr_int32 GPR_CALLTYPE
+GPR_EXPORT int32_t GPR_CALLTYPE
grpcsharp_server_add_secure_http2_port(grpc_server *server, const char *addr,
grpc_server_credentials *creds) {
return grpc_server_add_secure_http2_port(server, addr, creds);
@@ -929,19 +929,19 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_metadata_credentials_notify_from_plugin(
typedef void(GPR_CALLTYPE *grpcsharp_metadata_interceptor_func)(
void *state, const char *service_url, const char *method_name,
grpc_credentials_plugin_metadata_cb cb,
- void *user_data, gpr_int32 is_destroy);
+ void *user_data, int32_t is_destroy);
static void grpcsharp_get_metadata_handler(
void *state, grpc_auth_metadata_context context,
grpc_credentials_plugin_metadata_cb cb, void *user_data) {
grpcsharp_metadata_interceptor_func interceptor =
- (grpcsharp_metadata_interceptor_func)(gpr_intptr)state;
+ (grpcsharp_metadata_interceptor_func)(intptr_t)state;
interceptor(state, context.service_url, context.method_name, cb, user_data, 0);
}
static void grpcsharp_metadata_credentials_destroy_handler(void *state) {
grpcsharp_metadata_interceptor_func interceptor =
- (grpcsharp_metadata_interceptor_func)(gpr_intptr)state;
+ (grpcsharp_metadata_interceptor_func)(intptr_t)state;
interceptor(state, NULL, NULL, NULL, NULL, 1);
}
@@ -950,15 +950,15 @@ GPR_EXPORT grpc_call_credentials *GPR_CALLTYPE grpcsharp_metadata_credentials_cr
grpc_metadata_credentials_plugin plugin;
plugin.get_metadata = grpcsharp_get_metadata_handler;
plugin.destroy = grpcsharp_metadata_credentials_destroy_handler;
- plugin.state = (void*)(gpr_intptr)metadata_interceptor;
+ plugin.state = (void*)(intptr_t)metadata_interceptor;
plugin.type = "";
return grpc_metadata_credentials_create_from_plugin(plugin, NULL);
}
/* Logging */
-typedef void(GPR_CALLTYPE *grpcsharp_log_func)(const char *file, gpr_int32 line,
- gpr_uint64 thd_id,
+typedef void(GPR_CALLTYPE *grpcsharp_log_func)(const char *file, int32_t line,
+ uint64_t thd_id,
const char *severity_string,
const char *msg);
static grpcsharp_log_func log_func = NULL;
@@ -975,7 +975,7 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_redirect_log(grpcsharp_log_func func) {
gpr_set_log_function(grpcsharp_log_handler);
}
-typedef void(GPR_CALLTYPE *test_callback_funcptr)(gpr_int32 success);
+typedef void(GPR_CALLTYPE *test_callback_funcptr)(int32_t success);
/* Version info */
GPR_EXPORT const char *GPR_CALLTYPE grpcsharp_version_string() {
@@ -992,6 +992,6 @@ grpcsharp_test_callback(test_callback_funcptr callback) {
GPR_EXPORT void *GPR_CALLTYPE grpcsharp_test_nop(void *ptr) { return ptr; }
/* For testing */
-GPR_EXPORT gpr_int32 GPR_CALLTYPE grpcsharp_sizeof_grpc_event(void) {
+GPR_EXPORT int32_t GPR_CALLTYPE grpcsharp_sizeof_grpc_event(void) {
return sizeof(grpc_event);
}
diff --git a/src/node/ext/call.cc b/src/node/ext/call.cc
index 84a3e227c8..9f023b5883 100644
--- a/src/node/ext/call.cc
+++ b/src/node/ext/call.cc
@@ -582,7 +582,7 @@ NAN_METHOD(Call::New) {
return Nan::ThrowTypeError(
"Call's fifth argument must be another call, if provided");
}
- gpr_uint32 propagate_flags = GRPC_PROPAGATE_DEFAULTS;
+ uint32_t propagate_flags = GRPC_PROPAGATE_DEFAULTS;
if (info[5]->IsUint32()) {
propagate_flags = Nan::To<uint32_t>(info[5]).FromJust();
} else if (!(info[5]->IsUndefined() || info[5]->IsNull())) {
diff --git a/src/python/README.md b/src/python/README.md
index a3133b5aad..8b167659ff 100644
--- a/src/python/README.md
+++ b/src/python/README.md
@@ -52,6 +52,11 @@ BUILDING FROM SOURCE
---------------------
- Clone this repository
+- Install tox
+```
+$ sudo pip install tox
+```
+
- Initialize the git submodules
```
$ git submodule update --init
@@ -64,7 +69,7 @@ $ make
- Use build_python.sh to build the Python code and install it into a virtual environment
```
-$ CONFIG=opt tools/run_tests/build_python.sh 2.7
+$ CONFIG=opt tools/run_tests/build_python.sh
```
TESTING
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pxd b/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pxd
index fd562ad75b..1ed5d4b229 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pxd
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pxd
@@ -37,3 +37,5 @@ cdef class CompletionQueue:
cdef bint is_polling
cdef bint is_shutting_down
cdef bint is_shutdown
+
+ cdef _interpret_event(self, grpc.grpc_event event)
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx b/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx
index 2cf49707b4..635a38fe28 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx
@@ -46,35 +46,13 @@ cdef class CompletionQueue:
self.poll_condition = threading.Condition()
self.is_polling = False
- def poll(self, records.Timespec deadline=None):
- # We name this 'poll' to avoid problems with CPython's expectations for
- # 'special' methods (like next and __next__).
- cdef grpc.gpr_timespec c_deadline = grpc.gpr_inf_future(
- grpc.GPR_CLOCK_REALTIME)
+ cdef _interpret_event(self, grpc.grpc_event event):
cdef records.OperationTag tag = None
cdef object user_tag = None
cdef call.Call operation_call = None
cdef records.CallDetails request_call_details = None
cdef records.Metadata request_metadata = None
cdef records.Operations batch_operations = None
- if deadline is not None:
- c_deadline = deadline.c_time
- cdef grpc.grpc_event event
-
- # Poll within a critical section
- # TODO consider making queue polling contention a hard error to enable
- # easier bug discovery
- with self.poll_condition:
- while self.is_polling:
- self.poll_condition.wait(float(deadline) - time.time())
- self.is_polling = True
- with nogil:
- event = grpc.grpc_completion_queue_next(
- self.c_completion_queue, c_deadline, NULL)
- with self.poll_condition:
- self.is_polling = False
- self.poll_condition.notify()
-
if event.type == grpc.GRPC_QUEUE_TIMEOUT:
return records.Event(
event.type, False, None, None, None, None, False, None)
@@ -104,6 +82,54 @@ cdef class CompletionQueue:
request_call_details, request_metadata, tag.is_new_request,
batch_operations)
+ def poll(self, records.Timespec deadline=None):
+ # We name this 'poll' to avoid problems with CPython's expectations for
+ # 'special' methods (like next and __next__).
+ cdef grpc.gpr_timespec c_deadline = grpc.gpr_inf_future(
+ grpc.GPR_CLOCK_REALTIME)
+ if deadline is not None:
+ c_deadline = deadline.c_time
+ cdef grpc.grpc_event event
+
+ # Poll within a critical section
+ # TODO(atash) consider making queue polling contention a hard error to
+ # enable easier bug discovery
+ with self.poll_condition:
+ while self.is_polling:
+ self.poll_condition.wait(float(deadline) - time.time())
+ self.is_polling = True
+ with nogil:
+ event = grpc.grpc_completion_queue_next(
+ self.c_completion_queue, c_deadline, NULL)
+ with self.poll_condition:
+ self.is_polling = False
+ self.poll_condition.notify()
+ return self._interpret_event(event)
+
+ def pluck(self, records.OperationTag tag, records.Timespec deadline=None):
+ # Plucking a 'None' tag is equivalent to passing control to GRPC core until
+ # the deadline.
+ cdef grpc.gpr_timespec c_deadline = grpc.gpr_inf_future(
+ grpc.GPR_CLOCK_REALTIME)
+ if deadline is not None:
+ c_deadline = deadline.c_time
+ cdef grpc.grpc_event event
+
+ # Poll within a critical section
+ # TODO(atash) consider making queue polling contention a hard error to
+ # enable easier bug discovery
+ with self.poll_condition:
+ while self.is_polling:
+ self.poll_condition.wait(float(deadline) - time.time())
+ self.is_polling = True
+ with nogil:
+ event = grpc.grpc_completion_queue_pluck(
+ self.c_completion_queue, <cpython.PyObject *>tag, c_deadline, NULL)
+ with self.poll_condition:
+ self.is_polling = False
+ self.poll_condition.notify()
+ return self._interpret_event(event)
+
def shutdown(self):
grpc.grpc_completion_queue_shutdown(self.c_completion_queue)
self.is_shutting_down = True
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxd b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxd
index 643cdc9e3d..9b10d2ae75 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxd
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxd
@@ -28,6 +28,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cimport libc.time
+from libc.stdint cimport int64_t, uint32_t, int32_t
cdef extern from "grpc/support/alloc.h":
@@ -55,15 +56,6 @@ cdef extern from "grpc/support/slice.h":
size_t gpr_slice_length "GPR_SLICE_LENGTH" (gpr_slice s)
-cdef extern from "grpc/support/port_platform.h":
- # As long as the header file gets this type right, we don't need to get this
- # type exactly; just close enough that the operations will be supported in the
- # underlying C layers.
- ctypedef unsigned int gpr_uint32
- ctypedef int gpr_int32
- ctypedef long int gpr_int64
-
-
cdef extern from "grpc/support/time.h":
ctypedef enum gpr_clock_type:
@@ -73,8 +65,8 @@ cdef extern from "grpc/support/time.h":
GPR_TIMESPAN
ctypedef struct gpr_timespec:
- gpr_int64 seconds "tv_sec"
- gpr_int32 nanoseconds "tv_nsec"
+ int64_t seconds "tv_sec"
+ int32_t nanoseconds "tv_nsec"
gpr_clock_type clock_type
gpr_timespec gpr_time_0(gpr_clock_type type)
@@ -282,7 +274,7 @@ cdef extern from "grpc/grpc.h":
ctypedef struct grpc_op:
grpc_op_type type "op"
- gpr_uint32 flags
+ uint32_t flags
grpc_op_data data
void grpc_init()
@@ -292,6 +284,9 @@ cdef extern from "grpc/grpc.h":
grpc_event grpc_completion_queue_next(grpc_completion_queue *cq,
gpr_timespec deadline,
void *reserved) nogil
+ grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cq, void *tag,
+ gpr_timespec deadline,
+ void *reserved) nogil
void grpc_completion_queue_shutdown(grpc_completion_queue *cq)
void grpc_completion_queue_destroy(grpc_completion_queue *cq)
@@ -310,7 +305,7 @@ cdef extern from "grpc/grpc.h":
void *reserved)
grpc_call *grpc_channel_create_call(grpc_channel *channel,
grpc_call *parent_call,
- gpr_uint32 propagation_mask,
+ uint32_t propagation_mask,
grpc_completion_queue *completion_queue,
const char *method, const char *host,
gpr_timespec deadline, void *reserved)
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx b/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx
index 46df8bf77f..b0bafbc1f4 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx
@@ -89,6 +89,8 @@ cdef class Server:
self.register_completion_queue(self.backup_shutdown_queue)
self.is_started = True
grpc.grpc_server_start(self.c_server)
+ # Ensure the core has gotten a chance to do the start-up work
+ self.backup_shutdown_queue.pluck(None, records.Timespec(None))
def add_http2_port(self, address,
credentials.ServerCredentials server_credentials=None):
diff --git a/src/python/grpcio/grpc/framework/interfaces/face/face.py b/src/python/grpcio/grpc/framework/interfaces/face/face.py
index 3b402356d2..59da83dc9c 100644
--- a/src/python/grpcio/grpc/framework/interfaces/face/face.py
+++ b/src/python/grpcio/grpc/framework/interfaces/face/face.py
@@ -378,7 +378,7 @@ class UnaryUnaryMultiCallable(object):
metadata: A metadata value to be passed to the service-side of
the RPC.
with_call: Whether or not to include return a Call for the RPC in addition
- to the reponse.
+ to the response.
protocol_options: A value specified by the provider of a Face interface
implementation affording custom state and behavior.
@@ -496,7 +496,7 @@ class StreamUnaryMultiCallable(object):
metadata: A metadata value to be passed to the service-side of
the RPC.
with_call: Whether or not to include return a Call for the RPC in addition
- to the reponse.
+ to the response.
protocol_options: A value specified by the provider of a Face interface
implementation affording custom state and behavior.
@@ -699,7 +699,7 @@ class GenericStub(object):
timeout: A duration of time in seconds to allow for the RPC.
metadata: A metadata value to be passed to the service-side of the RPC.
with_call: Whether or not to include return a Call for the RPC in addition
- to the reponse.
+ to the response.
protocol_options: A value specified by the provider of a Face interface
implementation affording custom state and behavior.
@@ -774,7 +774,7 @@ class GenericStub(object):
timeout: A duration of time in seconds to allow for the RPC.
metadata: A metadata value to be passed to the service-side of the RPC.
with_call: Whether or not to include return a Call for the RPC in addition
- to the reponse.
+ to the response.
protocol_options: A value specified by the provider of a Face interface
implementation affording custom state and behavior.
diff --git a/src/python/grpcio/setup.py b/src/python/grpcio/setup.py
index b8a98c3d85..366ebe3b3f 100644
--- a/src/python/grpcio/setup.py
+++ b/src/python/grpcio/setup.py
@@ -146,7 +146,7 @@ TEST_PACKAGE_DATA = {
TESTS_REQUIRE = (
'oauth2client>=1.4.7',
- 'protobuf==3.0.0a3',
+ 'protobuf>=3.0.0a3',
'coverage>=4.0',
) + INSTALL_REQUIRES
diff --git a/src/ruby/ext/grpc/rb_grpc.c b/src/ruby/ext/grpc/rb_grpc.c
index a752a5f879..265ab58ecb 100644
--- a/src/ruby/ext/grpc/rb_grpc.c
+++ b/src/ruby/ext/grpc/rb_grpc.c
@@ -138,7 +138,7 @@ gpr_timespec grpc_rb_time_timeval(VALUE time, int interval) {
d += 1;
f -= 1;
}
- t.tv_sec = (gpr_int64)f;
+ t.tv_sec = (int64_t)f;
if (f != t.tv_sec) {
rb_raise(rb_eRangeError, "%f out of Time range",
RFLOAT_VALUE(time));