aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/ext/transport
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/ext/transport')
-rw-r--r--src/core/ext/transport/chttp2/alpn/alpn.cc6
-rw-r--r--src/core/ext/transport/chttp2/alpn/alpn.h4
-rw-r--r--src/core/ext/transport/chttp2/client/chttp2_connector.cc68
-rw-r--r--src/core/ext/transport/chttp2/client/insecure/channel_create.cc47
-rw-r--r--src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc25
-rw-r--r--src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc84
-rw-r--r--src/core/ext/transport/chttp2/server/chttp2_server.cc103
-rw-r--r--src/core/ext/transport/chttp2/server/chttp2_server.h6
-rw-r--r--src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc6
-rw-r--r--src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc18
-rw-r--r--src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc14
-rw-r--r--src/core/ext/transport/chttp2/transport/bin_decoder.cc14
-rw-r--r--src/core/ext/transport/chttp2/transport/bin_decoder.h14
-rw-r--r--src/core/ext/transport/chttp2/transport/bin_encoder.cc22
-rw-r--r--src/core/ext/transport/chttp2/transport/chttp2_transport.cc880
-rw-r--r--src/core/ext/transport/chttp2/transport/chttp2_transport.h20
-rw-r--r--src/core/ext/transport/chttp2/transport/flow_control.cc8
-rw-r--r--src/core/ext/transport/chttp2/transport/flow_control.h8
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_data.cc48
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_data.h34
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_goaway.cc32
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_goaway.h20
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_ping.cc24
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_ping.h8
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_rst_stream.cc32
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_rst_stream.h16
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_settings.cc32
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_settings.h18
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_window_update.cc32
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_window_update.h12
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_encoder.cc135
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_encoder.h28
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_parser.cc640
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_parser.h44
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_table.cc42
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_table.h22
-rw-r--r--src/core/ext/transport/chttp2/transport/http2_settings.cc2
-rw-r--r--src/core/ext/transport/chttp2/transport/http2_settings.h4
-rw-r--r--src/core/ext/transport/chttp2/transport/incoming_metadata.cc25
-rw-r--r--src/core/ext/transport/chttp2/transport/incoming_metadata.h20
-rw-r--r--src/core/ext/transport/chttp2/transport/internal.h359
-rw-r--r--src/core/ext/transport/chttp2/transport/parsing.cc202
-rw-r--r--src/core/ext/transport/chttp2/transport/stream_lists.cc84
-rw-r--r--src/core/ext/transport/chttp2/transport/stream_map.cc50
-rw-r--r--src/core/ext/transport/chttp2/transport/stream_map.h28
-rw-r--r--src/core/ext/transport/chttp2/transport/writing.cc102
-rw-r--r--src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc12
-rw-r--r--src/core/ext/transport/cronet/transport/cronet_transport.cc317
-rw-r--r--src/core/ext/transport/cronet/transport/cronet_transport.h6
-rw-r--r--src/core/ext/transport/inproc/inproc_transport.cc291
-rw-r--r--src/core/ext/transport/inproc/inproc_transport.h6
51 files changed, 2055 insertions, 2019 deletions
diff --git a/src/core/ext/transport/chttp2/alpn/alpn.cc b/src/core/ext/transport/chttp2/alpn/alpn.cc
index ca2e801ec8..89892457d6 100644
--- a/src/core/ext/transport/chttp2/alpn/alpn.cc
+++ b/src/core/ext/transport/chttp2/alpn/alpn.cc
@@ -21,9 +21,9 @@
#include <grpc/support/useful.h>
/* in order of preference */
-static const char *const supported_versions[] = {"grpc-exp", "h2"};
+static const char* const supported_versions[] = {"grpc-exp", "h2"};
-int grpc_chttp2_is_alpn_version_supported(const char *version, size_t size) {
+int grpc_chttp2_is_alpn_version_supported(const char* version, size_t size) {
size_t i;
for (i = 0; i < GPR_ARRAY_SIZE(supported_versions); i++) {
if (!strncmp(version, supported_versions[i], size)) return 1;
@@ -35,7 +35,7 @@ size_t grpc_chttp2_num_alpn_versions(void) {
return GPR_ARRAY_SIZE(supported_versions);
}
-const char *grpc_chttp2_get_alpn_version_index(size_t i) {
+const char* grpc_chttp2_get_alpn_version_index(size_t i) {
GPR_ASSERT(i < GPR_ARRAY_SIZE(supported_versions));
return supported_versions[i];
}
diff --git a/src/core/ext/transport/chttp2/alpn/alpn.h b/src/core/ext/transport/chttp2/alpn/alpn.h
index 99b928ea59..4a420e83e0 100644
--- a/src/core/ext/transport/chttp2/alpn/alpn.h
+++ b/src/core/ext/transport/chttp2/alpn/alpn.h
@@ -26,14 +26,14 @@ extern "C" {
#endif
/* Retuns 1 if the version is supported, 0 otherwise. */
-int grpc_chttp2_is_alpn_version_supported(const char *version, size_t size);
+int grpc_chttp2_is_alpn_version_supported(const char* version, size_t size);
/* Returns the number of protocol versions to advertise */
size_t grpc_chttp2_num_alpn_versions(void);
/* Returns the protocol version at index i (0 <= i <
* grpc_chttp2_num_alpn_versions()) */
-const char *grpc_chttp2_get_alpn_version_index(size_t i);
+const char* grpc_chttp2_get_alpn_version_index(size_t i);
#ifdef __cplusplus
}
diff --git a/src/core/ext/transport/chttp2/client/chttp2_connector.cc b/src/core/ext/transport/chttp2/client/chttp2_connector.cc
index 202bcd47f5..6cd476f4ca 100644
--- a/src/core/ext/transport/chttp2/client/chttp2_connector.cc
+++ b/src/core/ext/transport/chttp2/client/chttp2_connector.cc
@@ -45,25 +45,25 @@ typedef struct {
bool shutdown;
bool connecting;
- grpc_closure *notify;
+ grpc_closure* notify;
grpc_connect_in_args args;
- grpc_connect_out_args *result;
+ grpc_connect_out_args* result;
- grpc_endpoint *endpoint; // Non-NULL until handshaking starts.
+ grpc_endpoint* endpoint; // Non-NULL until handshaking starts.
grpc_closure connected;
- grpc_handshake_manager *handshake_mgr;
+ grpc_handshake_manager* handshake_mgr;
} chttp2_connector;
-static void chttp2_connector_ref(grpc_connector *con) {
- chttp2_connector *c = (chttp2_connector *)con;
+static void chttp2_connector_ref(grpc_connector* con) {
+ chttp2_connector* c = (chttp2_connector*)con;
gpr_ref(&c->refs);
}
-static void chttp2_connector_unref(grpc_exec_ctx *exec_ctx,
- grpc_connector *con) {
- chttp2_connector *c = (chttp2_connector *)con;
+static void chttp2_connector_unref(grpc_exec_ctx* exec_ctx,
+ grpc_connector* con) {
+ chttp2_connector* c = (chttp2_connector*)con;
if (gpr_unref(&c->refs)) {
gpr_mu_destroy(&c->mu);
// If handshaking is not yet in progress, destroy the endpoint.
@@ -73,9 +73,9 @@ static void chttp2_connector_unref(grpc_exec_ctx *exec_ctx,
}
}
-static void chttp2_connector_shutdown(grpc_exec_ctx *exec_ctx,
- grpc_connector *con, grpc_error *why) {
- chttp2_connector *c = (chttp2_connector *)con;
+static void chttp2_connector_shutdown(grpc_exec_ctx* exec_ctx,
+ grpc_connector* con, grpc_error* why) {
+ chttp2_connector* c = (chttp2_connector*)con;
gpr_mu_lock(&c->mu);
c->shutdown = true;
if (c->handshake_mgr != NULL) {
@@ -91,10 +91,10 @@ static void chttp2_connector_shutdown(grpc_exec_ctx *exec_ctx,
GRPC_ERROR_UNREF(why);
}
-static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_handshaker_args *args = (grpc_handshaker_args *)arg;
- chttp2_connector *c = (chttp2_connector *)args->user_data;
+static void on_handshake_done(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_error* error) {
+ grpc_handshaker_args* args = (grpc_handshaker_args*)arg;
+ chttp2_connector* c = (chttp2_connector*)args->user_data;
gpr_mu_lock(&c->mu);
if (error != GRPC_ERROR_NONE || c->shutdown) {
if (error == GRPC_ERROR_NONE) {
@@ -115,6 +115,8 @@ static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
}
memset(c->result, 0, sizeof(*c->result));
} else {
+ grpc_endpoint_delete_from_pollset_set(exec_ctx, args->endpoint,
+ c->args.interested_parties);
c->result->transport =
grpc_create_chttp2_transport(exec_ctx, args->args, args->endpoint, 1);
GPR_ASSERT(c->result->transport);
@@ -122,28 +124,30 @@ static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
args->read_buffer);
c->result->channel_args = args->args;
}
- grpc_closure *notify = c->notify;
+ grpc_closure* notify = c->notify;
c->notify = NULL;
GRPC_CLOSURE_SCHED(exec_ctx, notify, error);
grpc_handshake_manager_destroy(exec_ctx, c->handshake_mgr);
c->handshake_mgr = NULL;
gpr_mu_unlock(&c->mu);
- chttp2_connector_unref(exec_ctx, (grpc_connector *)c);
+ chttp2_connector_unref(exec_ctx, (grpc_connector*)c);
}
-static void start_handshake_locked(grpc_exec_ctx *exec_ctx,
- chttp2_connector *c) {
+static void start_handshake_locked(grpc_exec_ctx* exec_ctx,
+ chttp2_connector* c) {
c->handshake_mgr = grpc_handshake_manager_create();
grpc_handshakers_add(exec_ctx, HANDSHAKER_CLIENT, c->args.channel_args,
c->handshake_mgr);
+ grpc_endpoint_add_to_pollset_set(exec_ctx, c->endpoint,
+ c->args.interested_parties);
grpc_handshake_manager_do_handshake(
exec_ctx, c->handshake_mgr, c->endpoint, c->args.channel_args,
c->args.deadline, NULL /* acceptor */, on_handshake_done, c);
c->endpoint = NULL; // Endpoint handed off to handshake manager.
}
-static void connected(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- chttp2_connector *c = (chttp2_connector *)arg;
+static void connected(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+ chttp2_connector* c = (chttp2_connector*)arg;
gpr_mu_lock(&c->mu);
GPR_ASSERT(c->connecting);
c->connecting = false;
@@ -154,14 +158,14 @@ static void connected(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
error = GRPC_ERROR_REF(error);
}
memset(c->result, 0, sizeof(*c->result));
- grpc_closure *notify = c->notify;
+ grpc_closure* notify = c->notify;
c->notify = NULL;
GRPC_CLOSURE_SCHED(exec_ctx, notify, error);
if (c->endpoint != NULL) {
grpc_endpoint_shutdown(exec_ctx, c->endpoint, GRPC_ERROR_REF(error));
}
gpr_mu_unlock(&c->mu);
- chttp2_connector_unref(exec_ctx, (grpc_connector *)arg);
+ chttp2_connector_unref(exec_ctx, (grpc_connector*)arg);
} else {
GPR_ASSERT(c->endpoint != NULL);
start_handshake_locked(exec_ctx, c);
@@ -169,12 +173,12 @@ static void connected(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
}
}
-static void chttp2_connector_connect(grpc_exec_ctx *exec_ctx,
- grpc_connector *con,
- const grpc_connect_in_args *args,
- grpc_connect_out_args *result,
- grpc_closure *notify) {
- chttp2_connector *c = (chttp2_connector *)con;
+static void chttp2_connector_connect(grpc_exec_ctx* exec_ctx,
+ grpc_connector* con,
+ const grpc_connect_in_args* args,
+ grpc_connect_out_args* result,
+ grpc_closure* notify) {
+ chttp2_connector* c = (chttp2_connector*)con;
grpc_resolved_address addr;
grpc_get_subchannel_address_arg(exec_ctx, args->channel_args, &addr);
gpr_mu_lock(&c->mu);
@@ -197,8 +201,8 @@ static const grpc_connector_vtable chttp2_connector_vtable = {
chttp2_connector_ref, chttp2_connector_unref, chttp2_connector_shutdown,
chttp2_connector_connect};
-grpc_connector *grpc_chttp2_connector_create() {
- chttp2_connector *c = (chttp2_connector *)gpr_zalloc(sizeof(*c));
+grpc_connector* grpc_chttp2_connector_create() {
+ chttp2_connector* c = (chttp2_connector*)gpr_zalloc(sizeof(*c));
c->base.vtable = &chttp2_connector_vtable;
gpr_mu_init(&c->mu);
gpr_ref_init(&c->refs, 1);
diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc
index 6410a6043d..26c7f0debf 100644
--- a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc
+++ b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc
@@ -31,37 +31,37 @@
#include "src/core/lib/surface/channel.h"
static void client_channel_factory_ref(
- grpc_client_channel_factory *cc_factory) {}
+ grpc_client_channel_factory* cc_factory) {}
static void client_channel_factory_unref(
- grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory) {}
+ grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* cc_factory) {}
-static grpc_subchannel *client_channel_factory_create_subchannel(
- grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory,
- const grpc_subchannel_args *args) {
- grpc_connector *connector = grpc_chttp2_connector_create();
- grpc_subchannel *s = grpc_subchannel_create(exec_ctx, connector, args);
+static grpc_subchannel* client_channel_factory_create_subchannel(
+ grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* cc_factory,
+ const grpc_subchannel_args* args) {
+ grpc_connector* connector = grpc_chttp2_connector_create();
+ grpc_subchannel* s = grpc_subchannel_create(exec_ctx, connector, args);
grpc_connector_unref(exec_ctx, connector);
return s;
}
-static grpc_channel *client_channel_factory_create_channel(
- grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory,
- const char *target, grpc_client_channel_type type,
- const grpc_channel_args *args) {
+static grpc_channel* client_channel_factory_create_channel(
+ grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* cc_factory,
+ const char* target, grpc_client_channel_type type,
+ const grpc_channel_args* args) {
if (target == NULL) {
gpr_log(GPR_ERROR, "cannot create channel with NULL target name");
return NULL;
}
// Add channel arg containing the server URI.
grpc_arg arg = grpc_channel_arg_string_create(
- (char *)GRPC_ARG_SERVER_URI,
+ (char*)GRPC_ARG_SERVER_URI,
grpc_resolver_factory_add_default_prefix_if_needed(exec_ctx, target));
- const char *to_remove[] = {GRPC_ARG_SERVER_URI};
- grpc_channel_args *new_args =
+ const char* to_remove[] = {GRPC_ARG_SERVER_URI};
+ grpc_channel_args* new_args =
grpc_channel_args_copy_and_add_and_remove(args, to_remove, 1, &arg, 1);
gpr_free(arg.value.string);
- grpc_channel *channel = grpc_channel_create(exec_ctx, target, new_args,
+ grpc_channel* channel = grpc_channel_create(exec_ctx, target, new_args,
GRPC_CLIENT_CHANNEL, NULL);
grpc_channel_args_destroy(exec_ctx, new_args);
return channel;
@@ -79,9 +79,9 @@ static grpc_client_channel_factory client_channel_factory = {
Asynchronously: - resolve target
- connect to it (trying alternatives as presented)
- perform handshakes */
-grpc_channel *grpc_insecure_channel_create(const char *target,
- const grpc_channel_args *args,
- void *reserved) {
+grpc_channel* grpc_insecure_channel_create(const char* target,
+ const grpc_channel_args* args,
+ void* reserved) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
GRPC_API_TRACE(
"grpc_insecure_channel_create(target=%s, args=%p, reserved=%p)", 3,
@@ -90,15 +90,16 @@ grpc_channel *grpc_insecure_channel_create(const char *target,
// Add channel arg containing the client channel factory.
grpc_arg arg =
grpc_client_channel_factory_create_channel_arg(&client_channel_factory);
- grpc_channel_args *new_args = grpc_channel_args_copy_and_add(args, &arg, 1);
+ grpc_channel_args* new_args = grpc_channel_args_copy_and_add(args, &arg, 1);
// Create channel.
- grpc_channel *channel = client_channel_factory_create_channel(
+ grpc_channel* channel = client_channel_factory_create_channel(
&exec_ctx, &client_channel_factory, target,
GRPC_CLIENT_CHANNEL_TYPE_REGULAR, new_args);
// Clean up.
grpc_channel_args_destroy(&exec_ctx, new_args);
grpc_exec_ctx_finish(&exec_ctx);
- return channel != NULL ? channel : grpc_lame_client_channel_create(
- target, GRPC_STATUS_INTERNAL,
- "Failed to create client channel");
+ return channel != NULL ? channel
+ : grpc_lame_client_channel_create(
+ target, GRPC_STATUS_INTERNAL,
+ "Failed to create client channel");
}
diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc b/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc
index dd88136f7b..0974a7c393 100644
--- a/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc
+++ b/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc
@@ -35,42 +35,43 @@
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/transport/transport.h"
-grpc_channel *grpc_insecure_channel_create_from_fd(
- const char *target, int fd, const grpc_channel_args *args) {
+grpc_channel* grpc_insecure_channel_create_from_fd(
+ const char* target, int fd, const grpc_channel_args* args) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
GRPC_API_TRACE("grpc_insecure_channel_create(target=%p, fd=%d, args=%p)", 3,
(target, fd, args));
grpc_arg default_authority_arg = grpc_channel_arg_string_create(
- (char *)GRPC_ARG_DEFAULT_AUTHORITY, (char *)"test.authority");
- grpc_channel_args *final_args =
+ (char*)GRPC_ARG_DEFAULT_AUTHORITY, (char*)"test.authority");
+ grpc_channel_args* final_args =
grpc_channel_args_copy_and_add(args, &default_authority_arg, 1);
int flags = fcntl(fd, F_GETFL, 0);
GPR_ASSERT(fcntl(fd, F_SETFL, flags | O_NONBLOCK) == 0);
- grpc_endpoint *client = grpc_tcp_client_create_from_fd(
+ grpc_endpoint* client = grpc_tcp_client_create_from_fd(
&exec_ctx, grpc_fd_create(fd, "client"), args, "fd-client");
- grpc_transport *transport =
+ grpc_transport* transport =
grpc_create_chttp2_transport(&exec_ctx, final_args, client, 1);
GPR_ASSERT(transport);
- grpc_channel *channel = grpc_channel_create(
+ grpc_channel* channel = grpc_channel_create(
&exec_ctx, target, final_args, GRPC_CLIENT_DIRECT_CHANNEL, transport);
grpc_channel_args_destroy(&exec_ctx, final_args);
grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL);
grpc_exec_ctx_finish(&exec_ctx);
- return channel != NULL ? channel : grpc_lame_client_channel_create(
- target, GRPC_STATUS_INTERNAL,
- "Failed to create client channel");
+ return channel != NULL ? channel
+ : grpc_lame_client_channel_create(
+ target, GRPC_STATUS_INTERNAL,
+ "Failed to create client channel");
}
#else // !GPR_SUPPORT_CHANNELS_FROM_FD
-grpc_channel *grpc_insecure_channel_create_from_fd(
- const char *target, int fd, const grpc_channel_args *args) {
+grpc_channel* grpc_insecure_channel_create_from_fd(
+ const char* target, int fd, const grpc_channel_args* args) {
GPR_ASSERT(0);
return NULL;
}
diff --git a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc
index fe296cf4ff..68c1e1868c 100644
--- a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc
+++ b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc
@@ -38,14 +38,14 @@
#include "src/core/lib/surface/channel.h"
static void client_channel_factory_ref(
- grpc_client_channel_factory *cc_factory) {}
+ grpc_client_channel_factory* cc_factory) {}
static void client_channel_factory_unref(
- grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory) {}
+ grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* cc_factory) {}
-static grpc_subchannel_args *get_secure_naming_subchannel_args(
- grpc_exec_ctx *exec_ctx, const grpc_subchannel_args *args) {
- grpc_channel_credentials *channel_credentials =
+static grpc_subchannel_args* get_secure_naming_subchannel_args(
+ grpc_exec_ctx* exec_ctx, const grpc_subchannel_args* args) {
+ grpc_channel_credentials* channel_credentials =
grpc_channel_credentials_find_in_args(args->args);
if (channel_credentials == NULL) {
gpr_log(GPR_ERROR,
@@ -61,33 +61,33 @@ static grpc_subchannel_args *get_secure_naming_subchannel_args(
return NULL;
}
// To which address are we connecting? By default, use the server URI.
- const grpc_arg *server_uri_arg =
+ const grpc_arg* server_uri_arg =
grpc_channel_args_find(args->args, GRPC_ARG_SERVER_URI);
GPR_ASSERT(server_uri_arg != NULL);
GPR_ASSERT(server_uri_arg->type == GRPC_ARG_STRING);
- const char *server_uri_str = server_uri_arg->value.string;
+ const char* server_uri_str = server_uri_arg->value.string;
GPR_ASSERT(server_uri_str != NULL);
- grpc_uri *server_uri =
+ grpc_uri* server_uri =
grpc_uri_parse(exec_ctx, server_uri_str, true /* supress errors */);
GPR_ASSERT(server_uri != NULL);
- const char *server_uri_path;
+ const char* server_uri_path;
server_uri_path =
server_uri->path[0] == '/' ? server_uri->path + 1 : server_uri->path;
- const grpc_slice_hash_table *targets_info =
+ const grpc_slice_hash_table* targets_info =
grpc_lb_targets_info_find_in_args(args->args);
- char *target_name_to_check = NULL;
+ char* target_name_to_check = NULL;
if (targets_info != NULL) { // LB channel
// Find the balancer name for the target.
- const char *target_uri_str =
+ const char* target_uri_str =
grpc_get_subchannel_address_uri_arg(args->args);
- grpc_uri *target_uri =
+ grpc_uri* target_uri =
grpc_uri_parse(exec_ctx, target_uri_str, false /* suppress errors */);
GPR_ASSERT(target_uri != NULL);
if (target_uri->path[0] != '\0') { // "path" may be empty
const grpc_slice key = grpc_slice_from_static_string(
target_uri->path[0] == '/' ? target_uri->path + 1 : target_uri->path);
- const char *value =
- (const char *)grpc_slice_hash_table_get(targets_info, key);
+ const char* value =
+ (const char*)grpc_slice_hash_table_get(targets_info, key);
if (value != NULL) target_name_to_check = gpr_strdup(value);
grpc_slice_unref_internal(exec_ctx, key);
}
@@ -102,9 +102,9 @@ static grpc_subchannel_args *get_secure_naming_subchannel_args(
}
grpc_uri_destroy(server_uri);
GPR_ASSERT(target_name_to_check != NULL);
- grpc_channel_security_connector *subchannel_security_connector = NULL;
+ grpc_channel_security_connector* subchannel_security_connector = NULL;
// Create the security connector using the credentials and target name.
- grpc_channel_args *new_args_from_connector = NULL;
+ grpc_channel_args* new_args_from_connector = NULL;
const grpc_security_status security_status =
grpc_channel_credentials_create_security_connector(
exec_ctx, channel_credentials, target_name_to_check, args->args,
@@ -120,7 +120,7 @@ static grpc_subchannel_args *get_secure_naming_subchannel_args(
grpc_arg new_security_connector_arg =
grpc_security_connector_to_arg(&subchannel_security_connector->base);
- grpc_channel_args *new_args = grpc_channel_args_copy_and_add(
+ grpc_channel_args* new_args = grpc_channel_args_copy_and_add(
new_args_from_connector != NULL ? new_args_from_connector : args->args,
&new_security_connector_arg, 1);
GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, &subchannel_security_connector->base,
@@ -128,17 +128,17 @@ static grpc_subchannel_args *get_secure_naming_subchannel_args(
if (new_args_from_connector != NULL) {
grpc_channel_args_destroy(exec_ctx, new_args_from_connector);
}
- grpc_subchannel_args *final_sc_args =
- (grpc_subchannel_args *)gpr_malloc(sizeof(*final_sc_args));
+ grpc_subchannel_args* final_sc_args =
+ (grpc_subchannel_args*)gpr_malloc(sizeof(*final_sc_args));
memcpy(final_sc_args, args, sizeof(*args));
final_sc_args->args = new_args;
return final_sc_args;
}
-static grpc_subchannel *client_channel_factory_create_subchannel(
- grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory,
- const grpc_subchannel_args *args) {
- grpc_subchannel_args *subchannel_args =
+static grpc_subchannel* client_channel_factory_create_subchannel(
+ grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* cc_factory,
+ const grpc_subchannel_args* args) {
+ grpc_subchannel_args* subchannel_args =
get_secure_naming_subchannel_args(exec_ctx, args);
if (subchannel_args == NULL) {
gpr_log(
@@ -146,33 +146,33 @@ static grpc_subchannel *client_channel_factory_create_subchannel(
"Failed to create subchannel arguments during subchannel creation.");
return NULL;
}
- grpc_connector *connector = grpc_chttp2_connector_create();
- grpc_subchannel *s =
+ grpc_connector* connector = grpc_chttp2_connector_create();
+ grpc_subchannel* s =
grpc_subchannel_create(exec_ctx, connector, subchannel_args);
grpc_connector_unref(exec_ctx, connector);
grpc_channel_args_destroy(exec_ctx,
- (grpc_channel_args *)subchannel_args->args);
+ (grpc_channel_args*)subchannel_args->args);
gpr_free(subchannel_args);
return s;
}
-static grpc_channel *client_channel_factory_create_channel(
- grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory,
- const char *target, grpc_client_channel_type type,
- const grpc_channel_args *args) {
+static grpc_channel* client_channel_factory_create_channel(
+ grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* cc_factory,
+ const char* target, grpc_client_channel_type type,
+ const grpc_channel_args* args) {
if (target == NULL) {
gpr_log(GPR_ERROR, "cannot create channel with NULL target name");
return NULL;
}
// Add channel arg containing the server URI.
grpc_arg arg = grpc_channel_arg_string_create(
- (char *)GRPC_ARG_SERVER_URI,
+ (char*)GRPC_ARG_SERVER_URI,
grpc_resolver_factory_add_default_prefix_if_needed(exec_ctx, target));
- const char *to_remove[] = {GRPC_ARG_SERVER_URI};
- grpc_channel_args *new_args =
+ const char* to_remove[] = {GRPC_ARG_SERVER_URI};
+ grpc_channel_args* new_args =
grpc_channel_args_copy_and_add_and_remove(args, to_remove, 1, &arg, 1);
gpr_free(arg.value.string);
- grpc_channel *channel = grpc_channel_create(exec_ctx, target, new_args,
+ grpc_channel* channel = grpc_channel_create(exec_ctx, target, new_args,
GRPC_CLIENT_CHANNEL, NULL);
grpc_channel_args_destroy(exec_ctx, new_args);
return channel;
@@ -190,24 +190,24 @@ static grpc_client_channel_factory client_channel_factory = {
// Asynchronously: - resolve target
// - connect to it (trying alternatives as presented)
// - perform handshakes
-grpc_channel *grpc_secure_channel_create(grpc_channel_credentials *creds,
- const char *target,
- const grpc_channel_args *args,
- void *reserved) {
+grpc_channel* grpc_secure_channel_create(grpc_channel_credentials* creds,
+ const char* target,
+ const grpc_channel_args* args,
+ void* reserved) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
GRPC_API_TRACE(
"grpc_secure_channel_create(creds=%p, target=%s, args=%p, "
"reserved=%p)",
- 4, ((void *)creds, target, (void *)args, (void *)reserved));
+ 4, ((void*)creds, target, (void*)args, (void*)reserved));
GPR_ASSERT(reserved == NULL);
- grpc_channel *channel = NULL;
+ grpc_channel* channel = NULL;
if (creds != NULL) {
// Add channel args containing the client channel factory and channel
// credentials.
grpc_arg args_to_add[] = {
grpc_client_channel_factory_create_channel_arg(&client_channel_factory),
grpc_channel_credentials_to_arg(creds)};
- grpc_channel_args *new_args = grpc_channel_args_copy_and_add(
+ grpc_channel_args* new_args = grpc_channel_args_copy_and_add(
args, args_to_add, GPR_ARRAY_SIZE(args_to_add));
// Create channel.
channel = client_channel_factory_create_channel(
diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.cc b/src/core/ext/transport/chttp2/server/chttp2_server.cc
index 7ac7f4ece8..98683acc59 100644
--- a/src/core/ext/transport/chttp2/server/chttp2_server.cc
+++ b/src/core/ext/transport/chttp2/server/chttp2_server.cc
@@ -42,31 +42,31 @@
#include "src/core/lib/surface/server.h"
typedef struct {
- grpc_server *server;
- grpc_tcp_server *tcp_server;
- grpc_channel_args *args;
+ grpc_server* server;
+ grpc_tcp_server* tcp_server;
+ grpc_channel_args* args;
gpr_mu mu;
bool shutdown;
grpc_closure tcp_server_shutdown_complete;
- grpc_closure *server_destroy_listener_done;
- grpc_handshake_manager *pending_handshake_mgrs;
+ grpc_closure* server_destroy_listener_done;
+ grpc_handshake_manager* pending_handshake_mgrs;
} server_state;
typedef struct {
- server_state *svr_state;
- grpc_pollset *accepting_pollset;
- grpc_tcp_server_acceptor *acceptor;
- grpc_handshake_manager *handshake_mgr;
+ server_state* svr_state;
+ grpc_pollset* accepting_pollset;
+ grpc_tcp_server_acceptor* acceptor;
+ grpc_handshake_manager* handshake_mgr;
} server_connection_state;
-static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_handshaker_args *args = (grpc_handshaker_args *)arg;
- server_connection_state *connection_state =
- (server_connection_state *)args->user_data;
+static void on_handshake_done(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_error* error) {
+ grpc_handshaker_args* args = (grpc_handshaker_args*)arg;
+ server_connection_state* connection_state =
+ (server_connection_state*)args->user_data;
gpr_mu_lock(&connection_state->svr_state->mu);
if (error != GRPC_ERROR_NONE || connection_state->svr_state->shutdown) {
- const char *error_str = grpc_error_string(error);
+ const char* error_str = grpc_error_string(error);
gpr_log(GPR_DEBUG, "Handshaking failed: %s", error_str);
if (error == GRPC_ERROR_NONE && args->endpoint != NULL) {
@@ -87,7 +87,7 @@ static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
// handshaker may have handed off the connection to some external
// code, so we can just clean up here without creating a transport.
if (args->endpoint != NULL) {
- grpc_transport *transport =
+ grpc_transport* transport =
grpc_create_chttp2_transport(exec_ctx, args->args, args->endpoint, 0);
grpc_server_setup_transport(
exec_ctx, connection_state->svr_state->server, transport,
@@ -107,10 +107,10 @@ static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
gpr_free(connection_state);
}
-static void on_accept(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
- grpc_pollset *accepting_pollset,
- grpc_tcp_server_acceptor *acceptor) {
- server_state *state = (server_state *)arg;
+static void on_accept(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp,
+ grpc_pollset* accepting_pollset,
+ grpc_tcp_server_acceptor* acceptor) {
+ server_state* state = (server_state*)arg;
gpr_mu_lock(&state->mu);
if (state->shutdown) {
gpr_mu_unlock(&state->mu);
@@ -119,13 +119,13 @@ static void on_accept(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
gpr_free(acceptor);
return;
}
- grpc_handshake_manager *handshake_mgr = grpc_handshake_manager_create();
+ grpc_handshake_manager* handshake_mgr = grpc_handshake_manager_create();
grpc_handshake_manager_pending_list_add(&state->pending_handshake_mgrs,
handshake_mgr);
gpr_mu_unlock(&state->mu);
grpc_tcp_server_ref(state->tcp_server);
- server_connection_state *connection_state =
- (server_connection_state *)gpr_malloc(sizeof(*connection_state));
+ server_connection_state* connection_state =
+ (server_connection_state*)gpr_malloc(sizeof(*connection_state));
connection_state->svr_state = state;
connection_state->accepting_pollset = accepting_pollset;
connection_state->acceptor = acceptor;
@@ -142,10 +142,10 @@ static void on_accept(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
}
/* Server callback: start listening on our ports */
-static void server_start_listener(grpc_exec_ctx *exec_ctx, grpc_server *server,
- void *arg, grpc_pollset **pollsets,
+static void server_start_listener(grpc_exec_ctx* exec_ctx, grpc_server* server,
+ void* arg, grpc_pollset** pollsets,
size_t pollset_count) {
- server_state *state = (server_state *)arg;
+ server_state* state = (server_state*)arg;
gpr_mu_lock(&state->mu);
state->shutdown = false;
gpr_mu_unlock(&state->mu);
@@ -153,12 +153,12 @@ static void server_start_listener(grpc_exec_ctx *exec_ctx, grpc_server *server,
on_accept, state);
}
-static void tcp_server_shutdown_complete(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- server_state *state = (server_state *)arg;
+static void tcp_server_shutdown_complete(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_error* error) {
+ server_state* state = (server_state*)arg;
/* ensure all threads have unlocked */
gpr_mu_lock(&state->mu);
- grpc_closure *destroy_done = state->server_destroy_listener_done;
+ grpc_closure* destroy_done = state->server_destroy_listener_done;
GPR_ASSERT(state->shutdown);
grpc_handshake_manager_pending_list_shutdown_all(
exec_ctx, state->pending_handshake_mgrs, GRPC_ERROR_REF(error));
@@ -177,31 +177,31 @@ static void tcp_server_shutdown_complete(grpc_exec_ctx *exec_ctx, void *arg,
/* Server callback: destroy the tcp listener (so we don't generate further
callbacks) */
-static void server_destroy_listener(grpc_exec_ctx *exec_ctx,
- grpc_server *server, void *arg,
- grpc_closure *destroy_done) {
- server_state *state = (server_state *)arg;
+static void server_destroy_listener(grpc_exec_ctx* exec_ctx,
+ grpc_server* server, void* arg,
+ grpc_closure* destroy_done) {
+ server_state* state = (server_state*)arg;
gpr_mu_lock(&state->mu);
state->shutdown = true;
state->server_destroy_listener_done = destroy_done;
- grpc_tcp_server *tcp_server = state->tcp_server;
+ grpc_tcp_server* tcp_server = state->tcp_server;
gpr_mu_unlock(&state->mu);
grpc_tcp_server_shutdown_listeners(exec_ctx, tcp_server);
grpc_tcp_server_unref(exec_ctx, tcp_server);
}
-grpc_error *grpc_chttp2_server_add_port(grpc_exec_ctx *exec_ctx,
- grpc_server *server, const char *addr,
- grpc_channel_args *args,
- int *port_num) {
- grpc_resolved_addresses *resolved = NULL;
- grpc_tcp_server *tcp_server = NULL;
+grpc_error* grpc_chttp2_server_add_port(grpc_exec_ctx* exec_ctx,
+ grpc_server* server, const char* addr,
+ grpc_channel_args* args,
+ int* port_num) {
+ grpc_resolved_addresses* resolved = NULL;
+ grpc_tcp_server* tcp_server = NULL;
size_t i;
size_t count = 0;
int port_temp;
- grpc_error *err = GRPC_ERROR_NONE;
- server_state *state = NULL;
- grpc_error **errors = NULL;
+ grpc_error* err = GRPC_ERROR_NONE;
+ server_state* state = NULL;
+ grpc_error** errors = NULL;
size_t naddrs = 0;
*port_num = -1;
@@ -211,7 +211,7 @@ grpc_error *grpc_chttp2_server_add_port(grpc_exec_ctx *exec_ctx,
if (err != GRPC_ERROR_NONE) {
goto error;
}
- state = (server_state *)gpr_zalloc(sizeof(*state));
+ state = (server_state*)gpr_zalloc(sizeof(*state));
GRPC_CLOSURE_INIT(&state->tcp_server_shutdown_complete,
tcp_server_shutdown_complete, state,
grpc_schedule_on_exec_ctx);
@@ -228,7 +228,7 @@ grpc_error *grpc_chttp2_server_add_port(grpc_exec_ctx *exec_ctx,
gpr_mu_init(&state->mu);
naddrs = resolved->naddrs;
- errors = (grpc_error **)gpr_malloc(sizeof(*errors) * naddrs);
+ errors = (grpc_error**)gpr_malloc(sizeof(*errors) * naddrs);
for (i = 0; i < naddrs; i++) {
errors[i] =
grpc_tcp_server_add_port(tcp_server, &resolved->addrs[i], &port_temp);
@@ -242,21 +242,22 @@ grpc_error *grpc_chttp2_server_add_port(grpc_exec_ctx *exec_ctx,
}
}
if (count == 0) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "No address added out of total %" PRIuPTR " resolved",
naddrs);
err = GRPC_ERROR_CREATE_REFERENCING_FROM_COPIED_STRING(msg, errors, naddrs);
gpr_free(msg);
goto error;
} else if (count != naddrs) {
- char *msg;
- gpr_asprintf(&msg, "Only %" PRIuPTR
- " addresses added out of total %" PRIuPTR " resolved",
+ char* msg;
+ gpr_asprintf(&msg,
+ "Only %" PRIuPTR " addresses added out of total %" PRIuPTR
+ " resolved",
count, naddrs);
err = GRPC_ERROR_CREATE_REFERENCING_FROM_COPIED_STRING(msg, errors, naddrs);
gpr_free(msg);
- const char *warning_message = grpc_error_string(err);
+ const char* warning_message = grpc_error_string(err);
gpr_log(GPR_INFO, "WARNING: %s", warning_message);
/* we managed to bind some addresses: continue */
diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.h b/src/core/ext/transport/chttp2/server/chttp2_server.h
index 2ac155160f..4e0e7aa617 100644
--- a/src/core/ext/transport/chttp2/server/chttp2_server.h
+++ b/src/core/ext/transport/chttp2/server/chttp2_server.h
@@ -29,9 +29,9 @@ extern "C" {
/// Adds a port to \a server. Sets \a port_num to the port number.
/// Takes ownership of \a args.
-grpc_error *grpc_chttp2_server_add_port(grpc_exec_ctx *exec_ctx,
- grpc_server *server, const char *addr,
- grpc_channel_args *args, int *port_num);
+grpc_error* grpc_chttp2_server_add_port(grpc_exec_ctx* exec_ctx,
+ grpc_server* server, const char* addr,
+ grpc_channel_args* args, int* port_num);
#ifdef __cplusplus
}
diff --git a/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc b/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc
index d42b2d123e..8984896538 100644
--- a/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc
+++ b/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc
@@ -25,16 +25,16 @@
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/server.h"
-int grpc_server_add_insecure_http2_port(grpc_server *server, const char *addr) {
+int grpc_server_add_insecure_http2_port(grpc_server* server, const char* addr) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
int port_num = 0;
GRPC_API_TRACE("grpc_server_add_insecure_http2_port(server=%p, addr=%s)", 2,
(server, addr));
- grpc_error *err = grpc_chttp2_server_add_port(
+ grpc_error* err = grpc_chttp2_server_add_port(
&exec_ctx, server, addr,
grpc_channel_args_copy(grpc_server_get_channel_args(server)), &port_num);
if (err != GRPC_ERROR_NONE) {
- const char *msg = grpc_error_string(err);
+ const char* msg = grpc_error_string(err);
gpr_log(GPR_ERROR, "%s", msg);
GRPC_ERROR_UNREF(err);
diff --git a/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc b/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc
index e647067f73..e37d69e5e9 100644
--- a/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc
+++ b/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc
@@ -34,25 +34,25 @@
#include "src/core/lib/surface/completion_queue.h"
#include "src/core/lib/surface/server.h"
-void grpc_server_add_insecure_channel_from_fd(grpc_server *server,
- void *reserved, int fd) {
+void grpc_server_add_insecure_channel_from_fd(grpc_server* server,
+ void* reserved, int fd) {
GPR_ASSERT(reserved == NULL);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- char *name;
+ char* name;
gpr_asprintf(&name, "fd:%d", fd);
- grpc_endpoint *server_endpoint =
+ grpc_endpoint* server_endpoint =
grpc_tcp_create(&exec_ctx, grpc_fd_create(fd, name),
grpc_server_get_channel_args(server), name);
gpr_free(name);
- const grpc_channel_args *server_args = grpc_server_get_channel_args(server);
- grpc_transport *transport = grpc_create_chttp2_transport(
+ const grpc_channel_args* server_args = grpc_server_get_channel_args(server);
+ grpc_transport* transport = grpc_create_chttp2_transport(
&exec_ctx, server_args, server_endpoint, 0 /* is_client */);
- grpc_pollset **pollsets;
+ grpc_pollset** pollsets;
size_t num_pollsets = 0;
grpc_server_get_pollsets(server, &pollsets, &num_pollsets);
@@ -67,8 +67,8 @@ void grpc_server_add_insecure_channel_from_fd(grpc_server *server,
#else // !GPR_SUPPORT_CHANNELS_FROM_FD
-void grpc_server_add_insecure_channel_from_fd(grpc_server *server,
- void *reserved, int fd) {
+void grpc_server_add_insecure_channel_from_fd(grpc_server* server,
+ void* reserved, int fd) {
GPR_ASSERT(0);
}
diff --git a/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc b/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc
index e74a138d23..4b2e348780 100644
--- a/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc
+++ b/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc
@@ -34,14 +34,14 @@
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/server.h"
-int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr,
- grpc_server_credentials *creds) {
+int grpc_server_add_secure_http2_port(grpc_server* server, const char* addr,
+ grpc_server_credentials* creds) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_error *err = GRPC_ERROR_NONE;
- grpc_server_security_connector *sc = NULL;
+ grpc_error* err = GRPC_ERROR_NONE;
+ grpc_server_security_connector* sc = NULL;
int port_num = 0;
grpc_security_status status;
- grpc_channel_args *args = NULL;
+ grpc_channel_args* args = NULL;
GRPC_API_TRACE(
"grpc_server_add_secure_http2_port("
"server=%p, addr=%s, creds=%p)",
@@ -55,7 +55,7 @@ int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr,
status =
grpc_server_credentials_create_security_connector(&exec_ctx, creds, &sc);
if (status != GRPC_SECURITY_OK) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg,
"Unable to create secure server with credentials of type %s.",
creds->type);
@@ -79,7 +79,7 @@ done:
}
grpc_exec_ctx_finish(&exec_ctx);
if (err != GRPC_ERROR_NONE) {
- const char *msg = grpc_error_string(err);
+ const char* msg = grpc_error_string(err);
gpr_log(GPR_ERROR, "%s", msg);
GRPC_ERROR_UNREF(err);
diff --git a/src/core/ext/transport/chttp2/transport/bin_decoder.cc b/src/core/ext/transport/chttp2/transport/bin_decoder.cc
index 5a99cbeffc..3ccae7afc3 100644
--- a/src/core/ext/transport/chttp2/transport/bin_decoder.cc
+++ b/src/core/ext/transport/chttp2/transport/bin_decoder.cc
@@ -49,7 +49,7 @@ static uint8_t decode_table[] = {
static const uint8_t tail_xtra[4] = {0, 0, 1, 2};
-static bool input_is_valid(uint8_t *input_ptr, size_t length) {
+static bool input_is_valid(uint8_t* input_ptr, size_t length) {
size_t i;
for (i = 0; i < length; ++i) {
@@ -75,7 +75,7 @@ static bool input_is_valid(uint8_t *input_ptr, size_t length) {
#define COMPOSE_OUTPUT_BYTE_2(input_ptr) \
(uint8_t)((decode_table[input_ptr[2]] << 6) | decode_table[input_ptr[3]])
-bool grpc_base64_decode_partial(struct grpc_base64_decode_context *ctx) {
+bool grpc_base64_decode_partial(struct grpc_base64_decode_context* ctx) {
size_t input_tail;
if (ctx->input_cur > ctx->input_end || ctx->output_cur > ctx->output_end) {
@@ -130,7 +130,7 @@ bool grpc_base64_decode_partial(struct grpc_base64_decode_context *ctx) {
return true;
}
-grpc_slice grpc_chttp2_base64_decode(grpc_exec_ctx *exec_ctx,
+grpc_slice grpc_chttp2_base64_decode(grpc_exec_ctx* exec_ctx,
grpc_slice input) {
size_t input_length = GRPC_SLICE_LENGTH(input);
size_t output_length = input_length / 4 * 3;
@@ -147,7 +147,7 @@ grpc_slice grpc_chttp2_base64_decode(grpc_exec_ctx *exec_ctx,
}
if (input_length > 0) {
- uint8_t *input_end = GRPC_SLICE_END_PTR(input);
+ uint8_t* input_end = GRPC_SLICE_END_PTR(input);
if (*(--input_end) == '=') {
output_length--;
if (*(--input_end) == '=') {
@@ -164,7 +164,7 @@ grpc_slice grpc_chttp2_base64_decode(grpc_exec_ctx *exec_ctx,
ctx.contains_tail = false;
if (!grpc_base64_decode_partial(&ctx)) {
- char *s = grpc_slice_to_c_string(input);
+ char* s = grpc_slice_to_c_string(input);
gpr_log(GPR_ERROR, "Base64 decoding failed, input string:\n%s\n", s);
gpr_free(s);
grpc_slice_unref_internal(exec_ctx, output);
@@ -175,7 +175,7 @@ grpc_slice grpc_chttp2_base64_decode(grpc_exec_ctx *exec_ctx,
return output;
}
-grpc_slice grpc_chttp2_base64_decode_with_length(grpc_exec_ctx *exec_ctx,
+grpc_slice grpc_chttp2_base64_decode_with_length(grpc_exec_ctx* exec_ctx,
grpc_slice input,
size_t output_length) {
size_t input_length = GRPC_SLICE_LENGTH(input);
@@ -210,7 +210,7 @@ grpc_slice grpc_chttp2_base64_decode_with_length(grpc_exec_ctx *exec_ctx,
ctx.contains_tail = true;
if (!grpc_base64_decode_partial(&ctx)) {
- char *s = grpc_slice_to_c_string(input);
+ char* s = grpc_slice_to_c_string(input);
gpr_log(GPR_ERROR, "Base64 decoding failed, input string:\n%s\n", s);
gpr_free(s);
grpc_slice_unref_internal(exec_ctx, output);
diff --git a/src/core/ext/transport/chttp2/transport/bin_decoder.h b/src/core/ext/transport/chttp2/transport/bin_decoder.h
index 1c0b2b7e97..a9c4c9a0f6 100644
--- a/src/core/ext/transport/chttp2/transport/bin_decoder.h
+++ b/src/core/ext/transport/chttp2/transport/bin_decoder.h
@@ -28,10 +28,10 @@ extern "C" {
struct grpc_base64_decode_context {
/* input/output: */
- uint8_t *input_cur;
- uint8_t *input_end;
- uint8_t *output_cur;
- uint8_t *output_end;
+ uint8_t* input_cur;
+ uint8_t* input_end;
+ uint8_t* output_cur;
+ uint8_t* output_end;
/* Indicate if the decoder should handle the tail of input data*/
bool contains_tail;
};
@@ -40,16 +40,16 @@ struct grpc_base64_decode_context {
or output_end is reached. When input_end is reached, (input_end - input_cur)
is less than 4. When output_end is reached, (output_end - output_cur) is less
than 3. Returns false if decoding is failed. */
-bool grpc_base64_decode_partial(struct grpc_base64_decode_context *ctx);
+bool grpc_base64_decode_partial(struct grpc_base64_decode_context* ctx);
/* base64 decode a slice with pad chars. Returns a new slice, does not take
ownership of the input. Returns an empty slice if decoding is failed. */
-grpc_slice grpc_chttp2_base64_decode(grpc_exec_ctx *exec_ctx, grpc_slice input);
+grpc_slice grpc_chttp2_base64_decode(grpc_exec_ctx* exec_ctx, grpc_slice input);
/* base64 decode a slice without pad chars, data length is needed. Returns a new
slice, does not take ownership of the input. Returns an empty slice if
decoding is failed. */
-grpc_slice grpc_chttp2_base64_decode_with_length(grpc_exec_ctx *exec_ctx,
+grpc_slice grpc_chttp2_base64_decode_with_length(grpc_exec_ctx* exec_ctx,
grpc_slice input,
size_t output_length);
diff --git a/src/core/ext/transport/chttp2/transport/bin_encoder.cc b/src/core/ext/transport/chttp2/transport/bin_encoder.cc
index 42d481b3c0..09f984d7b2 100644
--- a/src/core/ext/transport/chttp2/transport/bin_encoder.cc
+++ b/src/core/ext/transport/chttp2/transport/bin_encoder.cc
@@ -52,8 +52,8 @@ grpc_slice grpc_chttp2_base64_encode(grpc_slice input) {
size_t tail_case = input_length % 3;
size_t output_length = input_triplets * 4 + tail_xtra[tail_case];
grpc_slice output = GRPC_SLICE_MALLOC(output_length);
- uint8_t *in = GRPC_SLICE_START_PTR(input);
- char *out = (char *)GRPC_SLICE_START_PTR(output);
+ uint8_t* in = GRPC_SLICE_START_PTR(input);
+ char* out = (char*)GRPC_SLICE_START_PTR(output);
size_t i;
/* encode full triplets */
@@ -85,15 +85,15 @@ grpc_slice grpc_chttp2_base64_encode(grpc_slice input) {
break;
}
- GPR_ASSERT(out == (char *)GRPC_SLICE_END_PTR(output));
+ GPR_ASSERT(out == (char*)GRPC_SLICE_END_PTR(output));
GPR_ASSERT(in == GRPC_SLICE_END_PTR(input));
return output;
}
grpc_slice grpc_chttp2_huffman_compress(grpc_slice input) {
size_t nbits;
- uint8_t *in;
- uint8_t *out;
+ uint8_t* in;
+ uint8_t* out;
grpc_slice output;
uint32_t temp = 0;
uint32_t temp_length = 0;
@@ -136,17 +136,17 @@ grpc_slice grpc_chttp2_huffman_compress(grpc_slice input) {
typedef struct {
uint32_t temp;
uint32_t temp_length;
- uint8_t *out;
+ uint8_t* out;
} huff_out;
-static void enc_flush_some(huff_out *out) {
+static void enc_flush_some(huff_out* out) {
while (out->temp_length > 8) {
out->temp_length -= 8;
*out->out++ = (uint8_t)(out->temp >> out->temp_length);
}
}
-static void enc_add2(huff_out *out, uint8_t a, uint8_t 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)) |
@@ -155,7 +155,7 @@ static void enc_add2(huff_out *out, uint8_t a, uint8_t b) {
enc_flush_some(out);
}
-static void enc_add1(huff_out *out, uint8_t 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;
@@ -170,8 +170,8 @@ grpc_slice grpc_chttp2_base64_encode_and_huffman_compress(grpc_slice input) {
size_t max_output_bits = 11 * output_syms;
size_t max_output_length = max_output_bits / 8 + (max_output_bits % 8 != 0);
grpc_slice output = GRPC_SLICE_MALLOC(max_output_length);
- uint8_t *in = GRPC_SLICE_START_PTR(input);
- uint8_t *start_out = GRPC_SLICE_START_PTR(output);
+ uint8_t* in = GRPC_SLICE_START_PTR(input);
+ uint8_t* start_out = GRPC_SLICE_START_PTR(output);
huff_out out;
size_t i;
diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc
index de62995ecf..a6ec7bb1d2 100644
--- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc
+++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc
@@ -92,98 +92,99 @@ static int g_default_max_ping_strikes = DEFAULT_MAX_PING_STRIKES;
#define MAX_CLIENT_STREAM_ID 0x7fffffffu
grpc_core::TraceFlag grpc_http_trace(false, "http");
-grpc_core::DebugOnlyTraceFlag grpc_trace_chttp2_refcount(false,
- "chttp2_refcount");
+#ifndef NDEBUG
+grpc_core::TraceFlag grpc_trace_chttp2_refcount(false, "chttp2_refcount");
+#endif
/* forward declarations of various callbacks that we'll build closures around */
-static void write_action_begin_locked(grpc_exec_ctx *exec_ctx, void *t,
- grpc_error *error);
-static void write_action(grpc_exec_ctx *exec_ctx, void *t, grpc_error *error);
-static void write_action_end_locked(grpc_exec_ctx *exec_ctx, void *t,
- grpc_error *error);
+static void write_action_begin_locked(grpc_exec_ctx* exec_ctx, void* t,
+ grpc_error* error);
+static void write_action(grpc_exec_ctx* exec_ctx, void* t, grpc_error* error);
+static void write_action_end_locked(grpc_exec_ctx* exec_ctx, void* t,
+ grpc_error* error);
-static void read_action_locked(grpc_exec_ctx *exec_ctx, void *t,
- grpc_error *error);
+static void read_action_locked(grpc_exec_ctx* exec_ctx, void* t,
+ grpc_error* error);
-static void complete_fetch_locked(grpc_exec_ctx *exec_ctx, void *gs,
- grpc_error *error);
+static void complete_fetch_locked(grpc_exec_ctx* exec_ctx, void* gs,
+ grpc_error* error);
/** Set a transport level setting, and push it to our peer */
-static void queue_setting_update(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+static void queue_setting_update(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
grpc_chttp2_setting_id id, uint32_t value);
-static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_chttp2_stream *s, grpc_error *error);
+static void close_from_api(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s, grpc_error* error);
/** Start new streams that have been created if we can */
-static void maybe_start_some_streams(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
+static void maybe_start_some_streams(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t);
-static void connectivity_state_set(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+static void connectivity_state_set(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
grpc_connectivity_state state,
- grpc_error *error, const char *reason);
+ grpc_error* error, const char* reason);
-static void incoming_byte_stream_destroy_locked(grpc_exec_ctx *exec_ctx,
- void *byte_stream,
- grpc_error *error_ignored);
+static void incoming_byte_stream_destroy_locked(grpc_exec_ctx* exec_ctx,
+ void* byte_stream,
+ grpc_error* error_ignored);
static void incoming_byte_stream_publish_error(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs,
- grpc_error *error);
-static void incoming_byte_stream_unref(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_incoming_byte_stream *bs);
-
-static void benign_reclaimer_locked(grpc_exec_ctx *exec_ctx, void *t,
- grpc_error *error);
-static void destructive_reclaimer_locked(grpc_exec_ctx *exec_ctx, void *t,
- grpc_error *error);
-
-static void post_benign_reclaimer(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
-static void post_destructive_reclaimer(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
-
-static void close_transport_locked(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t, grpc_error *error);
-static void end_all_the_calls(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_error *error);
-
-static void schedule_bdp_ping_locked(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
-static void start_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp,
- grpc_error *error);
-static void finish_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp,
- grpc_error *error);
-static void next_bdp_ping_timer_expired_locked(grpc_exec_ctx *exec_ctx,
- void *tp, grpc_error *error);
-
-static void cancel_pings(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_error *error);
-static void send_ping_locked(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_closure *on_initiate,
- grpc_closure *on_complete);
-static void retry_initiate_ping_locked(grpc_exec_ctx *exec_ctx, void *tp,
- grpc_error *error);
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_byte_stream* bs,
+ grpc_error* error);
+static void incoming_byte_stream_unref(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_incoming_byte_stream* bs);
+
+static void benign_reclaimer_locked(grpc_exec_ctx* exec_ctx, void* t,
+ grpc_error* error);
+static void destructive_reclaimer_locked(grpc_exec_ctx* exec_ctx, void* t,
+ grpc_error* error);
+
+static void post_benign_reclaimer(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t);
+static void post_destructive_reclaimer(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t);
+
+static void close_transport_locked(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t, grpc_error* error);
+static void end_all_the_calls(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
+ grpc_error* error);
+
+static void schedule_bdp_ping_locked(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t);
+static void start_bdp_ping_locked(grpc_exec_ctx* exec_ctx, void* tp,
+ grpc_error* error);
+static void finish_bdp_ping_locked(grpc_exec_ctx* exec_ctx, void* tp,
+ grpc_error* error);
+static void next_bdp_ping_timer_expired_locked(grpc_exec_ctx* exec_ctx,
+ void* tp, grpc_error* error);
+
+static void cancel_pings(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
+ grpc_error* error);
+static void send_ping_locked(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
+ grpc_closure* on_initiate,
+ grpc_closure* on_complete);
+static void retry_initiate_ping_locked(grpc_exec_ctx* exec_ctx, void* tp,
+ grpc_error* error);
/** keepalive-relevant functions */
-static void init_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error);
-static void start_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error);
-static void finish_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error);
-static void keepalive_watchdog_fired_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error);
-
-static void reset_byte_stream(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error);
+static void init_keepalive_ping_locked(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_error* error);
+static void start_keepalive_ping_locked(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_error* error);
+static void finish_keepalive_ping_locked(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_error* error);
+static void keepalive_watchdog_fired_locked(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_error* error);
+
+static void reset_byte_stream(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_error* error);
/*******************************************************************************
* CONSTRUCTION/DESTRUCTION/REFCOUNTING
*/
-static void destruct_transport(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
+static void destruct_transport(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t) {
size_t i;
grpc_endpoint_destroy(exec_ctx, t->ep);
@@ -202,6 +203,8 @@ static void destruct_transport(grpc_exec_ctx *exec_ctx,
GPR_ASSERT(t->lists[i].tail == NULL);
}
+ GRPC_ERROR_UNREF(t->goaway_error);
+
GPR_ASSERT(grpc_chttp2_stream_map_size(&t->stream_map) == 0);
grpc_chttp2_stream_map_destroy(&t->stream_map);
@@ -213,7 +216,7 @@ static void destruct_transport(grpc_exec_ctx *exec_ctx,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Transport destroyed"));
while (t->write_cb_pool) {
- grpc_chttp2_write_cb *next = t->write_cb_pool->next;
+ grpc_chttp2_write_cb* next = t->write_cb_pool->next;
gpr_free(t->write_cb_pool);
t->write_cb_pool = next;
}
@@ -227,9 +230,9 @@ static void destruct_transport(grpc_exec_ctx *exec_ctx,
}
#ifndef NDEBUG
-void grpc_chttp2_unref_transport(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t, const char *reason,
- const char *file, int line) {
+void grpc_chttp2_unref_transport(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t, const char* reason,
+ const char* file, int line) {
if (grpc_trace_chttp2_refcount.enabled()) {
gpr_atm val = gpr_atm_no_barrier_load(&t->refs.count);
gpr_log(GPR_DEBUG, "chttp2:unref:%p %" PRIdPTR "->%" PRIdPTR " %s [%s:%d]",
@@ -239,8 +242,8 @@ void grpc_chttp2_unref_transport(grpc_exec_ctx *exec_ctx,
destruct_transport(exec_ctx, t);
}
-void grpc_chttp2_ref_transport(grpc_chttp2_transport *t, const char *reason,
- const char *file, int line) {
+void grpc_chttp2_ref_transport(grpc_chttp2_transport* t, const char* reason,
+ const char* file, int line) {
if (grpc_trace_chttp2_refcount.enabled()) {
gpr_atm val = gpr_atm_no_barrier_load(&t->refs.count);
gpr_log(GPR_DEBUG, "chttp2: ref:%p %" PRIdPTR "->%" PRIdPTR " %s [%s:%d]",
@@ -249,20 +252,20 @@ void grpc_chttp2_ref_transport(grpc_chttp2_transport *t, const char *reason,
gpr_ref(&t->refs);
}
#else
-void grpc_chttp2_unref_transport(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
+void grpc_chttp2_unref_transport(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t) {
if (!gpr_unref(&t->refs)) return;
destruct_transport(exec_ctx, t);
}
-void grpc_chttp2_ref_transport(grpc_chttp2_transport *t) { gpr_ref(&t->refs); }
+void grpc_chttp2_ref_transport(grpc_chttp2_transport* t) { gpr_ref(&t->refs); }
#endif
-static const grpc_transport_vtable *get_vtable(void);
+static const grpc_transport_vtable* get_vtable(void);
-static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- const grpc_channel_args *channel_args,
- grpc_endpoint *ep, bool is_client) {
+static void init_transport(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
+ const grpc_channel_args* channel_args,
+ grpc_endpoint* ep, bool is_client) {
size_t i;
int j;
@@ -317,6 +320,7 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
keepalive_watchdog_fired_locked, t,
grpc_combiner_scheduler(t->combiner));
+ t->goaway_error = GRPC_ERROR_NONE;
grpc_chttp2_goaway_parser_init(&t->goaway_parser);
grpc_chttp2_hpack_parser_init(exec_ctx, &t->hpack_parser);
@@ -491,7 +495,7 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
}
} else {
static const struct {
- const char *channel_arg_name;
+ const char* channel_arg_name;
grpc_chttp2_setting_id setting_id;
grpc_integer_options integer_options;
bool availability[2] /* server, client */;
@@ -577,9 +581,9 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
post_benign_reclaimer(exec_ctx, t);
}
-static void destroy_transport_locked(grpc_exec_ctx *exec_ctx, void *tp,
- grpc_error *error) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)tp;
+static void destroy_transport_locked(grpc_exec_ctx* exec_ctx, void* tp,
+ grpc_error* error) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
t->destroying = 1;
close_transport_locked(
exec_ctx, t,
@@ -589,17 +593,17 @@ static void destroy_transport_locked(grpc_exec_ctx *exec_ctx, void *tp,
GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "destroy");
}
-static void destroy_transport(grpc_exec_ctx *exec_ctx, grpc_transport *gt) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt;
+static void destroy_transport(grpc_exec_ctx* exec_ctx, grpc_transport* gt) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
GRPC_CLOSURE_SCHED(exec_ctx,
GRPC_CLOSURE_CREATE(destroy_transport_locked, t,
grpc_combiner_scheduler(t->combiner)),
GRPC_ERROR_NONE);
}
-static void close_transport_locked(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_error *error) {
+static void close_transport_locked(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
+ grpc_error* error) {
end_all_the_calls(exec_ctx, t, GRPC_ERROR_REF(error));
cancel_pings(exec_ctx, t, GRPC_ERROR_REF(error));
if (t->closed_with_error == GRPC_ERROR_NONE) {
@@ -642,7 +646,7 @@ static void close_transport_locked(grpc_exec_ctx *exec_ctx,
}
/* flush writable stream list to avoid dangling references */
- grpc_chttp2_stream *s;
+ grpc_chttp2_stream* s;
while (grpc_chttp2_list_pop_writable_stream(t, &s)) {
GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "chttp2_writing:close");
}
@@ -653,28 +657,28 @@ static void close_transport_locked(grpc_exec_ctx *exec_ctx,
}
#ifndef NDEBUG
-void grpc_chttp2_stream_ref(grpc_chttp2_stream *s, const char *reason) {
+void grpc_chttp2_stream_ref(grpc_chttp2_stream* s, const char* reason) {
grpc_stream_ref(s->refcount, reason);
}
-void grpc_chttp2_stream_unref(grpc_exec_ctx *exec_ctx, grpc_chttp2_stream *s,
- const char *reason) {
+void grpc_chttp2_stream_unref(grpc_exec_ctx* exec_ctx, grpc_chttp2_stream* s,
+ const char* reason) {
grpc_stream_unref(exec_ctx, s->refcount, reason);
}
#else
-void grpc_chttp2_stream_ref(grpc_chttp2_stream *s) {
+void grpc_chttp2_stream_ref(grpc_chttp2_stream* s) {
grpc_stream_ref(s->refcount);
}
-void grpc_chttp2_stream_unref(grpc_exec_ctx *exec_ctx, grpc_chttp2_stream *s) {
+void grpc_chttp2_stream_unref(grpc_exec_ctx* exec_ctx, grpc_chttp2_stream* s) {
grpc_stream_unref(exec_ctx, s->refcount);
}
#endif
-static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs, grpc_stream_refcount *refcount,
- const void *server_data, gpr_arena *arena) {
+static int init_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
+ grpc_stream* gs, grpc_stream_refcount* refcount,
+ const void* server_data, gpr_arena* arena) {
GPR_TIMER_BEGIN("init_stream", 0);
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt;
- grpc_chttp2_stream *s = (grpc_chttp2_stream *)gs;
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
+ grpc_chttp2_stream* s = (grpc_chttp2_stream*)gs;
s->t = t;
s->refcount = refcount;
@@ -714,10 +718,10 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
return 0;
}
-static void destroy_stream_locked(grpc_exec_ctx *exec_ctx, void *sp,
- grpc_error *error) {
- grpc_chttp2_stream *s = (grpc_chttp2_stream *)sp;
- grpc_chttp2_transport *t = s->t;
+static void destroy_stream_locked(grpc_exec_ctx* exec_ctx, void* sp,
+ grpc_error* error) {
+ grpc_chttp2_stream* s = (grpc_chttp2_stream*)sp;
+ grpc_chttp2_transport* t = s->t;
GPR_TIMER_BEGIN("destroy_stream", 0);
@@ -768,12 +772,12 @@ static void destroy_stream_locked(grpc_exec_ctx *exec_ctx, void *sp,
GRPC_CLOSURE_SCHED(exec_ctx, s->destroy_stream_arg, GRPC_ERROR_NONE);
}
-static void destroy_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs,
- grpc_closure *then_schedule_closure) {
+static void destroy_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
+ grpc_stream* gs,
+ grpc_closure* then_schedule_closure) {
GPR_TIMER_BEGIN("destroy_stream", 0);
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt;
- grpc_chttp2_stream *s = (grpc_chttp2_stream *)gs;
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
+ grpc_chttp2_stream* s = (grpc_chttp2_stream*)gs;
if (s->stream_compression_ctx != NULL) {
grpc_stream_compression_context_destroy(s->stream_compression_ctx);
@@ -786,29 +790,30 @@ static void destroy_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
s->destroy_stream_arg = then_schedule_closure;
GRPC_CLOSURE_SCHED(
- exec_ctx, GRPC_CLOSURE_INIT(&s->destroy_stream, destroy_stream_locked, s,
- grpc_combiner_scheduler(t->combiner)),
+ exec_ctx,
+ GRPC_CLOSURE_INIT(&s->destroy_stream, destroy_stream_locked, s,
+ grpc_combiner_scheduler(t->combiner)),
GRPC_ERROR_NONE);
GPR_TIMER_END("destroy_stream", 0);
}
-grpc_chttp2_stream *grpc_chttp2_parsing_lookup_stream(grpc_chttp2_transport *t,
+grpc_chttp2_stream* grpc_chttp2_parsing_lookup_stream(grpc_chttp2_transport* t,
uint32_t id) {
- return (grpc_chttp2_stream *)grpc_chttp2_stream_map_find(&t->stream_map, id);
+ return (grpc_chttp2_stream*)grpc_chttp2_stream_map_find(&t->stream_map, id);
}
-grpc_chttp2_stream *grpc_chttp2_parsing_accept_stream(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+grpc_chttp2_stream* grpc_chttp2_parsing_accept_stream(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
uint32_t id) {
if (t->channel_callback.accept_stream == NULL) {
return NULL;
}
- grpc_chttp2_stream *accepting;
+ grpc_chttp2_stream* accepting;
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 *)(uintptr_t)id);
+ &t->base, (void*)(uintptr_t)id);
t->accepting_stream = NULL;
return accepting;
}
@@ -817,7 +822,7 @@ grpc_chttp2_stream *grpc_chttp2_parsing_accept_stream(grpc_exec_ctx *exec_ctx,
* OUTPUT PROCESSING
*/
-static const char *write_state_name(grpc_chttp2_write_state st) {
+static const char* write_state_name(grpc_chttp2_write_state st) {
switch (st) {
case GRPC_CHTTP2_WRITE_STATE_IDLE:
return "IDLE";
@@ -829,8 +834,8 @@ static const char *write_state_name(grpc_chttp2_write_state st) {
GPR_UNREACHABLE_CODE(return "UNKNOWN");
}
-static void set_write_state(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_chttp2_write_state st, const char *reason) {
+static void set_write_state(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
+ grpc_chttp2_write_state st, const char* reason) {
GRPC_CHTTP2_IF_TRACING(gpr_log(GPR_DEBUG, "W:%p %s state %s -> %s [%s]", t,
t->is_client ? "CLIENT" : "SERVER",
write_state_name(t->write_state),
@@ -839,7 +844,7 @@ static void set_write_state(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
if (st == GRPC_CHTTP2_WRITE_STATE_IDLE) {
GRPC_CLOSURE_LIST_SCHED(exec_ctx, &t->run_after_write);
if (t->close_transport_on_writes_finished != NULL) {
- grpc_error *err = t->close_transport_on_writes_finished;
+ grpc_error* err = t->close_transport_on_writes_finished;
t->close_transport_on_writes_finished = NULL;
close_transport_locked(exec_ctx, t, err);
}
@@ -847,7 +852,7 @@ static void set_write_state(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
}
static void inc_initiate_write_reason(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_initiate_write_reason reason) {
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_initiate_write_reason reason) {
switch (reason) {
case GRPC_CHTTP2_INITIATE_WRITE_INITIAL_WRITE:
GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_INITIAL_WRITE(exec_ctx);
@@ -918,8 +923,8 @@ static void inc_initiate_write_reason(
}
}
-void grpc_chttp2_initiate_write(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+void grpc_chttp2_initiate_write(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
grpc_chttp2_initiate_write_reason reason) {
GPR_TIMER_BEGIN("grpc_chttp2_initiate_write", 0);
@@ -947,16 +952,16 @@ void grpc_chttp2_initiate_write(grpc_exec_ctx *exec_ctx,
GPR_TIMER_END("grpc_chttp2_initiate_write", 0);
}
-void grpc_chttp2_mark_stream_writable(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+void grpc_chttp2_mark_stream_writable(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
if (t->closed_with_error == GRPC_ERROR_NONE &&
grpc_chttp2_list_add_writable_stream(t, s)) {
GRPC_CHTTP2_STREAM_REF(s, "chttp2_writing:become");
}
}
-static grpc_closure_scheduler *write_scheduler(grpc_chttp2_transport *t,
+static grpc_closure_scheduler* write_scheduler(grpc_chttp2_transport* t,
bool early_results_scheduled,
bool partial_write) {
/* if it's not the first write in a batch, always offload to the executor:
@@ -984,7 +989,7 @@ static grpc_closure_scheduler *write_scheduler(grpc_chttp2_transport *t,
}
#define WRITE_STATE_TUPLE_TO_INT(p, i) (2 * (int)(p) + (int)(i))
-static const char *begin_writing_desc(bool partial, bool inlined) {
+static const char* begin_writing_desc(bool partial, bool inlined) {
switch (WRITE_STATE_TUPLE_TO_INT(partial, inlined)) {
case WRITE_STATE_TUPLE_TO_INT(false, false):
return "begin write in background";
@@ -998,10 +1003,10 @@ static const char *begin_writing_desc(bool partial, bool inlined) {
GPR_UNREACHABLE_CODE(return "bad state tuple");
}
-static void write_action_begin_locked(grpc_exec_ctx *exec_ctx, void *gt,
- grpc_error *error_ignored) {
+static void write_action_begin_locked(grpc_exec_ctx* exec_ctx, void* gt,
+ grpc_error* error_ignored) {
GPR_TIMER_BEGIN("write_action_begin_locked", 0);
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt;
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
GPR_ASSERT(t->write_state != GRPC_CHTTP2_WRITE_STATE_IDLE);
grpc_chttp2_begin_write_result r;
if (t->closed_with_error != GRPC_ERROR_NONE) {
@@ -1016,18 +1021,20 @@ static void write_action_begin_locked(grpc_exec_ctx *exec_ctx, void *gt,
if (!t->is_first_write_in_batch) {
GRPC_STATS_INC_HTTP2_WRITES_CONTINUED(exec_ctx);
}
- grpc_closure_scheduler *scheduler =
+ grpc_closure_scheduler* scheduler =
write_scheduler(t, r.early_results_scheduled, r.partial);
if (scheduler != grpc_schedule_on_exec_ctx) {
GRPC_STATS_INC_HTTP2_WRITES_OFFLOADED(exec_ctx);
}
set_write_state(
- exec_ctx, t, r.partial ? GRPC_CHTTP2_WRITE_STATE_WRITING_WITH_MORE
- : GRPC_CHTTP2_WRITE_STATE_WRITING,
+ exec_ctx, t,
+ r.partial ? GRPC_CHTTP2_WRITE_STATE_WRITING_WITH_MORE
+ : GRPC_CHTTP2_WRITE_STATE_WRITING,
begin_writing_desc(r.partial, scheduler == grpc_schedule_on_exec_ctx));
- GRPC_CLOSURE_SCHED(exec_ctx, GRPC_CLOSURE_INIT(&t->write_action,
- write_action, t, scheduler),
- GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(
+ exec_ctx,
+ GRPC_CLOSURE_INIT(&t->write_action, write_action, t, scheduler),
+ GRPC_ERROR_NONE);
} else {
GRPC_STATS_INC_HTTP2_SPURIOUS_WRITES_BEGUN(exec_ctx);
set_write_state(exec_ctx, t, GRPC_CHTTP2_WRITE_STATE_IDLE,
@@ -1037,8 +1044,8 @@ static void write_action_begin_locked(grpc_exec_ctx *exec_ctx, void *gt,
GPR_TIMER_END("write_action_begin_locked", 0);
}
-static void write_action(grpc_exec_ctx *exec_ctx, void *gt, grpc_error *error) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt;
+static void write_action(grpc_exec_ctx* exec_ctx, void* gt, grpc_error* error) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
GPR_TIMER_BEGIN("write_action", 0);
grpc_endpoint_write(
exec_ctx, t->ep, &t->outbuf,
@@ -1047,10 +1054,10 @@ static void write_action(grpc_exec_ctx *exec_ctx, void *gt, grpc_error *error) {
GPR_TIMER_END("write_action", 0);
}
-static void write_action_end_locked(grpc_exec_ctx *exec_ctx, void *tp,
- grpc_error *error) {
+static void write_action_end_locked(grpc_exec_ctx* exec_ctx, void* tp,
+ grpc_error* error) {
GPR_TIMER_BEGIN("terminate_writing_with_lock", 0);
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)tp;
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
if (error != GRPC_ERROR_NONE) {
close_transport_locked(exec_ctx, t, GRPC_ERROR_REF(error));
@@ -1095,10 +1102,10 @@ static void write_action_end_locked(grpc_exec_ctx *exec_ctx, void *tp,
// Dirties an HTTP2 setting to be sent out next time a writing path occurs.
// If the change needs to occur immediately, manually initiate a write.
-static void queue_setting_update(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+static void queue_setting_update(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
grpc_chttp2_setting_id id, uint32_t value) {
- const grpc_chttp2_setting_parameters *sp =
+ const grpc_chttp2_setting_parameters* sp =
&grpc_chttp2_settings_parameters[id];
uint32_t use_value = GPR_CLAMP(value, sp->min_value, sp->max_value);
if (use_value != value) {
@@ -1111,13 +1118,22 @@ static void queue_setting_update(grpc_exec_ctx *exec_ctx,
}
}
-void grpc_chttp2_add_incoming_goaway(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+void grpc_chttp2_add_incoming_goaway(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
uint32_t goaway_error,
grpc_slice goaway_text) {
// GRPC_CHTTP2_IF_TRACING(
// gpr_log(GPR_DEBUG, "got goaway [%d]: %s", goaway_error, msg));
- t->seen_goaway = 1;
+
+ // Discard the error from a previous goaway frame (if any)
+ if (t->goaway_error != GRPC_ERROR_NONE) {
+ GRPC_ERROR_UNREF(t->goaway_error);
+ }
+ t->goaway_error = grpc_error_set_str(
+ grpc_error_set_int(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("GOAWAY received"),
+ GRPC_ERROR_INT_HTTP2_ERROR, (intptr_t)goaway_error),
+ GRPC_ERROR_STR_RAW_BYTES, goaway_text);
/* When a client receives a GOAWAY with error code ENHANCE_YOUR_CALM and debug
* data equal to "too_many_pings", it should log the occurrence at a log level
@@ -1138,19 +1154,13 @@ void grpc_chttp2_add_incoming_goaway(grpc_exec_ctx *exec_ctx,
/* lie: use transient failure from the transport to indicate goaway has been
* received */
- connectivity_state_set(
- exec_ctx, t, GRPC_CHANNEL_TRANSIENT_FAILURE,
- grpc_error_set_str(
- grpc_error_set_int(
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("GOAWAY received"),
- GRPC_ERROR_INT_HTTP2_ERROR, (intptr_t)goaway_error),
- GRPC_ERROR_STR_RAW_BYTES, goaway_text),
- "got_goaway");
+ connectivity_state_set(exec_ctx, t, GRPC_CHANNEL_TRANSIENT_FAILURE,
+ GRPC_ERROR_REF(t->goaway_error), "got_goaway");
}
-static void maybe_start_some_streams(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
- grpc_chttp2_stream *s;
+static void maybe_start_some_streams(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t) {
+ grpc_chttp2_stream* s;
/* start streams where we have free grpc_chttp2_stream ids and free
* concurrency */
while (t->next_stream_id <= MAX_CLIENT_STREAM_ID &&
@@ -1201,24 +1211,24 @@ static void maybe_start_some_streams(grpc_exec_ctx *exec_ctx,
bits being used for flags defined above) */
#define CLOSURE_BARRIER_FIRST_REF_BIT (1 << 16)
-static grpc_closure *add_closure_barrier(grpc_closure *closure) {
+static grpc_closure* add_closure_barrier(grpc_closure* closure) {
closure->next_data.scratch += CLOSURE_BARRIER_FIRST_REF_BIT;
return closure;
}
-static void null_then_run_closure(grpc_exec_ctx *exec_ctx,
- grpc_closure **closure, grpc_error *error) {
- grpc_closure *c = *closure;
+static void null_then_run_closure(grpc_exec_ctx* exec_ctx,
+ grpc_closure** closure, grpc_error* error) {
+ grpc_closure* c = *closure;
*closure = NULL;
GRPC_CLOSURE_RUN(exec_ctx, c, error);
}
-void grpc_chttp2_complete_closure_step(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
- grpc_closure **pclosure,
- grpc_error *error, const char *desc) {
- grpc_closure *closure = *pclosure;
+void grpc_chttp2_complete_closure_step(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
+ grpc_closure** pclosure,
+ grpc_error* error, const char* desc) {
+ grpc_closure* closure = *pclosure;
*pclosure = NULL;
if (closure == NULL) {
GRPC_ERROR_UNREF(error);
@@ -1226,7 +1236,7 @@ void grpc_chttp2_complete_closure_step(grpc_exec_ctx *exec_ctx,
}
closure->next_data.scratch -= CLOSURE_BARRIER_FIRST_REF_BIT;
if (grpc_http_trace.enabled()) {
- const char *errstr = grpc_error_string(error);
+ const char* errstr = grpc_error_string(error);
gpr_log(
GPR_DEBUG,
"complete_closure_step: t=%p %p refs=%d flags=0x%04x desc=%s err=%s "
@@ -1262,7 +1272,7 @@ void grpc_chttp2_complete_closure_step(grpc_exec_ctx *exec_ctx,
}
}
-static bool contains_non_ok_status(grpc_metadata_batch *batch) {
+static bool contains_non_ok_status(grpc_metadata_batch* batch) {
if (batch->idx.named.grpc_status != NULL) {
return !grpc_mdelem_eq(batch->idx.named.grpc_status->md,
GRPC_MDELEM_GRPC_STATUS_0);
@@ -1270,9 +1280,9 @@ static bool contains_non_ok_status(grpc_metadata_batch *batch) {
return false;
}
-static void maybe_become_writable_due_to_send_msg(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+static void maybe_become_writable_due_to_send_msg(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
if (s->id != 0 && (!s->write_buffering ||
s->flow_controlled_buffer.length > t->write_buffer_size)) {
grpc_chttp2_mark_stream_writable(exec_ctx, t, s);
@@ -1281,18 +1291,18 @@ static void maybe_become_writable_due_to_send_msg(grpc_exec_ctx *exec_ctx,
}
}
-static void add_fetched_slice_locked(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+static void add_fetched_slice_locked(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
s->fetched_send_message_length +=
(uint32_t)GRPC_SLICE_LENGTH(s->fetching_slice);
grpc_slice_buffer_add(&s->flow_controlled_buffer, s->fetching_slice);
maybe_become_writable_due_to_send_msg(exec_ctx, t, s);
}
-static void continue_fetching_send_locked(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+static void continue_fetching_send_locked(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
for (;;) {
if (s->fetching_send_message == NULL) {
/* Stream was cancelled before message fetch completed */
@@ -1307,16 +1317,16 @@ static void continue_fetching_send_locked(grpc_exec_ctx *exec_ctx,
exec_ctx, t, s, &s->fetching_send_message_finished, GRPC_ERROR_NONE,
"fetching_send_message_finished");
} else {
- grpc_chttp2_write_cb *cb = t->write_cb_pool;
+ grpc_chttp2_write_cb* cb = t->write_cb_pool;
if (cb == NULL) {
- cb = (grpc_chttp2_write_cb *)gpr_malloc(sizeof(*cb));
+ cb = (grpc_chttp2_write_cb*)gpr_malloc(sizeof(*cb));
} else {
t->write_cb_pool = cb->next;
}
cb->call_at_byte = notify_offset;
cb->closure = s->fetching_send_message_finished;
s->fetching_send_message_finished = NULL;
- grpc_chttp2_write_cb **list =
+ grpc_chttp2_write_cb** list =
s->fetching_send_message->flags & GRPC_WRITE_THROUGH
? &s->on_write_finished_cbs
: &s->on_flow_controlled_cbs;
@@ -1327,7 +1337,7 @@ static void continue_fetching_send_locked(grpc_exec_ctx *exec_ctx,
return; /* early out */
} else if (grpc_byte_stream_next(exec_ctx, s->fetching_send_message,
UINT32_MAX, &s->complete_fetch_locked)) {
- grpc_error *error = grpc_byte_stream_pull(
+ grpc_error* error = grpc_byte_stream_pull(
exec_ctx, s->fetching_send_message, &s->fetching_slice);
if (error != GRPC_ERROR_NONE) {
grpc_byte_stream_destroy(exec_ctx, s->fetching_send_message);
@@ -1339,10 +1349,10 @@ static void continue_fetching_send_locked(grpc_exec_ctx *exec_ctx,
}
}
-static void complete_fetch_locked(grpc_exec_ctx *exec_ctx, void *gs,
- grpc_error *error) {
- grpc_chttp2_stream *s = (grpc_chttp2_stream *)gs;
- grpc_chttp2_transport *t = s->t;
+static void complete_fetch_locked(grpc_exec_ctx* exec_ctx, void* gs,
+ grpc_error* error) {
+ grpc_chttp2_stream* s = (grpc_chttp2_stream*)gs;
+ grpc_chttp2_transport* t = s->t;
if (error == GRPC_ERROR_NONE) {
error = grpc_byte_stream_pull(exec_ctx, s->fetching_send_message,
&s->fetching_slice);
@@ -1357,14 +1367,14 @@ static void complete_fetch_locked(grpc_exec_ctx *exec_ctx, void *gs,
}
}
-static void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {}
+static void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {}
-static void log_metadata(const grpc_metadata_batch *md_batch, uint32_t id,
+static void log_metadata(const grpc_metadata_batch* md_batch, uint32_t id,
bool is_client, bool is_initial) {
- for (grpc_linked_mdelem *md = md_batch->list.head; md != NULL;
+ for (grpc_linked_mdelem* md = md_batch->list.head; md != NULL;
md = md->next) {
- char *key = grpc_slice_to_c_string(GRPC_MDKEY(md->md));
- char *value = grpc_slice_to_c_string(GRPC_MDVALUE(md->md));
+ char* key = grpc_slice_to_c_string(GRPC_MDKEY(md->md));
+ char* value = grpc_slice_to_c_string(GRPC_MDVALUE(md->md));
gpr_log(GPR_INFO, "HTTP:%d:%s:%s: %s: %s", id, is_initial ? "HDR" : "TRL",
is_client ? "CLI" : "SVR", key, value);
gpr_free(key);
@@ -1372,20 +1382,20 @@ static void log_metadata(const grpc_metadata_batch *md_batch, uint32_t id,
}
}
-static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
- grpc_error *error_ignored) {
+static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
+ grpc_error* error_ignored) {
GPR_TIMER_BEGIN("perform_stream_op_locked", 0);
- grpc_transport_stream_op_batch *op =
- (grpc_transport_stream_op_batch *)stream_op;
- grpc_chttp2_stream *s = (grpc_chttp2_stream *)op->handler_private.extra_arg;
- grpc_transport_stream_op_batch_payload *op_payload = op->payload;
- grpc_chttp2_transport *t = s->t;
+ grpc_transport_stream_op_batch* op =
+ (grpc_transport_stream_op_batch*)stream_op;
+ grpc_chttp2_stream* s = (grpc_chttp2_stream*)op->handler_private.extra_arg;
+ grpc_transport_stream_op_batch_payload* op_payload = op->payload;
+ grpc_chttp2_transport* t = s->t;
GRPC_STATS_INC_HTTP2_OP_BATCHES(exec_ctx);
if (grpc_http_trace.enabled()) {
- char *str = grpc_transport_stream_op_batch_string(op);
+ char* str = grpc_transport_stream_op_batch_string(op);
gpr_log(GPR_DEBUG, "perform_stream_op_locked: %s; on_complete = %p", str,
op->on_complete);
gpr_free(str);
@@ -1399,7 +1409,7 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
}
}
- grpc_closure *on_complete = op->on_complete;
+ grpc_closure* on_complete = op->on_complete;
if (on_complete == NULL) {
on_complete =
GRPC_CLOSURE_CREATE(do_nothing, NULL, grpc_schedule_on_exec_ctx);
@@ -1527,7 +1537,7 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
"fetching_send_message_finished");
} else {
GPR_ASSERT(s->fetching_send_message == NULL);
- uint8_t *frame_hdr = grpc_slice_buffer_tiny_add(
+ uint8_t* frame_hdr = grpc_slice_buffer_tiny_add(
&s->flow_controlled_buffer, GRPC_HEADER_SIZE_IN_BYTES);
uint32_t flags = op_payload->send_message.send_message->flags;
frame_hdr[0] = (flags & GRPC_WRITE_INTERNAL_COMPRESS) != 0;
@@ -1654,12 +1664,12 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "perform_stream_op");
}
-static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs,
- grpc_transport_stream_op_batch *op) {
+static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
+ grpc_stream* gs,
+ grpc_transport_stream_op_batch* op) {
GPR_TIMER_BEGIN("perform_stream_op", 0);
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt;
- grpc_chttp2_stream *s = (grpc_chttp2_stream *)gs;
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
+ grpc_chttp2_stream* s = (grpc_chttp2_stream*)gs;
if (!t->is_client) {
if (op->send_initial_metadata) {
@@ -1675,7 +1685,7 @@ static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
}
if (grpc_http_trace.enabled()) {
- char *str = grpc_transport_stream_op_batch_string(op);
+ char* str = grpc_transport_stream_op_batch_string(op);
gpr_log(GPR_DEBUG, "perform_stream_op[s=%p]: %s", s, str);
gpr_free(str);
}
@@ -1690,11 +1700,11 @@ static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
GPR_TIMER_END("perform_stream_op", 0);
}
-static void cancel_pings(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_error *error) {
+static void cancel_pings(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
+ grpc_error* error) {
/* callback remaining pings: they're not allowed to call into the transpot,
and maybe they hold resources that need to be freed */
- grpc_chttp2_ping_queue *pq = &t->ping_queue;
+ grpc_chttp2_ping_queue* pq = &t->ping_queue;
GPR_ASSERT(error != GRPC_ERROR_NONE);
for (size_t j = 0; j < GRPC_CHTTP2_PCL_COUNT; j++) {
grpc_closure_list_fail_all(&pq->lists[j], GRPC_ERROR_REF(error));
@@ -1703,24 +1713,24 @@ static void cancel_pings(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
GRPC_ERROR_UNREF(error);
}
-static void send_ping_locked(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_closure *on_initiate, grpc_closure *on_ack) {
+static void send_ping_locked(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
+ grpc_closure* on_initiate, grpc_closure* on_ack) {
if (t->closed_with_error != GRPC_ERROR_NONE) {
GRPC_CLOSURE_SCHED(exec_ctx, on_initiate,
GRPC_ERROR_REF(t->closed_with_error));
GRPC_CLOSURE_SCHED(exec_ctx, on_ack, GRPC_ERROR_REF(t->closed_with_error));
return;
}
- grpc_chttp2_ping_queue *pq = &t->ping_queue;
+ grpc_chttp2_ping_queue* pq = &t->ping_queue;
grpc_closure_list_append(&pq->lists[GRPC_CHTTP2_PCL_INITIATE], on_initiate,
GRPC_ERROR_NONE);
grpc_closure_list_append(&pq->lists[GRPC_CHTTP2_PCL_NEXT], on_ack,
GRPC_ERROR_NONE);
}
-static void retry_initiate_ping_locked(grpc_exec_ctx *exec_ctx, void *tp,
- grpc_error *error) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)tp;
+static void retry_initiate_ping_locked(grpc_exec_ctx* exec_ctx, void* tp,
+ grpc_error* error) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
t->ping_state.is_delayed_ping_timer_set = false;
if (error == GRPC_ERROR_NONE) {
grpc_chttp2_initiate_write(exec_ctx, t,
@@ -1728,11 +1738,11 @@ static void retry_initiate_ping_locked(grpc_exec_ctx *exec_ctx, void *tp,
}
}
-void grpc_chttp2_ack_ping(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
+void grpc_chttp2_ack_ping(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
uint64_t id) {
- grpc_chttp2_ping_queue *pq = &t->ping_queue;
+ grpc_chttp2_ping_queue* pq = &t->ping_queue;
if (pq->inflight_id != id) {
- char *from = grpc_endpoint_get_peer(t->ep);
+ char* from = grpc_endpoint_get_peer(t->ep);
gpr_log(GPR_DEBUG, "Unknown ping response from %s: %" PRIx64, from, id);
gpr_free(from);
return;
@@ -1744,8 +1754,8 @@ void grpc_chttp2_ack_ping(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
}
}
-static void send_goaway(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_error *error) {
+static void send_goaway(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
+ grpc_error* error) {
t->sent_goaway_state = GRPC_CHTTP2_GOAWAY_SEND_SCHEDULED;
grpc_http2_error_code http_error;
grpc_slice slice;
@@ -1758,8 +1768,8 @@ static void send_goaway(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
GRPC_ERROR_UNREF(error);
}
-void grpc_chttp2_add_ping_strike(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
+void grpc_chttp2_add_ping_strike(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t) {
t->ping_recv_state.ping_strikes++;
if (++t->ping_recv_state.ping_strikes > t->ping_policy.max_ping_strikes &&
t->ping_policy.max_ping_strikes != 0) {
@@ -1769,19 +1779,20 @@ void grpc_chttp2_add_ping_strike(grpc_exec_ctx *exec_ctx,
GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_ENHANCE_YOUR_CALM));
/*The transport will be closed after the write is done */
close_transport_locked(
- exec_ctx, t, grpc_error_set_int(
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Too many pings"),
- GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
+ exec_ctx, t,
+ grpc_error_set_int(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Too many pings"),
+ GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
}
}
-static void perform_transport_op_locked(grpc_exec_ctx *exec_ctx,
- void *stream_op,
- grpc_error *error_ignored) {
- grpc_transport_op *op = (grpc_transport_op *)stream_op;
- grpc_chttp2_transport *t =
- (grpc_chttp2_transport *)op->handler_private.extra_arg;
- grpc_error *close_transport = op->disconnect_with_error;
+static void perform_transport_op_locked(grpc_exec_ctx* exec_ctx,
+ void* stream_op,
+ grpc_error* error_ignored) {
+ grpc_transport_op* op = (grpc_transport_op*)stream_op;
+ grpc_chttp2_transport* t =
+ (grpc_chttp2_transport*)op->handler_private.extra_arg;
+ grpc_error* close_transport = op->disconnect_with_error;
if (op->goaway_error) {
send_goaway(exec_ctx, t, op->goaway_error);
@@ -1822,10 +1833,10 @@ static void perform_transport_op_locked(grpc_exec_ctx *exec_ctx,
GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "transport_op");
}
-static void perform_transport_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_transport_op *op) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt;
- char *msg = grpc_transport_op_string(op);
+static void perform_transport_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
+ grpc_transport_op* op) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
+ char* msg = grpc_transport_op_string(op);
gpr_free(msg);
op->handler_private.extra_arg = gt;
GRPC_CHTTP2_REF_TRANSPORT(t, "transport_op");
@@ -1840,9 +1851,9 @@ static void perform_transport_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
* INPUT PROCESSING - GENERAL
*/
-void grpc_chttp2_maybe_complete_recv_initial_metadata(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+void grpc_chttp2_maybe_complete_recv_initial_metadata(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
if (s->recv_initial_metadata_ready != NULL &&
s->published_metadata[0] != GRPC_METADATA_NOT_PUBLISHED) {
if (s->seen_error) {
@@ -1859,10 +1870,10 @@ void grpc_chttp2_maybe_complete_recv_initial_metadata(grpc_exec_ctx *exec_ctx,
}
}
-void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
- grpc_error *error = GRPC_ERROR_NONE;
+void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
+ grpc_error* error = GRPC_ERROR_NONE;
if (s->recv_message_ready != NULL) {
*s->recv_message = NULL;
if (s->final_metadata_requested && s->seen_error) {
@@ -1943,9 +1954,9 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx *exec_ctx,
}
}
-void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
grpc_chttp2_maybe_complete_recv_message(exec_ctx, t, s);
if (s->recv_trailing_metadata_finished != NULL && s->read_closed &&
s->write_closed) {
@@ -1997,10 +2008,10 @@ void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_exec_ctx *exec_ctx,
}
}
-static void remove_stream(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- uint32_t id, grpc_error *error) {
- grpc_chttp2_stream *s =
- (grpc_chttp2_stream *)grpc_chttp2_stream_map_delete(&t->stream_map, id);
+static void remove_stream(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
+ uint32_t id, grpc_error* error) {
+ grpc_chttp2_stream* s =
+ (grpc_chttp2_stream*)grpc_chttp2_stream_map_delete(&t->stream_map, id);
GPR_ASSERT(s);
if (t->incoming_stream == s) {
t->incoming_stream = NULL;
@@ -2008,7 +2019,7 @@ static void remove_stream(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
}
if (s->pending_byte_stream) {
if (s->on_next != NULL) {
- grpc_chttp2_incoming_byte_stream *bs = s->data_parser.parsing_frame;
+ grpc_chttp2_incoming_byte_stream* bs = s->data_parser.parsing_frame;
if (error == GRPC_ERROR_NONE) {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Truncated message");
}
@@ -2039,9 +2050,9 @@ static void remove_stream(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
maybe_start_some_streams(exec_ctx, t);
}
-void grpc_chttp2_cancel_stream(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t, grpc_chttp2_stream *s,
- grpc_error *due_to_error) {
+void grpc_chttp2_cancel_stream(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t, grpc_chttp2_stream* s,
+ grpc_error* due_to_error) {
if (!t->is_client && !s->sent_trailing_metadata &&
grpc_error_has_clear_grpc_status(due_to_error)) {
close_from_api(exec_ctx, t, s, due_to_error);
@@ -2066,12 +2077,11 @@ void grpc_chttp2_cancel_stream(grpc_exec_ctx *exec_ctx,
grpc_chttp2_mark_stream_closed(exec_ctx, t, s, 1, 1, due_to_error);
}
-void grpc_chttp2_fake_status(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_chttp2_stream *s, grpc_error *error) {
+void grpc_chttp2_fake_status(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s, grpc_error* error) {
grpc_status_code status;
grpc_slice slice;
grpc_error_get_status(exec_ctx, error, s->deadline, &status, &slice, NULL);
-
if (status != GRPC_STATUS_OK) {
s->seen_error = true;
}
@@ -2106,7 +2116,7 @@ void grpc_chttp2_fake_status(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
GRPC_ERROR_UNREF(error);
}
-static void add_error(grpc_error *error, grpc_error **refs, size_t *nrefs) {
+static void add_error(grpc_error* error, grpc_error** refs, size_t* nrefs) {
if (error == GRPC_ERROR_NONE) return;
for (size_t i = 0; i < *nrefs; i++) {
if (error == refs[i]) {
@@ -2117,14 +2127,14 @@ static void add_error(grpc_error *error, grpc_error **refs, size_t *nrefs) {
++*nrefs;
}
-static grpc_error *removal_error(grpc_error *extra_error, grpc_chttp2_stream *s,
- const char *master_error_msg) {
- grpc_error *refs[3];
+static grpc_error* removal_error(grpc_error* extra_error, grpc_chttp2_stream* s,
+ const char* master_error_msg) {
+ grpc_error* refs[3];
size_t nrefs = 0;
add_error(s->read_closed_error, refs, &nrefs);
add_error(s->write_closed_error, refs, &nrefs);
add_error(extra_error, refs, &nrefs);
- grpc_error *error = GRPC_ERROR_NONE;
+ grpc_error* error = GRPC_ERROR_NONE;
if (nrefs > 0) {
error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(master_error_msg,
refs, nrefs);
@@ -2133,11 +2143,11 @@ static grpc_error *removal_error(grpc_error *extra_error, grpc_chttp2_stream *s,
return error;
}
-static void flush_write_list(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_chttp2_stream *s, grpc_chttp2_write_cb **list,
- grpc_error *error) {
+static void flush_write_list(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s, grpc_chttp2_write_cb** list,
+ grpc_error* error) {
while (*list) {
- grpc_chttp2_write_cb *cb = *list;
+ grpc_chttp2_write_cb* cb = *list;
*list = cb->next;
grpc_chttp2_complete_closure_step(exec_ctx, t, s, &cb->closure,
GRPC_ERROR_REF(error),
@@ -2148,9 +2158,9 @@ static void flush_write_list(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
GRPC_ERROR_UNREF(error);
}
-void grpc_chttp2_fail_pending_writes(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s, grpc_error *error) {
+void grpc_chttp2_fail_pending_writes(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s, grpc_error* error) {
error =
removal_error(error, s, "Pending writes failed due to stream closure");
s->send_initial_metadata = NULL;
@@ -2172,10 +2182,10 @@ void grpc_chttp2_fail_pending_writes(grpc_exec_ctx *exec_ctx,
flush_write_list(exec_ctx, t, s, &s->on_flow_controlled_cbs, error);
}
-void grpc_chttp2_mark_stream_closed(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s, int close_reads,
- int close_writes, grpc_error *error) {
+void grpc_chttp2_mark_stream_closed(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s, int close_reads,
+ int close_writes, grpc_error* error) {
if (s->read_closed && s->write_closed) {
/* already closed */
grpc_chttp2_maybe_complete_recv_trailing_metadata(exec_ctx, t, s);
@@ -2196,7 +2206,7 @@ void grpc_chttp2_mark_stream_closed(grpc_exec_ctx *exec_ctx,
}
if (s->read_closed && s->write_closed) {
became_closed = true;
- grpc_error *overall_error =
+ grpc_error* overall_error =
removal_error(GRPC_ERROR_REF(error), s, "Stream removed");
if (s->id != 0) {
remove_stream(exec_ctx, t, s->id, GRPC_ERROR_REF(overall_error));
@@ -2224,14 +2234,14 @@ void grpc_chttp2_mark_stream_closed(grpc_exec_ctx *exec_ctx,
GRPC_ERROR_UNREF(error);
}
-static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_chttp2_stream *s, grpc_error *error) {
+static void close_from_api(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s, grpc_error* error) {
grpc_slice hdr;
grpc_slice status_hdr;
grpc_slice http_status_hdr;
grpc_slice content_type_hdr;
grpc_slice message_pfx;
- uint8_t *p;
+ uint8_t* p;
uint32_t len = 0;
grpc_status_code grpc_status;
grpc_slice slice;
@@ -2384,20 +2394,20 @@ static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
}
typedef struct {
- grpc_exec_ctx *exec_ctx;
- grpc_error *error;
- grpc_chttp2_transport *t;
+ grpc_exec_ctx* exec_ctx;
+ grpc_error* error;
+ grpc_chttp2_transport* t;
} cancel_stream_cb_args;
-static void cancel_stream_cb(void *user_data, uint32_t key, void *stream) {
- cancel_stream_cb_args *args = (cancel_stream_cb_args *)user_data;
- grpc_chttp2_stream *s = (grpc_chttp2_stream *)stream;
+static void cancel_stream_cb(void* user_data, uint32_t key, void* stream) {
+ cancel_stream_cb_args* args = (cancel_stream_cb_args*)user_data;
+ grpc_chttp2_stream* s = (grpc_chttp2_stream*)stream;
grpc_chttp2_cancel_stream(args->exec_ctx, args->t, s,
GRPC_ERROR_REF(args->error));
}
-static void end_all_the_calls(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_error *error) {
+static void end_all_the_calls(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
+ grpc_error* error) {
cancel_stream_cb_args args = {exec_ctx, error, t};
grpc_chttp2_stream_map_for_each(&t->stream_map, cancel_stream_cb, &args);
GRPC_ERROR_UNREF(error);
@@ -2408,7 +2418,7 @@ static void end_all_the_calls(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
*/
template <class F>
-static void WithUrgency(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
+static void WithUrgency(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
grpc_core::chttp2::FlowControlAction::Urgency urgency,
grpc_chttp2_initiate_write_reason reason, F action) {
switch (urgency) {
@@ -2424,8 +2434,8 @@ static void WithUrgency(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
}
void grpc_chttp2_act_on_flowctl_action(
- grpc_exec_ctx *exec_ctx, const grpc_core::chttp2::FlowControlAction &action,
- grpc_chttp2_transport *t, grpc_chttp2_stream *s) {
+ grpc_exec_ctx* exec_ctx, const grpc_core::chttp2::FlowControlAction& action,
+ grpc_chttp2_transport* t, grpc_chttp2_stream* s) {
WithUrgency(
exec_ctx, t, action.send_stream_update(),
GRPC_CHTTP2_INITIATE_WRITE_STREAM_FLOW_CONTROL,
@@ -2447,17 +2457,17 @@ void grpc_chttp2_act_on_flowctl_action(
});
}
-static grpc_error *try_http_parsing(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
+static grpc_error* try_http_parsing(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t) {
grpc_http_parser parser;
size_t i = 0;
- grpc_error *error = GRPC_ERROR_NONE;
+ grpc_error* error = GRPC_ERROR_NONE;
grpc_http_response response;
memset(&response, 0, sizeof(response));
grpc_http_parser_init(&parser, GRPC_HTTP_RESPONSE, &response);
- grpc_error *parse_error = GRPC_ERROR_NONE;
+ grpc_error* parse_error = GRPC_ERROR_NONE;
for (; i < t->read_buffer.count && parse_error == GRPC_ERROR_NONE; i++) {
parse_error =
grpc_http_parser_parse(&parser, t->read_buffer.slices[i], NULL);
@@ -2477,27 +2487,27 @@ static grpc_error *try_http_parsing(grpc_exec_ctx *exec_ctx,
return error;
}
-static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp,
- grpc_error *error) {
+static void read_action_locked(grpc_exec_ctx* exec_ctx, void* tp,
+ grpc_error* error) {
GPR_TIMER_BEGIN("reading_action_locked", 0);
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)tp;
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
GRPC_ERROR_REF(error);
- grpc_error *err = error;
+ grpc_error* err = error;
if (err != GRPC_ERROR_NONE) {
err = grpc_error_set_int(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Endpoint read failed", &err, 1),
GRPC_ERROR_INT_OCCURRED_DURING_WRITE,
t->write_state);
}
- GPR_SWAP(grpc_error *, err, error);
+ GPR_SWAP(grpc_error*, err, error);
GRPC_ERROR_UNREF(err);
if (t->closed_with_error == GRPC_ERROR_NONE) {
GPR_TIMER_BEGIN("reading_action.parse", 0);
size_t i = 0;
- grpc_error *errors[3] = {GRPC_ERROR_REF(error), GRPC_ERROR_NONE,
+ grpc_error* errors[3] = {GRPC_ERROR_REF(error), GRPC_ERROR_NONE,
GRPC_ERROR_NONE};
for (; i < t->read_buffer.count && errors[1] == GRPC_ERROR_NONE; i++) {
t->flow_control->bdp_estimator()->AddIncomingBytes(
@@ -2519,7 +2529,7 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp,
GPR_TIMER_BEGIN("post_parse_locked", 0);
if (t->initial_window_update != 0) {
if (t->initial_window_update > 0) {
- grpc_chttp2_stream *s;
+ grpc_chttp2_stream* s;
while (grpc_chttp2_list_pop_stalled_by_stream(t, &s)) {
grpc_chttp2_mark_stream_writable(exec_ctx, t, s);
grpc_chttp2_initiate_write(
@@ -2539,6 +2549,12 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp,
"Transport closed", &t->closed_with_error, 1);
}
if (error != GRPC_ERROR_NONE) {
+ /* If a goaway frame was received, this might be the reason why the read
+ * failed. Add this info to the error */
+ if (t->goaway_error != GRPC_ERROR_NONE) {
+ error = grpc_error_add_child(error, GRPC_ERROR_REF(t->goaway_error));
+ }
+
close_transport_locked(exec_ctx, t, GRPC_ERROR_REF(error));
t->endpoint_reading = 0;
} else if (t->closed_with_error == GRPC_ERROR_NONE) {
@@ -2566,16 +2582,16 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp,
// t is reffed prior to calling the first time, and once the callback chain
// that kicks off finishes, it's unreffed
-static void schedule_bdp_ping_locked(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
+static void schedule_bdp_ping_locked(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t) {
t->flow_control->bdp_estimator()->SchedulePing();
send_ping_locked(exec_ctx, t, &t->start_bdp_ping_locked,
&t->finish_bdp_ping_locked);
}
-static void start_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp,
- grpc_error *error) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)tp;
+static void start_bdp_ping_locked(grpc_exec_ctx* exec_ctx, void* tp,
+ grpc_error* error) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
if (grpc_http_trace.enabled()) {
gpr_log(GPR_DEBUG, "%s: Start BDP ping err=%s", t->peer_string,
grpc_error_string(error));
@@ -2587,9 +2603,9 @@ static void start_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp,
t->flow_control->bdp_estimator()->StartPing();
}
-static void finish_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp,
- grpc_error *error) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)tp;
+static void finish_bdp_ping_locked(grpc_exec_ctx* exec_ctx, void* tp,
+ grpc_error* error) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
if (grpc_http_trace.enabled()) {
gpr_log(GPR_DEBUG, "%s: Complete BDP ping err=%s", t->peer_string,
grpc_error_string(error));
@@ -2608,9 +2624,9 @@ static void finish_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp,
&t->next_bdp_ping_timer_expired_locked);
}
-static void next_bdp_ping_timer_expired_locked(grpc_exec_ctx *exec_ctx,
- void *tp, grpc_error *error) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)tp;
+static void next_bdp_ping_timer_expired_locked(grpc_exec_ctx* exec_ctx,
+ void* tp, grpc_error* error) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
GPR_ASSERT(t->have_next_bdp_ping_timer);
t->have_next_bdp_ping_timer = false;
if (error != GRPC_ERROR_NONE) {
@@ -2620,7 +2636,7 @@ static void next_bdp_ping_timer_expired_locked(grpc_exec_ctx *exec_ctx,
schedule_bdp_ping_locked(exec_ctx, t);
}
-void grpc_chttp2_config_default_keepalive_args(grpc_channel_args *args,
+void grpc_chttp2_config_default_keepalive_args(grpc_channel_args* args,
bool is_client) {
size_t i;
if (args) {
@@ -2678,9 +2694,9 @@ void grpc_chttp2_config_default_keepalive_args(grpc_channel_args *args,
}
}
-static void init_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)arg;
+static void init_keepalive_ping_locked(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_error* error) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
GPR_ASSERT(t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING);
if (t->destroying || t->closed_with_error != GRPC_ERROR_NONE) {
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_DYING;
@@ -2709,18 +2725,18 @@ static void init_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg,
GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "init keepalive ping");
}
-static void start_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)arg;
+static void start_keepalive_ping_locked(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_error* error) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
GRPC_CHTTP2_REF_TRANSPORT(t, "keepalive watchdog");
grpc_timer_init(exec_ctx, &t->keepalive_watchdog_timer,
grpc_exec_ctx_now(exec_ctx) + t->keepalive_time,
&t->keepalive_watchdog_fired_locked);
}
-static void finish_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)arg;
+static void finish_keepalive_ping_locked(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_error* error) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_PINGING) {
if (error == GRPC_ERROR_NONE) {
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_WAITING;
@@ -2734,9 +2750,9 @@ static void finish_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg,
GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "keepalive ping end");
}
-static void keepalive_watchdog_fired_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)arg;
+static void keepalive_watchdog_fired_locked(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_error* error) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_PINGING) {
if (error == GRPC_ERROR_NONE) {
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_DYING;
@@ -2761,10 +2777,10 @@ static void keepalive_watchdog_fired_locked(grpc_exec_ctx *exec_ctx, void *arg,
* CALLBACK LOOP
*/
-static void connectivity_state_set(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+static void connectivity_state_set(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
grpc_connectivity_state state,
- grpc_error *error, const char *reason) {
+ grpc_error* error, const char* reason) {
GRPC_CHTTP2_IF_TRACING(
gpr_log(GPR_DEBUG, "set connectivity_state=%d", state));
grpc_connectivity_state_set(exec_ctx, &t->channel_callback.state_tracker,
@@ -2775,15 +2791,15 @@ static void connectivity_state_set(grpc_exec_ctx *exec_ctx,
* POLLSET STUFF
*/
-static void set_pollset(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs, grpc_pollset *pollset) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt;
+static void set_pollset(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
+ grpc_stream* gs, grpc_pollset* pollset) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
grpc_endpoint_add_to_pollset(exec_ctx, t->ep, pollset);
}
-static void set_pollset_set(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs, grpc_pollset_set *pollset_set) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt;
+static void set_pollset_set(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
+ grpc_stream* gs, grpc_pollset_set* pollset_set) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
grpc_endpoint_add_to_pollset_set(exec_ctx, t->ep, pollset_set);
}
@@ -2791,9 +2807,9 @@ static void set_pollset_set(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
* BYTE STREAM
*/
-static void reset_byte_stream(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_chttp2_stream *s = (grpc_chttp2_stream *)arg;
+static void reset_byte_stream(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_error* error) {
+ grpc_chttp2_stream* s = (grpc_chttp2_stream*)arg;
s->pending_byte_stream = false;
if (error == GRPC_ERROR_NONE) {
@@ -2810,20 +2826,20 @@ static void reset_byte_stream(grpc_exec_ctx *exec_ctx, void *arg,
}
}
-static void incoming_byte_stream_unref(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_incoming_byte_stream *bs) {
+static void incoming_byte_stream_unref(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_incoming_byte_stream* bs) {
if (gpr_unref(&bs->refs)) {
gpr_free(bs);
}
}
-static void incoming_byte_stream_next_locked(grpc_exec_ctx *exec_ctx,
- void *argp,
- grpc_error *error_ignored) {
- grpc_chttp2_incoming_byte_stream *bs =
- (grpc_chttp2_incoming_byte_stream *)argp;
- grpc_chttp2_transport *t = bs->transport;
- grpc_chttp2_stream *s = bs->stream;
+static void incoming_byte_stream_next_locked(grpc_exec_ctx* exec_ctx,
+ void* argp,
+ grpc_error* error_ignored) {
+ grpc_chttp2_incoming_byte_stream* bs =
+ (grpc_chttp2_incoming_byte_stream*)argp;
+ grpc_chttp2_transport* t = bs->transport;
+ grpc_chttp2_stream* s = bs->stream;
size_t cur_length = s->frame_storage.length;
if (!s->read_closed) {
@@ -2865,14 +2881,14 @@ static void incoming_byte_stream_next_locked(grpc_exec_ctx *exec_ctx,
incoming_byte_stream_unref(exec_ctx, bs);
}
-static bool incoming_byte_stream_next(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *byte_stream,
+static bool incoming_byte_stream_next(grpc_exec_ctx* exec_ctx,
+ grpc_byte_stream* byte_stream,
size_t max_size_hint,
- grpc_closure *on_complete) {
+ grpc_closure* on_complete) {
GPR_TIMER_BEGIN("incoming_byte_stream_next", 0);
- grpc_chttp2_incoming_byte_stream *bs =
- (grpc_chttp2_incoming_byte_stream *)byte_stream;
- grpc_chttp2_stream *s = bs->stream;
+ grpc_chttp2_incoming_byte_stream* bs =
+ (grpc_chttp2_incoming_byte_stream*)byte_stream;
+ grpc_chttp2_stream* s = bs->stream;
if (s->unprocessed_incoming_frames_buffer.length > 0) {
GPR_TIMER_END("incoming_byte_stream_next", 0);
return true;
@@ -2891,14 +2907,14 @@ static bool incoming_byte_stream_next(grpc_exec_ctx *exec_ctx,
}
}
-static grpc_error *incoming_byte_stream_pull(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *byte_stream,
- grpc_slice *slice) {
+static grpc_error* incoming_byte_stream_pull(grpc_exec_ctx* exec_ctx,
+ grpc_byte_stream* byte_stream,
+ grpc_slice* slice) {
GPR_TIMER_BEGIN("incoming_byte_stream_pull", 0);
- grpc_chttp2_incoming_byte_stream *bs =
- (grpc_chttp2_incoming_byte_stream *)byte_stream;
- grpc_chttp2_stream *s = bs->stream;
- grpc_error *error;
+ grpc_chttp2_incoming_byte_stream* bs =
+ (grpc_chttp2_incoming_byte_stream*)byte_stream;
+ grpc_chttp2_stream* s = bs->stream;
+ grpc_error* error;
if (s->unprocessed_incoming_frames_buffer.length > 0) {
if (!s->unprocessed_incoming_frames_decompressed) {
@@ -2942,27 +2958,28 @@ static grpc_error *incoming_byte_stream_pull(grpc_exec_ctx *exec_ctx,
return GRPC_ERROR_NONE;
}
-static void incoming_byte_stream_destroy_locked(grpc_exec_ctx *exec_ctx,
- void *byte_stream,
- grpc_error *error_ignored);
+static void incoming_byte_stream_destroy_locked(grpc_exec_ctx* exec_ctx,
+ void* byte_stream,
+ grpc_error* error_ignored);
-static void incoming_byte_stream_destroy(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *byte_stream) {
+static void incoming_byte_stream_destroy(grpc_exec_ctx* exec_ctx,
+ grpc_byte_stream* byte_stream) {
GPR_TIMER_BEGIN("incoming_byte_stream_destroy", 0);
- grpc_chttp2_incoming_byte_stream *bs =
- (grpc_chttp2_incoming_byte_stream *)byte_stream;
+ grpc_chttp2_incoming_byte_stream* bs =
+ (grpc_chttp2_incoming_byte_stream*)byte_stream;
GRPC_CLOSURE_SCHED(
- exec_ctx, GRPC_CLOSURE_INIT(
- &bs->destroy_action, incoming_byte_stream_destroy_locked,
- bs, grpc_combiner_scheduler(bs->transport->combiner)),
+ exec_ctx,
+ GRPC_CLOSURE_INIT(&bs->destroy_action,
+ incoming_byte_stream_destroy_locked, bs,
+ grpc_combiner_scheduler(bs->transport->combiner)),
GRPC_ERROR_NONE);
GPR_TIMER_END("incoming_byte_stream_destroy", 0);
}
static void incoming_byte_stream_publish_error(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs,
- grpc_error *error) {
- grpc_chttp2_stream *s = bs->stream;
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_byte_stream* bs,
+ grpc_error* error) {
+ grpc_chttp2_stream* s = bs->stream;
GPR_ASSERT(error != GRPC_ERROR_NONE);
GRPC_CLOSURE_SCHED(exec_ctx, s->on_next, GRPC_ERROR_REF(error));
@@ -2973,13 +2990,13 @@ static void incoming_byte_stream_publish_error(
GRPC_ERROR_REF(error));
}
-grpc_error *grpc_chttp2_incoming_byte_stream_push(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs,
- grpc_slice slice, grpc_slice *slice_out) {
- grpc_chttp2_stream *s = bs->stream;
+grpc_error* grpc_chttp2_incoming_byte_stream_push(
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_byte_stream* bs,
+ grpc_slice slice, grpc_slice* slice_out) {
+ grpc_chttp2_stream* s = bs->stream;
if (bs->remaining_bytes < GRPC_SLICE_LENGTH(slice)) {
- grpc_error *error =
+ grpc_error* error =
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Too many bytes in stream");
GRPC_CLOSURE_SCHED(exec_ctx, &s->reset_byte_stream, GRPC_ERROR_REF(error));
@@ -2994,10 +3011,10 @@ grpc_error *grpc_chttp2_incoming_byte_stream_push(
}
}
-grpc_error *grpc_chttp2_incoming_byte_stream_finished(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs,
- grpc_error *error, bool reset_on_error) {
- grpc_chttp2_stream *s = bs->stream;
+grpc_error* grpc_chttp2_incoming_byte_stream_finished(
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_byte_stream* bs,
+ grpc_error* error, bool reset_on_error) {
+ grpc_chttp2_stream* s = bs->stream;
if (error == GRPC_ERROR_NONE) {
if (bs->remaining_bytes != 0) {
@@ -3011,11 +3028,11 @@ grpc_error *grpc_chttp2_incoming_byte_stream_finished(
return error;
}
-static void incoming_byte_stream_shutdown(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *byte_stream,
- grpc_error *error) {
- grpc_chttp2_incoming_byte_stream *bs =
- (grpc_chttp2_incoming_byte_stream *)byte_stream;
+static void incoming_byte_stream_shutdown(grpc_exec_ctx* exec_ctx,
+ grpc_byte_stream* byte_stream,
+ grpc_error* error) {
+ grpc_chttp2_incoming_byte_stream* bs =
+ (grpc_chttp2_incoming_byte_stream*)byte_stream;
GRPC_ERROR_UNREF(grpc_chttp2_incoming_byte_stream_finished(
exec_ctx, bs, error, true /* reset_on_error */));
}
@@ -3024,13 +3041,13 @@ static const grpc_byte_stream_vtable grpc_chttp2_incoming_byte_stream_vtable = {
incoming_byte_stream_next, incoming_byte_stream_pull,
incoming_byte_stream_shutdown, incoming_byte_stream_destroy};
-static void incoming_byte_stream_destroy_locked(grpc_exec_ctx *exec_ctx,
- void *byte_stream,
- grpc_error *error_ignored) {
- grpc_chttp2_incoming_byte_stream *bs =
- (grpc_chttp2_incoming_byte_stream *)byte_stream;
- grpc_chttp2_stream *s = bs->stream;
- grpc_chttp2_transport *t = s->t;
+static void incoming_byte_stream_destroy_locked(grpc_exec_ctx* exec_ctx,
+ void* byte_stream,
+ grpc_error* error_ignored) {
+ grpc_chttp2_incoming_byte_stream* bs =
+ (grpc_chttp2_incoming_byte_stream*)byte_stream;
+ grpc_chttp2_stream* s = bs->stream;
+ grpc_chttp2_transport* t = s->t;
GPR_ASSERT(bs->base.vtable == &grpc_chttp2_incoming_byte_stream_vtable);
incoming_byte_stream_unref(exec_ctx, bs);
@@ -3039,11 +3056,11 @@ static void incoming_byte_stream_destroy_locked(grpc_exec_ctx *exec_ctx,
grpc_chttp2_maybe_complete_recv_trailing_metadata(exec_ctx, t, s);
}
-grpc_chttp2_incoming_byte_stream *grpc_chttp2_incoming_byte_stream_create(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_chttp2_stream *s,
+grpc_chttp2_incoming_byte_stream* grpc_chttp2_incoming_byte_stream_create(
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t, grpc_chttp2_stream* s,
uint32_t frame_size, uint32_t flags) {
- grpc_chttp2_incoming_byte_stream *incoming_byte_stream =
- (grpc_chttp2_incoming_byte_stream *)gpr_malloc(
+ grpc_chttp2_incoming_byte_stream* incoming_byte_stream =
+ (grpc_chttp2_incoming_byte_stream*)gpr_malloc(
sizeof(*incoming_byte_stream));
incoming_byte_stream->base.length = frame_size;
incoming_byte_stream->remaining_bytes = frame_size;
@@ -3061,8 +3078,8 @@ grpc_chttp2_incoming_byte_stream *grpc_chttp2_incoming_byte_stream_create(
* RESOURCE QUOTAS
*/
-static void post_benign_reclaimer(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
+static void post_benign_reclaimer(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t) {
if (!t->benign_reclaimer_registered) {
t->benign_reclaimer_registered = true;
GRPC_CHTTP2_REF_TRANSPORT(t, "benign_reclaimer");
@@ -3072,8 +3089,8 @@ static void post_benign_reclaimer(grpc_exec_ctx *exec_ctx,
}
}
-static void post_destructive_reclaimer(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
+static void post_destructive_reclaimer(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t) {
if (!t->destructive_reclaimer_registered) {
t->destructive_reclaimer_registered = true;
GRPC_CHTTP2_REF_TRANSPORT(t, "destructive_reclaimer");
@@ -3083,9 +3100,9 @@ static void post_destructive_reclaimer(grpc_exec_ctx *exec_ctx,
}
}
-static void benign_reclaimer_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)arg;
+static void benign_reclaimer_locked(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_error* error) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
if (error == GRPC_ERROR_NONE &&
grpc_chttp2_stream_map_size(&t->stream_map) == 0) {
/* Channel with no active streams: send a goaway to try and make it
@@ -3098,7 +3115,8 @@ static void benign_reclaimer_locked(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Buffers full"),
GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_ENHANCE_YOUR_CALM));
- } else if (error == GRPC_ERROR_NONE && grpc_resource_quota_trace.enabled()) {
+ } else if (error == GRPC_ERROR_NONE &&
+ grpc_resource_quota_trace.enabled()) {
gpr_log(GPR_DEBUG,
"HTTP2: %s - skip benign reclamation, there are still %" PRIdPTR
" streams",
@@ -3112,14 +3130,14 @@ static void benign_reclaimer_locked(grpc_exec_ctx *exec_ctx, void *arg,
GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "benign_reclaimer");
}
-static void destructive_reclaimer_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)arg;
+static void destructive_reclaimer_locked(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_error* error) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
size_t n = grpc_chttp2_stream_map_size(&t->stream_map);
t->destructive_reclaimer_registered = false;
if (error == GRPC_ERROR_NONE && n > 0) {
- grpc_chttp2_stream *s =
- (grpc_chttp2_stream *)grpc_chttp2_stream_map_rand(&t->stream_map);
+ grpc_chttp2_stream* s =
+ (grpc_chttp2_stream*)grpc_chttp2_stream_map_rand(&t->stream_map);
if (grpc_resource_quota_trace.enabled()) {
gpr_log(GPR_DEBUG, "HTTP2: %s - abandon stream id %d", t->peer_string,
s->id);
@@ -3148,7 +3166,7 @@ static void destructive_reclaimer_locked(grpc_exec_ctx *exec_ctx, void *arg,
* MONITORING
*/
-const char *grpc_chttp2_initiate_write_reason_string(
+const char* grpc_chttp2_initiate_write_reason_string(
grpc_chttp2_initiate_write_reason reason) {
switch (reason) {
case GRPC_CHTTP2_INITIATE_WRITE_INITIAL_WRITE:
@@ -3195,9 +3213,9 @@ const char *grpc_chttp2_initiate_write_reason_string(
GPR_UNREACHABLE_CODE(return "unknown");
}
-static grpc_endpoint *chttp2_get_endpoint(grpc_exec_ctx *exec_ctx,
- grpc_transport *t) {
- return ((grpc_chttp2_transport *)t)->ep;
+static grpc_endpoint* chttp2_get_endpoint(grpc_exec_ctx* exec_ctx,
+ grpc_transport* t) {
+ return ((grpc_chttp2_transport*)t)->ep;
}
static const grpc_transport_vtable vtable = {sizeof(grpc_chttp2_stream),
@@ -3211,21 +3229,21 @@ static const grpc_transport_vtable vtable = {sizeof(grpc_chttp2_stream),
destroy_transport,
chttp2_get_endpoint};
-static const grpc_transport_vtable *get_vtable(void) { return &vtable; }
+static const grpc_transport_vtable* get_vtable(void) { return &vtable; }
-grpc_transport *grpc_create_chttp2_transport(
- grpc_exec_ctx *exec_ctx, const grpc_channel_args *channel_args,
- grpc_endpoint *ep, int is_client) {
- grpc_chttp2_transport *t =
- (grpc_chttp2_transport *)gpr_zalloc(sizeof(grpc_chttp2_transport));
+grpc_transport* grpc_create_chttp2_transport(
+ grpc_exec_ctx* exec_ctx, const grpc_channel_args* channel_args,
+ grpc_endpoint* ep, int is_client) {
+ grpc_chttp2_transport* t =
+ (grpc_chttp2_transport*)gpr_zalloc(sizeof(grpc_chttp2_transport));
init_transport(exec_ctx, t, channel_args, ep, is_client != 0);
return &t->base;
}
-void grpc_chttp2_transport_start_reading(grpc_exec_ctx *exec_ctx,
- grpc_transport *transport,
- grpc_slice_buffer *read_buffer) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)transport;
+void grpc_chttp2_transport_start_reading(grpc_exec_ctx* exec_ctx,
+ grpc_transport* transport,
+ grpc_slice_buffer* read_buffer) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)transport;
GRPC_CHTTP2_REF_TRANSPORT(
t, "reading_action"); /* matches unref inside reading_action */
if (read_buffer != NULL) {
diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.h b/src/core/ext/transport/chttp2/transport/chttp2_transport.h
index 982db403d8..44702d44ef 100644
--- a/src/core/ext/transport/chttp2/transport/chttp2_transport.h
+++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.h
@@ -23,10 +23,6 @@
#include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/transport/transport.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
extern grpc_core::TraceFlag grpc_http_trace;
extern grpc_core::TraceFlag grpc_trace_http2_stream_state;
@@ -34,15 +30,19 @@ extern grpc_core::TraceFlag grpc_trace_http2_stream_state;
extern grpc_core::TraceFlag grpc_trace_chttp2_refcount;
#endif
-grpc_transport *grpc_create_chttp2_transport(
- grpc_exec_ctx *exec_ctx, const grpc_channel_args *channel_args,
- grpc_endpoint *ep, int is_client);
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+grpc_transport* grpc_create_chttp2_transport(
+ grpc_exec_ctx* exec_ctx, const grpc_channel_args* channel_args,
+ grpc_endpoint* ep, int is_client);
/// Takes ownership of \a read_buffer, which (if non-NULL) contains
/// leftover bytes previously read from the endpoint (e.g., by handshakers).
-void grpc_chttp2_transport_start_reading(grpc_exec_ctx *exec_ctx,
- grpc_transport *transport,
- grpc_slice_buffer *read_buffer);
+void grpc_chttp2_transport_start_reading(grpc_exec_ctx* exec_ctx,
+ grpc_transport* transport,
+ grpc_slice_buffer* read_buffer);
#ifdef __cplusplus
}
diff --git a/src/core/ext/transport/chttp2/transport/flow_control.cc b/src/core/ext/transport/chttp2/transport/flow_control.cc
index 5a1358e260..bc4e0f9e22 100644
--- a/src/core/ext/transport/chttp2/transport/flow_control.cc
+++ b/src/core/ext/transport/chttp2/transport/flow_control.cc
@@ -167,7 +167,7 @@ TransportFlowControl::TransportFlowControl(grpc_exec_ctx* exec_ctx,
uint32_t TransportFlowControl::MaybeSendUpdate(bool writing_anyway) {
FlowControlTrace trace("t updt sent", this, nullptr);
- const uint32_t target_announced_window = target_window();
+ const uint32_t target_announced_window = (const uint32_t)target_window();
if ((writing_anyway || announced_window_ <= target_announced_window / 2) &&
announced_window_ != target_announced_window) {
const uint32_t announce = (uint32_t)GPR_CLAMP(
@@ -226,9 +226,9 @@ grpc_error* StreamFlowControl::RecvData(int64_t incoming_frame_size) {
incoming_frame_size, acked_stream_window, sent_stream_window);
} else {
char* msg;
- gpr_asprintf(&msg, "frame of size %" PRId64
- " overflows local window of %" PRId64,
- incoming_frame_size, acked_stream_window);
+ gpr_asprintf(
+ &msg, "frame of size %" PRId64 " overflows local window of %" PRId64,
+ incoming_frame_size, acked_stream_window);
grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return err;
diff --git a/src/core/ext/transport/chttp2/transport/flow_control.h b/src/core/ext/transport/chttp2/transport/flow_control.h
index 59ba758d52..bb710fef83 100644
--- a/src/core/ext/transport/chttp2/transport/flow_control.h
+++ b/src/core/ext/transport/chttp2/transport/flow_control.h
@@ -32,6 +32,12 @@ struct grpc_chttp2_stream;
extern grpc_core::TraceFlag grpc_flowctl_trace;
+namespace grpc {
+namespace testing {
+class TrickledCHTTP2; // to make this a friend
+} // namespace testing
+} // namespace grpc
+
namespace grpc_core {
namespace chttp2 {
@@ -203,6 +209,7 @@ class TransportFlowControl {
}
private:
+ friend class ::grpc::testing::TrickledCHTTP2;
double TargetLogBdp();
double SmoothLogBdp(grpc_exec_ctx* exec_ctx, double value);
FlowControlAction::Urgency DeltaUrgency(int32_t value,
@@ -297,6 +304,7 @@ class StreamFlowControl {
}
private:
+ friend class ::grpc::testing::TrickledCHTTP2;
TransportFlowControl* const tfc_;
const grpc_chttp2_stream* const s_;
diff --git a/src/core/ext/transport/chttp2/transport/frame_data.cc b/src/core/ext/transport/chttp2/transport/frame_data.cc
index 73aaab1802..7d2c7f5ab9 100644
--- a/src/core/ext/transport/chttp2/transport/frame_data.cc
+++ b/src/core/ext/transport/chttp2/transport/frame_data.cc
@@ -30,14 +30,14 @@
#include "src/core/lib/support/string.h"
#include "src/core/lib/transport/transport.h"
-grpc_error *grpc_chttp2_data_parser_init(grpc_chttp2_data_parser *parser) {
+grpc_error* grpc_chttp2_data_parser_init(grpc_chttp2_data_parser* parser) {
parser->state = GRPC_CHTTP2_DATA_FH_0;
parser->parsing_frame = NULL;
return GRPC_ERROR_NONE;
}
-void grpc_chttp2_data_parser_destroy(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_data_parser *parser) {
+void grpc_chttp2_data_parser_destroy(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_data_parser* parser) {
if (parser->parsing_frame != NULL) {
GRPC_ERROR_UNREF(grpc_chttp2_incoming_byte_stream_finished(
exec_ctx, parser->parsing_frame,
@@ -46,14 +46,14 @@ void grpc_chttp2_data_parser_destroy(grpc_exec_ctx *exec_ctx,
GRPC_ERROR_UNREF(parser->error);
}
-grpc_error *grpc_chttp2_data_parser_begin_frame(grpc_chttp2_data_parser *parser,
+grpc_error* grpc_chttp2_data_parser_begin_frame(grpc_chttp2_data_parser* parser,
uint8_t flags,
uint32_t stream_id,
- grpc_chttp2_stream *s) {
+ grpc_chttp2_stream* s) {
if (flags & ~GRPC_CHTTP2_DATA_FLAG_END_STREAM) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "unsupported data flags: 0x%02x", flags);
- grpc_error *err =
+ grpc_error* err =
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg),
GRPC_ERROR_INT_STREAM_ID, (intptr_t)stream_id);
gpr_free(msg);
@@ -69,12 +69,12 @@ grpc_error *grpc_chttp2_data_parser_begin_frame(grpc_chttp2_data_parser *parser,
return GRPC_ERROR_NONE;
}
-void grpc_chttp2_encode_data(uint32_t id, grpc_slice_buffer *inbuf,
+void grpc_chttp2_encode_data(uint32_t id, grpc_slice_buffer* inbuf,
uint32_t write_bytes, int is_eof,
- grpc_transport_one_way_stats *stats,
- grpc_slice_buffer *outbuf) {
+ grpc_transport_one_way_stats* stats,
+ grpc_slice_buffer* outbuf) {
grpc_slice hdr;
- uint8_t *p;
+ uint8_t* p;
static const size_t header_size = 9;
hdr = GRPC_SLICE_MALLOC(header_size);
@@ -97,17 +97,17 @@ void grpc_chttp2_encode_data(uint32_t id, grpc_slice_buffer *inbuf,
stats->data_bytes += write_bytes;
}
-grpc_error *grpc_deframe_unprocessed_incoming_frames(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_data_parser *p, grpc_chttp2_stream *s,
- grpc_slice_buffer *slices, grpc_slice *slice_out,
- grpc_byte_stream **stream_out) {
- grpc_error *error = GRPC_ERROR_NONE;
- grpc_chttp2_transport *t = s->t;
+grpc_error* grpc_deframe_unprocessed_incoming_frames(
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_data_parser* p, grpc_chttp2_stream* s,
+ grpc_slice_buffer* slices, grpc_slice* slice_out,
+ grpc_byte_stream** stream_out) {
+ grpc_error* error = GRPC_ERROR_NONE;
+ grpc_chttp2_transport* t = s->t;
while (slices->count > 0) {
- uint8_t *beg = NULL;
- uint8_t *end = NULL;
- uint8_t *cur = NULL;
+ uint8_t* beg = NULL;
+ uint8_t* end = NULL;
+ uint8_t* cur = NULL;
grpc_slice slice = grpc_slice_buffer_take_first(slices);
@@ -115,7 +115,7 @@ grpc_error *grpc_deframe_unprocessed_incoming_frames(
end = GRPC_SLICE_END_PTR(slice);
cur = beg;
uint32_t message_flags;
- char *msg;
+ char* msg;
if (cur == end) {
grpc_slice_unref_internal(exec_ctx, slice);
@@ -289,9 +289,9 @@ grpc_error *grpc_deframe_unprocessed_incoming_frames(
return GRPC_ERROR_NONE;
}
-grpc_error *grpc_chttp2_data_parser_parse(grpc_exec_ctx *exec_ctx, void *parser,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+grpc_error* grpc_chttp2_data_parser_parse(grpc_exec_ctx* exec_ctx, void* parser,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_slice slice, int is_last) {
if (!s->pending_byte_stream) {
grpc_slice_ref_internal(slice);
diff --git a/src/core/ext/transport/chttp2/transport/frame_data.h b/src/core/ext/transport/chttp2/transport/frame_data.h
index 81ec5361a3..96f823a0ad 100644
--- a/src/core/ext/transport/chttp2/transport/frame_data.h
+++ b/src/core/ext/transport/chttp2/transport/frame_data.h
@@ -49,40 +49,40 @@ typedef struct {
grpc_chttp2_stream_state state;
uint8_t frame_type;
uint32_t frame_size;
- grpc_error *error;
+ grpc_error* error;
bool is_frame_compressed;
- grpc_chttp2_incoming_byte_stream *parsing_frame;
+ grpc_chttp2_incoming_byte_stream* parsing_frame;
} grpc_chttp2_data_parser;
/* initialize per-stream state for data frame parsing */
-grpc_error *grpc_chttp2_data_parser_init(grpc_chttp2_data_parser *parser);
+grpc_error* grpc_chttp2_data_parser_init(grpc_chttp2_data_parser* parser);
-void grpc_chttp2_data_parser_destroy(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_data_parser *parser);
+void grpc_chttp2_data_parser_destroy(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_data_parser* parser);
/* start processing a new data frame */
-grpc_error *grpc_chttp2_data_parser_begin_frame(grpc_chttp2_data_parser *parser,
+grpc_error* grpc_chttp2_data_parser_begin_frame(grpc_chttp2_data_parser* parser,
uint8_t flags,
uint32_t stream_id,
- grpc_chttp2_stream *s);
+ grpc_chttp2_stream* s);
/* handle a slice of a data frame - is_last indicates the last slice of a
frame */
-grpc_error *grpc_chttp2_data_parser_parse(grpc_exec_ctx *exec_ctx, void *parser,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+grpc_error* grpc_chttp2_data_parser_parse(grpc_exec_ctx* exec_ctx, void* parser,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_slice slice, int is_last);
-void grpc_chttp2_encode_data(uint32_t id, grpc_slice_buffer *inbuf,
+void grpc_chttp2_encode_data(uint32_t id, grpc_slice_buffer* inbuf,
uint32_t write_bytes, int is_eof,
- grpc_transport_one_way_stats *stats,
- grpc_slice_buffer *outbuf);
+ grpc_transport_one_way_stats* stats,
+ grpc_slice_buffer* outbuf);
-grpc_error *grpc_deframe_unprocessed_incoming_frames(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_data_parser *p, grpc_chttp2_stream *s,
- grpc_slice_buffer *slices, grpc_slice *slice_out,
- grpc_byte_stream **stream_out);
+grpc_error* grpc_deframe_unprocessed_incoming_frames(
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_data_parser* p, grpc_chttp2_stream* s,
+ grpc_slice_buffer* slices, grpc_slice* slice_out,
+ grpc_byte_stream** stream_out);
#ifdef __cplusplus
}
diff --git a/src/core/ext/transport/chttp2/transport/frame_goaway.cc b/src/core/ext/transport/chttp2/transport/frame_goaway.cc
index 78ec08e177..6be1d0e0f0 100644
--- a/src/core/ext/transport/chttp2/transport/frame_goaway.cc
+++ b/src/core/ext/transport/chttp2/transport/frame_goaway.cc
@@ -25,42 +25,42 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
-void grpc_chttp2_goaway_parser_init(grpc_chttp2_goaway_parser *p) {
+void grpc_chttp2_goaway_parser_init(grpc_chttp2_goaway_parser* p) {
p->debug_data = NULL;
}
-void grpc_chttp2_goaway_parser_destroy(grpc_chttp2_goaway_parser *p) {
+void grpc_chttp2_goaway_parser_destroy(grpc_chttp2_goaway_parser* p) {
gpr_free(p->debug_data);
}
-grpc_error *grpc_chttp2_goaway_parser_begin_frame(grpc_chttp2_goaway_parser *p,
+grpc_error* grpc_chttp2_goaway_parser_begin_frame(grpc_chttp2_goaway_parser* p,
uint32_t length,
uint8_t flags) {
if (length < 8) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "goaway frame too short (%d bytes)", length);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return err;
}
gpr_free(p->debug_data);
p->debug_length = length - 8;
- p->debug_data = (char *)gpr_malloc(p->debug_length);
+ p->debug_data = (char*)gpr_malloc(p->debug_length);
p->debug_pos = 0;
p->state = GRPC_CHTTP2_GOAWAY_LSI0;
return GRPC_ERROR_NONE;
}
-grpc_error *grpc_chttp2_goaway_parser_parse(grpc_exec_ctx *exec_ctx,
- void *parser,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+grpc_error* grpc_chttp2_goaway_parser_parse(grpc_exec_ctx* exec_ctx,
+ void* parser,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_slice slice, int is_last) {
- uint8_t *const beg = GRPC_SLICE_START_PTR(slice);
- uint8_t *const end = GRPC_SLICE_END_PTR(slice);
- uint8_t *cur = beg;
- grpc_chttp2_goaway_parser *p = (grpc_chttp2_goaway_parser *)parser;
+ uint8_t* const beg = GRPC_SLICE_START_PTR(slice);
+ uint8_t* const end = GRPC_SLICE_END_PTR(slice);
+ uint8_t* cur = beg;
+ grpc_chttp2_goaway_parser* p = (grpc_chttp2_goaway_parser*)parser;
switch (p->state) {
case GRPC_CHTTP2_GOAWAY_LSI0:
@@ -147,9 +147,9 @@ grpc_error *grpc_chttp2_goaway_parser_parse(grpc_exec_ctx *exec_ctx,
void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code,
grpc_slice debug_data,
- grpc_slice_buffer *slice_buffer) {
+ grpc_slice_buffer* slice_buffer) {
grpc_slice header = GRPC_SLICE_MALLOC(9 + 4 + 4);
- uint8_t *p = GRPC_SLICE_START_PTR(header);
+ uint8_t* p = GRPC_SLICE_START_PTR(header);
uint32_t frame_length;
GPR_ASSERT(GRPC_SLICE_LENGTH(debug_data) < UINT32_MAX - 4 - 4);
frame_length = 4 + 4 + (uint32_t)GRPC_SLICE_LENGTH(debug_data);
diff --git a/src/core/ext/transport/chttp2/transport/frame_goaway.h b/src/core/ext/transport/chttp2/transport/frame_goaway.h
index 7b3aa45f3f..9790d0b08d 100644
--- a/src/core/ext/transport/chttp2/transport/frame_goaway.h
+++ b/src/core/ext/transport/chttp2/transport/frame_goaway.h
@@ -45,24 +45,24 @@ typedef struct {
grpc_chttp2_goaway_parse_state state;
uint32_t last_stream_id;
uint32_t error_code;
- char *debug_data;
+ char* debug_data;
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_error *grpc_chttp2_goaway_parser_begin_frame(
- grpc_chttp2_goaway_parser *parser, uint32_t length, uint8_t flags);
-grpc_error *grpc_chttp2_goaway_parser_parse(grpc_exec_ctx *exec_ctx,
- void *parser,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+void grpc_chttp2_goaway_parser_init(grpc_chttp2_goaway_parser* p);
+void grpc_chttp2_goaway_parser_destroy(grpc_chttp2_goaway_parser* p);
+grpc_error* grpc_chttp2_goaway_parser_begin_frame(
+ grpc_chttp2_goaway_parser* parser, uint32_t length, uint8_t flags);
+grpc_error* grpc_chttp2_goaway_parser_parse(grpc_exec_ctx* exec_ctx,
+ void* parser,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_slice slice, int is_last);
void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code,
grpc_slice debug_data,
- grpc_slice_buffer *slice_buffer);
+ grpc_slice_buffer* slice_buffer);
#ifdef __cplusplus
}
diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.cc b/src/core/ext/transport/chttp2/transport/frame_ping.cc
index 1cfa883ee1..d0feb51922 100644
--- a/src/core/ext/transport/chttp2/transport/frame_ping.cc
+++ b/src/core/ext/transport/chttp2/transport/frame_ping.cc
@@ -29,7 +29,7 @@ static bool g_disable_ping_ack = false;
grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint64_t opaque_8bytes) {
grpc_slice slice = GRPC_SLICE_MALLOC(9 + 8);
- uint8_t *p = GRPC_SLICE_START_PTR(slice);
+ uint8_t* p = GRPC_SLICE_START_PTR(slice);
*p++ = 0;
*p++ = 0;
@@ -52,13 +52,13 @@ grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint64_t opaque_8bytes) {
return slice;
}
-grpc_error *grpc_chttp2_ping_parser_begin_frame(grpc_chttp2_ping_parser *parser,
+grpc_error* grpc_chttp2_ping_parser_begin_frame(grpc_chttp2_ping_parser* parser,
uint32_t length,
uint8_t flags) {
if (flags & 0xfe || length != 8) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "invalid ping: length=%d, flags=%02x", length, flags);
- grpc_error *error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return error;
}
@@ -68,14 +68,14 @@ grpc_error *grpc_chttp2_ping_parser_begin_frame(grpc_chttp2_ping_parser *parser,
return GRPC_ERROR_NONE;
}
-grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+grpc_error* grpc_chttp2_ping_parser_parse(grpc_exec_ctx* exec_ctx, void* parser,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_slice slice, int is_last) {
- uint8_t *const beg = GRPC_SLICE_START_PTR(slice);
- uint8_t *const end = GRPC_SLICE_END_PTR(slice);
- uint8_t *cur = beg;
- grpc_chttp2_ping_parser *p = (grpc_chttp2_ping_parser *)parser;
+ uint8_t* const beg = GRPC_SLICE_START_PTR(slice);
+ uint8_t* const end = GRPC_SLICE_END_PTR(slice);
+ uint8_t* cur = beg;
+ grpc_chttp2_ping_parser* p = (grpc_chttp2_ping_parser*)parser;
while (p->byte != 8 && cur != end) {
p->opaque_8bytes |= (((uint64_t)*cur) << (56 - 8 * p->byte));
@@ -112,7 +112,7 @@ grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser,
if (!g_disable_ping_ack) {
if (t->ping_ack_count == t->ping_ack_capacity) {
t->ping_ack_capacity = GPR_MAX(t->ping_ack_capacity * 3 / 2, 3);
- t->ping_acks = (uint64_t *)gpr_realloc(
+ t->ping_acks = (uint64_t*)gpr_realloc(
t->ping_acks, t->ping_ack_capacity * sizeof(*t->ping_acks));
}
t->ping_acks[t->ping_ack_count++] = p->opaque_8bytes;
diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.h b/src/core/ext/transport/chttp2/transport/frame_ping.h
index ffc2f0cf2f..034aad002e 100644
--- a/src/core/ext/transport/chttp2/transport/frame_ping.h
+++ b/src/core/ext/transport/chttp2/transport/frame_ping.h
@@ -35,11 +35,11 @@ typedef struct {
grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint64_t opaque_8bytes);
-grpc_error *grpc_chttp2_ping_parser_begin_frame(grpc_chttp2_ping_parser *parser,
+grpc_error* grpc_chttp2_ping_parser_begin_frame(grpc_chttp2_ping_parser* parser,
uint32_t length, uint8_t flags);
-grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+grpc_error* grpc_chttp2_ping_parser_parse(grpc_exec_ctx* exec_ctx, void* parser,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_slice slice, int is_last);
/* Test-only function for disabling ping ack */
diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc b/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc
index 0133b6efa2..05a7f056a4 100644
--- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc
+++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc
@@ -27,11 +27,11 @@
#include "src/core/lib/transport/http2_errors.h"
grpc_slice grpc_chttp2_rst_stream_create(uint32_t id, uint32_t code,
- grpc_transport_one_way_stats *stats) {
+ grpc_transport_one_way_stats* stats) {
static const size_t frame_size = 13;
grpc_slice slice = GRPC_SLICE_MALLOC(frame_size);
stats->framing_bytes += frame_size;
- uint8_t *p = GRPC_SLICE_START_PTR(slice);
+ uint8_t* p = GRPC_SLICE_START_PTR(slice);
// Frame size.
*p++ = 0;
@@ -55,13 +55,13 @@ grpc_slice grpc_chttp2_rst_stream_create(uint32_t id, uint32_t code,
return slice;
}
-grpc_error *grpc_chttp2_rst_stream_parser_begin_frame(
- grpc_chttp2_rst_stream_parser *parser, uint32_t length, uint8_t flags) {
+grpc_error* grpc_chttp2_rst_stream_parser_begin_frame(
+ grpc_chttp2_rst_stream_parser* parser, uint32_t length, uint8_t flags) {
if (length != 4) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "invalid rst_stream: length=%d, flags=%02x", length,
flags);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return err;
}
@@ -69,15 +69,15 @@ grpc_error *grpc_chttp2_rst_stream_parser_begin_frame(
return GRPC_ERROR_NONE;
}
-grpc_error *grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx *exec_ctx,
- void *parser,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+grpc_error* grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx* exec_ctx,
+ void* parser,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_slice slice, int is_last) {
- uint8_t *const beg = GRPC_SLICE_START_PTR(slice);
- uint8_t *const end = GRPC_SLICE_END_PTR(slice);
- uint8_t *cur = beg;
- grpc_chttp2_rst_stream_parser *p = (grpc_chttp2_rst_stream_parser *)parser;
+ uint8_t* const beg = GRPC_SLICE_START_PTR(slice);
+ uint8_t* const end = GRPC_SLICE_END_PTR(slice);
+ uint8_t* cur = beg;
+ grpc_chttp2_rst_stream_parser* p = (grpc_chttp2_rst_stream_parser*)parser;
while (p->byte != 4 && cur != end) {
p->reason_bytes[p->byte] = *cur;
@@ -92,9 +92,9 @@ grpc_error *grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx *exec_ctx,
(((uint32_t)p->reason_bytes[1]) << 16) |
(((uint32_t)p->reason_bytes[2]) << 8) |
(((uint32_t)p->reason_bytes[3]));
- grpc_error *error = GRPC_ERROR_NONE;
+ grpc_error* error = GRPC_ERROR_NONE;
if (reason != GRPC_HTTP2_NO_ERROR || s->metadata_buffer[1].size == 0) {
- char *message;
+ char* message;
gpr_asprintf(&message, "Received RST_STREAM with error code %d", reason);
error = grpc_error_set_int(
grpc_error_set_str(GRPC_ERROR_CREATE_FROM_STATIC_STRING("RST_STREAM"),
diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h
index 102ffdb3f3..3f5417e993 100644
--- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h
+++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h
@@ -34,14 +34,14 @@ typedef struct {
} grpc_chttp2_rst_stream_parser;
grpc_slice grpc_chttp2_rst_stream_create(uint32_t stream_id, uint32_t code,
- grpc_transport_one_way_stats *stats);
-
-grpc_error *grpc_chttp2_rst_stream_parser_begin_frame(
- grpc_chttp2_rst_stream_parser *parser, uint32_t length, uint8_t flags);
-grpc_error *grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx *exec_ctx,
- void *parser,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+ grpc_transport_one_way_stats* stats);
+
+grpc_error* grpc_chttp2_rst_stream_parser_begin_frame(
+ grpc_chttp2_rst_stream_parser* parser, uint32_t length, uint8_t flags);
+grpc_error* grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx* exec_ctx,
+ void* parser,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_slice slice, int is_last);
#ifdef __cplusplus
diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.cc b/src/core/ext/transport/chttp2/transport/frame_settings.cc
index 82906d3db4..75bb78db4c 100644
--- a/src/core/ext/transport/chttp2/transport/frame_settings.cc
+++ b/src/core/ext/transport/chttp2/transport/frame_settings.cc
@@ -31,7 +31,7 @@
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/transport/http2_errors.h"
-static uint8_t *fill_header(uint8_t *out, uint32_t length, uint8_t flags) {
+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);
@@ -44,13 +44,13 @@ static uint8_t *fill_header(uint8_t *out, uint32_t length, uint8_t flags) {
return out;
}
-grpc_slice grpc_chttp2_settings_create(uint32_t *old_settings,
- const uint32_t *new_settings,
+grpc_slice grpc_chttp2_settings_create(uint32_t* old_settings,
+ const uint32_t* new_settings,
uint32_t force_mask, size_t count) {
size_t i;
uint32_t n = 0;
grpc_slice output;
- uint8_t *p;
+ uint8_t* p;
for (i = 0; i < count; i++) {
n += (new_settings[i] != old_settings[i] || (force_mask & (1u << i)) != 0);
@@ -82,9 +82,9 @@ grpc_slice grpc_chttp2_settings_ack_create(void) {
return output;
}
-grpc_error *grpc_chttp2_settings_parser_begin_frame(
- grpc_chttp2_settings_parser *parser, uint32_t length, uint8_t flags,
- uint32_t *settings) {
+grpc_error* grpc_chttp2_settings_parser_begin_frame(
+ 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(uint32_t));
@@ -108,14 +108,14 @@ grpc_error *grpc_chttp2_settings_parser_begin_frame(
}
}
-grpc_error *grpc_chttp2_settings_parser_parse(grpc_exec_ctx *exec_ctx, void *p,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+grpc_error* grpc_chttp2_settings_parser_parse(grpc_exec_ctx* exec_ctx, void* p,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_slice slice, int is_last) {
- grpc_chttp2_settings_parser *parser = (grpc_chttp2_settings_parser *)p;
- const uint8_t *cur = GRPC_SLICE_START_PTR(slice);
- const uint8_t *end = GRPC_SLICE_END_PTR(slice);
- char *msg;
+ grpc_chttp2_settings_parser* parser = (grpc_chttp2_settings_parser*)p;
+ const uint8_t* cur = GRPC_SLICE_START_PTR(slice);
+ const uint8_t* end = GRPC_SLICE_END_PTR(slice);
+ char* msg;
grpc_chttp2_setting_id id;
if (parser->is_ack) {
@@ -180,7 +180,7 @@ grpc_error *grpc_chttp2_settings_parser_parse(grpc_exec_ctx *exec_ctx, void *p,
cur++;
if (grpc_wire_id_to_setting_id(parser->id, &id)) {
- const grpc_chttp2_setting_parameters *sp =
+ const grpc_chttp2_setting_parameters* sp =
&grpc_chttp2_settings_parameters[id];
if (parser->value < sp->min_value || parser->value > sp->max_value) {
switch (sp->invalid_value_behavior) {
@@ -195,7 +195,7 @@ grpc_error *grpc_chttp2_settings_parser_parse(grpc_exec_ctx *exec_ctx, void *p,
&t->qbuf);
gpr_asprintf(&msg, "invalid value %u passed for %s",
parser->value, sp->name);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return err;
}
diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.h b/src/core/ext/transport/chttp2/transport/frame_settings.h
index 3364da1520..18bde92815 100644
--- a/src/core/ext/transport/chttp2/transport/frame_settings.h
+++ b/src/core/ext/transport/chttp2/transport/frame_settings.h
@@ -40,7 +40,7 @@ typedef enum {
typedef struct {
grpc_chttp2_settings_parse_state state;
- uint32_t *target_settings;
+ uint32_t* target_settings;
uint8_t is_ack;
uint16_t id;
uint32_t value;
@@ -48,18 +48,18 @@ typedef struct {
} grpc_chttp2_settings_parser;
/* Create a settings frame by diffing old & new, and updating old to be new */
-grpc_slice grpc_chttp2_settings_create(uint32_t *old, const uint32_t *newval,
+grpc_slice grpc_chttp2_settings_create(uint32_t* old, const uint32_t* newval,
uint32_t force_mask, size_t count);
/* Create an ack settings frame */
grpc_slice grpc_chttp2_settings_ack_create(void);
-grpc_error *grpc_chttp2_settings_parser_begin_frame(
- grpc_chttp2_settings_parser *parser, uint32_t length, uint8_t flags,
- uint32_t *settings);
-grpc_error *grpc_chttp2_settings_parser_parse(grpc_exec_ctx *exec_ctx,
- void *parser,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+grpc_error* grpc_chttp2_settings_parser_begin_frame(
+ grpc_chttp2_settings_parser* parser, uint32_t length, uint8_t flags,
+ uint32_t* settings);
+grpc_error* grpc_chttp2_settings_parser_parse(grpc_exec_ctx* exec_ctx,
+ void* parser,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_slice slice, int is_last);
#ifdef __cplusplus
diff --git a/src/core/ext/transport/chttp2/transport/frame_window_update.cc b/src/core/ext/transport/chttp2/transport/frame_window_update.cc
index 15eaf59285..62a4587ac6 100644
--- a/src/core/ext/transport/chttp2/transport/frame_window_update.cc
+++ b/src/core/ext/transport/chttp2/transport/frame_window_update.cc
@@ -24,11 +24,11 @@
#include <grpc/support/string_util.h>
grpc_slice grpc_chttp2_window_update_create(
- uint32_t id, uint32_t window_update, grpc_transport_one_way_stats *stats) {
+ uint32_t id, uint32_t window_update, grpc_transport_one_way_stats* stats) {
static const size_t frame_size = 13;
grpc_slice slice = GRPC_SLICE_MALLOC(frame_size);
stats->header_bytes += frame_size;
- uint8_t *p = GRPC_SLICE_START_PTR(slice);
+ uint8_t* p = GRPC_SLICE_START_PTR(slice);
GPR_ASSERT(window_update);
@@ -49,13 +49,13 @@ grpc_slice grpc_chttp2_window_update_create(
return slice;
}
-grpc_error *grpc_chttp2_window_update_parser_begin_frame(
- grpc_chttp2_window_update_parser *parser, uint32_t length, uint8_t flags) {
+grpc_error* grpc_chttp2_window_update_parser_begin_frame(
+ grpc_chttp2_window_update_parser* parser, uint32_t length, uint8_t flags) {
if (flags || length != 4) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "invalid window update: length=%d, flags=%02x", length,
flags);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return err;
}
@@ -64,14 +64,14 @@ grpc_error *grpc_chttp2_window_update_parser_begin_frame(
return GRPC_ERROR_NONE;
}
-grpc_error *grpc_chttp2_window_update_parser_parse(
- grpc_exec_ctx *exec_ctx, void *parser, grpc_chttp2_transport *t,
- grpc_chttp2_stream *s, grpc_slice slice, int is_last) {
- uint8_t *const beg = GRPC_SLICE_START_PTR(slice);
- uint8_t *const end = GRPC_SLICE_END_PTR(slice);
- uint8_t *cur = beg;
- grpc_chttp2_window_update_parser *p =
- (grpc_chttp2_window_update_parser *)parser;
+grpc_error* grpc_chttp2_window_update_parser_parse(
+ grpc_exec_ctx* exec_ctx, void* parser, grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s, grpc_slice slice, int is_last) {
+ uint8_t* const beg = GRPC_SLICE_START_PTR(slice);
+ uint8_t* const end = GRPC_SLICE_END_PTR(slice);
+ uint8_t* cur = beg;
+ grpc_chttp2_window_update_parser* p =
+ (grpc_chttp2_window_update_parser*)parser;
while (p->byte != 4 && cur != end) {
p->amount |= ((uint32_t)*cur) << (8 * (3 - p->byte));
@@ -86,9 +86,9 @@ grpc_error *grpc_chttp2_window_update_parser_parse(
if (p->byte == 4) {
uint32_t received_update = p->amount;
if (received_update == 0 || (received_update & 0x80000000u)) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "invalid window update bytes: %d", p->amount);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return err;
}
diff --git a/src/core/ext/transport/chttp2/transport/frame_window_update.h b/src/core/ext/transport/chttp2/transport/frame_window_update.h
index 400f9f5398..daf7d2da6b 100644
--- a/src/core/ext/transport/chttp2/transport/frame_window_update.h
+++ b/src/core/ext/transport/chttp2/transport/frame_window_update.h
@@ -35,13 +35,13 @@ typedef struct {
} grpc_chttp2_window_update_parser;
grpc_slice grpc_chttp2_window_update_create(
- uint32_t id, uint32_t window_delta, grpc_transport_one_way_stats *stats);
+ uint32_t id, uint32_t window_delta, grpc_transport_one_way_stats* stats);
-grpc_error *grpc_chttp2_window_update_parser_begin_frame(
- grpc_chttp2_window_update_parser *parser, uint32_t length, uint8_t flags);
-grpc_error *grpc_chttp2_window_update_parser_parse(
- grpc_exec_ctx *exec_ctx, void *parser, grpc_chttp2_transport *t,
- grpc_chttp2_stream *s, grpc_slice slice, int is_last);
+grpc_error* grpc_chttp2_window_update_parser_begin_frame(
+ grpc_chttp2_window_update_parser* parser, uint32_t length, uint8_t flags);
+grpc_error* grpc_chttp2_window_update_parser_parse(
+ grpc_exec_ctx* exec_ctx, void* parser, grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s, grpc_slice slice, int is_last);
#ifdef __cplusplus
}
diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc
index c380869fc6..b57c9304a4 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc
+++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc
@@ -57,8 +57,6 @@ static const grpc_slice terminal_slice = {
{{0, 0}} /* data.refcounted */
};
-extern grpc_core::TraceFlag grpc_http_trace;
-
typedef struct {
int is_first_frame;
/* number of bytes in 'output' when we started the frame - used to calculate
@@ -70,15 +68,15 @@ typedef struct {
uint8_t seen_regular_header;
/* output stream id */
uint32_t stream_id;
- grpc_slice_buffer *output;
- grpc_transport_one_way_stats *stats;
+ grpc_slice_buffer* output;
+ grpc_transport_one_way_stats* stats;
/* maximum size of a frame */
size_t max_frame_size;
bool use_true_binary_metadata;
} framer_state;
/* fills p (which is expected to be 9 bytes long) with a data frame header */
-static void fill_header(uint8_t *p, uint8_t type, uint32_t id, size_t len,
+static void fill_header(uint8_t* p, uint8_t type, uint32_t id, size_t len,
uint8_t flags) {
GPR_ASSERT(len < 16777316);
*p++ = (uint8_t)(len >> 16);
@@ -93,7 +91,7 @@ static void fill_header(uint8_t *p, uint8_t type, uint32_t id, size_t len,
}
/* finish a frame - fill in the previously reserved header */
-static void finish_frame(framer_state *st, int is_header_boundary,
+static void finish_frame(framer_state* st, int is_header_boundary,
int is_last_in_stream) {
uint8_t type = 0xff;
type = st->is_first_frame ? GRPC_CHTTP2_FRAME_HEADER
@@ -109,7 +107,7 @@ static void finish_frame(framer_state *st, int is_header_boundary,
/* begin a new frame: reserve off header space, remember how many bytes we'd
output before beginning */
-static void begin_frame(framer_state *st) {
+static void begin_frame(framer_state* st) {
st->header_idx =
grpc_slice_buffer_add_indexed(st->output, GRPC_SLICE_MALLOC(9));
st->output_length_at_start_of_frame = st->output->length;
@@ -118,7 +116,7 @@ static void begin_frame(framer_state *st) {
/* make sure that the current frame is of the type desired, and has sufficient
space to add at least about_to_add bytes -- finishes the current frame if
needed */
-static void ensure_space(framer_state *st, size_t need_bytes) {
+static void ensure_space(framer_state* st, size_t need_bytes) {
if (st->output->length - st->output_length_at_start_of_frame + need_bytes <=
st->max_frame_size) {
return;
@@ -128,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(uint8_t idx, uint32_t *sum, uint8_t *elems) {
+static void inc_filter(uint8_t idx, uint32_t* sum, uint8_t* elems) {
elems[idx]++;
if (elems[idx] < 255) {
(*sum)++;
@@ -142,7 +140,7 @@ static void inc_filter(uint8_t idx, uint32_t *sum, uint8_t *elems) {
}
}
-static void add_header_data(framer_state *st, grpc_slice slice) {
+static void add_header_data(framer_state* st, grpc_slice slice) {
size_t len = GRPC_SLICE_LENGTH(slice);
size_t remaining;
if (len == 0) return;
@@ -160,13 +158,13 @@ static void add_header_data(framer_state *st, grpc_slice slice) {
}
}
-static uint8_t *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);
st->stats->header_bytes += len;
return grpc_slice_buffer_tiny_add(st->output, len);
}
-static void evict_entry(grpc_chttp2_hpack_compressor *c) {
+static void evict_entry(grpc_chttp2_hpack_compressor* c) {
c->tail_remote_index++;
GPR_ASSERT(c->tail_remote_index > 0);
GPR_ASSERT(c->table_size >=
@@ -181,7 +179,7 @@ static void evict_entry(grpc_chttp2_hpack_compressor *c) {
// Reserve space in table for the new element, evict entries if needed.
// Return the new index of the element. Return 0 to indicate not adding to
// table.
-static uint32_t prepare_space_for_new_elem(grpc_chttp2_hpack_compressor *c,
+static uint32_t prepare_space_for_new_elem(grpc_chttp2_hpack_compressor* c,
size_t elem_size) {
uint32_t new_index = c->tail_remote_index + c->table_elems + 1;
GPR_ASSERT(elem_size < 65536);
@@ -208,14 +206,14 @@ static uint32_t prepare_space_for_new_elem(grpc_chttp2_hpack_compressor *c,
}
/* dummy function */
-static void add_nothing(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_compressor *c, grpc_mdelem elem,
+static void add_nothing(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_compressor* c, grpc_mdelem elem,
size_t elem_size) {}
// Add a key to the dynamic table. Both key and value will be added to table at
// the decoder.
-static void add_key_with_index(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_compressor *c,
+static void add_key_with_index(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_compressor* c,
grpc_mdelem elem, uint32_t new_index) {
if (new_index == 0) {
return;
@@ -257,8 +255,8 @@ static void add_key_with_index(grpc_exec_ctx *exec_ctx,
}
/* add an element to the decoder table */
-static void add_elem_with_index(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_compressor *c,
+static void add_elem_with_index(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_compressor* c,
grpc_mdelem elem, uint32_t new_index) {
if (new_index == 0) {
return;
@@ -301,21 +299,21 @@ static void add_elem_with_index(grpc_exec_ctx *exec_ctx,
add_key_with_index(exec_ctx, c, elem, new_index);
}
-static void add_elem(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
+static void add_elem(grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_compressor* c,
grpc_mdelem elem, size_t elem_size) {
uint32_t new_index = prepare_space_for_new_elem(c, elem_size);
add_elem_with_index(exec_ctx, c, elem, new_index);
}
-static void add_key(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
+static void add_key(grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_compressor* c,
grpc_mdelem elem, size_t elem_size) {
uint32_t new_index = prepare_space_for_new_elem(c, elem_size);
add_key_with_index(exec_ctx, c, elem, new_index);
}
-static void emit_indexed(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_compressor *c, uint32_t elem_index,
- framer_state *st) {
+static void emit_indexed(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_compressor* c, uint32_t elem_index,
+ framer_state* st) {
GRPC_STATS_INC_HPACK_SEND_INDEXED(exec_ctx);
uint32_t len = GRPC_CHTTP2_VARINT_LENGTH(elem_index, 1);
GRPC_CHTTP2_WRITE_VARINT(elem_index, 1, 0x80, add_tiny_header_data(st, len),
@@ -328,7 +326,7 @@ typedef struct {
bool insert_null_before_wire_value;
} wire_value;
-static wire_value get_wire_value(grpc_exec_ctx *exec_ctx, grpc_mdelem elem,
+static wire_value get_wire_value(grpc_exec_ctx* exec_ctx, grpc_mdelem elem,
bool true_binary_enabled) {
wire_value wire_val;
if (grpc_is_binary_header(GRPC_MDKEY(elem))) {
@@ -359,15 +357,15 @@ static size_t wire_value_length(wire_value v) {
return GPR_SLICE_LENGTH(v.data) + v.insert_null_before_wire_value;
}
-static void add_wire_value(framer_state *st, wire_value v) {
+static void add_wire_value(framer_state* st, wire_value v) {
if (v.insert_null_before_wire_value) *add_tiny_header_data(st, 1) = 0;
add_header_data(st, v.data);
}
-static void emit_lithdr_incidx(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_compressor *c,
+static void emit_lithdr_incidx(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_compressor* c,
uint32_t key_index, grpc_mdelem elem,
- framer_state *st) {
+ framer_state* st) {
GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX(exec_ctx);
uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 2);
wire_value value =
@@ -383,10 +381,10 @@ static void emit_lithdr_incidx(grpc_exec_ctx *exec_ctx,
add_wire_value(st, value);
}
-static void emit_lithdr_noidx(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_compressor *c,
+static void emit_lithdr_noidx(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_compressor* c,
uint32_t key_index, grpc_mdelem elem,
- framer_state *st) {
+ framer_state* st) {
GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX(exec_ctx);
uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 4);
wire_value value =
@@ -402,10 +400,10 @@ static void emit_lithdr_noidx(grpc_exec_ctx *exec_ctx,
add_wire_value(st, value);
}
-static void emit_lithdr_incidx_v(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_compressor *c,
+static void emit_lithdr_incidx_v(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_compressor* c,
uint32_t unused_index, grpc_mdelem elem,
- framer_state *st) {
+ framer_state* st) {
GPR_ASSERT(unused_index == 0);
GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX_V(exec_ctx);
GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED(exec_ctx);
@@ -426,10 +424,10 @@ static void emit_lithdr_incidx_v(grpc_exec_ctx *exec_ctx,
add_wire_value(st, value);
}
-static void emit_lithdr_noidx_v(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_compressor *c,
+static void emit_lithdr_noidx_v(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_compressor* c,
uint32_t unused_index, grpc_mdelem elem,
- framer_state *st) {
+ framer_state* st) {
GPR_ASSERT(unused_index == 0);
GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX_V(exec_ctx);
GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED(exec_ctx);
@@ -450,22 +448,22 @@ static void emit_lithdr_noidx_v(grpc_exec_ctx *exec_ctx,
add_wire_value(st, value);
}
-static void emit_advertise_table_size_change(grpc_chttp2_hpack_compressor *c,
- framer_state *st) {
+static void emit_advertise_table_size_change(grpc_chttp2_hpack_compressor* c,
+ framer_state* st) {
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 uint32_t dynidx(grpc_chttp2_hpack_compressor *c, uint32_t 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;
}
/* encode an mdelem */
-static void hpack_enc(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
- grpc_mdelem elem, framer_state *st) {
+static void hpack_enc(grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_compressor* c,
+ grpc_mdelem elem, framer_state* st) {
GPR_ASSERT(GRPC_SLICE_LENGTH(GRPC_MDKEY(elem)) > 0);
if (GRPC_SLICE_START_PTR(GRPC_MDKEY(elem))[0] != ':') { /* regular header */
st->seen_regular_header = 1;
@@ -476,8 +474,8 @@ static void hpack_enc(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
}
if (grpc_http_trace.enabled()) {
- char *k = grpc_slice_to_c_string(GRPC_MDKEY(elem));
- char *v = NULL;
+ char* k = grpc_slice_to_c_string(GRPC_MDKEY(elem));
+ char* v = NULL;
if (grpc_is_binary_header(GRPC_MDKEY(elem))) {
v = grpc_dump_slice(GRPC_MDVALUE(elem), GPR_DUMP_HEX);
} else {
@@ -540,11 +538,10 @@ static void hpack_enc(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
decoder_space_usage < MAX_DECODER_SPACE_USAGE &&
c->filter_elems[HASH_FRAGMENT_1(elem_hash)] >=
c->filter_elems_sum / ONE_ON_ADD_PROBABILITY;
- void (*maybe_add)(grpc_exec_ctx *, grpc_chttp2_hpack_compressor *,
- grpc_mdelem, size_t) =
- should_add_elem ? add_elem : add_nothing;
- void (*emit)(grpc_exec_ctx *, grpc_chttp2_hpack_compressor *, uint32_t,
- grpc_mdelem, framer_state *) =
+ void (*maybe_add)(grpc_exec_ctx*, grpc_chttp2_hpack_compressor*, grpc_mdelem,
+ size_t) = should_add_elem ? add_elem : add_nothing;
+ void (*emit)(grpc_exec_ctx*, grpc_chttp2_hpack_compressor*, uint32_t,
+ grpc_mdelem, framer_state*) =
should_add_elem ? emit_lithdr_incidx : emit_lithdr_noidx;
/* no hits for the elem... maybe there's a key? */
@@ -582,9 +579,9 @@ static void hpack_enc(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
#define STRLEN_LIT(x) (sizeof(x) - 1)
#define TIMEOUT_KEY "grpc-timeout"
-static void deadline_enc(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_compressor *c, grpc_millis deadline,
- framer_state *st) {
+static void deadline_enc(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_compressor* c, grpc_millis deadline,
+ framer_state* st) {
char timeout_str[GRPC_HTTP2_TIMEOUT_ENCODE_MIN_BUFSIZE];
grpc_mdelem mdelem;
grpc_http2_encode_timeout(deadline - grpc_exec_ctx_now(exec_ctx),
@@ -597,14 +594,14 @@ static void deadline_enc(grpc_exec_ctx *exec_ctx,
static uint32_t elems_for_bytes(uint32_t bytes) { return (bytes + 31) / 32; }
-void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor *c) {
+void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor* c) {
memset(c, 0, sizeof(*c));
c->max_table_size = GRPC_CHTTP2_HPACKC_INITIAL_TABLE_SIZE;
c->cap_table_elems = elems_for_bytes(c->max_table_size);
c->max_table_elems = c->cap_table_elems;
c->max_usable_size = GRPC_CHTTP2_HPACKC_INITIAL_TABLE_SIZE;
c->table_elem_size =
- (uint16_t *)gpr_malloc(sizeof(*c->table_elem_size) * c->cap_table_elems);
+ (uint16_t*)gpr_malloc(sizeof(*c->table_elem_size) * c->cap_table_elems);
memset(c->table_elem_size, 0,
sizeof(*c->table_elem_size) * c->cap_table_elems);
for (size_t i = 0; i < GPR_ARRAY_SIZE(c->entries_keys); i++) {
@@ -612,8 +609,8 @@ void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor *c) {
}
}
-void grpc_chttp2_hpack_compressor_destroy(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_compressor *c) {
+void grpc_chttp2_hpack_compressor_destroy(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_compressor* c) {
int i;
for (i = 0; i < GRPC_CHTTP2_HPACKC_NUM_VALUES; i++) {
if (c->entries_keys[i].refcount != &terminal_slice_refcount) {
@@ -625,15 +622,15 @@ void grpc_chttp2_hpack_compressor_destroy(grpc_exec_ctx *exec_ctx,
}
void grpc_chttp2_hpack_compressor_set_max_usable_size(
- grpc_chttp2_hpack_compressor *c, uint32_t 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, uint32_t new_cap) {
- uint16_t *table_elem_size =
- (uint16_t *)gpr_malloc(sizeof(*table_elem_size) * new_cap);
+static void rebuild_elems(grpc_chttp2_hpack_compressor* c, uint32_t new_cap) {
+ uint16_t* table_elem_size =
+ (uint16_t*)gpr_malloc(sizeof(*table_elem_size) * new_cap);
uint32_t i;
memset(table_elem_size, 0, sizeof(*table_elem_size) * new_cap);
@@ -651,7 +648,7 @@ static void rebuild_elems(grpc_chttp2_hpack_compressor *c, uint32_t new_cap) {
}
void grpc_chttp2_hpack_compressor_set_max_table_size(
- grpc_chttp2_hpack_compressor *c, uint32_t 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;
@@ -675,13 +672,13 @@ void grpc_chttp2_hpack_compressor_set_max_table_size(
}
}
-void grpc_chttp2_encode_header(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_compressor *c,
- grpc_mdelem **extra_headers,
+void grpc_chttp2_encode_header(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_compressor* c,
+ grpc_mdelem** extra_headers,
size_t extra_headers_size,
- grpc_metadata_batch *metadata,
- const grpc_encode_header_options *options,
- grpc_slice_buffer *outbuf) {
+ grpc_metadata_batch* metadata,
+ const grpc_encode_header_options* options,
+ grpc_slice_buffer* outbuf) {
GPR_ASSERT(options->stream_id != 0);
framer_state st;
@@ -705,7 +702,7 @@ void grpc_chttp2_encode_header(grpc_exec_ctx *exec_ctx,
hpack_enc(exec_ctx, c, *extra_headers[i], &st);
}
grpc_metadata_batch_assert_ok(metadata);
- for (grpc_linked_mdelem *l = metadata->list.head; l; l = l->next) {
+ for (grpc_linked_mdelem* l = metadata->list.head; l; l = l->next) {
hpack_enc(exec_ctx, c, l->md, &st);
}
grpc_millis deadline = metadata->deadline;
diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.h b/src/core/ext/transport/chttp2/transport/hpack_encoder.h
index 16316b63f7..96d8e99dd0 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_encoder.h
+++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.h
@@ -34,6 +34,8 @@
/* maximum table size we'll actually use */
#define GRPC_CHTTP2_HPACKC_MAX_TABLE_SIZE (1024 * 1024)
+extern grpc_core::TraceFlag grpc_http_trace;
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -68,32 +70,32 @@ typedef struct {
uint32_t indices_keys[GRPC_CHTTP2_HPACKC_NUM_VALUES];
uint32_t indices_elems[GRPC_CHTTP2_HPACKC_NUM_VALUES];
- uint16_t *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_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_compressor *c);
+void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor* c);
+void grpc_chttp2_hpack_compressor_destroy(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_compressor* c);
void grpc_chttp2_hpack_compressor_set_max_table_size(
- grpc_chttp2_hpack_compressor *c, uint32_t 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, uint32_t max_table_size);
+ grpc_chttp2_hpack_compressor* c, uint32_t max_table_size);
typedef struct {
uint32_t stream_id;
bool is_eof;
bool use_true_binary_metadata;
size_t max_frame_size;
- grpc_transport_one_way_stats *stats;
+ grpc_transport_one_way_stats* stats;
} grpc_encode_header_options;
-void grpc_chttp2_encode_header(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_compressor *c,
- grpc_mdelem **extra_headers,
+void grpc_chttp2_encode_header(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_compressor* c,
+ grpc_mdelem** extra_headers,
size_t extra_headers_size,
- grpc_metadata_batch *metadata,
- const grpc_encode_header_options *options,
- grpc_slice_buffer *outbuf);
+ grpc_metadata_batch* metadata,
+ const grpc_encode_header_options* options,
+ grpc_slice_buffer* outbuf);
#ifdef __cplusplus
}
diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.cc b/src/core/ext/transport/chttp2/transport/hpack_parser.cc
index 0c190db641..6f7db56ad7 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_parser.cc
+++ b/src/core/ext/transport/chttp2/transport/hpack_parser.cc
@@ -61,97 +61,97 @@ typedef enum {
a set of indirect jumps, and so not waste stack space. */
/* forward declarations for parsing states */
-static grpc_error *parse_begin(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_error(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end, grpc_error *error);
-static grpc_error *still_parse_error(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end);
-static grpc_error *parse_illegal_op(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end);
-
-static grpc_error *parse_string_prefix(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end);
-static grpc_error *parse_key_string(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end);
-static grpc_error *parse_value_string_with_indexed_key(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_value_string_with_literal_key(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end);
-
-static grpc_error *parse_value0(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_value1(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_value2(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_value3(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_value4(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_value5up(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end);
-
-static grpc_error *parse_indexed_field(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end);
-static grpc_error *parse_indexed_field_x(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_lithdr_incidx(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end);
-static grpc_error *parse_lithdr_incidx_x(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_lithdr_incidx_v(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_lithdr_notidx(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end);
-static grpc_error *parse_lithdr_notidx_x(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_lithdr_notidx_v(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_lithdr_nvridx(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end);
-static grpc_error *parse_lithdr_nvridx_x(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_lithdr_nvridx_v(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_max_tbl_size(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end);
-static grpc_error *parse_max_tbl_size_x(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end);
+static grpc_error* parse_begin(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_error(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end, grpc_error* error);
+static grpc_error* still_parse_error(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end);
+static grpc_error* parse_illegal_op(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end);
+
+static grpc_error* parse_string_prefix(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end);
+static grpc_error* parse_key_string(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end);
+static grpc_error* parse_value_string_with_indexed_key(
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_value_string_with_literal_key(
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end);
+
+static grpc_error* parse_value0(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_value1(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_value2(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_value3(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_value4(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_value5up(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end);
+
+static grpc_error* parse_indexed_field(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end);
+static grpc_error* parse_indexed_field_x(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_lithdr_incidx(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end);
+static grpc_error* parse_lithdr_incidx_x(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_lithdr_incidx_v(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_lithdr_notidx(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end);
+static grpc_error* parse_lithdr_notidx_x(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_lithdr_notidx_v(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_lithdr_nvridx(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end);
+static grpc_error* parse_lithdr_nvridx_x(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_lithdr_nvridx_v(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_max_tbl_size(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end);
+static grpc_error* parse_max_tbl_size_x(grpc_exec_ctx* exec_ctx,
+ 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.
@@ -649,11 +649,11 @@ static const uint8_t inverse_base64[256] = {
};
/* emission helpers */
-static grpc_error *on_hdr(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_parser *p,
+static grpc_error* on_hdr(grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_parser* p,
grpc_mdelem md, int add_to_table) {
if (grpc_http_trace.enabled()) {
- char *k = grpc_slice_to_c_string(GRPC_MDKEY(md));
- char *v = NULL;
+ char* k = grpc_slice_to_c_string(GRPC_MDKEY(md));
+ char* v = NULL;
if (grpc_is_binary_header(GRPC_MDKEY(md))) {
v = grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_HEX);
} else {
@@ -671,7 +671,7 @@ static grpc_error *on_hdr(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_parser *p,
if (add_to_table) {
GPR_ASSERT(GRPC_MDELEM_STORAGE(md) == GRPC_MDELEM_STORAGE_INTERNED ||
GRPC_MDELEM_STORAGE(md) == GRPC_MDELEM_STORAGE_STATIC);
- grpc_error *err = grpc_chttp2_hptbl_add(exec_ctx, &p->table, md);
+ grpc_error* err = grpc_chttp2_hptbl_add(exec_ctx, &p->table, md);
if (err != GRPC_ERROR_NONE) return err;
}
if (p->on_header == NULL) {
@@ -682,9 +682,9 @@ static grpc_error *on_hdr(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_parser *p,
return GRPC_ERROR_NONE;
}
-static grpc_slice take_string(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- grpc_chttp2_hpack_parser_string *str,
+static grpc_slice take_string(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ grpc_chttp2_hpack_parser_string* str,
bool intern) {
grpc_slice s;
if (!str->copied) {
@@ -708,18 +708,18 @@ static grpc_slice take_string(grpc_exec_ctx *exec_ctx,
}
/* jump to the next state */
-static grpc_error *parse_next(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_next(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end) {
p->state = *p->next_state++;
return p->state(exec_ctx, p, cur, end);
}
/* begin parsing a header: all functionality is encoded into lookup tables
above */
-static grpc_error *parse_begin(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_begin(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end) {
if (cur == end) {
p->state = parse_begin;
return GRPC_ERROR_NONE;
@@ -729,9 +729,9 @@ static grpc_error *parse_begin(grpc_exec_ctx *exec_ctx,
}
/* stream dependency and prioritization data: we just skip it */
-static grpc_error *parse_stream_weight(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_stream_weight(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
if (cur == end) {
p->state = parse_stream_weight;
return GRPC_ERROR_NONE;
@@ -740,9 +740,9 @@ static grpc_error *parse_stream_weight(grpc_exec_ctx *exec_ctx,
return p->after_prioritization(exec_ctx, p, cur + 1, end);
}
-static grpc_error *parse_stream_dep3(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_stream_dep3(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
if (cur == end) {
p->state = parse_stream_dep3;
return GRPC_ERROR_NONE;
@@ -751,9 +751,9 @@ static grpc_error *parse_stream_dep3(grpc_exec_ctx *exec_ctx,
return parse_stream_weight(exec_ctx, p, cur + 1, end);
}
-static grpc_error *parse_stream_dep2(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_stream_dep2(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
if (cur == end) {
p->state = parse_stream_dep2;
return GRPC_ERROR_NONE;
@@ -762,9 +762,9 @@ static grpc_error *parse_stream_dep2(grpc_exec_ctx *exec_ctx,
return parse_stream_dep3(exec_ctx, p, cur + 1, end);
}
-static grpc_error *parse_stream_dep1(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_stream_dep1(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
if (cur == end) {
p->state = parse_stream_dep1;
return GRPC_ERROR_NONE;
@@ -773,9 +773,9 @@ static grpc_error *parse_stream_dep1(grpc_exec_ctx *exec_ctx,
return parse_stream_dep2(exec_ctx, p, cur + 1, end);
}
-static grpc_error *parse_stream_dep0(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_stream_dep0(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
if (cur == end) {
p->state = parse_stream_dep0;
return GRPC_ERROR_NONE;
@@ -785,10 +785,10 @@ static grpc_error *parse_stream_dep0(grpc_exec_ctx *exec_ctx,
}
/* emit an indexed field; jumps to begin the next field on completion */
-static grpc_error *finish_indexed_field(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* finish_indexed_field(grpc_exec_ctx* exec_ctx,
+ 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 (GRPC_MDISNULL(md)) {
return grpc_error_set_int(
@@ -799,25 +799,25 @@ static grpc_error *finish_indexed_field(grpc_exec_ctx *exec_ctx,
}
GRPC_MDELEM_REF(md);
GRPC_STATS_INC_HPACK_RECV_INDEXED(exec_ctx);
- grpc_error *err = on_hdr(exec_ctx, p, md, 0);
+ grpc_error* err = on_hdr(exec_ctx, p, md, 0);
if (err != GRPC_ERROR_NONE) return err;
return parse_begin(exec_ctx, p, cur, end);
}
/* parse an indexed field with index < 127 */
-static grpc_error *parse_indexed_field(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_indexed_field(grpc_exec_ctx* exec_ctx,
+ 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(exec_ctx, p, cur + 1, end);
}
/* parse an indexed field with index >= 127 */
-static grpc_error *parse_indexed_field_x(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_indexed_field_x(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ 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;
@@ -828,14 +828,14 @@ static grpc_error *parse_indexed_field_x(grpc_exec_ctx *exec_ctx,
}
/* finish a literal header with incremental indexing */
-static grpc_error *finish_lithdr_incidx(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* finish_lithdr_incidx(grpc_exec_ctx* exec_ctx,
+ 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(!GRPC_MDISNULL(md)); /* handled in string parsing */
GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX(exec_ctx);
- grpc_error *err = on_hdr(
+ grpc_error* err = on_hdr(
exec_ctx, p,
grpc_mdelem_from_slices(exec_ctx, grpc_slice_ref_internal(GRPC_MDKEY(md)),
take_string(exec_ctx, p, &p->value, true)),
@@ -845,12 +845,12 @@ static grpc_error *finish_lithdr_incidx(grpc_exec_ctx *exec_ctx,
}
/* finish a literal header with incremental indexing with no index */
-static grpc_error *finish_lithdr_incidx_v(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* finish_lithdr_incidx_v(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end) {
GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX_V(exec_ctx);
- grpc_error *err = on_hdr(
+ grpc_error* err = on_hdr(
exec_ctx, p,
grpc_mdelem_from_slices(exec_ctx, take_string(exec_ctx, p, &p->key, true),
take_string(exec_ctx, p, &p->value, true)),
@@ -860,9 +860,9 @@ static grpc_error *finish_lithdr_incidx_v(grpc_exec_ctx *exec_ctx,
}
/* parse a literal header with incremental indexing; index < 63 */
-static grpc_error *parse_lithdr_incidx(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_lithdr_incidx(grpc_exec_ctx* exec_ctx,
+ 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;
@@ -872,10 +872,10 @@ static grpc_error *parse_lithdr_incidx(grpc_exec_ctx *exec_ctx,
}
/* parse a literal header with incremental indexing; index >= 63 */
-static grpc_error *parse_lithdr_incidx_x(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_lithdr_incidx_x(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ 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};
@@ -887,10 +887,10 @@ static grpc_error *parse_lithdr_incidx_x(grpc_exec_ctx *exec_ctx,
}
/* parse a literal header with incremental indexing; index = 0 */
-static grpc_error *parse_lithdr_incidx_v(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_lithdr_incidx_v(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ 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};
@@ -900,14 +900,14 @@ static grpc_error *parse_lithdr_incidx_v(grpc_exec_ctx *exec_ctx,
}
/* finish a literal header without incremental indexing */
-static grpc_error *finish_lithdr_notidx(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* finish_lithdr_notidx(grpc_exec_ctx* exec_ctx,
+ 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(!GRPC_MDISNULL(md)); /* handled in string parsing */
GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX(exec_ctx);
- grpc_error *err = on_hdr(
+ grpc_error* err = on_hdr(
exec_ctx, p,
grpc_mdelem_from_slices(exec_ctx, grpc_slice_ref_internal(GRPC_MDKEY(md)),
take_string(exec_ctx, p, &p->value, false)),
@@ -917,12 +917,12 @@ static grpc_error *finish_lithdr_notidx(grpc_exec_ctx *exec_ctx,
}
/* finish a literal header without incremental indexing with index = 0 */
-static grpc_error *finish_lithdr_notidx_v(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* finish_lithdr_notidx_v(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end) {
GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX_V(exec_ctx);
- grpc_error *err = on_hdr(
+ grpc_error* err = on_hdr(
exec_ctx, p,
grpc_mdelem_from_slices(exec_ctx, take_string(exec_ctx, p, &p->key, true),
take_string(exec_ctx, p, &p->value, false)),
@@ -932,9 +932,9 @@ static grpc_error *finish_lithdr_notidx_v(grpc_exec_ctx *exec_ctx,
}
/* parse a literal header without incremental indexing; index < 15 */
-static grpc_error *parse_lithdr_notidx(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_lithdr_notidx(grpc_exec_ctx* exec_ctx,
+ 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;
@@ -944,10 +944,10 @@ static grpc_error *parse_lithdr_notidx(grpc_exec_ctx *exec_ctx,
}
/* parse a literal header without incremental indexing; index >= 15 */
-static grpc_error *parse_lithdr_notidx_x(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_lithdr_notidx_x(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ 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};
@@ -959,10 +959,10 @@ static grpc_error *parse_lithdr_notidx_x(grpc_exec_ctx *exec_ctx,
}
/* parse a literal header without incremental indexing; index == 0 */
-static grpc_error *parse_lithdr_notidx_v(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_lithdr_notidx_v(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ 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};
@@ -972,14 +972,14 @@ static grpc_error *parse_lithdr_notidx_v(grpc_exec_ctx *exec_ctx,
}
/* finish a literal header that is never indexed */
-static grpc_error *finish_lithdr_nvridx(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* finish_lithdr_nvridx(grpc_exec_ctx* exec_ctx,
+ 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(!GRPC_MDISNULL(md)); /* handled in string parsing */
GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX(exec_ctx);
- grpc_error *err = on_hdr(
+ grpc_error* err = on_hdr(
exec_ctx, p,
grpc_mdelem_from_slices(exec_ctx, grpc_slice_ref_internal(GRPC_MDKEY(md)),
take_string(exec_ctx, p, &p->value, false)),
@@ -989,12 +989,12 @@ static grpc_error *finish_lithdr_nvridx(grpc_exec_ctx *exec_ctx,
}
/* finish a literal header that is never indexed with an extra value */
-static grpc_error *finish_lithdr_nvridx_v(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* finish_lithdr_nvridx_v(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end) {
GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX_V(exec_ctx);
- grpc_error *err = on_hdr(
+ grpc_error* err = on_hdr(
exec_ctx, p,
grpc_mdelem_from_slices(exec_ctx, take_string(exec_ctx, p, &p->key, true),
take_string(exec_ctx, p, &p->value, false)),
@@ -1004,9 +1004,9 @@ static grpc_error *finish_lithdr_nvridx_v(grpc_exec_ctx *exec_ctx,
}
/* parse a literal header that is never indexed; index < 15 */
-static grpc_error *parse_lithdr_nvridx(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_lithdr_nvridx(grpc_exec_ctx* exec_ctx,
+ 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;
@@ -1016,10 +1016,10 @@ static grpc_error *parse_lithdr_nvridx(grpc_exec_ctx *exec_ctx,
}
/* parse a literal header that is never indexed; index >= 15 */
-static grpc_error *parse_lithdr_nvridx_x(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_lithdr_nvridx_x(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ 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};
@@ -1031,10 +1031,10 @@ static grpc_error *parse_lithdr_nvridx_x(grpc_exec_ctx *exec_ctx,
}
/* parse a literal header that is never indexed; index == 0 */
-static grpc_error *parse_lithdr_nvridx_v(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_lithdr_nvridx_v(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ 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};
@@ -1044,22 +1044,22 @@ static grpc_error *parse_lithdr_nvridx_v(grpc_exec_ctx *exec_ctx,
}
/* finish parsing a max table size change */
-static grpc_error *finish_max_tbl_size(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* finish_max_tbl_size(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
if (grpc_http_trace.enabled()) {
gpr_log(GPR_INFO, "MAX TABLE SIZE: %d", p->index);
}
- grpc_error *err =
+ grpc_error* err =
grpc_chttp2_hptbl_set_current_table_size(exec_ctx, &p->table, p->index);
if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
return parse_begin(exec_ctx, p, cur, end);
}
/* parse a max table size change, max size < 15 */
-static grpc_error *parse_max_tbl_size(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_max_tbl_size(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
if (p->dynamic_table_update_allowed == 0) {
return parse_error(
exec_ctx, p, cur, end,
@@ -1072,10 +1072,10 @@ static grpc_error *parse_max_tbl_size(grpc_exec_ctx *exec_ctx,
}
/* parse a max table size change, max size >= 15 */
-static grpc_error *parse_max_tbl_size_x(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_max_tbl_size_x(grpc_exec_ctx* exec_ctx,
+ 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) {
@@ -1092,9 +1092,9 @@ static grpc_error *parse_max_tbl_size_x(grpc_exec_ctx *exec_ctx,
}
/* a parse error: jam the parse state into parse_error, and return error */
-static grpc_error *parse_error(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end, grpc_error *err) {
+static grpc_error* parse_error(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end, grpc_error* err) {
GPR_ASSERT(err != GRPC_ERROR_NONE);
if (p->last_error == GRPC_ERROR_NONE) {
p->last_error = GRPC_ERROR_REF(err);
@@ -1103,28 +1103,28 @@ static grpc_error *parse_error(grpc_exec_ctx *exec_ctx,
return err;
}
-static grpc_error *still_parse_error(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* still_parse_error(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
return GRPC_ERROR_REF(p->last_error);
}
-static grpc_error *parse_illegal_op(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_illegal_op(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
GPR_ASSERT(cur != end);
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "Illegal hpack op code %d", *cur);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return parse_error(exec_ctx, p, cur, end, err);
}
/* parse the 1st byte of a varint into p->parsing.value
no overflow is possible */
-static grpc_error *parse_value0(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_value0(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end) {
if (cur == end) {
p->state = parse_value0;
return GRPC_ERROR_NONE;
@@ -1141,9 +1141,9 @@ static grpc_error *parse_value0(grpc_exec_ctx *exec_ctx,
/* parse the 2nd byte of a varint into p->parsing.value
no overflow is possible */
-static grpc_error *parse_value1(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_value1(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end) {
if (cur == end) {
p->state = parse_value1;
return GRPC_ERROR_NONE;
@@ -1160,9 +1160,9 @@ static grpc_error *parse_value1(grpc_exec_ctx *exec_ctx,
/* parse the 3rd byte of a varint into p->parsing.value
no overflow is possible */
-static grpc_error *parse_value2(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_value2(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end) {
if (cur == end) {
p->state = parse_value2;
return GRPC_ERROR_NONE;
@@ -1179,9 +1179,9 @@ static grpc_error *parse_value2(grpc_exec_ctx *exec_ctx,
/* parse the 4th byte of a varint into p->parsing.value
no overflow is possible */
-static grpc_error *parse_value3(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_value3(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end) {
if (cur == end) {
p->state = parse_value3;
return GRPC_ERROR_NONE;
@@ -1198,13 +1198,13 @@ static grpc_error *parse_value3(grpc_exec_ctx *exec_ctx,
/* parse the 5th byte of a varint into p->parsing.value
depending on the byte, we may overflow, and care must be taken */
-static grpc_error *parse_value4(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_value4(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end) {
uint8_t c;
uint32_t cur_value;
uint32_t add_value;
- char *msg;
+ char* msg;
if (cur == end) {
p->state = parse_value4;
@@ -1235,7 +1235,7 @@ error:
"integer overflow in hpack integer decoding: have 0x%08x, "
"got byte 0x%02x on byte 5",
*p->parsing.value, *cur);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return parse_error(exec_ctx, p, cur, end, err);
}
@@ -1243,9 +1243,9 @@ 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 grpc_error *parse_value5up(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_value5up(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
while (cur != end && *cur == 0x80) {
++cur;
}
@@ -1259,20 +1259,20 @@ static grpc_error *parse_value5up(grpc_exec_ctx *exec_ctx,
return parse_next(exec_ctx, p, cur + 1, end);
}
- char *msg;
+ char* msg;
gpr_asprintf(&msg,
"integer overflow in hpack integer decoding: have 0x%08x, "
"got byte 0x%02x sometime after byte 5",
*p->parsing.value, *cur);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return parse_error(exec_ctx, p, cur, end, err);
}
/* parse a string prefix */
-static grpc_error *parse_string_prefix(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_string_prefix(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
if (cur == end) {
p->state = parse_string_prefix;
return GRPC_ERROR_NONE;
@@ -1289,24 +1289,24 @@ static grpc_error *parse_string_prefix(grpc_exec_ctx *exec_ctx,
}
/* append some bytes to a string */
-static void append_bytes(grpc_chttp2_hpack_parser_string *str,
- const uint8_t *data, size_t length) {
+static void append_bytes(grpc_chttp2_hpack_parser_string* str,
+ const uint8_t* data, size_t length) {
if (length == 0) return;
if (length + str->data.copied.length > str->data.copied.capacity) {
GPR_ASSERT(str->data.copied.length + length <= UINT32_MAX);
str->data.copied.capacity = (uint32_t)(str->data.copied.length + length);
str->data.copied.str =
- (char *)gpr_realloc(str->data.copied.str, str->data.copied.capacity);
+ (char*)gpr_realloc(str->data.copied.str, str->data.copied.capacity);
}
memcpy(str->data.copied.str + str->data.copied.length, data, length);
GPR_ASSERT(length <= UINT32_MAX - str->data.copied.length);
str->data.copied.length += (uint32_t)length;
}
-static grpc_error *append_string(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
- grpc_chttp2_hpack_parser_string *str = p->parsing.str;
+static grpc_error* append_string(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
+ grpc_chttp2_hpack_parser_string* str = p->parsing.str;
uint32_t bits;
uint8_t decoded[3];
switch ((binary_state)p->binary) {
@@ -1403,12 +1403,12 @@ static grpc_error *append_string(grpc_exec_ctx *exec_ctx,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Should never reach here")));
}
-static grpc_error *finish_str(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* finish_str(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end) {
uint8_t decoded[2];
uint32_t bits;
- grpc_chttp2_hpack_parser_string *str = p->parsing.str;
+ grpc_chttp2_hpack_parser_string* str = p->parsing.str;
switch ((binary_state)p->binary) {
case NOT_BINARY:
break;
@@ -1423,10 +1423,10 @@ static grpc_error *finish_str(grpc_exec_ctx *exec_ctx,
case B64_BYTE2:
bits = p->base64_buffer;
if (bits & 0xffff) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "trailing bits in base64 encoding: 0x%04x",
bits & 0xffff);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return parse_error(exec_ctx, p, cur, end, err);
}
@@ -1436,10 +1436,10 @@ static grpc_error *finish_str(grpc_exec_ctx *exec_ctx,
case B64_BYTE3:
bits = p->base64_buffer;
if (bits & 0xff) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "trailing bits in base64 encoding: 0x%02x",
bits & 0xff);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return parse_error(exec_ctx, p, cur, end, err);
}
@@ -1452,14 +1452,14 @@ static grpc_error *finish_str(grpc_exec_ctx *exec_ctx,
}
/* decode a nibble from a huffman encoded stream */
-static grpc_error *huff_nibble(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, uint8_t nibble) {
+static grpc_error* huff_nibble(grpc_exec_ctx* exec_ctx,
+ 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) {
uint8_t c = (uint8_t)emit;
- grpc_error *err = append_string(exec_ctx, p, &c, (&c) + 1);
+ grpc_error* err = append_string(exec_ctx, p, &c, (&c) + 1);
if (err != GRPC_ERROR_NONE) return err;
} else {
assert(emit == 256);
@@ -1470,11 +1470,11 @@ static grpc_error *huff_nibble(grpc_exec_ctx *exec_ctx,
}
/* decode full bytes from a huffman encoded stream */
-static grpc_error *add_huff_bytes(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* add_huff_bytes(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
for (; cur != end; ++cur) {
- grpc_error *err = huff_nibble(exec_ctx, p, *cur >> 4);
+ grpc_error* err = huff_nibble(exec_ctx, p, *cur >> 4);
if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
err = huff_nibble(exec_ctx, p, *cur & 0xf);
if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
@@ -1484,9 +1484,9 @@ static grpc_error *add_huff_bytes(grpc_exec_ctx *exec_ctx,
/* decode some string bytes based on the current decoding mode
(huffman or not) */
-static grpc_error *add_str_bytes(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* add_str_bytes(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
if (p->huff) {
return add_huff_bytes(exec_ctx, p, cur, end);
} else {
@@ -1495,19 +1495,19 @@ static grpc_error *add_str_bytes(grpc_exec_ctx *exec_ctx,
}
/* parse a string - tries to do large chunks at a time */
-static grpc_error *parse_string(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_string(grpc_exec_ctx* exec_ctx,
+ 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) {
- grpc_error *err = add_str_bytes(exec_ctx, p, cur, cur + remaining);
+ grpc_error* err = add_str_bytes(exec_ctx, p, cur, cur + remaining);
if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
err = finish_str(exec_ctx, p, cur + remaining, end);
if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
return parse_next(exec_ctx, p, cur + remaining, end);
} else {
- grpc_error *err = add_str_bytes(exec_ctx, p, cur, cur + given);
+ grpc_error* err = add_str_bytes(exec_ctx, p, cur, cur + given);
if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
GPR_ASSERT(given <= UINT32_MAX - p->strgot);
p->strgot += (uint32_t)given;
@@ -1517,17 +1517,17 @@ static grpc_error *parse_string(grpc_exec_ctx *exec_ctx,
}
/* begin parsing a string - performs setup, calls parse_string */
-static grpc_error *begin_parse_string(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end,
+static grpc_error* begin_parse_string(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end,
uint8_t binary,
- grpc_chttp2_hpack_parser_string *str) {
+ grpc_chttp2_hpack_parser_string* str) {
if (!p->huff && binary == NOT_BINARY && (end - cur) >= (intptr_t)p->strlen &&
p->current_slice_refcount != NULL) {
GRPC_STATS_INC_HPACK_RECV_UNCOMPRESSED(exec_ctx);
str->copied = false;
str->data.referenced.refcount = p->current_slice_refcount;
- str->data.referenced.data.refcounted.bytes = (uint8_t *)cur;
+ str->data.referenced.data.refcounted.bytes = (uint8_t*)cur;
str->data.referenced.data.refcounted.length = p->strlen;
grpc_slice_ref_internal(str->data.referenced);
return parse_next(exec_ctx, p, cur + p->strlen, end);
@@ -1556,23 +1556,23 @@ static grpc_error *begin_parse_string(grpc_exec_ctx *exec_ctx,
}
/* parse the key string */
-static grpc_error *parse_key_string(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_key_string(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
return begin_parse_string(exec_ctx, p, cur, end, NOT_BINARY, &p->key);
}
/* check if a key represents a binary header or not */
-static bool is_binary_literal_header(grpc_chttp2_hpack_parser *p) {
+static bool is_binary_literal_header(grpc_chttp2_hpack_parser* p) {
return grpc_is_binary_header(
p->key.copied ? grpc_slice_from_static_buffer(p->key.data.copied.str,
p->key.data.copied.length)
: p->key.data.referenced);
}
-static grpc_error *is_binary_indexed_header(grpc_chttp2_hpack_parser *p,
- bool *is) {
+static grpc_error* is_binary_indexed_header(grpc_chttp2_hpack_parser* p,
+ bool* is) {
grpc_mdelem elem = grpc_chttp2_hptbl_lookup(&p->table, p->index);
if (GRPC_MDISNULL(elem)) {
return grpc_error_set_int(
@@ -1586,33 +1586,33 @@ static grpc_error *is_binary_indexed_header(grpc_chttp2_hpack_parser *p,
}
/* parse the value string */
-static grpc_error *parse_value_string(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end,
+static grpc_error* parse_value_string(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end,
bool is_binary) {
return begin_parse_string(exec_ctx, p, cur, end,
is_binary ? BINARY_BEGIN : NOT_BINARY, &p->value);
}
-static grpc_error *parse_value_string_with_indexed_key(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_value_string_with_indexed_key(
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end) {
bool is_binary = false;
- grpc_error *err = is_binary_indexed_header(p, &is_binary);
+ grpc_error* err = is_binary_indexed_header(p, &is_binary);
if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
return parse_value_string(exec_ctx, p, cur, end, is_binary);
}
-static grpc_error *parse_value_string_with_literal_key(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_value_string_with_literal_key(
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end) {
return parse_value_string(exec_ctx, p, cur, end, is_binary_literal_header(p));
}
/* PUBLIC INTERFACE */
-void grpc_chttp2_hpack_parser_init(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p) {
+void grpc_chttp2_hpack_parser_init(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p) {
p->on_header = NULL;
p->on_header_user_data = NULL;
p->state = parse_begin;
@@ -1629,13 +1629,13 @@ void grpc_chttp2_hpack_parser_init(grpc_exec_ctx *exec_ctx,
grpc_chttp2_hptbl_init(exec_ctx, &p->table);
}
-void grpc_chttp2_hpack_parser_set_has_priority(grpc_chttp2_hpack_parser *p) {
+void grpc_chttp2_hpack_parser_set_has_priority(grpc_chttp2_hpack_parser* p) {
p->after_prioritization = p->state;
p->state = parse_stream_dep0;
}
-void grpc_chttp2_hpack_parser_destroy(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p) {
+void grpc_chttp2_hpack_parser_destroy(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p) {
grpc_chttp2_hptbl_destroy(exec_ctx, &p->table);
GRPC_ERROR_UNREF(p->last_error);
grpc_slice_unref_internal(exec_ctx, p->key.data.referenced);
@@ -1644,18 +1644,18 @@ void grpc_chttp2_hpack_parser_destroy(grpc_exec_ctx *exec_ctx,
gpr_free(p->value.data.copied.str);
}
-grpc_error *grpc_chttp2_hpack_parser_parse(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
+grpc_error* grpc_chttp2_hpack_parser_parse(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
grpc_slice slice) {
/* max number of bytes to parse at a time... limits call stack depth on
* compilers without TCO */
#define MAX_PARSE_LENGTH 1024
p->current_slice_refcount = slice.refcount;
- uint8_t *start = GRPC_SLICE_START_PTR(slice);
- uint8_t *end = GRPC_SLICE_END_PTR(slice);
- grpc_error *error = GRPC_ERROR_NONE;
+ uint8_t* start = GRPC_SLICE_START_PTR(slice);
+ uint8_t* end = GRPC_SLICE_END_PTR(slice);
+ grpc_error* error = GRPC_ERROR_NONE;
while (start != end && error == GRPC_ERROR_NONE) {
- uint8_t *target = start + GPR_MIN(MAX_PARSE_LENGTH, end - start);
+ uint8_t* target = start + GPR_MIN(MAX_PARSE_LENGTH, end - start);
error = p->state(exec_ctx, p, start, target);
start = target;
}
@@ -1663,17 +1663,17 @@ grpc_error *grpc_chttp2_hpack_parser_parse(grpc_exec_ctx *exec_ctx,
return error;
}
-typedef void (*maybe_complete_func_type)(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
+typedef void (*maybe_complete_func_type)(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
static const maybe_complete_func_type maybe_complete_funcs[] = {
grpc_chttp2_maybe_complete_recv_initial_metadata,
grpc_chttp2_maybe_complete_recv_trailing_metadata};
-static void force_client_rst_stream(grpc_exec_ctx *exec_ctx, void *sp,
- grpc_error *error) {
- grpc_chttp2_stream *s = (grpc_chttp2_stream *)sp;
- grpc_chttp2_transport *t = s->t;
+static void force_client_rst_stream(grpc_exec_ctx* exec_ctx, void* sp,
+ grpc_error* error) {
+ grpc_chttp2_stream* s = (grpc_chttp2_stream*)sp;
+ grpc_chttp2_transport* t = s->t;
if (!s->write_closed) {
grpc_slice_buffer_add(
&t->qbuf, grpc_chttp2_rst_stream_create(s->id, GRPC_HTTP2_NO_ERROR,
@@ -1685,10 +1685,10 @@ static void force_client_rst_stream(grpc_exec_ctx *exec_ctx, void *sp,
GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "final_rst");
}
-static void parse_stream_compression_md(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
- grpc_metadata_batch *initial_metadata) {
+static void parse_stream_compression_md(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
+ grpc_metadata_batch* initial_metadata) {
if (initial_metadata->idx.named.content_encoding == NULL ||
grpc_stream_compression_method_parse(
GRPC_MDVALUE(initial_metadata->idx.named.content_encoding->md), false,
@@ -1698,17 +1698,17 @@ static void parse_stream_compression_md(grpc_exec_ctx *exec_ctx,
}
}
-grpc_error *grpc_chttp2_header_parser_parse(grpc_exec_ctx *exec_ctx,
- void *hpack_parser,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+grpc_error* grpc_chttp2_header_parser_parse(grpc_exec_ctx* exec_ctx,
+ void* hpack_parser,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_slice slice, int is_last) {
- grpc_chttp2_hpack_parser *parser = (grpc_chttp2_hpack_parser *)hpack_parser;
+ grpc_chttp2_hpack_parser* parser = (grpc_chttp2_hpack_parser*)hpack_parser;
GPR_TIMER_BEGIN("grpc_chttp2_hpack_parser_parse", 0);
if (s != NULL) {
s->stats.incoming.header_bytes += GRPC_SLICE_LENGTH(slice);
}
- grpc_error *error = grpc_chttp2_hpack_parser_parse(exec_ctx, parser, slice);
+ grpc_error* error = grpc_chttp2_hpack_parser_parse(exec_ctx, parser, slice);
if (error != GRPC_ERROR_NONE) {
GPR_TIMER_END("grpc_chttp2_hpack_parser_parse", 0);
return error;
diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.h b/src/core/ext/transport/chttp2/transport/hpack_parser.h
index 52014175a0..838c482e4a 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_parser.h
+++ b/src/core/ext/transport/chttp2/transport/hpack_parser.h
@@ -33,16 +33,16 @@ extern "C" {
typedef struct grpc_chttp2_hpack_parser grpc_chttp2_hpack_parser;
-typedef grpc_error *(*grpc_chttp2_hpack_parser_state)(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_parser *p, const uint8_t *beg,
- const uint8_t *end);
+typedef grpc_error* (*grpc_chttp2_hpack_parser_state)(
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_parser* p, const uint8_t* beg,
+ const uint8_t* end);
typedef struct {
bool copied;
struct {
grpc_slice referenced;
struct {
- char *str;
+ char* str;
uint32_t length;
uint32_t capacity;
} copied;
@@ -51,23 +51,23 @@ typedef struct {
struct grpc_chttp2_hpack_parser {
/* user specified callback for each header output */
- void (*on_header)(grpc_exec_ctx *exec_ctx, void *user_data, grpc_mdelem md);
- void *on_header_user_data;
+ void (*on_header)(grpc_exec_ctx* exec_ctx, void* user_data, grpc_mdelem md);
+ void* on_header_user_data;
- grpc_error *last_error;
+ grpc_error* last_error;
/* current parse state - or a function that implements it */
grpc_chttp2_hpack_parser_state state;
/* future states dependent on the opening op code */
- const grpc_chttp2_hpack_parser_state *next_state;
+ const grpc_chttp2_hpack_parser_state* next_state;
/* what to do after skipping prioritization data */
grpc_chttp2_hpack_parser_state after_prioritization;
/* the refcount of the slice that we're currently parsing */
- grpc_slice_refcount *current_slice_refcount;
+ grpc_slice_refcount* current_slice_refcount;
/* the value we're currently parsing */
union {
- uint32_t *value;
- grpc_chttp2_hpack_parser_string *str;
+ uint32_t* value;
+ grpc_chttp2_hpack_parser_string* str;
} parsing;
/* string parameters for each chunk */
grpc_chttp2_hpack_parser_string key;
@@ -96,23 +96,23 @@ struct grpc_chttp2_hpack_parser {
grpc_chttp2_hptbl table;
};
-void grpc_chttp2_hpack_parser_init(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p);
-void grpc_chttp2_hpack_parser_destroy(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p);
+void grpc_chttp2_hpack_parser_init(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p);
+void grpc_chttp2_hpack_parser_destroy(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p);
-void grpc_chttp2_hpack_parser_set_has_priority(grpc_chttp2_hpack_parser *p);
+void grpc_chttp2_hpack_parser_set_has_priority(grpc_chttp2_hpack_parser* p);
-grpc_error *grpc_chttp2_hpack_parser_parse(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
+grpc_error* grpc_chttp2_hpack_parser_parse(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hpack_parser* p,
grpc_slice slice);
/* wraps grpc_chttp2_hpack_parser_parse to provide a frame level parser for
the transport */
-grpc_error *grpc_chttp2_header_parser_parse(grpc_exec_ctx *exec_ctx,
- void *hpack_parser,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+grpc_error* grpc_chttp2_header_parser_parse(grpc_exec_ctx* exec_ctx,
+ void* hpack_parser,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_slice slice, int is_last);
#ifdef __cplusplus
diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.cc b/src/core/ext/transport/chttp2/transport/hpack_table.cc
index 1cb8c0a85b..b18c35fe2a 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_table.cc
+++ b/src/core/ext/transport/chttp2/transport/hpack_table.cc
@@ -31,8 +31,8 @@
extern grpc_core::TraceFlag grpc_http_trace;
static struct {
- const char *key;
- const char *value;
+ const char* key;
+ const char* value;
} static_table[] = {
/* 0: */
{NULL, NULL},
@@ -165,7 +165,7 @@ static uint32_t entries_for_bytes(uint32_t bytes) {
GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD;
}
-void grpc_chttp2_hptbl_init(grpc_exec_ctx *exec_ctx, grpc_chttp2_hptbl *tbl) {
+void grpc_chttp2_hptbl_init(grpc_exec_ctx* exec_ctx, grpc_chttp2_hptbl* tbl) {
size_t i;
memset(tbl, 0, sizeof(*tbl));
@@ -173,7 +173,7 @@ void grpc_chttp2_hptbl_init(grpc_exec_ctx *exec_ctx, grpc_chttp2_hptbl *tbl) {
GRPC_CHTTP2_INITIAL_HPACK_TABLE_SIZE;
tbl->max_entries = tbl->cap_entries =
entries_for_bytes(tbl->current_table_bytes);
- tbl->ents = (grpc_mdelem *)gpr_malloc(sizeof(*tbl->ents) * tbl->cap_entries);
+ tbl->ents = (grpc_mdelem*)gpr_malloc(sizeof(*tbl->ents) * tbl->cap_entries);
memset(tbl->ents, 0, sizeof(*tbl->ents) * tbl->cap_entries);
for (i = 1; i <= GRPC_CHTTP2_LAST_STATIC_ENTRY; i++) {
tbl->static_ents[i - 1] = grpc_mdelem_from_slices(
@@ -184,8 +184,8 @@ void grpc_chttp2_hptbl_init(grpc_exec_ctx *exec_ctx, grpc_chttp2_hptbl *tbl) {
}
}
-void grpc_chttp2_hptbl_destroy(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hptbl *tbl) {
+void grpc_chttp2_hptbl_destroy(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hptbl* tbl) {
size_t i;
for (i = 0; i < GRPC_CHTTP2_LAST_STATIC_ENTRY; i++) {
GRPC_MDELEM_UNREF(exec_ctx, tbl->static_ents[i]);
@@ -197,7 +197,7 @@ void grpc_chttp2_hptbl_destroy(grpc_exec_ctx *exec_ctx,
gpr_free(tbl->ents);
}
-grpc_mdelem grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl *tbl,
+grpc_mdelem grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl* tbl,
uint32_t tbl_index) {
/* Static table comes first, just return an entry from it */
if (tbl_index <= GRPC_CHTTP2_LAST_STATIC_ENTRY) {
@@ -215,7 +215,7 @@ grpc_mdelem grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl *tbl,
}
/* Evict one element from the table */
-static void evict1(grpc_exec_ctx *exec_ctx, grpc_chttp2_hptbl *tbl) {
+static void evict1(grpc_exec_ctx* exec_ctx, grpc_chttp2_hptbl* tbl) {
grpc_mdelem first_ent = tbl->ents[tbl->first_ent];
size_t elem_bytes = GRPC_SLICE_LENGTH(GRPC_MDKEY(first_ent)) +
GRPC_SLICE_LENGTH(GRPC_MDVALUE(first_ent)) +
@@ -227,8 +227,8 @@ static void evict1(grpc_exec_ctx *exec_ctx, grpc_chttp2_hptbl *tbl) {
GRPC_MDELEM_UNREF(exec_ctx, first_ent);
}
-static void rebuild_ents(grpc_chttp2_hptbl *tbl, uint32_t new_cap) {
- grpc_mdelem *ents = (grpc_mdelem *)gpr_malloc(sizeof(*ents) * new_cap);
+static void rebuild_ents(grpc_chttp2_hptbl* tbl, uint32_t new_cap) {
+ grpc_mdelem* ents = (grpc_mdelem*)gpr_malloc(sizeof(*ents) * new_cap);
uint32_t i;
for (i = 0; i < tbl->num_ents; i++) {
@@ -240,8 +240,8 @@ static void rebuild_ents(grpc_chttp2_hptbl *tbl, uint32_t new_cap) {
tbl->first_ent = 0;
}
-void grpc_chttp2_hptbl_set_max_bytes(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hptbl *tbl,
+void grpc_chttp2_hptbl_set_max_bytes(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hptbl* tbl,
uint32_t max_bytes) {
if (tbl->max_bytes == max_bytes) {
return;
@@ -255,18 +255,18 @@ void grpc_chttp2_hptbl_set_max_bytes(grpc_exec_ctx *exec_ctx,
tbl->max_bytes = max_bytes;
}
-grpc_error *grpc_chttp2_hptbl_set_current_table_size(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hptbl *tbl,
+grpc_error* grpc_chttp2_hptbl_set_current_table_size(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hptbl* tbl,
uint32_t bytes) {
if (tbl->current_table_bytes == bytes) {
return GRPC_ERROR_NONE;
}
if (bytes > tbl->max_bytes) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg,
"Attempt to make hpack table %d bytes when max is %d bytes",
bytes, tbl->max_bytes);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return err;
}
@@ -289,21 +289,21 @@ grpc_error *grpc_chttp2_hptbl_set_current_table_size(grpc_exec_ctx *exec_ctx,
return GRPC_ERROR_NONE;
}
-grpc_error *grpc_chttp2_hptbl_add(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hptbl *tbl, grpc_mdelem md) {
+grpc_error* grpc_chttp2_hptbl_add(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hptbl* tbl, grpc_mdelem md) {
/* determine how many bytes of buffer this entry represents */
size_t elem_bytes = GRPC_SLICE_LENGTH(GRPC_MDKEY(md)) +
GRPC_SLICE_LENGTH(GRPC_MDVALUE(md)) +
GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD;
if (tbl->current_table_bytes > tbl->max_bytes) {
- char *msg;
+ char* msg;
gpr_asprintf(
&msg,
"HPACK max table size reduced to %d but not reflected by hpack "
"stream (still at %d)",
tbl->max_bytes, tbl->current_table_bytes);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return err;
}
@@ -341,7 +341,7 @@ grpc_error *grpc_chttp2_hptbl_add(grpc_exec_ctx *exec_ctx,
}
grpc_chttp2_hptbl_find_result grpc_chttp2_hptbl_find(
- const grpc_chttp2_hptbl *tbl, grpc_mdelem md) {
+ const grpc_chttp2_hptbl* tbl, grpc_mdelem md) {
grpc_chttp2_hptbl_find_result r = {0, 0};
uint32_t i;
diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.h b/src/core/ext/transport/chttp2/transport/hpack_table.h
index a3ce2730a8..ddc8888f86 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_table.h
+++ b/src/core/ext/transport/chttp2/transport/hpack_table.h
@@ -68,26 +68,26 @@ typedef struct {
/* 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 */
- grpc_mdelem *ents;
+ grpc_mdelem* ents;
grpc_mdelem static_ents[GRPC_CHTTP2_LAST_STATIC_ENTRY];
} grpc_chttp2_hptbl;
/* initialize a hpack table */
-void grpc_chttp2_hptbl_init(grpc_exec_ctx *exec_ctx, grpc_chttp2_hptbl *tbl);
-void grpc_chttp2_hptbl_destroy(grpc_exec_ctx *exec_ctx, grpc_chttp2_hptbl *tbl);
-void grpc_chttp2_hptbl_set_max_bytes(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hptbl *tbl,
+void grpc_chttp2_hptbl_init(grpc_exec_ctx* exec_ctx, grpc_chttp2_hptbl* tbl);
+void grpc_chttp2_hptbl_destroy(grpc_exec_ctx* exec_ctx, grpc_chttp2_hptbl* tbl);
+void grpc_chttp2_hptbl_set_max_bytes(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hptbl* tbl,
uint32_t max_bytes);
-grpc_error *grpc_chttp2_hptbl_set_current_table_size(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hptbl *tbl,
+grpc_error* grpc_chttp2_hptbl_set_current_table_size(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_hptbl* tbl,
uint32_t bytes);
/* lookup a table entry based on its hpack index */
-grpc_mdelem grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl *tbl,
+grpc_mdelem grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl* tbl,
uint32_t index);
/* add a table entry to the index */
-grpc_error *grpc_chttp2_hptbl_add(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hptbl *tbl,
+grpc_error* grpc_chttp2_hptbl_add(grpc_exec_ctx* exec_ctx,
+ 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 */
@@ -96,7 +96,7 @@ typedef struct {
int has_value;
} grpc_chttp2_hptbl_find_result;
grpc_chttp2_hptbl_find_result grpc_chttp2_hptbl_find(
- const grpc_chttp2_hptbl *tbl, grpc_mdelem md);
+ const grpc_chttp2_hptbl* tbl, grpc_mdelem md);
#ifdef __cplusplus
}
diff --git a/src/core/ext/transport/chttp2/transport/http2_settings.cc b/src/core/ext/transport/chttp2/transport/http2_settings.cc
index 46b7c0c49c..0aab864400 100644
--- a/src/core/ext/transport/chttp2/transport/http2_settings.cc
+++ b/src/core/ext/transport/chttp2/transport/http2_settings.cc
@@ -25,7 +25,7 @@
const uint16_t grpc_setting_id_to_wire_id[] = {1, 2, 3, 4, 5, 6, 65027};
-bool grpc_wire_id_to_setting_id(uint32_t wire_id, grpc_chttp2_setting_id *out) {
+bool grpc_wire_id_to_setting_id(uint32_t wire_id, grpc_chttp2_setting_id* out) {
uint32_t i = wire_id - 1;
uint32_t x = i % 256;
uint32_t y = i / 256;
diff --git a/src/core/ext/transport/chttp2/transport/http2_settings.h b/src/core/ext/transport/chttp2/transport/http2_settings.h
index 0f76106dce..86069b498b 100644
--- a/src/core/ext/transport/chttp2/transport/http2_settings.h
+++ b/src/core/ext/transport/chttp2/transport/http2_settings.h
@@ -41,7 +41,7 @@ extern "C" {
#endif
extern const uint16_t grpc_setting_id_to_wire_id[];
-bool grpc_wire_id_to_setting_id(uint32_t wire_id, grpc_chttp2_setting_id *out);
+bool grpc_wire_id_to_setting_id(uint32_t wire_id, grpc_chttp2_setting_id* out);
typedef enum {
GRPC_CHTTP2_CLAMP_INVALID_VALUE,
@@ -49,7 +49,7 @@ typedef enum {
} grpc_chttp2_invalid_value_behavior;
typedef struct {
- const char *name;
+ const char* name;
uint32_t default_value;
uint32_t min_value;
uint32_t max_value;
diff --git a/src/core/ext/transport/chttp2/transport/incoming_metadata.cc b/src/core/ext/transport/chttp2/transport/incoming_metadata.cc
index 187ce0ea87..15f80fb8a1 100644
--- a/src/core/ext/transport/chttp2/transport/incoming_metadata.cc
+++ b/src/core/ext/transport/chttp2/transport/incoming_metadata.cc
@@ -26,31 +26,32 @@
#include <grpc/support/log.h>
void grpc_chttp2_incoming_metadata_buffer_init(
- grpc_chttp2_incoming_metadata_buffer *buffer, gpr_arena *arena) {
+ grpc_chttp2_incoming_metadata_buffer* buffer, gpr_arena* arena) {
buffer->arena = arena;
grpc_metadata_batch_init(&buffer->batch);
buffer->batch.deadline = GRPC_MILLIS_INF_FUTURE;
}
void grpc_chttp2_incoming_metadata_buffer_destroy(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_metadata_buffer *buffer) {
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_metadata_buffer* buffer) {
grpc_metadata_batch_destroy(exec_ctx, &buffer->batch);
}
-grpc_error *grpc_chttp2_incoming_metadata_buffer_add(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_metadata_buffer *buffer,
+grpc_error* grpc_chttp2_incoming_metadata_buffer_add(
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_metadata_buffer* buffer,
grpc_mdelem elem) {
buffer->size += GRPC_MDELEM_LENGTH(elem);
return grpc_metadata_batch_add_tail(
- exec_ctx, &buffer->batch, (grpc_linked_mdelem *)gpr_arena_alloc(
- buffer->arena, sizeof(grpc_linked_mdelem)),
+ exec_ctx, &buffer->batch,
+ (grpc_linked_mdelem*)gpr_arena_alloc(buffer->arena,
+ sizeof(grpc_linked_mdelem)),
elem);
}
-grpc_error *grpc_chttp2_incoming_metadata_buffer_replace_or_add(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_metadata_buffer *buffer,
+grpc_error* grpc_chttp2_incoming_metadata_buffer_replace_or_add(
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_metadata_buffer* buffer,
grpc_mdelem elem) {
- for (grpc_linked_mdelem *l = buffer->batch.list.head; l != NULL;
+ for (grpc_linked_mdelem* l = buffer->batch.list.head; l != NULL;
l = l->next) {
if (grpc_slice_eq(GRPC_MDKEY(l->md), GRPC_MDKEY(elem))) {
GRPC_MDELEM_UNREF(exec_ctx, l->md);
@@ -62,13 +63,13 @@ grpc_error *grpc_chttp2_incoming_metadata_buffer_replace_or_add(
}
void grpc_chttp2_incoming_metadata_buffer_set_deadline(
- grpc_chttp2_incoming_metadata_buffer *buffer, grpc_millis deadline) {
+ grpc_chttp2_incoming_metadata_buffer* buffer, grpc_millis deadline) {
buffer->batch.deadline = deadline;
}
void grpc_chttp2_incoming_metadata_buffer_publish(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_metadata_buffer *buffer,
- grpc_metadata_batch *batch) {
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_metadata_buffer* buffer,
+ grpc_metadata_batch* batch) {
*batch = buffer->batch;
grpc_metadata_batch_init(&buffer->batch);
}
diff --git a/src/core/ext/transport/chttp2/transport/incoming_metadata.h b/src/core/ext/transport/chttp2/transport/incoming_metadata.h
index a0e01f2c4d..7ccb4a0126 100644
--- a/src/core/ext/transport/chttp2/transport/incoming_metadata.h
+++ b/src/core/ext/transport/chttp2/transport/incoming_metadata.h
@@ -26,28 +26,28 @@ extern "C" {
#endif
typedef struct {
- gpr_arena *arena;
+ gpr_arena* arena;
grpc_metadata_batch batch;
size_t size; // total size of metadata
} grpc_chttp2_incoming_metadata_buffer;
/** assumes everything initially zeroed */
void grpc_chttp2_incoming_metadata_buffer_init(
- grpc_chttp2_incoming_metadata_buffer *buffer, gpr_arena *arena);
+ grpc_chttp2_incoming_metadata_buffer* buffer, gpr_arena* arena);
void grpc_chttp2_incoming_metadata_buffer_destroy(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_metadata_buffer *buffer);
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_metadata_buffer* buffer);
void grpc_chttp2_incoming_metadata_buffer_publish(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_metadata_buffer *buffer,
- grpc_metadata_batch *batch);
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_metadata_buffer* buffer,
+ grpc_metadata_batch* batch);
-grpc_error *grpc_chttp2_incoming_metadata_buffer_add(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_metadata_buffer *buffer,
+grpc_error* grpc_chttp2_incoming_metadata_buffer_add(
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_metadata_buffer* buffer,
grpc_mdelem elem) GRPC_MUST_USE_RESULT;
-grpc_error *grpc_chttp2_incoming_metadata_buffer_replace_or_add(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_metadata_buffer *buffer,
+grpc_error* grpc_chttp2_incoming_metadata_buffer_replace_or_add(
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_metadata_buffer* buffer,
grpc_mdelem elem) GRPC_MUST_USE_RESULT;
void grpc_chttp2_incoming_metadata_buffer_set_deadline(
- grpc_chttp2_incoming_metadata_buffer *buffer, grpc_millis deadline);
+ grpc_chttp2_incoming_metadata_buffer* buffer, grpc_millis deadline);
#ifdef __cplusplus
}
diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h
index ee6974a6d5..17eecbd7fd 100644
--- a/src/core/ext/transport/chttp2/transport/internal.h
+++ b/src/core/ext/transport/chttp2/transport/internal.h
@@ -100,7 +100,7 @@ typedef enum {
GRPC_CHTTP2_INITIATE_WRITE_FORCE_RST_STREAM,
} grpc_chttp2_initiate_write_reason;
-const char *grpc_chttp2_initiate_write_reason_string(
+const char* grpc_chttp2_initiate_write_reason_string(
grpc_chttp2_initiate_write_reason reason);
typedef struct {
@@ -171,13 +171,13 @@ typedef enum {
} grpc_chttp2_deframe_transport_state;
typedef struct {
- grpc_chttp2_stream *head;
- grpc_chttp2_stream *tail;
+ grpc_chttp2_stream* head;
+ grpc_chttp2_stream* tail;
} grpc_chttp2_stream_list;
typedef struct {
- grpc_chttp2_stream *next;
- grpc_chttp2_stream *prev;
+ grpc_chttp2_stream* next;
+ grpc_chttp2_stream* prev;
} grpc_chttp2_stream_link;
/* We keep several sets of connection wide parameters */
@@ -201,8 +201,8 @@ typedef enum {
typedef struct grpc_chttp2_write_cb {
int64_t call_at_byte;
- grpc_closure *closure;
- struct grpc_chttp2_write_cb *next;
+ grpc_closure* closure;
+ struct grpc_chttp2_write_cb* next;
} grpc_chttp2_write_cb;
/* forward declared in frame_data.h */
@@ -210,8 +210,8 @@ struct grpc_chttp2_incoming_byte_stream {
grpc_byte_stream base;
gpr_refcount refs;
- grpc_chttp2_transport *transport; /* immutable */
- grpc_chttp2_stream *stream; /* immutable */
+ grpc_chttp2_transport* transport; /* immutable */
+ grpc_chttp2_stream* stream; /* immutable */
/* Accessed only by transport thread when stream->pending_byte_stream == false
* Accessed only by application thread when stream->pending_byte_stream ==
@@ -224,7 +224,7 @@ struct grpc_chttp2_incoming_byte_stream {
struct {
grpc_closure closure;
size_t max_size_hint;
- grpc_closure *on_complete;
+ grpc_closure* on_complete;
} next_action;
grpc_closure destroy_action;
grpc_closure finished_action;
@@ -240,10 +240,10 @@ typedef enum {
struct grpc_chttp2_transport {
grpc_transport base; /* must be first */
gpr_refcount refs;
- grpc_endpoint *ep;
- char *peer_string;
+ grpc_endpoint* ep;
+ char* peer_string;
- grpc_combiner *combiner;
+ grpc_combiner* combiner;
/** write execution state of the transport */
grpc_chttp2_write_state write_state;
@@ -255,7 +255,7 @@ struct grpc_chttp2_transport {
/** is the transport destroying itself? */
uint8_t destroying;
/** has the upper layer closed the transport? */
- grpc_error *closed_with_error;
+ grpc_error* closed_with_error;
/** is there a read request to the endpoint outstanding? */
uint8_t endpoint_reading;
@@ -280,13 +280,13 @@ struct grpc_chttp2_transport {
/** address to place a newly accepted stream - set and unset by
grpc_chttp2_parsing_accept_stream; used by init_stream to
publish the accepted server stream */
- grpc_chttp2_stream **accepting_stream;
+ grpc_chttp2_stream** accepting_stream;
struct {
/* accept stream callback */
- void (*accept_stream)(grpc_exec_ctx *exec_ctx, void *user_data,
- grpc_transport *transport, const void *server_data);
- void *accept_stream_user_data;
+ void (*accept_stream)(grpc_exec_ctx* exec_ctx, void* user_data,
+ grpc_transport* transport, const void* server_data);
+ void* accept_stream_user_data;
/** connectivity tracking */
grpc_connectivity_state_tracker state_tracker;
@@ -306,9 +306,10 @@ struct grpc_chttp2_transport {
*/
uint32_t write_buffer_size;
- /** have we seen a goaway */
- bool seen_goaway;
- /** have we sent a goaway */
+ /** Set to a grpc_error object if a goaway frame is received. By default, set
+ * to GRPC_ERROR_NONE */
+ grpc_error* goaway_error;
+
grpc_chttp2_sent_goaway_state sent_goaway_state;
/** are the local settings dirty and need to be sent? */
@@ -337,7 +338,7 @@ struct grpc_chttp2_transport {
/** ping acks */
size_t ping_ack_count;
size_t ping_ack_capacity;
- uint64_t *ping_acks;
+ uint64_t* ping_acks;
grpc_chttp2_server_ping_recv_state ping_recv_state;
/** parser for headers */
@@ -370,18 +371,13 @@ struct grpc_chttp2_transport {
uint32_t incoming_stream_id;
/* active parser */
- void *parser_data;
- grpc_chttp2_stream *incoming_stream;
- grpc_error *(*parser)(grpc_exec_ctx *exec_ctx, void *parser_user_data,
- grpc_chttp2_transport *t, grpc_chttp2_stream *s,
+ void* parser_data;
+ grpc_chttp2_stream* incoming_stream;
+ grpc_error* (*parser)(grpc_exec_ctx* exec_ctx, void* parser_user_data,
+ grpc_chttp2_transport* t, grpc_chttp2_stream* s,
grpc_slice slice, int is_last);
- /* goaway data */
- grpc_status_code goaway_error;
- uint32_t goaway_last_stream_index;
- grpc_slice goaway_text;
-
- grpc_chttp2_write_cb *write_cb_pool;
+ grpc_chttp2_write_cb* write_cb_pool;
/* bdp estimator */
grpc_closure next_bdp_ping_timer_expired_locked;
@@ -390,7 +386,7 @@ struct grpc_chttp2_transport {
/* if non-NULL, close the transport with this error when writes are finished
*/
- grpc_error *close_transport_on_writes_finished;
+ grpc_error* close_transport_on_writes_finished;
/* a list of closures to run after writes are finished */
grpc_closure_list run_after_write;
@@ -440,11 +436,11 @@ typedef enum {
} grpc_published_metadata_method;
struct grpc_chttp2_stream {
- grpc_chttp2_transport *t;
- grpc_stream_refcount *refcount;
+ grpc_chttp2_transport* t;
+ grpc_stream_refcount* refcount;
grpc_closure destroy_stream;
- grpc_closure *destroy_stream_arg;
+ grpc_closure* destroy_stream_arg;
grpc_chttp2_stream_link links[STREAM_LIST_COUNT];
uint8_t included[STREAM_LIST_COUNT];
@@ -453,29 +449,29 @@ struct grpc_chttp2_stream {
uint32_t id;
/** things the upper layers would like to send */
- grpc_metadata_batch *send_initial_metadata;
- grpc_closure *send_initial_metadata_finished;
- grpc_metadata_batch *send_trailing_metadata;
- grpc_closure *send_trailing_metadata_finished;
+ grpc_metadata_batch* send_initial_metadata;
+ grpc_closure* send_initial_metadata_finished;
+ grpc_metadata_batch* send_trailing_metadata;
+ grpc_closure* send_trailing_metadata_finished;
- grpc_byte_stream *fetching_send_message;
+ grpc_byte_stream* fetching_send_message;
uint32_t fetched_send_message_length;
grpc_slice fetching_slice;
int64_t next_message_end_offset;
int64_t flow_controlled_bytes_written;
int64_t flow_controlled_bytes_flowed;
grpc_closure complete_fetch_locked;
- grpc_closure *fetching_send_message_finished;
+ grpc_closure* fetching_send_message_finished;
- grpc_metadata_batch *recv_initial_metadata;
- grpc_closure *recv_initial_metadata_ready;
- bool *trailing_metadata_available;
- grpc_byte_stream **recv_message;
- grpc_closure *recv_message_ready;
- grpc_metadata_batch *recv_trailing_metadata;
- grpc_closure *recv_trailing_metadata_finished;
+ grpc_metadata_batch* recv_initial_metadata;
+ grpc_closure* recv_initial_metadata_ready;
+ bool* trailing_metadata_available;
+ grpc_byte_stream** recv_message;
+ grpc_closure* recv_message_ready;
+ grpc_metadata_batch* recv_trailing_metadata;
+ grpc_closure* recv_trailing_metadata_finished;
- grpc_transport_stream_stats *collecting_stats;
+ grpc_transport_stream_stats* collecting_stats;
grpc_transport_stream_stats stats;
/** Is this stream closed for writing. */
@@ -494,9 +490,9 @@ struct grpc_chttp2_stream {
bool received_trailing_metadata;
/** the error that resulted in this stream being read-closed */
- grpc_error *read_closed_error;
+ grpc_error* read_closed_error;
/** the error that resulted in this stream being write-closed */
- grpc_error *write_closed_error;
+ grpc_error* write_closed_error;
grpc_published_metadata_method published_metadata[2];
bool final_metadata_requested;
@@ -509,16 +505,16 @@ struct grpc_chttp2_stream {
* Accessed only by application thread when stream->pending_byte_stream ==
* true */
grpc_slice_buffer unprocessed_incoming_frames_buffer;
- grpc_closure *on_next; /* protected by t combiner */
+ grpc_closure* on_next; /* protected by t combiner */
bool pending_byte_stream; /* protected by t combiner */
grpc_closure reset_byte_stream;
- grpc_error *byte_stream_error; /* protected by t combiner */
+ grpc_error* byte_stream_error; /* protected by t combiner */
bool received_last_frame; /* protected by t combiner */
grpc_millis deadline;
/** saw some stream level error */
- grpc_error *forced_close_error;
+ grpc_error* forced_close_error;
/** how many header frames have we received? */
uint8_t header_frames_received;
/** parsing state for data frames */
@@ -537,9 +533,9 @@ struct grpc_chttp2_stream {
grpc_slice_buffer flow_controlled_buffer;
- grpc_chttp2_write_cb *on_flow_controlled_cbs;
- grpc_chttp2_write_cb *on_write_finished_cbs;
- grpc_chttp2_write_cb *finish_after_write;
+ grpc_chttp2_write_cb* on_flow_controlled_cbs;
+ grpc_chttp2_write_cb* on_write_finished_cbs;
+ grpc_chttp2_write_cb* finish_after_write;
size_t sending_bytes;
/* Stream compression method to be used. */
@@ -547,9 +543,9 @@ struct grpc_chttp2_stream {
/* Stream decompression method to be used. */
grpc_stream_compression_method stream_decompression_method;
/** Stream compression decompress context */
- grpc_stream_compression_context *stream_decompression_ctx;
+ grpc_stream_compression_context* stream_decompression_ctx;
/** Stream compression compress context */
- grpc_stream_compression_context *stream_compression_ctx;
+ grpc_stream_compression_context* stream_compression_ctx;
/** Buffer storing data that is compressed but not sent */
grpc_slice_buffer compressed_data_buffer;
@@ -577,8 +573,8 @@ struct grpc_chttp2_stream {
The actual call chain is documented in the implementation of this function.
*/
-void grpc_chttp2_initiate_write(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+void grpc_chttp2_initiate_write(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
grpc_chttp2_initiate_write_reason reason);
typedef struct {
@@ -591,85 +587,85 @@ typedef struct {
} grpc_chttp2_begin_write_result;
grpc_chttp2_begin_write_result grpc_chttp2_begin_write(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t);
-void grpc_chttp2_end_write(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_error *error);
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t);
+void grpc_chttp2_end_write(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
+ grpc_error* error);
/** Process one slice of incoming data; return 1 if the connection is still
viable after reading, or 0 if the connection should be torn down */
-grpc_error *grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+grpc_error* grpc_chttp2_perform_read(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
grpc_slice slice);
-bool grpc_chttp2_list_add_writable_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
+bool grpc_chttp2_list_add_writable_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
/** Get a writable stream
returns non-zero if there was a stream available */
-bool grpc_chttp2_list_pop_writable_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream **s);
-bool grpc_chttp2_list_remove_writable_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
-
-bool grpc_chttp2_list_add_writing_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
-bool grpc_chttp2_list_have_writing_streams(grpc_chttp2_transport *t);
-bool grpc_chttp2_list_pop_writing_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream **s);
-
-void grpc_chttp2_list_add_written_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
-bool grpc_chttp2_list_pop_written_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream **s);
-
-void grpc_chttp2_list_add_waiting_for_concurrency(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
-bool grpc_chttp2_list_pop_waiting_for_concurrency(grpc_chttp2_transport *t,
- grpc_chttp2_stream **s);
-void grpc_chttp2_list_remove_waiting_for_concurrency(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
-
-void grpc_chttp2_list_add_stalled_by_transport(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
-bool grpc_chttp2_list_pop_stalled_by_transport(grpc_chttp2_transport *t,
- grpc_chttp2_stream **s);
-void grpc_chttp2_list_remove_stalled_by_transport(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
-
-void grpc_chttp2_list_add_stalled_by_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
-bool grpc_chttp2_list_pop_stalled_by_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream **s);
-bool grpc_chttp2_list_remove_stalled_by_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
+bool grpc_chttp2_list_pop_writable_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream** s);
+bool grpc_chttp2_list_remove_writable_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
+
+bool grpc_chttp2_list_add_writing_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
+bool grpc_chttp2_list_have_writing_streams(grpc_chttp2_transport* t);
+bool grpc_chttp2_list_pop_writing_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream** s);
+
+void grpc_chttp2_list_add_written_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
+bool grpc_chttp2_list_pop_written_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream** s);
+
+void grpc_chttp2_list_add_waiting_for_concurrency(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
+bool grpc_chttp2_list_pop_waiting_for_concurrency(grpc_chttp2_transport* t,
+ grpc_chttp2_stream** s);
+void grpc_chttp2_list_remove_waiting_for_concurrency(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
+
+void grpc_chttp2_list_add_stalled_by_transport(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
+bool grpc_chttp2_list_pop_stalled_by_transport(grpc_chttp2_transport* t,
+ grpc_chttp2_stream** s);
+void grpc_chttp2_list_remove_stalled_by_transport(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
+
+void grpc_chttp2_list_add_stalled_by_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
+bool grpc_chttp2_list_pop_stalled_by_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream** s);
+bool grpc_chttp2_list_remove_stalled_by_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
/********* Flow Control ***************/
// Takes in a flow control action and performs all the needed operations.
void grpc_chttp2_act_on_flowctl_action(
- grpc_exec_ctx *exec_ctx, const grpc_core::chttp2::FlowControlAction &action,
- grpc_chttp2_transport *t, grpc_chttp2_stream *s);
+ grpc_exec_ctx* exec_ctx, const grpc_core::chttp2::FlowControlAction& action,
+ grpc_chttp2_transport* t, grpc_chttp2_stream* s);
/********* End of Flow Control ***************/
-grpc_chttp2_stream *grpc_chttp2_parsing_lookup_stream(grpc_chttp2_transport *t,
+grpc_chttp2_stream* grpc_chttp2_parsing_lookup_stream(grpc_chttp2_transport* t,
uint32_t id);
-grpc_chttp2_stream *grpc_chttp2_parsing_accept_stream(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+grpc_chttp2_stream* grpc_chttp2_parsing_accept_stream(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
uint32_t id);
-void grpc_chttp2_add_incoming_goaway(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+void grpc_chttp2_add_incoming_goaway(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
uint32_t goaway_error,
grpc_slice goaway_text);
-void grpc_chttp2_parsing_become_skip_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
+void grpc_chttp2_parsing_become_skip_parser(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t);
-void grpc_chttp2_complete_closure_step(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
- grpc_closure **pclosure,
- grpc_error *error, const char *desc);
+void grpc_chttp2_complete_closure_step(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
+ grpc_closure** pclosure,
+ grpc_error* error, const char* desc);
#define GRPC_HEADER_SIZE_IN_BYTES 5
#define MAX_SIZE_T (~(size_t)0)
@@ -678,37 +674,38 @@ void grpc_chttp2_complete_closure_step(grpc_exec_ctx *exec_ctx,
#define GRPC_CHTTP2_CLIENT_CONNECT_STRLEN \
(sizeof(GRPC_CHTTP2_CLIENT_CONNECT_STRING) - 1)
-extern grpc_core::TraceFlag grpc_http_trace;
+// extern grpc_core::TraceFlag grpc_http_trace;
+// extern grpc_core::TraceFlag grpc_flowctl_trace;
-#define GRPC_CHTTP2_IF_TRACING(stmt) \
- if (!grpc_http_trace.enabled()) \
- ; \
- else \
- stmt
+#define GRPC_CHTTP2_IF_TRACING(stmt) \
+ if (!(grpc_http_trace.enabled())) \
+ ; \
+ else \
+ stmt
-void grpc_chttp2_fake_status(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_chttp2_stream *stream, grpc_error *error);
-void grpc_chttp2_mark_stream_closed(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s, int close_reads,
- int close_writes, grpc_error *error);
-void grpc_chttp2_start_writing(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
+void grpc_chttp2_fake_status(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
+ grpc_chttp2_stream* stream, grpc_error* error);
+void grpc_chttp2_mark_stream_closed(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s, int close_reads,
+ int close_writes, grpc_error* error);
+void grpc_chttp2_start_writing(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t);
#ifndef NDEBUG
#define GRPC_CHTTP2_STREAM_REF(stream, reason) \
grpc_chttp2_stream_ref(stream, reason)
#define GRPC_CHTTP2_STREAM_UNREF(exec_ctx, stream, reason) \
grpc_chttp2_stream_unref(exec_ctx, stream, reason)
-void grpc_chttp2_stream_ref(grpc_chttp2_stream *s, const char *reason);
-void grpc_chttp2_stream_unref(grpc_exec_ctx *exec_ctx, grpc_chttp2_stream *s,
- const char *reason);
+void grpc_chttp2_stream_ref(grpc_chttp2_stream* s, const char* reason);
+void grpc_chttp2_stream_unref(grpc_exec_ctx* exec_ctx, grpc_chttp2_stream* s,
+ const char* reason);
#else
#define GRPC_CHTTP2_STREAM_REF(stream, reason) grpc_chttp2_stream_ref(stream)
#define GRPC_CHTTP2_STREAM_UNREF(exec_ctx, stream, reason) \
grpc_chttp2_stream_unref(exec_ctx, stream)
-void grpc_chttp2_stream_ref(grpc_chttp2_stream *s);
-void grpc_chttp2_stream_unref(grpc_exec_ctx *exec_ctx, grpc_chttp2_stream *s);
+void grpc_chttp2_stream_ref(grpc_chttp2_stream* s);
+void grpc_chttp2_stream_unref(grpc_exec_ctx* exec_ctx, grpc_chttp2_stream* s);
#endif
#ifndef NDEBUG
@@ -716,69 +713,69 @@ void grpc_chttp2_stream_unref(grpc_exec_ctx *exec_ctx, grpc_chttp2_stream *s);
grpc_chttp2_ref_transport(t, r, __FILE__, __LINE__)
#define GRPC_CHTTP2_UNREF_TRANSPORT(cl, t, r) \
grpc_chttp2_unref_transport(cl, t, r, __FILE__, __LINE__)
-void grpc_chttp2_unref_transport(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t, const char *reason,
- const char *file, int line);
-void grpc_chttp2_ref_transport(grpc_chttp2_transport *t, const char *reason,
- const char *file, int line);
+void grpc_chttp2_unref_transport(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t, const char* reason,
+ const char* file, int line);
+void grpc_chttp2_ref_transport(grpc_chttp2_transport* t, const char* reason,
+ const char* file, int line);
#else
#define GRPC_CHTTP2_REF_TRANSPORT(t, r) grpc_chttp2_ref_transport(t)
#define GRPC_CHTTP2_UNREF_TRANSPORT(cl, t, r) grpc_chttp2_unref_transport(cl, t)
-void grpc_chttp2_unref_transport(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
-void grpc_chttp2_ref_transport(grpc_chttp2_transport *t);
+void grpc_chttp2_unref_transport(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t);
+void grpc_chttp2_ref_transport(grpc_chttp2_transport* t);
#endif
-grpc_chttp2_incoming_byte_stream *grpc_chttp2_incoming_byte_stream_create(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_chttp2_stream *s,
+grpc_chttp2_incoming_byte_stream* grpc_chttp2_incoming_byte_stream_create(
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t, grpc_chttp2_stream* s,
uint32_t frame_size, uint32_t flags);
-grpc_error *grpc_chttp2_incoming_byte_stream_push(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs,
- grpc_slice slice, grpc_slice *slice_out);
-grpc_error *grpc_chttp2_incoming_byte_stream_finished(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs,
- grpc_error *error, bool reset_on_error);
+grpc_error* grpc_chttp2_incoming_byte_stream_push(
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_byte_stream* bs,
+ grpc_slice slice, grpc_slice* slice_out);
+grpc_error* grpc_chttp2_incoming_byte_stream_finished(
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_byte_stream* bs,
+ grpc_error* error, bool reset_on_error);
void grpc_chttp2_incoming_byte_stream_notify(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs,
- grpc_error *error);
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_byte_stream* bs,
+ grpc_error* error);
-void grpc_chttp2_ack_ping(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
+void grpc_chttp2_ack_ping(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
uint64_t id);
/** Add a new ping strike to ping_recv_state.ping_strikes. If
ping_recv_state.ping_strikes > ping_policy.max_ping_strikes, it sends GOAWAY
with error code ENHANCE_YOUR_CALM and additional debug data resembling
"too_many_pings" followed by immediately closing the connection. */
-void grpc_chttp2_add_ping_strike(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
+void grpc_chttp2_add_ping_strike(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t);
/** add a ref to the stream and add it to the writable list;
ref will be dropped in writing.c */
-void grpc_chttp2_mark_stream_writable(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
-
-void grpc_chttp2_cancel_stream(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t, grpc_chttp2_stream *s,
- grpc_error *due_to_error);
-
-void grpc_chttp2_maybe_complete_recv_initial_metadata(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
-void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
-void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
-
-void grpc_chttp2_fail_pending_writes(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s, grpc_error *error);
+void grpc_chttp2_mark_stream_writable(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
+
+void grpc_chttp2_cancel_stream(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t, grpc_chttp2_stream* s,
+ grpc_error* due_to_error);
+
+void grpc_chttp2_maybe_complete_recv_initial_metadata(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
+void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
+void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
+
+void grpc_chttp2_fail_pending_writes(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s, grpc_error* error);
/** Set the default keepalive configurations, must only be called at
initialization */
-void grpc_chttp2_config_default_keepalive_args(grpc_channel_args *args,
+void grpc_chttp2_config_default_keepalive_args(grpc_channel_args* args,
bool is_client);
#ifdef __cplusplus
diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc
index 28a14e11b5..80f12c1022 100644
--- a/src/core/ext/transport/chttp2/transport/parsing.cc
+++ b/src/core/ext/transport/chttp2/transport/parsing.cc
@@ -31,38 +31,38 @@
#include "src/core/lib/transport/status_conversion.h"
#include "src/core/lib/transport/timeout_encoding.h"
-static grpc_error *init_frame_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
-static grpc_error *init_header_frame_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+static grpc_error* init_frame_parser(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t);
+static grpc_error* init_header_frame_parser(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
int is_continuation);
-static grpc_error *init_data_frame_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
-static grpc_error *init_rst_stream_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
-static grpc_error *init_settings_frame_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
-static grpc_error *init_window_update_frame_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
-static grpc_error *init_ping_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
-static grpc_error *init_goaway_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
-static grpc_error *init_skip_frame_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+static grpc_error* init_data_frame_parser(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t);
+static grpc_error* init_rst_stream_parser(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t);
+static grpc_error* init_settings_frame_parser(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t);
+static grpc_error* init_window_update_frame_parser(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t);
+static grpc_error* init_ping_parser(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t);
+static grpc_error* init_goaway_parser(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t);
+static grpc_error* init_skip_frame_parser(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
int is_header);
-static grpc_error *parse_frame_slice(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t, grpc_slice slice,
+static grpc_error* parse_frame_slice(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t, grpc_slice slice,
int is_last);
-grpc_error *grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+grpc_error* grpc_chttp2_perform_read(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
grpc_slice slice) {
- uint8_t *beg = GRPC_SLICE_START_PTR(slice);
- uint8_t *end = GRPC_SLICE_END_PTR(slice);
- uint8_t *cur = beg;
- grpc_error *err;
+ uint8_t* beg = GRPC_SLICE_START_PTR(slice);
+ uint8_t* end = GRPC_SLICE_END_PTR(slice);
+ uint8_t* cur = beg;
+ grpc_error* err;
if (cur == end) return GRPC_ERROR_NONE;
@@ -93,7 +93,7 @@ grpc_error *grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
case GRPC_DTS_CLIENT_PREFIX_23:
while (cur != end && t->deframe_state != GRPC_DTS_FH_0) {
if (*cur != GRPC_CHTTP2_CLIENT_CONNECT_STRING[t->deframe_state]) {
- char *msg;
+ char* msg;
gpr_asprintf(
&msg,
"Connect string mismatch: expected '%c' (%d) got '%c' (%d) "
@@ -200,7 +200,7 @@ grpc_error *grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
} else if (t->incoming_frame_size >
t->settings[GRPC_ACKED_SETTINGS]
[GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE]) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "Frame size %d is larger than max frame size %d",
t->incoming_frame_size,
t->settings[GRPC_ACKED_SETTINGS]
@@ -216,10 +216,11 @@ grpc_error *grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
case GRPC_DTS_FRAME:
GPR_ASSERT(cur < end);
if ((uint32_t)(end - cur) == t->incoming_frame_size) {
- err = parse_frame_slice(
- exec_ctx, t, grpc_slice_sub_no_ref(slice, (size_t)(cur - beg),
- (size_t)(end - beg)),
- 1);
+ err =
+ parse_frame_slice(exec_ctx, t,
+ grpc_slice_sub_no_ref(slice, (size_t)(cur - beg),
+ (size_t)(end - beg)),
+ 1);
if (err != GRPC_ERROR_NONE) {
return err;
}
@@ -240,10 +241,11 @@ grpc_error *grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
t->incoming_stream = NULL;
goto dts_fh_0; /* loop */
} else {
- err = parse_frame_slice(
- exec_ctx, t, grpc_slice_sub_no_ref(slice, (size_t)(cur - beg),
- (size_t)(end - beg)),
- 0);
+ err =
+ parse_frame_slice(exec_ctx, t,
+ grpc_slice_sub_no_ref(slice, (size_t)(cur - beg),
+ (size_t)(end - beg)),
+ 0);
if (err != GRPC_ERROR_NONE) {
return err;
}
@@ -256,36 +258,36 @@ grpc_error *grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
GPR_UNREACHABLE_CODE(return 0);
}
-static grpc_error *init_frame_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
+static grpc_error* init_frame_parser(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t) {
if (t->is_first_frame &&
t->incoming_frame_type != GRPC_CHTTP2_FRAME_SETTINGS) {
- char *msg;
+ char* msg;
gpr_asprintf(
&msg, "Expected SETTINGS frame as the first frame, got frame type %d",
t->incoming_frame_type);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return err;
}
t->is_first_frame = false;
if (t->expect_continuation_stream_id != 0) {
if (t->incoming_frame_type != GRPC_CHTTP2_FRAME_CONTINUATION) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "Expected CONTINUATION frame, got frame type %02x",
t->incoming_frame_type);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return err;
}
if (t->expect_continuation_stream_id != t->incoming_stream_id) {
- char *msg;
+ char* msg;
gpr_asprintf(
&msg,
"Expected CONTINUATION frame for grpc_chttp2_stream %08x, got "
"grpc_chttp2_stream %08x",
t->expect_continuation_stream_id, t->incoming_stream_id);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return err;
}
@@ -317,18 +319,18 @@ static grpc_error *init_frame_parser(grpc_exec_ctx *exec_ctx,
}
}
-static grpc_error *skip_parser(grpc_exec_ctx *exec_ctx, void *parser,
- grpc_chttp2_transport *t, grpc_chttp2_stream *s,
+static grpc_error* skip_parser(grpc_exec_ctx* exec_ctx, void* parser,
+ grpc_chttp2_transport* t, grpc_chttp2_stream* s,
grpc_slice slice, int is_last) {
return GRPC_ERROR_NONE;
}
-static void skip_header(grpc_exec_ctx *exec_ctx, void *tp, grpc_mdelem md) {
+static void skip_header(grpc_exec_ctx* exec_ctx, void* tp, grpc_mdelem md) {
GRPC_MDELEM_UNREF(exec_ctx, md);
}
-static grpc_error *init_skip_frame_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+static grpc_error* init_skip_frame_parser(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
int is_header) {
if (is_header) {
uint8_t is_eoh = t->expect_continuation_stream_id != 0;
@@ -344,17 +346,17 @@ static grpc_error *init_skip_frame_parser(grpc_exec_ctx *exec_ctx,
return GRPC_ERROR_NONE;
}
-void grpc_chttp2_parsing_become_skip_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
+void grpc_chttp2_parsing_become_skip_parser(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t) {
init_skip_frame_parser(exec_ctx, t,
t->parser == grpc_chttp2_header_parser_parse);
}
-static grpc_error *init_data_frame_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
- grpc_chttp2_stream *s =
+static grpc_error* init_data_frame_parser(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t) {
+ grpc_chttp2_stream* s =
grpc_chttp2_parsing_lookup_stream(t, t->incoming_stream_id);
- grpc_error *err = GRPC_ERROR_NONE;
+ grpc_error* err = GRPC_ERROR_NONE;
grpc_core::chttp2::FlowControlAction action;
if (s == nullptr) {
err = t->flow_control->RecvData(t->incoming_frame_size);
@@ -404,20 +406,20 @@ error_handler:
}
}
-static void free_timeout(void *p) { gpr_free(p); }
+static void free_timeout(void* p) { gpr_free(p); }
-static void on_initial_header(grpc_exec_ctx *exec_ctx, void *tp,
+static void on_initial_header(grpc_exec_ctx* exec_ctx, void* tp,
grpc_mdelem md) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)tp;
- grpc_chttp2_stream *s = t->incoming_stream;
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
+ grpc_chttp2_stream* s = t->incoming_stream;
GPR_TIMER_BEGIN("on_initial_header", 0);
GPR_ASSERT(s != NULL);
if (grpc_http_trace.enabled()) {
- char *key = grpc_slice_to_c_string(GRPC_MDKEY(md));
- char *value =
+ char* key = grpc_slice_to_c_string(GRPC_MDKEY(md));
+ char* value =
grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_INFO, "HTTP:%d:HDR:%s: %s: %s", s->id,
t->is_client ? "CLI" : "SVR", key, value);
@@ -432,21 +434,21 @@ static void on_initial_header(grpc_exec_ctx *exec_ctx, void *tp,
}
if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_TIMEOUT)) {
- grpc_millis *cached_timeout =
- static_cast<grpc_millis *>(grpc_mdelem_get_user_data(md, free_timeout));
+ grpc_millis* cached_timeout =
+ static_cast<grpc_millis*>(grpc_mdelem_get_user_data(md, free_timeout));
grpc_millis timeout;
if (cached_timeout != NULL) {
timeout = *cached_timeout;
} else {
if (!grpc_http2_decode_timeout(GRPC_MDVALUE(md), &timeout)) {
- char *val = grpc_slice_to_c_string(GRPC_MDVALUE(md));
+ char* val = grpc_slice_to_c_string(GRPC_MDVALUE(md));
gpr_log(GPR_ERROR, "Ignoring bad timeout value '%s'", val);
gpr_free(val);
timeout = GRPC_MILLIS_INF_FUTURE;
}
if (GRPC_MDELEM_IS_INTERNED(md)) {
/* store the result */
- cached_timeout = (grpc_millis *)gpr_malloc(sizeof(grpc_millis));
+ cached_timeout = (grpc_millis*)gpr_malloc(sizeof(grpc_millis));
*cached_timeout = timeout;
grpc_mdelem_set_user_data(md, free_timeout, cached_timeout);
}
@@ -476,7 +478,7 @@ static void on_initial_header(grpc_exec_ctx *exec_ctx, void *tp,
s->seen_error = true;
GRPC_MDELEM_UNREF(exec_ctx, md);
} else {
- grpc_error *error = grpc_chttp2_incoming_metadata_buffer_add(
+ grpc_error* error = grpc_chttp2_incoming_metadata_buffer_add(
exec_ctx, &s->metadata_buffer[0], md);
if (error != GRPC_ERROR_NONE) {
grpc_chttp2_cancel_stream(exec_ctx, t, s, error);
@@ -490,18 +492,18 @@ static void on_initial_header(grpc_exec_ctx *exec_ctx, void *tp,
GPR_TIMER_END("on_initial_header", 0);
}
-static void on_trailing_header(grpc_exec_ctx *exec_ctx, void *tp,
+static void on_trailing_header(grpc_exec_ctx* exec_ctx, void* tp,
grpc_mdelem md) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)tp;
- grpc_chttp2_stream *s = t->incoming_stream;
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
+ grpc_chttp2_stream* s = t->incoming_stream;
GPR_TIMER_BEGIN("on_trailing_header", 0);
GPR_ASSERT(s != NULL);
if (grpc_http_trace.enabled()) {
- char *key = grpc_slice_to_c_string(GRPC_MDKEY(md));
- char *value =
+ char* key = grpc_slice_to_c_string(GRPC_MDKEY(md));
+ char* value =
grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_INFO, "HTTP:%d:TRL:%s: %s: %s", s->id,
t->is_client ? "CLI" : "SVR", key, value);
@@ -534,7 +536,7 @@ static void on_trailing_header(grpc_exec_ctx *exec_ctx, void *tp,
s->seen_error = true;
GRPC_MDELEM_UNREF(exec_ctx, md);
} else {
- grpc_error *error = grpc_chttp2_incoming_metadata_buffer_add(
+ grpc_error* error = grpc_chttp2_incoming_metadata_buffer_add(
exec_ctx, &s->metadata_buffer[1], md);
if (error != GRPC_ERROR_NONE) {
grpc_chttp2_cancel_stream(exec_ctx, t, s, error);
@@ -547,12 +549,12 @@ static void on_trailing_header(grpc_exec_ctx *exec_ctx, void *tp,
GPR_TIMER_END("on_trailing_header", 0);
}
-static grpc_error *init_header_frame_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+static grpc_error* init_header_frame_parser(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t,
int is_continuation) {
uint8_t is_eoh =
(t->incoming_frame_flags & GRPC_CHTTP2_DATA_FLAG_END_HEADERS) != 0;
- grpc_chttp2_stream *s;
+ grpc_chttp2_stream* s;
/* TODO(ctiller): when to increment header_frames_received? */
@@ -588,7 +590,11 @@ static grpc_error *init_header_frame_parser(grpc_exec_ctx *exec_ctx,
GRPC_CHTTP2_IF_TRACING(gpr_log(
GPR_ERROR, "ignoring new grpc_chttp2_stream creation on client"));
}
- return init_skip_frame_parser(exec_ctx, t, 1);
+ grpc_error* err = init_skip_frame_parser(exec_ctx, t, 1);
+ if (t->incoming_frame_flags & GRPC_CHTTP2_FLAG_HAS_PRIORITY) {
+ grpc_chttp2_hpack_parser_set_has_priority(&t->hpack_parser);
+ }
+ return err;
} else if (t->last_new_stream_id >= t->incoming_stream_id) {
GRPC_CHTTP2_IF_TRACING(gpr_log(
GPR_ERROR,
@@ -662,14 +668,14 @@ static grpc_error *init_header_frame_parser(grpc_exec_ctx *exec_ctx,
return GRPC_ERROR_NONE;
}
-static grpc_error *init_window_update_frame_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
- grpc_error *err = grpc_chttp2_window_update_parser_begin_frame(
+static grpc_error* init_window_update_frame_parser(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t) {
+ grpc_error* err = grpc_chttp2_window_update_parser_begin_frame(
&t->simple.window_update, t->incoming_frame_size,
t->incoming_frame_flags);
if (err != GRPC_ERROR_NONE) return err;
if (t->incoming_stream_id != 0) {
- grpc_chttp2_stream *s = t->incoming_stream =
+ grpc_chttp2_stream* s = t->incoming_stream =
grpc_chttp2_parsing_lookup_stream(t, t->incoming_stream_id);
if (s == NULL) {
return init_skip_frame_parser(exec_ctx, t, 0);
@@ -681,9 +687,9 @@ static grpc_error *init_window_update_frame_parser(grpc_exec_ctx *exec_ctx,
return GRPC_ERROR_NONE;
}
-static grpc_error *init_ping_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
- grpc_error *err = grpc_chttp2_ping_parser_begin_frame(
+static grpc_error* init_ping_parser(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t) {
+ grpc_error* err = grpc_chttp2_ping_parser_begin_frame(
&t->simple.ping, t->incoming_frame_size, t->incoming_frame_flags);
if (err != GRPC_ERROR_NONE) return err;
t->parser = grpc_chttp2_ping_parser_parse;
@@ -691,12 +697,12 @@ static grpc_error *init_ping_parser(grpc_exec_ctx *exec_ctx,
return GRPC_ERROR_NONE;
}
-static grpc_error *init_rst_stream_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
- grpc_error *err = grpc_chttp2_rst_stream_parser_begin_frame(
+static grpc_error* init_rst_stream_parser(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t) {
+ grpc_error* err = grpc_chttp2_rst_stream_parser_begin_frame(
&t->simple.rst_stream, t->incoming_frame_size, t->incoming_frame_flags);
if (err != GRPC_ERROR_NONE) return err;
- grpc_chttp2_stream *s = t->incoming_stream =
+ grpc_chttp2_stream* s = t->incoming_stream =
grpc_chttp2_parsing_lookup_stream(t, t->incoming_stream_id);
if (!t->incoming_stream) {
return init_skip_frame_parser(exec_ctx, t, 0);
@@ -707,9 +713,9 @@ static grpc_error *init_rst_stream_parser(grpc_exec_ctx *exec_ctx,
return GRPC_ERROR_NONE;
}
-static grpc_error *init_goaway_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
- grpc_error *err = grpc_chttp2_goaway_parser_begin_frame(
+static grpc_error* init_goaway_parser(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t) {
+ grpc_error* err = grpc_chttp2_goaway_parser_begin_frame(
&t->goaway_parser, t->incoming_frame_size, t->incoming_frame_flags);
if (err != GRPC_ERROR_NONE) return err;
t->parser = grpc_chttp2_goaway_parser_parse;
@@ -717,14 +723,14 @@ static grpc_error *init_goaway_parser(grpc_exec_ctx *exec_ctx,
return GRPC_ERROR_NONE;
}
-static grpc_error *init_settings_frame_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
+static grpc_error* init_settings_frame_parser(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t) {
if (t->incoming_stream_id != 0) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Settings frame received for grpc_chttp2_stream");
}
- grpc_error *err = grpc_chttp2_settings_parser_begin_frame(
+ grpc_error* err = grpc_chttp2_settings_parser_begin_frame(
&t->simple.settings, t->incoming_frame_size, t->incoming_frame_flags,
t->settings[GRPC_PEER_SETTINGS]);
if (err != GRPC_ERROR_NONE) {
@@ -744,16 +750,16 @@ static grpc_error *init_settings_frame_parser(grpc_exec_ctx *exec_ctx,
return GRPC_ERROR_NONE;
}
-static grpc_error *parse_frame_slice(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t, grpc_slice slice,
+static grpc_error* parse_frame_slice(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t, grpc_slice slice,
int is_last) {
- grpc_chttp2_stream *s = t->incoming_stream;
- grpc_error *err = t->parser(exec_ctx, t->parser_data, t, s, slice, is_last);
+ grpc_chttp2_stream* s = t->incoming_stream;
+ grpc_error* err = t->parser(exec_ctx, t->parser_data, t, s, slice, is_last);
if (err == GRPC_ERROR_NONE) {
return err;
} else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, NULL)) {
if (grpc_http_trace.enabled()) {
- const char *msg = grpc_error_string(err);
+ const char* msg = grpc_error_string(err);
gpr_log(GPR_ERROR, "%s", msg);
}
grpc_chttp2_parsing_become_skip_parser(exec_ctx, t);
diff --git a/src/core/ext/transport/chttp2/transport/stream_lists.cc b/src/core/ext/transport/chttp2/transport/stream_lists.cc
index f2acdd4165..5e9d5d3594 100644
--- a/src/core/ext/transport/chttp2/transport/stream_lists.cc
+++ b/src/core/ext/transport/chttp2/transport/stream_lists.cc
@@ -21,7 +21,7 @@
#include <grpc/support/log.h>
-static const char *stream_list_id_string(grpc_chttp2_stream_list_id id) {
+static const char* stream_list_id_string(grpc_chttp2_stream_list_id id) {
switch (id) {
case GRPC_CHTTP2_LIST_WRITABLE:
return "writable";
@@ -43,17 +43,17 @@ grpc_core::TraceFlag grpc_trace_http2_stream_state(false, "http2_stream_state");
/* core list management */
-static bool stream_list_empty(grpc_chttp2_transport *t,
+static bool stream_list_empty(grpc_chttp2_transport* t,
grpc_chttp2_stream_list_id id) {
return t->lists[id].head == NULL;
}
-static bool stream_list_pop(grpc_chttp2_transport *t,
- grpc_chttp2_stream **stream,
+static bool stream_list_pop(grpc_chttp2_transport* t,
+ grpc_chttp2_stream** stream,
grpc_chttp2_stream_list_id id) {
- grpc_chttp2_stream *s = t->lists[id].head;
+ grpc_chttp2_stream* s = t->lists[id].head;
if (s) {
- grpc_chttp2_stream *new_head = s->links[id].next;
+ grpc_chttp2_stream* new_head = s->links[id].next;
GPR_ASSERT(s->included[id]);
if (new_head) {
t->lists[id].head = new_head;
@@ -72,7 +72,7 @@ static bool stream_list_pop(grpc_chttp2_transport *t,
return s != 0;
}
-static void stream_list_remove(grpc_chttp2_transport *t, grpc_chttp2_stream *s,
+static void stream_list_remove(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
grpc_chttp2_stream_list_id id) {
GPR_ASSERT(s->included[id]);
s->included[id] = 0;
@@ -93,8 +93,8 @@ static void stream_list_remove(grpc_chttp2_transport *t, grpc_chttp2_stream *s,
}
}
-static bool stream_list_maybe_remove(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+static bool stream_list_maybe_remove(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_chttp2_stream_list_id id) {
if (s->included[id]) {
stream_list_remove(t, s, id);
@@ -104,10 +104,10 @@ static bool stream_list_maybe_remove(grpc_chttp2_transport *t,
}
}
-static void stream_list_add_tail(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+static void stream_list_add_tail(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_chttp2_stream_list_id id) {
- grpc_chttp2_stream *old_tail;
+ grpc_chttp2_stream* old_tail;
GPR_ASSERT(!s->included[id]);
old_tail = t->lists[id].tail;
s->links[id].next = NULL;
@@ -125,7 +125,7 @@ static void stream_list_add_tail(grpc_chttp2_transport *t,
}
}
-static bool stream_list_add(grpc_chttp2_transport *t, grpc_chttp2_stream *s,
+static bool stream_list_add(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
grpc_chttp2_stream_list_id id) {
if (s->included[id]) {
return false;
@@ -136,77 +136,77 @@ static bool stream_list_add(grpc_chttp2_transport *t, grpc_chttp2_stream *s,
/* wrappers for specializations */
-bool grpc_chttp2_list_add_writable_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+bool grpc_chttp2_list_add_writable_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
GPR_ASSERT(s->id != 0);
return stream_list_add(t, s, GRPC_CHTTP2_LIST_WRITABLE);
}
-bool grpc_chttp2_list_pop_writable_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream **s) {
+bool grpc_chttp2_list_pop_writable_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream** s) {
return stream_list_pop(t, s, GRPC_CHTTP2_LIST_WRITABLE);
}
-bool grpc_chttp2_list_remove_writable_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+bool grpc_chttp2_list_remove_writable_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
return stream_list_maybe_remove(t, s, GRPC_CHTTP2_LIST_WRITABLE);
}
-bool grpc_chttp2_list_add_writing_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+bool grpc_chttp2_list_add_writing_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
return stream_list_add(t, s, GRPC_CHTTP2_LIST_WRITING);
}
-bool grpc_chttp2_list_have_writing_streams(grpc_chttp2_transport *t) {
+bool grpc_chttp2_list_have_writing_streams(grpc_chttp2_transport* t) {
return !stream_list_empty(t, GRPC_CHTTP2_LIST_WRITING);
}
-bool grpc_chttp2_list_pop_writing_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream **s) {
+bool grpc_chttp2_list_pop_writing_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream** s) {
return stream_list_pop(t, s, GRPC_CHTTP2_LIST_WRITING);
}
-void grpc_chttp2_list_add_waiting_for_concurrency(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+void grpc_chttp2_list_add_waiting_for_concurrency(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
stream_list_add(t, s, GRPC_CHTTP2_LIST_WAITING_FOR_CONCURRENCY);
}
-bool grpc_chttp2_list_pop_waiting_for_concurrency(grpc_chttp2_transport *t,
- grpc_chttp2_stream **s) {
+bool grpc_chttp2_list_pop_waiting_for_concurrency(grpc_chttp2_transport* t,
+ grpc_chttp2_stream** s) {
return stream_list_pop(t, s, GRPC_CHTTP2_LIST_WAITING_FOR_CONCURRENCY);
}
-void grpc_chttp2_list_remove_waiting_for_concurrency(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+void grpc_chttp2_list_remove_waiting_for_concurrency(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
stream_list_maybe_remove(t, s, GRPC_CHTTP2_LIST_WAITING_FOR_CONCURRENCY);
}
-void grpc_chttp2_list_add_stalled_by_transport(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+void grpc_chttp2_list_add_stalled_by_transport(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
stream_list_add(t, s, GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT);
}
-bool grpc_chttp2_list_pop_stalled_by_transport(grpc_chttp2_transport *t,
- grpc_chttp2_stream **s) {
+bool grpc_chttp2_list_pop_stalled_by_transport(grpc_chttp2_transport* t,
+ grpc_chttp2_stream** s) {
return stream_list_pop(t, s, GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT);
}
-void grpc_chttp2_list_remove_stalled_by_transport(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+void grpc_chttp2_list_remove_stalled_by_transport(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
stream_list_maybe_remove(t, s, GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT);
}
-void grpc_chttp2_list_add_stalled_by_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+void grpc_chttp2_list_add_stalled_by_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
stream_list_add(t, s, GRPC_CHTTP2_LIST_STALLED_BY_STREAM);
}
-bool grpc_chttp2_list_pop_stalled_by_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream **s) {
+bool grpc_chttp2_list_pop_stalled_by_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream** s) {
return stream_list_pop(t, s, GRPC_CHTTP2_LIST_STALLED_BY_STREAM);
}
-bool grpc_chttp2_list_remove_stalled_by_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+bool grpc_chttp2_list_remove_stalled_by_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
return stream_list_maybe_remove(t, s, GRPC_CHTTP2_LIST_STALLED_BY_STREAM);
}
diff --git a/src/core/ext/transport/chttp2/transport/stream_map.cc b/src/core/ext/transport/chttp2/transport/stream_map.cc
index d6079a9a33..c863191795 100644
--- a/src/core/ext/transport/chttp2/transport/stream_map.cc
+++ b/src/core/ext/transport/chttp2/transport/stream_map.cc
@@ -24,22 +24,22 @@
#include <grpc/support/log.h>
#include <grpc/support/useful.h>
-void grpc_chttp2_stream_map_init(grpc_chttp2_stream_map *map,
+void grpc_chttp2_stream_map_init(grpc_chttp2_stream_map* map,
size_t initial_capacity) {
GPR_ASSERT(initial_capacity > 1);
- map->keys = (uint32_t *)gpr_malloc(sizeof(uint32_t) * initial_capacity);
- map->values = (void **)gpr_malloc(sizeof(void *) * initial_capacity);
+ map->keys = (uint32_t*)gpr_malloc(sizeof(uint32_t) * initial_capacity);
+ map->values = (void**)gpr_malloc(sizeof(void*) * initial_capacity);
map->count = 0;
map->free = 0;
map->capacity = initial_capacity;
}
-void grpc_chttp2_stream_map_destroy(grpc_chttp2_stream_map *map) {
+void grpc_chttp2_stream_map_destroy(grpc_chttp2_stream_map* map) {
gpr_free(map->keys);
gpr_free(map->values);
}
-static size_t compact(uint32_t *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++) {
@@ -53,12 +53,12 @@ static size_t compact(uint32_t *keys, void **values, size_t count) {
return out;
}
-void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map *map, uint32_t key,
- void *value) {
+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;
- uint32_t *keys = map->keys;
- void **values = map->values;
+ uint32_t* keys = map->keys;
+ void** values = map->values;
GPR_ASSERT(count == 0 || keys[count - 1] < key);
GPR_ASSERT(value);
@@ -73,9 +73,9 @@ void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map *map, uint32_t key,
won't help much */
map->capacity = capacity = 3 * capacity / 2;
map->keys = keys =
- (uint32_t *)gpr_realloc(keys, capacity * sizeof(uint32_t));
+ (uint32_t*)gpr_realloc(keys, capacity * sizeof(uint32_t));
map->values = values =
- (void **)gpr_realloc(values, capacity * sizeof(void *));
+ (void**)gpr_realloc(values, capacity * sizeof(void*));
}
}
@@ -84,12 +84,12 @@ void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map *map, uint32_t key,
map->count = count + 1;
}
-static void **find(grpc_chttp2_stream_map *map, uint32_t 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;
- uint32_t *keys = map->keys;
- void **values = map->values;
+ uint32_t* keys = map->keys;
+ void** values = map->values;
uint32_t mid_key;
if (max_idx == 0) return NULL;
@@ -112,9 +112,9 @@ static void **find(grpc_chttp2_stream_map *map, uint32_t key) {
return NULL;
}
-void *grpc_chttp2_stream_map_delete(grpc_chttp2_stream_map *map, uint32_t key) {
- void **pvalue = find(map, key);
- void *out = NULL;
+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) {
out = *pvalue;
*pvalue = NULL;
@@ -129,16 +129,16 @@ void *grpc_chttp2_stream_map_delete(grpc_chttp2_stream_map *map, uint32_t key) {
return out;
}
-void *grpc_chttp2_stream_map_find(grpc_chttp2_stream_map *map, uint32_t key) {
- void **pvalue = find(map, 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;
}
-size_t grpc_chttp2_stream_map_size(grpc_chttp2_stream_map *map) {
+size_t grpc_chttp2_stream_map_size(grpc_chttp2_stream_map* map) {
return map->count - map->free;
}
-void *grpc_chttp2_stream_map_rand(grpc_chttp2_stream_map *map) {
+void* grpc_chttp2_stream_map_rand(grpc_chttp2_stream_map* map) {
if (map->count == map->free) {
return NULL;
}
@@ -149,10 +149,10 @@ void *grpc_chttp2_stream_map_rand(grpc_chttp2_stream_map *map) {
return map->values[((size_t)rand()) % map->count];
}
-void grpc_chttp2_stream_map_for_each(grpc_chttp2_stream_map *map,
- void (*f)(void *user_data, uint32_t key,
- void *value),
- void *user_data) {
+void grpc_chttp2_stream_map_for_each(grpc_chttp2_stream_map* map,
+ void (*f)(void* user_data, uint32_t key,
+ void* value),
+ void* user_data) {
size_t i;
for (i = 0; i < map->count; i++) {
diff --git a/src/core/ext/transport/chttp2/transport/stream_map.h b/src/core/ext/transport/chttp2/transport/stream_map.h
index 7ab6a4f5ed..c89d20047c 100644
--- a/src/core/ext/transport/chttp2/transport/stream_map.h
+++ b/src/core/ext/transport/chttp2/transport/stream_map.h
@@ -34,40 +34,40 @@ extern "C" {
Adds are restricted to strictly higher keys than previously seen (this is
guaranteed by http2). */
typedef struct {
- uint32_t *keys;
- void **values;
+ uint32_t* keys;
+ void** values;
size_t count;
size_t free;
size_t capacity;
} grpc_chttp2_stream_map;
-void grpc_chttp2_stream_map_init(grpc_chttp2_stream_map *map,
+void grpc_chttp2_stream_map_init(grpc_chttp2_stream_map* map,
size_t initial_capacity);
-void grpc_chttp2_stream_map_destroy(grpc_chttp2_stream_map *map);
+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, uint32_t key,
- void *value);
+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, uint32_t key);
+void* grpc_chttp2_stream_map_delete(grpc_chttp2_stream_map* map, uint32_t key);
/* Return an existing key, or NULL if it does not exist */
-void *grpc_chttp2_stream_map_find(grpc_chttp2_stream_map *map, uint32_t key);
+void* grpc_chttp2_stream_map_find(grpc_chttp2_stream_map* map, uint32_t key);
/* Return a random entry */
-void *grpc_chttp2_stream_map_rand(grpc_chttp2_stream_map *map);
+void* grpc_chttp2_stream_map_rand(grpc_chttp2_stream_map* map);
/* How many (populated) entries are in the stream map? */
-size_t grpc_chttp2_stream_map_size(grpc_chttp2_stream_map *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, uint32_t key,
- void *value),
- void *user_data);
+void grpc_chttp2_stream_map_for_each(grpc_chttp2_stream_map* map,
+ void (*f)(void* user_data, uint32_t key,
+ void* value),
+ void* user_data);
#ifdef __cplusplus
}
diff --git a/src/core/ext/transport/chttp2/transport/writing.cc b/src/core/ext/transport/chttp2/transport/writing.cc
index 25f7c858f8..2620694e5a 100644
--- a/src/core/ext/transport/chttp2/transport/writing.cc
+++ b/src/core/ext/transport/chttp2/transport/writing.cc
@@ -27,24 +27,24 @@
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/transport/http2_errors.h"
-static void add_to_write_list(grpc_chttp2_write_cb **list,
- grpc_chttp2_write_cb *cb) {
+static void add_to_write_list(grpc_chttp2_write_cb** list,
+ grpc_chttp2_write_cb* cb) {
cb->next = *list;
*list = cb;
}
-static void finish_write_cb(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_chttp2_stream *s, grpc_chttp2_write_cb *cb,
- grpc_error *error) {
+static void finish_write_cb(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s, grpc_chttp2_write_cb* cb,
+ grpc_error* error) {
grpc_chttp2_complete_closure_step(exec_ctx, t, s, &cb->closure, error,
"finish_write_cb");
cb->next = t->write_cb_pool;
t->write_cb_pool = cb;
}
-static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
- grpc_chttp2_ping_queue *pq = &t->ping_queue;
+static void maybe_initiate_ping(grpc_exec_ctx* exec_ctx,
+ grpc_chttp2_transport* t) {
+ grpc_chttp2_ping_queue* pq = &t->ping_queue;
if (grpc_closure_list_empty(pq->lists[GRPC_CHTTP2_PCL_NEXT])) {
/* no ping needed: wait */
return;
@@ -110,16 +110,16 @@ static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx,
(t->ping_state.pings_before_data_required != 0);
}
-static bool update_list(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_chttp2_stream *s, int64_t send_bytes,
- grpc_chttp2_write_cb **list, int64_t *ctr,
- grpc_error *error) {
+static bool update_list(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s, int64_t send_bytes,
+ grpc_chttp2_write_cb** list, int64_t* ctr,
+ grpc_error* error) {
bool sched_any = false;
- grpc_chttp2_write_cb *cb = *list;
+ grpc_chttp2_write_cb* cb = *list;
*list = NULL;
*ctr += send_bytes;
while (cb) {
- grpc_chttp2_write_cb *next = cb->next;
+ grpc_chttp2_write_cb* next = cb->next;
if (cb->call_at_byte <= *ctr) {
sched_any = true;
finish_write_cb(exec_ctx, t, s, cb, GRPC_ERROR_REF(error));
@@ -132,8 +132,8 @@ static bool update_list(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
return sched_any;
}
-static void report_stall(grpc_chttp2_transport *t, grpc_chttp2_stream *s,
- const char *staller) {
+static void report_stall(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
+ const char* staller) {
gpr_log(
GPR_DEBUG,
"%s:%p stream %d stalled by %s [fc:pending=%" PRIdPTR ":flowed=%" PRId64
@@ -151,7 +151,7 @@ static void report_stall(grpc_chttp2_transport *t, grpc_chttp2_stream *s,
s->flow_control->remote_window_delta());
}
-static bool stream_ref_if_not_destroyed(gpr_refcount *r) {
+static bool stream_ref_if_not_destroyed(gpr_refcount* r) {
gpr_atm count;
do {
count = gpr_atm_acq_load(&r->count);
@@ -161,12 +161,12 @@ static bool stream_ref_if_not_destroyed(gpr_refcount *r) {
}
/* How many bytes would we like to put on the wire during a single syscall */
-static uint32_t target_write_size(grpc_chttp2_transport *t) {
+static uint32_t target_write_size(grpc_chttp2_transport* t) {
return 1024 * 1024;
}
// Returns true if initial_metadata contains only default headers.
-static bool is_default_initial_metadata(grpc_metadata_batch *initial_metadata) {
+static bool is_default_initial_metadata(grpc_metadata_batch* initial_metadata) {
return initial_metadata->list.default_count == initial_metadata->list.count;
}
@@ -175,13 +175,13 @@ class StreamWriteContext;
class WriteContext {
public:
- WriteContext(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t) : t_(t) {
+ WriteContext(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t) : t_(t) {
GRPC_STATS_INC_HTTP2_WRITES_BEGUN(exec_ctx);
GPR_TIMER_BEGIN("grpc_chttp2_begin_write", 0);
}
// TODO(ctiller): make this the destructor
- void FlushStats(grpc_exec_ctx *exec_ctx) {
+ void FlushStats(grpc_exec_ctx* exec_ctx) {
GRPC_STATS_INC_HTTP2_SEND_INITIAL_METADATA_PER_WRITE(
exec_ctx, initial_metadata_writes_);
GRPC_STATS_INC_HTTP2_SEND_MESSAGE_PER_WRITE(exec_ctx, message_writes_);
@@ -190,7 +190,7 @@ class WriteContext {
GRPC_STATS_INC_HTTP2_SEND_FLOWCTL_PER_WRITE(exec_ctx, flow_control_writes_);
}
- void FlushSettings(grpc_exec_ctx *exec_ctx) {
+ void FlushSettings(grpc_exec_ctx* exec_ctx) {
if (t_->dirtied_local_settings && !t_->sent_local_settings) {
grpc_slice_buffer_add(
&t_->outbuf, grpc_chttp2_settings_create(
@@ -204,13 +204,13 @@ class WriteContext {
}
}
- void FlushQueuedBuffers(grpc_exec_ctx *exec_ctx) {
+ void FlushQueuedBuffers(grpc_exec_ctx* exec_ctx) {
/* simple writes are queued to qbuf, and flushed here */
grpc_slice_buffer_move_into(&t_->qbuf, &t_->outbuf);
GPR_ASSERT(t_->qbuf.count == 0);
}
- void FlushWindowUpdates(grpc_exec_ctx *exec_ctx) {
+ void FlushWindowUpdates(grpc_exec_ctx* exec_ctx) {
uint32_t transport_announce =
t_->flow_control->MaybeSendUpdate(t_->outbuf.count > 0);
if (transport_announce) {
@@ -230,7 +230,7 @@ class WriteContext {
t_->ping_ack_count = 0;
}
- void EnactHpackSettings(grpc_exec_ctx *exec_ctx) {
+ void EnactHpackSettings(grpc_exec_ctx* exec_ctx) {
grpc_chttp2_hpack_compressor_set_max_table_size(
&t_->hpack_compressor,
t_->settings[GRPC_PEER_SETTINGS]
@@ -238,7 +238,7 @@ class WriteContext {
}
void UpdateStreamsNoLongerStalled() {
- grpc_chttp2_stream *s;
+ grpc_chttp2_stream* s;
while (grpc_chttp2_list_pop_stalled_by_transport(t_, &s)) {
if (t_->closed_with_error == GRPC_ERROR_NONE &&
grpc_chttp2_list_add_writable_stream(t_, s)) {
@@ -249,13 +249,13 @@ class WriteContext {
}
}
- grpc_chttp2_stream *NextStream() {
+ grpc_chttp2_stream* NextStream() {
if (t_->outbuf.length > target_write_size(t_)) {
result_.partial = true;
return nullptr;
}
- grpc_chttp2_stream *s;
+ grpc_chttp2_stream* s;
if (!grpc_chttp2_list_pop_writable_stream(t_, &s)) {
return nullptr;
}
@@ -277,7 +277,7 @@ class WriteContext {
void NoteScheduledResults() { result_.early_results_scheduled = true; }
- grpc_chttp2_transport *transport() const { return t_; }
+ grpc_chttp2_transport* transport() const { return t_; }
grpc_chttp2_begin_write_result Result() {
result_.writing = t_->outbuf.count > 0;
@@ -285,7 +285,7 @@ class WriteContext {
}
private:
- grpc_chttp2_transport *const t_;
+ grpc_chttp2_transport* const t_;
/* stats histogram counters: we increment these throughout this function,
and at the end publish to the central stats histograms */
@@ -298,8 +298,8 @@ class WriteContext {
class DataSendContext {
public:
- DataSendContext(WriteContext *write_context, grpc_chttp2_transport *t,
- grpc_chttp2_stream *s)
+ DataSendContext(WriteContext* write_context, grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s)
: write_context_(write_context),
t_(t),
s_(s),
@@ -369,7 +369,7 @@ class DataSendContext {
bool is_last_frame() const { return is_last_frame_; }
- void CallCallbacks(grpc_exec_ctx *exec_ctx) {
+ void CallCallbacks(grpc_exec_ctx* exec_ctx) {
if (update_list(exec_ctx, t_, s_,
(int64_t)(s_->sending_bytes - sending_bytes_before_),
&s_->on_flow_controlled_cbs,
@@ -379,16 +379,16 @@ class DataSendContext {
}
private:
- WriteContext *write_context_;
- grpc_chttp2_transport *t_;
- grpc_chttp2_stream *s_;
+ WriteContext* write_context_;
+ grpc_chttp2_transport* t_;
+ grpc_chttp2_stream* s_;
const size_t sending_bytes_before_;
bool is_last_frame_ = false;
};
class StreamWriteContext {
public:
- StreamWriteContext(WriteContext *write_context, grpc_chttp2_stream *s)
+ StreamWriteContext(WriteContext* write_context, grpc_chttp2_stream* s)
: write_context_(write_context), t_(write_context->transport()), s_(s) {
GRPC_CHTTP2_IF_TRACING(
gpr_log(GPR_DEBUG, "W:%p %s[%d] im-(sent,send)=(%d,%d) announce=%d", t_,
@@ -398,7 +398,7 @@ class StreamWriteContext {
s->flow_control->announced_window_delta())));
}
- void FlushInitialMetadata(grpc_exec_ctx *exec_ctx) {
+ void FlushInitialMetadata(grpc_exec_ctx* exec_ctx) {
/* send initial metadata if it's available */
if (s_->sent_initial_metadata) return;
if (s_->send_initial_metadata == nullptr) return;
@@ -439,7 +439,7 @@ class StreamWriteContext {
"send_initial_metadata_finished");
}
- void FlushWindowUpdates(grpc_exec_ctx *exec_ctx) {
+ void FlushWindowUpdates(grpc_exec_ctx* exec_ctx) {
/* send any window updates */
const uint32_t stream_announce = s_->flow_control->MaybeSendUpdate();
if (stream_announce == 0) return;
@@ -451,7 +451,7 @@ class StreamWriteContext {
write_context_->IncWindowUpdateWrites();
}
- void FlushData(grpc_exec_ctx *exec_ctx) {
+ void FlushData(grpc_exec_ctx* exec_ctx) {
if (!s_->sent_initial_metadata) return;
if (s_->flow_controlled_buffer.length == 0 &&
@@ -495,7 +495,7 @@ class StreamWriteContext {
write_context_->IncMessageWrites();
}
- void FlushTrailingMetadata(grpc_exec_ctx *exec_ctx) {
+ void FlushTrailingMetadata(grpc_exec_ctx* exec_ctx) {
if (!s_->sent_initial_metadata) return;
if (s_->send_trailing_metadata == NULL) return;
@@ -551,7 +551,7 @@ class StreamWriteContext {
}
}
- void SentLastFrame(grpc_exec_ctx *exec_ctx) {
+ void SentLastFrame(grpc_exec_ctx* exec_ctx) {
s_->send_trailing_metadata = NULL;
s_->sent_trailing_metadata = true;
@@ -564,17 +564,17 @@ class StreamWriteContext {
GRPC_ERROR_NONE);
}
- WriteContext *const write_context_;
- grpc_chttp2_transport *const t_;
- grpc_chttp2_stream *const s_;
+ WriteContext* const write_context_;
+ grpc_chttp2_transport* const t_;
+ grpc_chttp2_stream* const s_;
bool stream_became_writable_ = false;
- grpc_mdelem *extra_headers_for_trailing_metadata_[2];
+ grpc_mdelem* extra_headers_for_trailing_metadata_[2];
size_t num_extra_headers_for_trailing_metadata_ = 0;
};
} // namespace
grpc_chttp2_begin_write_result grpc_chttp2_begin_write(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t) {
+ grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t) {
WriteContext ctx(exec_ctx, t);
ctx.FlushSettings(exec_ctx);
ctx.FlushPingAcks();
@@ -587,7 +587,7 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write(
/* for each grpc_chttp2_stream that's become writable, frame it's data
(according to available window sizes) and add to the output buffer */
- while (grpc_chttp2_stream *s = ctx.NextStream()) {
+ while (grpc_chttp2_stream* s = ctx.NextStream()) {
StreamWriteContext stream_ctx(&ctx, s);
stream_ctx.FlushInitialMetadata(exec_ctx);
stream_ctx.FlushWindowUpdates(exec_ctx);
@@ -615,10 +615,10 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write(
return ctx.Result();
}
-void grpc_chttp2_end_write(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_error *error) {
+void grpc_chttp2_end_write(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
+ grpc_error* error) {
GPR_TIMER_BEGIN("grpc_chttp2_end_write", 0);
- grpc_chttp2_stream *s;
+ grpc_chttp2_stream* s;
while (grpc_chttp2_list_pop_writing_stream(t, &s)) {
if (s->sending_bytes != 0) {
diff --git a/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc b/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc
index b280487ca3..d590ba0371 100644
--- a/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc
+++ b/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc
@@ -33,20 +33,20 @@
// Cronet transport object
typedef struct cronet_transport {
grpc_transport base; // must be first element in this structure
- void *engine;
- char *host;
+ void* engine;
+ char* host;
} cronet_transport;
extern grpc_transport_vtable grpc_cronet_vtable;
-GRPCAPI grpc_channel *grpc_cronet_secure_channel_create(
- void *engine, const char *target, const grpc_channel_args *args,
- void *reserved) {
+GRPCAPI grpc_channel* grpc_cronet_secure_channel_create(
+ void* engine, const char* target, const grpc_channel_args* args,
+ void* reserved) {
gpr_log(GPR_DEBUG,
"grpc_create_cronet_transport: stream_engine = %p, target=%s", engine,
target);
- grpc_transport *ct =
+ grpc_transport* ct =
grpc_create_cronet_transport(engine, target, args, reserved);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.cc b/src/core/ext/transport/cronet/transport/cronet_transport.cc
index 97e4f7d72b..0b1ddf8839 100644
--- a/src/core/ext/transport/cronet/transport/cronet_transport.cc
+++ b/src/core/ext/transport/cronet/transport/cronet_transport.cc
@@ -75,17 +75,17 @@ enum e_op_id {
/* Cronet callbacks. See cronet_c_for_grpc.h for documentation for each. */
-static void on_stream_ready(bidirectional_stream *);
+static void on_stream_ready(bidirectional_stream*);
static void on_response_headers_received(
- bidirectional_stream *, const bidirectional_stream_header_array *,
- const char *);
-static void on_write_completed(bidirectional_stream *, const char *);
-static void on_read_completed(bidirectional_stream *, char *, int);
+ bidirectional_stream*, const bidirectional_stream_header_array*,
+ const char*);
+static void on_write_completed(bidirectional_stream*, const char*);
+static void on_read_completed(bidirectional_stream*, char*, int);
static void on_response_trailers_received(
- bidirectional_stream *, const bidirectional_stream_header_array *);
-static void on_succeeded(bidirectional_stream *);
-static void on_failed(bidirectional_stream *, int);
-static void on_canceled(bidirectional_stream *);
+ bidirectional_stream*, const bidirectional_stream_header_array*);
+static void on_succeeded(bidirectional_stream*);
+static void on_failed(bidirectional_stream*, int);
+static void on_canceled(bidirectional_stream*);
static bidirectional_stream_callback cronet_callbacks = {
on_stream_ready,
on_response_headers_received,
@@ -99,8 +99,8 @@ static bidirectional_stream_callback cronet_callbacks = {
/* Cronet transport object */
struct grpc_cronet_transport {
grpc_transport base; /* must be first element in this structure */
- stream_engine *engine;
- char *host;
+ stream_engine* engine;
+ char* host;
bool use_packet_coalescing;
};
typedef struct grpc_cronet_transport grpc_cronet_transport;
@@ -109,14 +109,14 @@ typedef struct grpc_cronet_transport grpc_cronet_transport;
http://www.catb.org/esr/structure-packing/#_structure_reordering: */
struct read_state {
/* vars to store data coming from server */
- char *read_buffer;
+ char* read_buffer;
bool length_field_received;
int received_bytes;
int remaining_bytes;
int length_field;
bool compressed;
char grpc_header_bytes[GRPC_HEADER_SIZE_IN_BYTES];
- char *payload_field;
+ char* payload_field;
bool read_stream_closed;
/* vars for holding data destined for the application */
@@ -132,7 +132,7 @@ struct read_state {
};
struct write_state {
- char *write_buffer;
+ char* write_buffer;
};
/* track state of one stream op */
@@ -150,7 +150,7 @@ struct op_state {
bool pending_recv_trailing_metadata;
/* Cronet has not issued a callback of a bidirectional read */
bool pending_read_from_cronet;
- grpc_error *cancel_error;
+ grpc_error* cancel_error;
/* data structure for storing data coming from server */
struct read_state rs;
/* data structure for storing data going to the server */
@@ -161,22 +161,22 @@ struct op_and_state {
grpc_transport_stream_op_batch op;
struct op_state state;
bool done;
- struct stream_obj *s; /* Pointer back to the stream object */
- struct op_and_state *next; /* next op_and_state in the linked list */
+ struct stream_obj* s; /* Pointer back to the stream object */
+ struct op_and_state* next; /* next op_and_state in the linked list */
};
struct op_storage {
int num_pending_ops;
- struct op_and_state *head;
+ struct op_and_state* head;
};
struct stream_obj {
- gpr_arena *arena;
- struct op_and_state *oas;
- grpc_transport_stream_op_batch *curr_op;
- grpc_cronet_transport *curr_ct;
- grpc_stream *curr_gs;
- bidirectional_stream *cbs;
+ gpr_arena* arena;
+ struct op_and_state* oas;
+ grpc_transport_stream_op_batch* curr_op;
+ grpc_cronet_transport* curr_ct;
+ grpc_stream* curr_gs;
+ bidirectional_stream* cbs;
bidirectional_stream_header_array header_array;
/* Stream level state. Some state will be tracked both at stream and stream_op
@@ -190,7 +190,7 @@ struct stream_obj {
gpr_mu mu;
/* Refcount object of the stream */
- grpc_stream_refcount *refcount;
+ grpc_stream_refcount* refcount;
};
typedef struct stream_obj stream_obj;
@@ -199,30 +199,30 @@ typedef struct stream_obj stream_obj;
grpc_cronet_stream_ref((stream), (reason))
#define GRPC_CRONET_STREAM_UNREF(exec_ctx, stream, reason) \
grpc_cronet_stream_unref((exec_ctx), (stream), (reason))
-void grpc_cronet_stream_ref(stream_obj *s, const char *reason) {
+void grpc_cronet_stream_ref(stream_obj* s, const char* reason) {
grpc_stream_ref(s->refcount, reason);
}
-void grpc_cronet_stream_unref(grpc_exec_ctx *exec_ctx, stream_obj *s,
- const char *reason) {
+void grpc_cronet_stream_unref(grpc_exec_ctx* exec_ctx, stream_obj* s,
+ const char* reason) {
grpc_stream_unref(exec_ctx, s->refcount, reason);
}
#else
#define GRPC_CRONET_STREAM_REF(stream, reason) grpc_cronet_stream_ref((stream))
#define GRPC_CRONET_STREAM_UNREF(exec_ctx, stream, reason) \
grpc_cronet_stream_unref((exec_ctx), (stream))
-void grpc_cronet_stream_ref(stream_obj *s) { grpc_stream_ref(s->refcount); }
-void grpc_cronet_stream_unref(grpc_exec_ctx *exec_ctx, stream_obj *s) {
+void grpc_cronet_stream_ref(stream_obj* s) { grpc_stream_ref(s->refcount); }
+void grpc_cronet_stream_unref(grpc_exec_ctx* exec_ctx, stream_obj* s) {
grpc_stream_unref(exec_ctx, s->refcount);
}
#endif
-static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
- struct op_and_state *oas);
+static enum e_op_result execute_stream_op(grpc_exec_ctx* exec_ctx,
+ struct op_and_state* oas);
/*
Utility function to translate enum into string for printing
*/
-static const char *op_result_string(enum e_op_result i) {
+static const char* op_result_string(enum e_op_result i) {
switch (i) {
case ACTION_TAKEN_WITH_CALLBACK:
return "ACTION_TAKEN_WITH_CALLBACK";
@@ -234,7 +234,7 @@ static const char *op_result_string(enum e_op_result i) {
GPR_UNREACHABLE_CODE(return "UNKNOWN");
}
-static const char *op_id_string(enum e_op_id i) {
+static const char* op_id_string(enum e_op_id i) {
switch (i) {
case OP_SEND_INITIAL_METADATA:
return "OP_SEND_INITIAL_METADATA";
@@ -268,7 +268,7 @@ static const char *op_id_string(enum e_op_id i) {
return "UNKNOWN";
}
-static void null_and_maybe_free_read_buffer(stream_obj *s) {
+static void null_and_maybe_free_read_buffer(stream_obj* s) {
if (s->state.rs.read_buffer &&
s->state.rs.read_buffer != s->state.rs.grpc_header_bytes) {
gpr_free(s->state.rs.read_buffer);
@@ -276,7 +276,7 @@ static void null_and_maybe_free_read_buffer(stream_obj *s) {
s->state.rs.read_buffer = NULL;
}
-static void maybe_flush_read(stream_obj *s) {
+static void maybe_flush_read(stream_obj* s) {
/* To enter flush read state (discarding all the buffered messages in
* transport layer), two conditions must be satisfied: 1) non-zero grpc status
* has been received, and 2) an op requesting the status code
@@ -289,7 +289,7 @@ static void maybe_flush_read(stream_obj *s) {
CRONET_LOG(GPR_DEBUG, "%p: Flush read", s);
s->state.flush_read = true;
null_and_maybe_free_read_buffer(s);
- s->state.rs.read_buffer = (char *)gpr_malloc(GRPC_FLUSH_READ_SIZE);
+ s->state.rs.read_buffer = (char*)gpr_malloc(GRPC_FLUSH_READ_SIZE);
if (!s->state.pending_read_from_cronet) {
CRONET_LOG(GPR_DEBUG, "bidirectional_stream_read(%p)", s->cbs);
bidirectional_stream_read(s->cbs, s->state.rs.read_buffer,
@@ -300,8 +300,8 @@ static void maybe_flush_read(stream_obj *s) {
}
}
-static grpc_error *make_error_with_desc(int error_code, const char *desc) {
- grpc_error *error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(desc);
+static grpc_error* make_error_with_desc(int error_code, const char* desc) {
+ grpc_error* error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(desc);
error = grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS, error_code);
return error;
}
@@ -309,13 +309,13 @@ static grpc_error *make_error_with_desc(int error_code, const char *desc) {
/*
Add a new stream op to op storage.
*/
-static void add_to_storage(struct stream_obj *s,
- grpc_transport_stream_op_batch *op) {
- struct op_storage *storage = &s->storage;
+static void add_to_storage(struct stream_obj* s,
+ grpc_transport_stream_op_batch* op) {
+ struct op_storage* storage = &s->storage;
/* add new op at the beginning of the linked list. The memory is freed
in remove_from_storage */
- struct op_and_state *new_op =
- (struct op_and_state *)gpr_malloc(sizeof(struct op_and_state));
+ struct op_and_state* new_op =
+ (struct op_and_state*)gpr_malloc(sizeof(struct op_and_state));
memcpy(&new_op->op, op, sizeof(grpc_transport_stream_op_batch));
memset(&new_op->state, 0, sizeof(new_op->state));
new_op->s = s;
@@ -339,9 +339,9 @@ static void add_to_storage(struct stream_obj *s,
/*
Traverse the linked list and delete op and free memory
*/
-static void remove_from_storage(struct stream_obj *s,
- struct op_and_state *oas) {
- struct op_and_state *curr;
+static void remove_from_storage(struct stream_obj* s,
+ struct op_and_state* oas) {
+ struct op_and_state* curr;
if (s->storage.head == NULL || oas == NULL) {
return;
}
@@ -373,9 +373,9 @@ static void remove_from_storage(struct stream_obj *s,
This can get executed from the Cronet network thread via cronet callback
or on the application supplied thread via the perform_stream_op function.
*/
-static void execute_from_storage(grpc_exec_ctx *exec_ctx, stream_obj *s) {
+static void execute_from_storage(grpc_exec_ctx* exec_ctx, stream_obj* s) {
gpr_mu_lock(&s->mu);
- for (struct op_and_state *curr = s->storage.head; curr != NULL;) {
+ for (struct op_and_state* curr = s->storage.head; curr != NULL;) {
CRONET_LOG(GPR_DEBUG, "calling op at %p. done = %d", curr, curr->done);
GPR_ASSERT(curr->done == 0);
enum e_op_result result = execute_stream_op(exec_ctx, curr);
@@ -383,7 +383,7 @@ static void execute_from_storage(grpc_exec_ctx *exec_ctx, stream_obj *s) {
op_result_string(result));
/* if this op is done, then remove it and free memory */
if (curr->done) {
- struct op_and_state *next = curr->next;
+ struct op_and_state* next = curr->next;
remove_from_storage(s, curr);
curr = next;
}
@@ -400,11 +400,11 @@ static void execute_from_storage(grpc_exec_ctx *exec_ctx, stream_obj *s) {
/*
Cronet callback
*/
-static void on_failed(bidirectional_stream *stream, int net_error) {
+static void on_failed(bidirectional_stream* stream, int net_error) {
CRONET_LOG(GPR_DEBUG, "on_failed(%p, %d)", stream, net_error);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- stream_obj *s = (stream_obj *)stream->annotation;
+ stream_obj* s = (stream_obj*)stream->annotation;
gpr_mu_lock(&s->mu);
bidirectional_stream_destroy(s->cbs);
s->state.state_callback_received[OP_FAILED] = true;
@@ -427,11 +427,11 @@ static void on_failed(bidirectional_stream *stream, int net_error) {
/*
Cronet callback
*/
-static void on_canceled(bidirectional_stream *stream) {
+static void on_canceled(bidirectional_stream* stream) {
CRONET_LOG(GPR_DEBUG, "on_canceled(%p)", stream);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- stream_obj *s = (stream_obj *)stream->annotation;
+ stream_obj* s = (stream_obj*)stream->annotation;
gpr_mu_lock(&s->mu);
bidirectional_stream_destroy(s->cbs);
s->state.state_callback_received[OP_CANCELED] = true;
@@ -454,11 +454,11 @@ static void on_canceled(bidirectional_stream *stream) {
/*
Cronet callback
*/
-static void on_succeeded(bidirectional_stream *stream) {
+static void on_succeeded(bidirectional_stream* stream) {
CRONET_LOG(GPR_DEBUG, "on_succeeded(%p)", stream);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- stream_obj *s = (stream_obj *)stream->annotation;
+ stream_obj* s = (stream_obj*)stream->annotation;
gpr_mu_lock(&s->mu);
bidirectional_stream_destroy(s->cbs);
s->state.state_callback_received[OP_SUCCEEDED] = true;
@@ -473,11 +473,11 @@ static void on_succeeded(bidirectional_stream *stream) {
/*
Cronet callback
*/
-static void on_stream_ready(bidirectional_stream *stream) {
+static void on_stream_ready(bidirectional_stream* stream) {
CRONET_LOG(GPR_DEBUG, "W: on_stream_ready(%p)", stream);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- stream_obj *s = (stream_obj *)stream->annotation;
- grpc_cronet_transport *t = (grpc_cronet_transport *)s->curr_ct;
+ stream_obj* s = (stream_obj*)stream->annotation;
+ grpc_cronet_transport* t = (grpc_cronet_transport*)s->curr_ct;
gpr_mu_lock(&s->mu);
s->state.state_op_done[OP_SEND_INITIAL_METADATA] = true;
s->state.state_callback_received[OP_SEND_INITIAL_METADATA] = true;
@@ -503,13 +503,13 @@ static void on_stream_ready(bidirectional_stream *stream) {
Cronet callback
*/
static void on_response_headers_received(
- bidirectional_stream *stream,
- const bidirectional_stream_header_array *headers,
- const char *negotiated_protocol) {
+ bidirectional_stream* stream,
+ const bidirectional_stream_header_array* headers,
+ const char* negotiated_protocol) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
CRONET_LOG(GPR_DEBUG, "R: on_response_headers_received(%p, %p, %s)", stream,
headers, negotiated_protocol);
- stream_obj *s = (stream_obj *)stream->annotation;
+ stream_obj* s = (stream_obj*)stream->annotation;
/* Identify if this is a header or a trailer (in a trailer-only response case)
*/
@@ -526,15 +526,15 @@ static void on_response_headers_received(
grpc_chttp2_incoming_metadata_buffer_init(&s->state.rs.initial_metadata,
s->arena);
for (size_t i = 0; i < headers->count; i++) {
- GRPC_LOG_IF_ERROR(
- "on_response_headers_received",
- grpc_chttp2_incoming_metadata_buffer_add(
- &exec_ctx, &s->state.rs.initial_metadata,
- grpc_mdelem_from_slices(
- &exec_ctx, grpc_slice_intern(grpc_slice_from_static_string(
- headers->headers[i].key)),
- grpc_slice_intern(grpc_slice_from_static_string(
- headers->headers[i].value)))));
+ GRPC_LOG_IF_ERROR("on_response_headers_received",
+ grpc_chttp2_incoming_metadata_buffer_add(
+ &exec_ctx, &s->state.rs.initial_metadata,
+ grpc_mdelem_from_slices(
+ &exec_ctx,
+ grpc_slice_intern(grpc_slice_from_static_string(
+ headers->headers[i].key)),
+ grpc_slice_intern(grpc_slice_from_static_string(
+ headers->headers[i].value)))));
}
s->state.state_callback_received[OP_RECV_INITIAL_METADATA] = true;
if (!(s->state.state_op_done[OP_CANCEL_ERROR] ||
@@ -559,9 +559,9 @@ static void on_response_headers_received(
/*
Cronet callback
*/
-static void on_write_completed(bidirectional_stream *stream, const char *data) {
+static void on_write_completed(bidirectional_stream* stream, const char* data) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- stream_obj *s = (stream_obj *)stream->annotation;
+ stream_obj* s = (stream_obj*)stream->annotation;
CRONET_LOG(GPR_DEBUG, "W: on_write_completed(%p, %s)", stream, data);
gpr_mu_lock(&s->mu);
if (s->state.ws.write_buffer) {
@@ -577,10 +577,10 @@ static void on_write_completed(bidirectional_stream *stream, const char *data) {
/*
Cronet callback
*/
-static void on_read_completed(bidirectional_stream *stream, char *data,
+static void on_read_completed(bidirectional_stream* stream, char* data,
int count) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- stream_obj *s = (stream_obj *)stream->annotation;
+ stream_obj* s = (stream_obj*)stream->annotation;
CRONET_LOG(GPR_DEBUG, "R: on_read_completed(%p, %p, %d)", stream, data,
count);
gpr_mu_lock(&s->mu);
@@ -620,13 +620,13 @@ static void on_read_completed(bidirectional_stream *stream, char *data,
Cronet callback
*/
static void on_response_trailers_received(
- bidirectional_stream *stream,
- const bidirectional_stream_header_array *trailers) {
+ bidirectional_stream* stream,
+ const bidirectional_stream_header_array* trailers) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
CRONET_LOG(GPR_DEBUG, "R: on_response_trailers_received(%p,%p)", stream,
trailers);
- stream_obj *s = (stream_obj *)stream->annotation;
- grpc_cronet_transport *t = (grpc_cronet_transport *)s->curr_ct;
+ stream_obj* s = (stream_obj*)stream->annotation;
+ grpc_cronet_transport* t = (grpc_cronet_transport*)s->curr_ct;
gpr_mu_lock(&s->mu);
memset(&s->state.rs.trailing_metadata, 0,
sizeof(s->state.rs.trailing_metadata));
@@ -636,15 +636,15 @@ static void on_response_trailers_received(
for (size_t i = 0; i < trailers->count; i++) {
CRONET_LOG(GPR_DEBUG, "trailer key=%s, value=%s", trailers->headers[i].key,
trailers->headers[i].value);
- GRPC_LOG_IF_ERROR(
- "on_response_trailers_received",
- grpc_chttp2_incoming_metadata_buffer_add(
- &exec_ctx, &s->state.rs.trailing_metadata,
- grpc_mdelem_from_slices(
- &exec_ctx, grpc_slice_intern(grpc_slice_from_static_string(
- trailers->headers[i].key)),
- grpc_slice_intern(grpc_slice_from_static_string(
- trailers->headers[i].value)))));
+ GRPC_LOG_IF_ERROR("on_response_trailers_received",
+ grpc_chttp2_incoming_metadata_buffer_add(
+ &exec_ctx, &s->state.rs.trailing_metadata,
+ grpc_mdelem_from_slices(
+ &exec_ctx,
+ grpc_slice_intern(grpc_slice_from_static_string(
+ trailers->headers[i].key)),
+ grpc_slice_intern(grpc_slice_from_static_string(
+ trailers->headers[i].value)))));
s->state.rs.trailing_metadata_valid = true;
if (0 == strcmp(trailers->headers[i].key, "grpc-status") &&
0 != strcmp(trailers->headers[i].value, "0")) {
@@ -679,17 +679,17 @@ static void on_response_trailers_received(
Utility function that takes the data from s->write_slice_buffer and assembles
into a contiguous byte stream with 5 byte gRPC header prepended.
*/
-static void create_grpc_frame(grpc_exec_ctx *exec_ctx,
- grpc_slice_buffer *write_slice_buffer,
- char **pp_write_buffer,
- size_t *p_write_buffer_size, uint32_t flags) {
+static void create_grpc_frame(grpc_exec_ctx* exec_ctx,
+ grpc_slice_buffer* write_slice_buffer,
+ char** pp_write_buffer,
+ size_t* p_write_buffer_size, uint32_t flags) {
grpc_slice slice = grpc_slice_buffer_take_first(write_slice_buffer);
size_t length = GRPC_SLICE_LENGTH(slice);
*p_write_buffer_size = length + GRPC_HEADER_SIZE_IN_BYTES;
/* This is freed in the on_write_completed callback */
- char *write_buffer = (char *)gpr_malloc(length + GRPC_HEADER_SIZE_IN_BYTES);
+ char* write_buffer = (char*)gpr_malloc(length + GRPC_HEADER_SIZE_IN_BYTES);
*pp_write_buffer = write_buffer;
- uint8_t *p = (uint8_t *)write_buffer;
+ uint8_t* p = (uint8_t*)write_buffer;
/* Append 5 byte header */
/* Compressed flag */
*p++ = (uint8_t)((flags & GRPC_WRITE_INTERNAL_COMPRESS) ? 1 : 0);
@@ -707,10 +707,10 @@ static void create_grpc_frame(grpc_exec_ctx *exec_ctx,
Convert metadata in a format that Cronet can consume
*/
static void convert_metadata_to_cronet_headers(
- grpc_linked_mdelem *head, const char *host, char **pp_url,
- bidirectional_stream_header **pp_headers, size_t *p_num_headers,
- const char **method) {
- grpc_linked_mdelem *curr = head;
+ grpc_linked_mdelem* head, const char* host, char** pp_url,
+ bidirectional_stream_header** pp_headers, size_t* p_num_headers,
+ const char** method) {
+ grpc_linked_mdelem* curr = head;
/* Walk the linked list and get number of header fields */
size_t num_headers_available = 0;
while (curr != NULL) {
@@ -719,8 +719,8 @@ static void convert_metadata_to_cronet_headers(
}
/* Allocate enough memory. It is freed in the on_stream_ready callback
*/
- bidirectional_stream_header *headers =
- (bidirectional_stream_header *)gpr_malloc(
+ bidirectional_stream_header* headers =
+ (bidirectional_stream_header*)gpr_malloc(
sizeof(bidirectional_stream_header) * num_headers_available);
*pp_headers = headers;
@@ -734,8 +734,8 @@ static void convert_metadata_to_cronet_headers(
while (num_headers < num_headers_available) {
grpc_mdelem mdelem = curr->md;
curr = curr->next;
- char *key = grpc_slice_to_c_string(GRPC_MDKEY(mdelem));
- char *value = grpc_slice_to_c_string(GRPC_MDVALUE(mdelem));
+ char* key = grpc_slice_to_c_string(GRPC_MDKEY(mdelem));
+ char* value = grpc_slice_to_c_string(GRPC_MDVALUE(mdelem));
if (grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_SCHEME) ||
grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_AUTHORITY)) {
/* Cronet populates these fields on its own */
@@ -772,10 +772,10 @@ static void convert_metadata_to_cronet_headers(
*p_num_headers = (size_t)num_headers;
}
-static void parse_grpc_header(const uint8_t *data, int *length,
- bool *compressed) {
+static void parse_grpc_header(const uint8_t* data, int* length,
+ bool* compressed) {
const uint8_t c = *data;
- const uint8_t *p = data + 1;
+ const uint8_t* p = data + 1;
*compressed = ((c & 0x01) == 0x01);
*length = 0;
*length |= ((uint8_t)*p++) << 24;
@@ -784,7 +784,7 @@ static void parse_grpc_header(const uint8_t *data, int *length,
*length |= ((uint8_t)*p++);
}
-static bool header_has_authority(grpc_linked_mdelem *head) {
+static bool header_has_authority(grpc_linked_mdelem* head) {
while (head != NULL) {
if (grpc_slice_eq(GRPC_MDKEY(head->md), GRPC_MDSTR_AUTHORITY)) {
return true;
@@ -798,11 +798,11 @@ static bool header_has_authority(grpc_linked_mdelem *head) {
Op Execution: Decide if one of the actions contained in the stream op can be
executed. This is the heart of the state machine.
*/
-static bool op_can_be_run(grpc_transport_stream_op_batch *curr_op,
- struct stream_obj *s, struct op_state *op_state,
+static bool op_can_be_run(grpc_transport_stream_op_batch* curr_op,
+ struct stream_obj* s, struct op_state* op_state,
enum e_op_id op_id) {
- struct op_state *stream_state = &s->state;
- grpc_cronet_transport *t = s->curr_ct;
+ struct op_state* stream_state = &s->state;
+ grpc_cronet_transport* t = s->curr_ct;
bool result = true;
/* When call is canceled, every op can be run, except under following
conditions
@@ -981,12 +981,12 @@ static bool op_can_be_run(grpc_transport_stream_op_batch *curr_op,
/*
TODO (makdharma): Break down this function in smaller chunks for readability.
*/
-static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
- struct op_and_state *oas) {
- grpc_transport_stream_op_batch *stream_op = &oas->op;
- struct stream_obj *s = oas->s;
- grpc_cronet_transport *t = (grpc_cronet_transport *)s->curr_ct;
- struct op_state *stream_state = &s->state;
+static enum e_op_result execute_stream_op(grpc_exec_ctx* exec_ctx,
+ struct op_and_state* oas) {
+ grpc_transport_stream_op_batch* stream_op = &oas->op;
+ struct stream_obj* s = oas->s;
+ grpc_cronet_transport* t = (grpc_cronet_transport*)s->curr_ct;
+ struct op_state* stream_state = &s->state;
enum e_op_result result = NO_ACTION_POSSIBLE;
if (stream_op->send_initial_metadata &&
op_can_be_run(stream_op, s, &oas->state, OP_SEND_INITIAL_METADATA)) {
@@ -1002,8 +1002,8 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
bidirectional_stream_disable_auto_flush(s->cbs, true);
bidirectional_stream_delay_request_headers_until_flush(s->cbs, true);
}
- char *url = NULL;
- const char *method = "POST";
+ char* url = NULL;
+ const char* method = "POST";
s->header_array.headers = NULL;
convert_metadata_to_cronet_headers(stream_op->payload->send_initial_metadata
.send_initial_metadata->list.head,
@@ -1018,8 +1018,8 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
unsigned int header_index;
for (header_index = 0; header_index < s->header_array.count;
header_index++) {
- gpr_free((void *)s->header_array.headers[header_index].key);
- gpr_free((void *)s->header_array.headers[header_index].value);
+ gpr_free((void*)s->header_array.headers[header_index].key);
+ gpr_free((void*)s->header_array.headers[header_index].value);
}
stream_state->state_op_done[OP_SEND_INITIAL_METADATA] = true;
if (t->use_packet_coalescing) {
@@ -1177,14 +1177,14 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
stream_state->rs.remaining_bytes == 0) {
/* Start a read operation for data */
stream_state->rs.length_field_received = true;
- parse_grpc_header((const uint8_t *)stream_state->rs.read_buffer,
+ parse_grpc_header((const uint8_t*)stream_state->rs.read_buffer,
&stream_state->rs.length_field,
&stream_state->rs.compressed);
CRONET_LOG(GPR_DEBUG, "length field = %d",
stream_state->rs.length_field);
if (stream_state->rs.length_field > 0) {
stream_state->rs.read_buffer =
- (char *)gpr_malloc((size_t)stream_state->rs.length_field);
+ (char*)gpr_malloc((size_t)stream_state->rs.length_field);
GPR_ASSERT(stream_state->rs.read_buffer);
stream_state->rs.remaining_bytes = stream_state->rs.length_field;
stream_state->rs.received_bytes = 0;
@@ -1207,9 +1207,8 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
if (stream_state->rs.compressed) {
stream_state->rs.sbs.base.flags |= GRPC_WRITE_INTERNAL_COMPRESS;
}
- *((grpc_byte_buffer **)
- stream_op->payload->recv_message.recv_message) =
- (grpc_byte_buffer *)&stream_state->rs.sbs;
+ *((grpc_byte_buffer**)stream_op->payload->recv_message.recv_message) =
+ (grpc_byte_buffer*)&stream_state->rs.sbs;
GRPC_CLOSURE_SCHED(
exec_ctx, stream_op->payload->recv_message.recv_message_ready,
GRPC_ERROR_NONE);
@@ -1250,7 +1249,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
CRONET_LOG(GPR_DEBUG, "read operation complete");
grpc_slice read_data_slice =
GRPC_SLICE_MALLOC((uint32_t)stream_state->rs.length_field);
- uint8_t *dst_p = GRPC_SLICE_START_PTR(read_data_slice);
+ uint8_t* dst_p = GRPC_SLICE_START_PTR(read_data_slice);
memcpy(dst_p, stream_state->rs.read_buffer,
(size_t)stream_state->rs.length_field);
null_and_maybe_free_read_buffer(s);
@@ -1265,8 +1264,8 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
if (stream_state->rs.compressed) {
stream_state->rs.sbs.base.flags = GRPC_WRITE_INTERNAL_COMPRESS;
}
- *((grpc_byte_buffer **)stream_op->payload->recv_message.recv_message) =
- (grpc_byte_buffer *)&stream_state->rs.sbs;
+ *((grpc_byte_buffer**)stream_op->payload->recv_message.recv_message) =
+ (grpc_byte_buffer*)&stream_state->rs.sbs;
GRPC_CLOSURE_SCHED(exec_ctx,
stream_op->payload->recv_message.recv_message_ready,
GRPC_ERROR_NONE);
@@ -1351,10 +1350,10 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
Functions used by upper layers to access transport functionality.
*/
-static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs, grpc_stream_refcount *refcount,
- const void *server_data, gpr_arena *arena) {
- stream_obj *s = (stream_obj *)gs;
+static int init_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
+ grpc_stream* gs, grpc_stream_refcount* refcount,
+ const void* server_data, gpr_arena* arena) {
+ stream_obj* s = (stream_obj*)gs;
s->refcount = refcount;
GRPC_CRONET_STREAM_REF(s, "cronet transport");
@@ -1377,23 +1376,23 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
s->state.pending_read_from_cronet = false;
s->curr_gs = gs;
- s->curr_ct = (grpc_cronet_transport *)gt;
+ s->curr_ct = (grpc_cronet_transport*)gt;
s->arena = arena;
gpr_mu_init(&s->mu);
return 0;
}
-static void set_pollset_do_nothing(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs, grpc_pollset *pollset) {}
+static void set_pollset_do_nothing(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
+ grpc_stream* gs, grpc_pollset* pollset) {}
-static void set_pollset_set_do_nothing(grpc_exec_ctx *exec_ctx,
- grpc_transport *gt, grpc_stream *gs,
- grpc_pollset_set *pollset_set) {}
+static void set_pollset_set_do_nothing(grpc_exec_ctx* exec_ctx,
+ grpc_transport* gt, grpc_stream* gs,
+ grpc_pollset_set* pollset_set) {}
-static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs,
- grpc_transport_stream_op_batch *op) {
+static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
+ grpc_stream* gs,
+ grpc_transport_stream_op_batch* op) {
CRONET_LOG(GPR_DEBUG, "perform_stream_op");
if (op->send_initial_metadata &&
header_has_authority(op->payload->send_initial_metadata
@@ -1413,15 +1412,15 @@ static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
GRPC_CLOSURE_SCHED(exec_ctx, op->on_complete, GRPC_ERROR_CANCELLED);
return;
}
- stream_obj *s = (stream_obj *)gs;
+ stream_obj* s = (stream_obj*)gs;
add_to_storage(s, op);
execute_from_storage(exec_ctx, s);
}
-static void destroy_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs,
- grpc_closure *then_schedule_closure) {
- stream_obj *s = (stream_obj *)gs;
+static void destroy_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
+ grpc_stream* gs,
+ grpc_closure* then_schedule_closure) {
+ stream_obj* s = (stream_obj*)gs;
null_and_maybe_free_read_buffer(s);
/* Clean up read_slice_buffer in case there is unread data. */
grpc_slice_buffer_destroy_internal(exec_ctx, &s->state.rs.read_slice_buffer);
@@ -1429,15 +1428,15 @@ static void destroy_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
GRPC_CLOSURE_SCHED(exec_ctx, then_schedule_closure, GRPC_ERROR_NONE);
}
-static void destroy_transport(grpc_exec_ctx *exec_ctx, grpc_transport *gt) {}
+static void destroy_transport(grpc_exec_ctx* exec_ctx, grpc_transport* gt) {}
-static grpc_endpoint *get_endpoint(grpc_exec_ctx *exec_ctx,
- grpc_transport *gt) {
+static grpc_endpoint* get_endpoint(grpc_exec_ctx* exec_ctx,
+ grpc_transport* gt) {
return NULL;
}
-static void perform_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_transport_op *op) {}
+static void perform_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
+ grpc_transport_op* op) {}
static const grpc_transport_vtable grpc_cronet_vtable = {
sizeof(stream_obj),
@@ -1451,17 +1450,17 @@ static const grpc_transport_vtable grpc_cronet_vtable = {
destroy_transport,
get_endpoint};
-grpc_transport *grpc_create_cronet_transport(void *engine, const char *target,
- const grpc_channel_args *args,
- void *reserved) {
- grpc_cronet_transport *ct =
- (grpc_cronet_transport *)gpr_malloc(sizeof(grpc_cronet_transport));
+grpc_transport* grpc_create_cronet_transport(void* engine, const char* target,
+ const grpc_channel_args* args,
+ void* reserved) {
+ grpc_cronet_transport* ct =
+ (grpc_cronet_transport*)gpr_malloc(sizeof(grpc_cronet_transport));
if (!ct) {
goto error;
}
ct->base.vtable = &grpc_cronet_vtable;
- ct->engine = (stream_engine *)engine;
- ct->host = (char *)gpr_malloc(strlen(target) + 1);
+ ct->engine = (stream_engine*)engine;
+ ct->host = (char*)gpr_malloc(strlen(target) + 1);
if (!ct->host) {
goto error;
}
diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.h b/src/core/ext/transport/cronet/transport/cronet_transport.h
index 43ff391f79..7643fdb585 100644
--- a/src/core/ext/transport/cronet/transport/cronet_transport.h
+++ b/src/core/ext/transport/cronet/transport/cronet_transport.h
@@ -25,9 +25,9 @@
extern "C" {
#endif
-grpc_transport *grpc_create_cronet_transport(void *engine, const char *target,
- const grpc_channel_args *args,
- void *reserved);
+grpc_transport* grpc_create_cronet_transport(void* engine, const char* target,
+ const grpc_channel_args* args,
+ void* reserved);
#ifdef __cplusplus
}
diff --git a/src/core/ext/transport/inproc/inproc_transport.cc b/src/core/ext/transport/inproc/inproc_transport.cc
index 9d0feea6fe..baefabe1b3 100644
--- a/src/core/ext/transport/inproc/inproc_transport.cc
+++ b/src/core/ext/transport/inproc/inproc_transport.cc
@@ -32,8 +32,8 @@
#include "src/core/lib/transport/error_utils.h"
#include "src/core/lib/transport/transport_impl.h"
-#define INPROC_LOG(...) \
- do { \
+#define INPROC_LOG(...) \
+ do { \
if (grpc_inproc_trace.enabled()) gpr_log(__VA_ARGS__); \
} while (0)
@@ -50,20 +50,20 @@ typedef struct {
typedef struct inproc_transport {
grpc_transport base;
- shared_mu *mu;
+ shared_mu* mu;
gpr_refcount refs;
bool is_client;
grpc_connectivity_state_tracker connectivity;
- void (*accept_stream_cb)(grpc_exec_ctx *exec_ctx, void *user_data,
- grpc_transport *transport, const void *server_data);
- void *accept_stream_data;
+ void (*accept_stream_cb)(grpc_exec_ctx* exec_ctx, void* user_data,
+ grpc_transport* transport, const void* server_data);
+ void* accept_stream_data;
bool is_closed;
- struct inproc_transport *other_side;
- struct inproc_stream *stream_list;
+ struct inproc_transport* other_side;
+ struct inproc_stream* stream_list;
} inproc_transport;
typedef struct inproc_stream {
- inproc_transport *t;
+ inproc_transport* t;
grpc_metadata_batch to_read_initial_md;
uint32_t to_read_initial_md_flags;
bool to_read_initial_md_filled;
@@ -80,21 +80,21 @@ typedef struct inproc_stream {
grpc_millis write_buffer_deadline;
grpc_metadata_batch write_buffer_trailing_md;
bool write_buffer_trailing_md_filled;
- grpc_error *write_buffer_cancel_error;
+ grpc_error* write_buffer_cancel_error;
- struct inproc_stream *other_side;
+ struct inproc_stream* other_side;
bool other_side_closed; // won't talk anymore
bool write_buffer_other_side_closed; // on hold
- grpc_stream_refcount *refs;
- grpc_closure *closure_at_destroy;
+ grpc_stream_refcount* refs;
+ grpc_closure* closure_at_destroy;
- gpr_arena *arena;
+ gpr_arena* arena;
- grpc_transport_stream_op_batch *send_message_op;
- grpc_transport_stream_op_batch *send_trailing_md_op;
- grpc_transport_stream_op_batch *recv_initial_md_op;
- grpc_transport_stream_op_batch *recv_message_op;
- grpc_transport_stream_op_batch *recv_trailing_md_op;
+ grpc_transport_stream_op_batch* send_message_op;
+ grpc_transport_stream_op_batch* send_trailing_md_op;
+ grpc_transport_stream_op_batch* recv_initial_md_op;
+ grpc_transport_stream_op_batch* recv_message_op;
+ grpc_transport_stream_op_batch* recv_trailing_md_op;
grpc_slice_buffer recv_message;
grpc_slice_buffer_stream recv_stream;
@@ -107,29 +107,29 @@ typedef struct inproc_stream {
bool closed;
- grpc_error *cancel_self_error;
- grpc_error *cancel_other_error;
+ grpc_error* cancel_self_error;
+ grpc_error* cancel_other_error;
grpc_millis deadline;
bool listed;
- struct inproc_stream *stream_list_prev;
- struct inproc_stream *stream_list_next;
+ struct inproc_stream* stream_list_prev;
+ struct inproc_stream* stream_list_next;
} inproc_stream;
static grpc_closure do_nothing_closure;
-static bool cancel_stream_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s,
- grpc_error *error);
-static void op_state_machine(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error);
+static bool cancel_stream_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
+ grpc_error* error);
+static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_error* error);
-static void ref_transport(inproc_transport *t) {
+static void ref_transport(inproc_transport* t) {
INPROC_LOG(GPR_DEBUG, "ref_transport %p", t);
gpr_ref(&t->refs);
}
-static void really_destroy_transport(grpc_exec_ctx *exec_ctx,
- inproc_transport *t) {
+static void really_destroy_transport(grpc_exec_ctx* exec_ctx,
+ inproc_transport* t) {
INPROC_LOG(GPR_DEBUG, "really_destroy_transport %p", t);
grpc_connectivity_state_destroy(exec_ctx, &t->connectivity);
if (gpr_unref(&t->mu->refs)) {
@@ -138,7 +138,7 @@ static void really_destroy_transport(grpc_exec_ctx *exec_ctx,
gpr_free(t);
}
-static void unref_transport(grpc_exec_ctx *exec_ctx, inproc_transport *t) {
+static void unref_transport(grpc_exec_ctx* exec_ctx, inproc_transport* t) {
INPROC_LOG(GPR_DEBUG, "unref_transport %p", t);
if (gpr_unref(&t->refs)) {
really_destroy_transport(exec_ctx, t);
@@ -153,18 +153,18 @@ static void unref_transport(grpc_exec_ctx *exec_ctx, inproc_transport *t) {
#define STREAM_UNREF(e, refs, reason) grpc_stream_unref(e, refs)
#endif
-static void ref_stream(inproc_stream *s, const char *reason) {
+static void ref_stream(inproc_stream* s, const char* reason) {
INPROC_LOG(GPR_DEBUG, "ref_stream %p %s", s, reason);
STREAM_REF(s->refs, reason);
}
-static void unref_stream(grpc_exec_ctx *exec_ctx, inproc_stream *s,
- const char *reason) {
+static void unref_stream(grpc_exec_ctx* exec_ctx, inproc_stream* s,
+ const char* reason) {
INPROC_LOG(GPR_DEBUG, "unref_stream %p %s", s, reason);
STREAM_UNREF(exec_ctx, s->refs, reason);
}
-static void really_destroy_stream(grpc_exec_ctx *exec_ctx, inproc_stream *s) {
+static void really_destroy_stream(grpc_exec_ctx* exec_ctx, inproc_stream* s) {
INPROC_LOG(GPR_DEBUG, "really_destroy_stream %p", s);
GRPC_ERROR_UNREF(s->write_buffer_cancel_error);
@@ -182,12 +182,12 @@ static void really_destroy_stream(grpc_exec_ctx *exec_ctx, inproc_stream *s) {
}
}
-static void log_metadata(const grpc_metadata_batch *md_batch, bool is_client,
+static void log_metadata(const grpc_metadata_batch* md_batch, bool is_client,
bool is_initial) {
- for (grpc_linked_mdelem *md = md_batch->list.head; md != NULL;
+ for (grpc_linked_mdelem* md = md_batch->list.head; md != NULL;
md = md->next) {
- char *key = grpc_slice_to_c_string(GRPC_MDKEY(md->md));
- char *value = grpc_slice_to_c_string(GRPC_MDVALUE(md->md));
+ char* key = grpc_slice_to_c_string(GRPC_MDKEY(md->md));
+ char* value = grpc_slice_to_c_string(GRPC_MDVALUE(md->md));
gpr_log(GPR_INFO, "INPROC:%s:%s: %s: %s", is_initial ? "HDR" : "TRL",
is_client ? "CLI" : "SVR", key, value);
gpr_free(key);
@@ -195,10 +195,10 @@ static void log_metadata(const grpc_metadata_batch *md_batch, bool is_client,
}
}
-static grpc_error *fill_in_metadata(grpc_exec_ctx *exec_ctx, inproc_stream *s,
- const grpc_metadata_batch *metadata,
- uint32_t flags, grpc_metadata_batch *out_md,
- uint32_t *outflags, bool *markfilled) {
+static grpc_error* fill_in_metadata(grpc_exec_ctx* exec_ctx, inproc_stream* s,
+ const grpc_metadata_batch* metadata,
+ uint32_t flags, grpc_metadata_batch* out_md,
+ uint32_t* outflags, bool* markfilled) {
if (grpc_inproc_trace.enabled()) {
log_metadata(metadata, s->t->is_client, outflags != NULL);
}
@@ -209,11 +209,11 @@ static grpc_error *fill_in_metadata(grpc_exec_ctx *exec_ctx, inproc_stream *s,
if (markfilled != NULL) {
*markfilled = true;
}
- grpc_error *error = GRPC_ERROR_NONE;
- for (grpc_linked_mdelem *elem = metadata->list.head;
+ grpc_error* error = GRPC_ERROR_NONE;
+ for (grpc_linked_mdelem* elem = metadata->list.head;
(elem != NULL) && (error == GRPC_ERROR_NONE); elem = elem->next) {
- grpc_linked_mdelem *nelem =
- (grpc_linked_mdelem *)gpr_arena_alloc(s->arena, sizeof(*nelem));
+ grpc_linked_mdelem* nelem =
+ (grpc_linked_mdelem*)gpr_arena_alloc(s->arena, sizeof(*nelem));
nelem->md = grpc_mdelem_from_slices(
exec_ctx, grpc_slice_intern(GRPC_MDKEY(elem->md)),
grpc_slice_intern(GRPC_MDVALUE(elem->md)));
@@ -223,12 +223,12 @@ static grpc_error *fill_in_metadata(grpc_exec_ctx *exec_ctx, inproc_stream *s,
return error;
}
-static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs, grpc_stream_refcount *refcount,
- const void *server_data, gpr_arena *arena) {
+static int init_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
+ grpc_stream* gs, grpc_stream_refcount* refcount,
+ const void* server_data, gpr_arena* arena) {
INPROC_LOG(GPR_DEBUG, "init_stream %p %p %p", gt, gs, server_data);
- inproc_transport *t = (inproc_transport *)gt;
- inproc_stream *s = (inproc_stream *)gs;
+ inproc_transport* t = (inproc_transport*)gt;
+ inproc_stream* s = (inproc_stream*)gs;
s->arena = arena;
s->refs = refcount;
@@ -277,7 +277,7 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
if (!server_data) {
ref_transport(t);
- inproc_transport *st = t->other_side;
+ inproc_transport* st = t->other_side;
ref_transport(st);
s->other_side = NULL; // will get filled in soon
// Pass the client-side stream address to the server-side for a ref
@@ -286,10 +286,10 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
INPROC_LOG(GPR_DEBUG, "calling accept stream cb %p %p",
st->accept_stream_cb, st->accept_stream_data);
(*st->accept_stream_cb)(exec_ctx, st->accept_stream_data, &st->base,
- (void *)s);
+ (void*)s);
} else {
// This is the server-side and is being called through accept_stream_cb
- inproc_stream *cs = (inproc_stream *)server_data;
+ inproc_stream* cs = (inproc_stream*)server_data;
s->other_side = cs;
// Ref the server-side stream on behalf of the client now
ref_stream(s, "inproc_init_stream:srv");
@@ -326,15 +326,15 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
return 0; // return value is not important
}
-static void close_stream_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s) {
+static void close_stream_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s) {
if (!s->closed) {
// Release the metadata that we would have written out
grpc_metadata_batch_destroy(exec_ctx, &s->write_buffer_initial_md);
grpc_metadata_batch_destroy(exec_ctx, &s->write_buffer_trailing_md);
if (s->listed) {
- inproc_stream *p = s->stream_list_prev;
- inproc_stream *n = s->stream_list_next;
+ inproc_stream* p = s->stream_list_prev;
+ inproc_stream* n = s->stream_list_next;
if (p != NULL) {
p->stream_list_next = n;
} else {
@@ -352,8 +352,8 @@ static void close_stream_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s) {
}
// This function means that we are done talking/listening to the other side
-static void close_other_side_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s,
- const char *reason) {
+static void close_other_side_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
+ const char* reason) {
if (s->other_side != NULL) {
// First release the metadata that came from the other side's arena
grpc_metadata_batch_destroy(exec_ctx, &s->to_read_initial_md);
@@ -371,10 +371,10 @@ static void close_other_side_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s,
// this stream_op_batch is only one of the pending operations for this
// stream. This is called when one of the pending operations for the stream
// is done and about to be NULLed out
-static void complete_if_batch_end_locked(grpc_exec_ctx *exec_ctx,
- inproc_stream *s, grpc_error *error,
- grpc_transport_stream_op_batch *op,
- const char *msg) {
+static void complete_if_batch_end_locked(grpc_exec_ctx* exec_ctx,
+ inproc_stream* s, grpc_error* error,
+ grpc_transport_stream_op_batch* op,
+ const char* msg) {
int is_sm = (int)(op == s->send_message_op);
int is_stm = (int)(op == s->send_trailing_md_op);
int is_rim = (int)(op == s->recv_initial_md_op);
@@ -387,9 +387,9 @@ static void complete_if_batch_end_locked(grpc_exec_ctx *exec_ctx,
}
}
-static void maybe_schedule_op_closure_locked(grpc_exec_ctx *exec_ctx,
- inproc_stream *s,
- grpc_error *error) {
+static void maybe_schedule_op_closure_locked(grpc_exec_ctx* exec_ctx,
+ inproc_stream* s,
+ grpc_error* error) {
if (s && s->ops_needed && !s->op_closure_scheduled) {
GRPC_CLOSURE_SCHED(exec_ctx, &s->op_closure, GRPC_ERROR_REF(error));
s->op_closure_scheduled = true;
@@ -397,8 +397,8 @@ static void maybe_schedule_op_closure_locked(grpc_exec_ctx *exec_ctx,
}
}
-static void fail_helper_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s,
- grpc_error *error) {
+static void fail_helper_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
+ grpc_error* error) {
INPROC_LOG(GPR_DEBUG, "op_state_machine %p fail_helper", s);
// If we're failing this side, we need to make sure that
// we also send or have already sent trailing metadata
@@ -409,10 +409,10 @@ static void fail_helper_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s,
grpc_metadata_batch fake_md;
grpc_metadata_batch_init(&fake_md);
- inproc_stream *other = s->other_side;
- grpc_metadata_batch *dest = (other == NULL) ? &s->write_buffer_trailing_md
+ inproc_stream* other = s->other_side;
+ grpc_metadata_batch* dest = (other == NULL) ? &s->write_buffer_trailing_md
: &other->to_read_trailing_md;
- bool *destfilled = (other == NULL) ? &s->write_buffer_trailing_md_filled
+ bool* destfilled = (other == NULL) ? &s->write_buffer_trailing_md_filled
: &other->to_read_trailing_md_filled;
fill_in_metadata(exec_ctx, s, &fake_md, 0, dest, NULL, destfilled);
grpc_metadata_batch_destroy(exec_ctx, &fake_md);
@@ -427,20 +427,20 @@ static void fail_helper_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s,
}
}
if (s->recv_initial_md_op) {
- grpc_error *err;
+ grpc_error* err;
if (!s->t->is_client) {
// If this is a server, provide initial metadata with a path and authority
// since it expects that as well as no error yet
grpc_metadata_batch fake_md;
grpc_metadata_batch_init(&fake_md);
- grpc_linked_mdelem *path_md =
- (grpc_linked_mdelem *)gpr_arena_alloc(s->arena, sizeof(*path_md));
+ grpc_linked_mdelem* path_md =
+ (grpc_linked_mdelem*)gpr_arena_alloc(s->arena, sizeof(*path_md));
path_md->md =
grpc_mdelem_from_slices(exec_ctx, g_fake_path_key, g_fake_path_value);
GPR_ASSERT(grpc_metadata_batch_link_tail(exec_ctx, &fake_md, path_md) ==
GRPC_ERROR_NONE);
- grpc_linked_mdelem *auth_md =
- (grpc_linked_mdelem *)gpr_arena_alloc(s->arena, sizeof(*auth_md));
+ grpc_linked_mdelem* auth_md =
+ (grpc_linked_mdelem*)gpr_arena_alloc(s->arena, sizeof(*auth_md));
auth_md->md =
grpc_mdelem_from_slices(exec_ctx, g_fake_auth_key, g_fake_auth_value);
GPR_ASSERT(grpc_metadata_batch_link_tail(exec_ctx, &fake_md, auth_md) ==
@@ -509,9 +509,9 @@ static void fail_helper_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s,
GRPC_ERROR_UNREF(error);
}
-static void message_transfer_locked(grpc_exec_ctx *exec_ctx,
- inproc_stream *sender,
- inproc_stream *receiver) {
+static void message_transfer_locked(grpc_exec_ctx* exec_ctx,
+ inproc_stream* sender,
+ inproc_stream* receiver) {
size_t remaining =
sender->send_message_op->payload->send_message.send_message->length;
if (receiver->recv_inited) {
@@ -525,7 +525,7 @@ static void message_transfer_locked(grpc_exec_ctx *exec_ctx,
GPR_ASSERT(grpc_byte_stream_next(
exec_ctx, sender->send_message_op->payload->send_message.send_message,
SIZE_MAX, &unused));
- grpc_error *error = grpc_byte_stream_pull(
+ grpc_error* error = grpc_byte_stream_pull(
exec_ctx, sender->send_message_op->payload->send_message.send_message,
&message_slice);
if (error != GRPC_ERROR_NONE) {
@@ -558,8 +558,8 @@ static void message_transfer_locked(grpc_exec_ctx *exec_ctx,
sender->send_message_op = NULL;
}
-static void op_state_machine(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
+static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_error* error) {
// This function gets called when we have contents in the unprocessed reads
// Get what we want based on our ops wanted
// Schedule our appropriate closures
@@ -567,17 +567,17 @@ static void op_state_machine(grpc_exec_ctx *exec_ctx, void *arg,
// Since this is a closure directly invoked by the combiner, it should not
// unref the error parameter explicitly; the combiner will do that implicitly
- grpc_error *new_err = GRPC_ERROR_NONE;
+ grpc_error* new_err = GRPC_ERROR_NONE;
bool needs_close = false;
INPROC_LOG(GPR_DEBUG, "op_state_machine %p", arg);
- inproc_stream *s = (inproc_stream *)arg;
- gpr_mu *mu = &s->t->mu->mu; // keep aside in case s gets closed
+ inproc_stream* s = (inproc_stream*)arg;
+ gpr_mu* mu = &s->t->mu->mu; // keep aside in case s gets closed
gpr_mu_lock(mu);
s->op_closure_scheduled = false;
// cancellation takes precedence
- inproc_stream *other = s->other_side;
+ inproc_stream* other = s->other_side;
if (s->cancel_self_error != GRPC_ERROR_NONE) {
fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(s->cancel_self_error));
@@ -612,9 +612,9 @@ static void op_state_machine(grpc_exec_ctx *exec_ctx, void *arg,
(!s->send_message_op ||
(s->t->is_client &&
(s->trailing_md_recvd || s->to_read_trailing_md_filled)))) {
- grpc_metadata_batch *dest = (other == NULL) ? &s->write_buffer_trailing_md
+ grpc_metadata_batch* dest = (other == NULL) ? &s->write_buffer_trailing_md
: &other->to_read_trailing_md;
- bool *destfilled = (other == NULL) ? &s->write_buffer_trailing_md_filled
+ bool* destfilled = (other == NULL) ? &s->write_buffer_trailing_md_filled
: &other->to_read_trailing_md_filled;
if (*destfilled || s->trailing_md_sent) {
// The buffer is already in use; that's an error!
@@ -810,8 +810,8 @@ done:
GRPC_ERROR_UNREF(new_err);
}
-static bool cancel_stream_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s,
- grpc_error *error) {
+static bool cancel_stream_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
+ grpc_error* error) {
bool ret = false; // was the cancel accepted
INPROC_LOG(GPR_DEBUG, "cancel_stream %p with %s", s,
grpc_error_string(error));
@@ -826,10 +826,10 @@ static bool cancel_stream_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s,
grpc_metadata_batch cancel_md;
grpc_metadata_batch_init(&cancel_md);
- inproc_stream *other = s->other_side;
- grpc_metadata_batch *dest = (other == NULL) ? &s->write_buffer_trailing_md
+ inproc_stream* other = s->other_side;
+ grpc_metadata_batch* dest = (other == NULL) ? &s->write_buffer_trailing_md
: &other->to_read_trailing_md;
- bool *destfilled = (other == NULL) ? &s->write_buffer_trailing_md_filled
+ bool* destfilled = (other == NULL) ? &s->write_buffer_trailing_md_filled
: &other->to_read_trailing_md_filled;
fill_in_metadata(exec_ctx, s, &cancel_md, 0, dest, NULL, destfilled);
grpc_metadata_batch_destroy(exec_ctx, &cancel_md);
@@ -862,12 +862,12 @@ static bool cancel_stream_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s,
return ret;
}
-static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs,
- grpc_transport_stream_op_batch *op) {
+static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
+ grpc_stream* gs,
+ grpc_transport_stream_op_batch* op) {
INPROC_LOG(GPR_DEBUG, "perform_stream_op %p %p %p", gt, gs, op);
- inproc_stream *s = (inproc_stream *)gs;
- gpr_mu *mu = &s->t->mu->mu; // save aside in case s gets closed
+ inproc_stream* s = (inproc_stream*)gs;
+ gpr_mu* mu = &s->t->mu->mu; // save aside in case s gets closed
gpr_mu_lock(mu);
if (grpc_inproc_trace.enabled()) {
@@ -880,8 +880,8 @@ static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
s->t->is_client, false);
}
}
- grpc_error *error = GRPC_ERROR_NONE;
- grpc_closure *on_complete = op->on_complete;
+ grpc_error* error = GRPC_ERROR_NONE;
+ grpc_closure* on_complete = op->on_complete;
if (on_complete == NULL) {
on_complete = &do_nothing_closure;
}
@@ -907,18 +907,18 @@ static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
bool needs_close = false;
- inproc_stream *other = s->other_side;
+ inproc_stream* other = s->other_side;
if (error == GRPC_ERROR_NONE &&
(op->send_initial_metadata || op->send_trailing_metadata)) {
if (s->t->is_closed) {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Endpoint already shutdown");
}
if (error == GRPC_ERROR_NONE && op->send_initial_metadata) {
- grpc_metadata_batch *dest = (other == NULL) ? &s->write_buffer_initial_md
+ grpc_metadata_batch* dest = (other == NULL) ? &s->write_buffer_initial_md
: &other->to_read_initial_md;
- uint32_t *destflags = (other == NULL) ? &s->write_buffer_initial_md_flags
+ uint32_t* destflags = (other == NULL) ? &s->write_buffer_initial_md_flags
: &other->to_read_initial_md_flags;
- bool *destfilled = (other == NULL) ? &s->write_buffer_initial_md_filled
+ bool* destfilled = (other == NULL) ? &s->write_buffer_initial_md_filled
: &other->to_read_initial_md_filled;
if (*destfilled || s->initial_md_sent) {
// The buffer is already in use; that's an error!
@@ -933,7 +933,7 @@ static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
dest, destflags, destfilled);
}
if (s->t->is_client) {
- grpc_millis *dl =
+ grpc_millis* dl =
(other == NULL) ? &s->write_buffer_deadline : &other->deadline;
*dl = GPR_MIN(*dl, op->payload->send_initial_metadata
.send_initial_metadata->deadline);
@@ -972,8 +972,9 @@ static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
// 4. We want to receive a message and there is a message ready
// 5. There is trailing metadata, even if nothing specifically wants
// that because that can shut down the receive message as well
- if ((op->send_message && other && ((other->recv_message_op != NULL) ||
- (other->recv_trailing_md_op != NULL))) ||
+ if ((op->send_message && other &&
+ ((other->recv_message_op != NULL) ||
+ (other->recv_trailing_md_op != NULL))) ||
(op->send_trailing_metadata && !op->send_message) ||
(op->recv_initial_metadata && s->to_read_initial_md_filled) ||
(op->recv_message && other && (other->send_message_op != NULL)) ||
@@ -1020,8 +1021,8 @@ static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
GRPC_ERROR_UNREF(error);
}
-static void close_transport_locked(grpc_exec_ctx *exec_ctx,
- inproc_transport *t) {
+static void close_transport_locked(grpc_exec_ctx* exec_ctx,
+ inproc_transport* t) {
INPROC_LOG(GPR_DEBUG, "close_transport %p %d", t, t->is_closed);
grpc_connectivity_state_set(
exec_ctx, &t->connectivity, GRPC_CHANNEL_SHUTDOWN,
@@ -1041,9 +1042,9 @@ static void close_transport_locked(grpc_exec_ctx *exec_ctx,
}
}
-static void perform_transport_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_transport_op *op) {
- inproc_transport *t = (inproc_transport *)gt;
+static void perform_transport_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
+ grpc_transport_op* op) {
+ inproc_transport* t = (inproc_transport*)gt;
INPROC_LOG(GPR_DEBUG, "perform_transport_op %p %p", t, op);
gpr_mu_lock(&t->mu->mu);
if (op->on_connectivity_state_change) {
@@ -1075,17 +1076,17 @@ static void perform_transport_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
gpr_mu_unlock(&t->mu->mu);
}
-static void destroy_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs,
- grpc_closure *then_schedule_closure) {
+static void destroy_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
+ grpc_stream* gs,
+ grpc_closure* then_schedule_closure) {
INPROC_LOG(GPR_DEBUG, "destroy_stream %p %p", gs, then_schedule_closure);
- inproc_stream *s = (inproc_stream *)gs;
+ inproc_stream* s = (inproc_stream*)gs;
s->closure_at_destroy = then_schedule_closure;
really_destroy_stream(exec_ctx, s);
}
-static void destroy_transport(grpc_exec_ctx *exec_ctx, grpc_transport *gt) {
- inproc_transport *t = (inproc_transport *)gt;
+static void destroy_transport(grpc_exec_ctx* exec_ctx, grpc_transport* gt) {
+ inproc_transport* t = (inproc_transport*)gt;
INPROC_LOG(GPR_DEBUG, "destroy_transport %p", t);
gpr_mu_lock(&t->mu->mu);
close_transport_locked(exec_ctx, t);
@@ -1098,24 +1099,24 @@ static void destroy_transport(grpc_exec_ctx *exec_ctx, grpc_transport *gt) {
* INTEGRATION GLUE
*/
-static void set_pollset(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs, grpc_pollset *pollset) {
+static void set_pollset(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
+ grpc_stream* gs, grpc_pollset* pollset) {
// Nothing to do here
}
-static void set_pollset_set(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs, grpc_pollset_set *pollset_set) {
+static void set_pollset_set(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
+ grpc_stream* gs, grpc_pollset_set* pollset_set) {
// Nothing to do here
}
-static grpc_endpoint *get_endpoint(grpc_exec_ctx *exec_ctx, grpc_transport *t) {
+static grpc_endpoint* get_endpoint(grpc_exec_ctx* exec_ctx, grpc_transport* t) {
return NULL;
}
/*******************************************************************************
* GLOBAL INIT AND DESTROY
*/
-static void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {}
+static void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {}
void grpc_inproc_transport_init(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
@@ -1146,16 +1147,16 @@ static const grpc_transport_vtable inproc_vtable = {
/*******************************************************************************
* Main inproc transport functions
*/
-static void inproc_transports_create(grpc_exec_ctx *exec_ctx,
- grpc_transport **server_transport,
- const grpc_channel_args *server_args,
- grpc_transport **client_transport,
- const grpc_channel_args *client_args) {
+static void inproc_transports_create(grpc_exec_ctx* exec_ctx,
+ grpc_transport** server_transport,
+ const grpc_channel_args* server_args,
+ grpc_transport** client_transport,
+ const grpc_channel_args* client_args) {
INPROC_LOG(GPR_DEBUG, "inproc_transports_create");
- inproc_transport *st = (inproc_transport *)gpr_zalloc(sizeof(*st));
- inproc_transport *ct = (inproc_transport *)gpr_zalloc(sizeof(*ct));
+ inproc_transport* st = (inproc_transport*)gpr_zalloc(sizeof(*st));
+ inproc_transport* ct = (inproc_transport*)gpr_zalloc(sizeof(*ct));
// Share one lock between both sides since both sides get affected
- st->mu = ct->mu = (shared_mu *)gpr_malloc(sizeof(*st->mu));
+ st->mu = ct->mu = (shared_mu*)gpr_malloc(sizeof(*st->mu));
gpr_mu_init(&st->mu->mu);
gpr_ref_init(&st->mu->refs, 2);
st->base.vtable = &inproc_vtable;
@@ -1174,37 +1175,37 @@ static void inproc_transports_create(grpc_exec_ctx *exec_ctx,
ct->other_side = st;
st->stream_list = NULL;
ct->stream_list = NULL;
- *server_transport = (grpc_transport *)st;
- *client_transport = (grpc_transport *)ct;
+ *server_transport = (grpc_transport*)st;
+ *client_transport = (grpc_transport*)ct;
}
-grpc_channel *grpc_inproc_channel_create(grpc_server *server,
- grpc_channel_args *args,
- void *reserved) {
+grpc_channel* grpc_inproc_channel_create(grpc_server* server,
+ grpc_channel_args* args,
+ void* reserved) {
GRPC_API_TRACE("grpc_inproc_channel_create(server=%p, args=%p)", 2,
(server, args));
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- const grpc_channel_args *server_args = grpc_server_get_channel_args(server);
+ const grpc_channel_args* server_args = grpc_server_get_channel_args(server);
// Add a default authority channel argument for the client
grpc_arg default_authority_arg;
default_authority_arg.type = GRPC_ARG_STRING;
- default_authority_arg.key = (char *)GRPC_ARG_DEFAULT_AUTHORITY;
- default_authority_arg.value.string = (char *)"inproc.authority";
- grpc_channel_args *client_args =
+ default_authority_arg.key = (char*)GRPC_ARG_DEFAULT_AUTHORITY;
+ default_authority_arg.value.string = (char*)"inproc.authority";
+ grpc_channel_args* client_args =
grpc_channel_args_copy_and_add(args, &default_authority_arg, 1);
- grpc_transport *server_transport;
- grpc_transport *client_transport;
+ grpc_transport* server_transport;
+ grpc_transport* client_transport;
inproc_transports_create(&exec_ctx, &server_transport, server_args,
&client_transport, client_args);
grpc_server_setup_transport(&exec_ctx, server, server_transport, NULL,
server_args);
- grpc_channel *channel =
+ grpc_channel* channel =
grpc_channel_create(&exec_ctx, "inproc", client_args,
GRPC_CLIENT_DIRECT_CHANNEL, client_transport);
diff --git a/src/core/ext/transport/inproc/inproc_transport.h b/src/core/ext/transport/inproc/inproc_transport.h
index 248a9dd54e..f27789a50d 100644
--- a/src/core/ext/transport/inproc/inproc_transport.h
+++ b/src/core/ext/transport/inproc/inproc_transport.h
@@ -25,9 +25,9 @@
extern "C" {
#endif
-grpc_channel *grpc_inproc_channel_create(grpc_server *server,
- grpc_channel_args *args,
- void *reserved);
+grpc_channel* grpc_inproc_channel_create(grpc_server* server,
+ grpc_channel_args* args,
+ void* reserved);
extern grpc_core::TraceFlag grpc_inproc_trace;