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/client/insecure/channel_create.cc2
-rw-r--r--src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc11
-rw-r--r--src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc2
-rw-r--r--src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc2
-rw-r--r--src/core/ext/transport/chttp2/transport/bin_decoder.cc17
-rw-r--r--src/core/ext/transport/chttp2/transport/chttp2_transport.cc13
-rw-r--r--src/core/ext/transport/chttp2/transport/parsing.cc26
-rw-r--r--src/core/ext/transport/chttp2/transport/writing.cc12
-rw-r--r--src/core/ext/transport/cronet/transport/cronet_transport.cc6
9 files changed, 48 insertions, 43 deletions
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 e6c8c38260..62ec635378 100644
--- a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc
+++ b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc
@@ -54,7 +54,7 @@ static grpc_subchannel* client_channel_factory_create_subchannel(
static grpc_channel* client_channel_factory_create_channel(
grpc_client_channel_factory* cc_factory, const char* target,
grpc_client_channel_type type, const grpc_channel_args* args) {
- if (target == nullptr) {
+ if (GPR_UNLIKELY(target == nullptr)) {
gpr_log(GPR_ERROR, "cannot create channel with NULL target name");
return nullptr;
}
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 5ce73a95d7..5928ed876c 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
@@ -50,14 +50,15 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args(
const grpc_subchannel_args* args) {
grpc_channel_credentials* channel_credentials =
grpc_channel_credentials_find_in_args(args->args);
- if (channel_credentials == nullptr) {
+ if (GPR_UNLIKELY(channel_credentials == nullptr)) {
gpr_log(GPR_ERROR,
"Can't create subchannel: channel credentials missing for secure "
"channel.");
return nullptr;
}
// Make sure security connector does not already exist in args.
- if (grpc_security_connector_find_in_args(args->args) != nullptr) {
+ if (GPR_UNLIKELY(grpc_security_connector_find_in_args(args->args) !=
+ nullptr)) {
gpr_log(GPR_ERROR,
"Can't create subchannel: security connector already present in "
"channel args.");
@@ -117,7 +118,7 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args(
grpc_channel_credentials_create_security_connector(
channel_credentials, authority.get(), args_with_authority,
&subchannel_security_connector, &new_args_from_connector);
- if (security_status != GRPC_SECURITY_OK) {
+ if (GPR_UNLIKELY(security_status != GRPC_SECURITY_OK)) {
gpr_log(GPR_ERROR,
"Failed to create secure subchannel for secure name '%s'",
authority.get());
@@ -149,7 +150,7 @@ static grpc_subchannel* client_channel_factory_create_subchannel(
grpc_client_channel_factory* cc_factory, const grpc_subchannel_args* args) {
grpc_subchannel_args* subchannel_args =
get_secure_naming_subchannel_args(args);
- if (subchannel_args == nullptr) {
+ if (GPR_UNLIKELY(subchannel_args == nullptr)) {
gpr_log(
GPR_ERROR,
"Failed to create subchannel arguments during subchannel creation.");
@@ -167,7 +168,7 @@ static grpc_subchannel* client_channel_factory_create_subchannel(
static grpc_channel* client_channel_factory_create_channel(
grpc_client_channel_factory* cc_factory, const char* target,
grpc_client_channel_type type, const grpc_channel_args* args) {
- if (target == nullptr) {
+ if (GPR_UNLIKELY(target == nullptr)) {
gpr_log(GPR_ERROR, "cannot create channel with NULL target name");
return nullptr;
}
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 99f18cdf39..b4ec88a834 100644
--- a/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc
+++ b/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc
@@ -35,7 +35,7 @@ int grpc_server_add_insecure_http2_port(grpc_server* server, const char* addr) {
grpc_error* err = grpc_chttp2_server_add_port(
server, addr,
grpc_channel_args_copy(grpc_server_get_channel_args(server)), &port_num);
- if (err != GRPC_ERROR_NONE) {
+ if (GPR_UNLIKELY(err != GRPC_ERROR_NONE)) {
const char* msg = grpc_error_string(err);
gpr_log(GPR_ERROR, "%s", msg);
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 6689a17da6..bc6b7a46f9 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
@@ -79,7 +79,7 @@ done:
GRPC_SECURITY_CONNECTOR_UNREF(&sc->base, "server");
}
- if (err != GRPC_ERROR_NONE) {
+ if (GPR_UNLIKELY(err != GRPC_ERROR_NONE)) {
const char* msg = grpc_error_string(err);
gpr_log(GPR_ERROR, "%s", msg);
diff --git a/src/core/ext/transport/chttp2/transport/bin_decoder.cc b/src/core/ext/transport/chttp2/transport/bin_decoder.cc
index f0f32da028..b660a45652 100644
--- a/src/core/ext/transport/chttp2/transport/bin_decoder.cc
+++ b/src/core/ext/transport/chttp2/transport/bin_decoder.cc
@@ -55,7 +55,7 @@ static bool input_is_valid(uint8_t* input_ptr, size_t length) {
size_t i;
for (i = 0; i < length; ++i) {
- if ((decode_table[input_ptr[i]] & 0xC0) != 0) {
+ if (GPR_UNLIKELY((decode_table[input_ptr[i]] & 0xC0) != 0)) {
gpr_log(GPR_ERROR,
"Base64 decoding failed, invalid character '%c' in base64 "
"input.\n",
@@ -86,14 +86,14 @@ size_t grpc_chttp2_base64_infer_length_after_decode(const grpc_slice& slice) {
while (len > 0 && bytes[len - 1] == '=') {
len--;
}
- if (GRPC_SLICE_LENGTH(slice) - len > 2) {
+ if (GPR_UNLIKELY(GRPC_SLICE_LENGTH(slice) - len > 2)) {
gpr_log(GPR_ERROR,
"Base64 decoding failed. Input has more than 2 paddings.");
return 0;
}
size_t tuples = len / 4;
size_t tail_case = len % 4;
- if (tail_case == 1) {
+ if (GPR_UNLIKELY(tail_case == 1)) {
gpr_log(GPR_ERROR,
"Base64 decoding failed. Input has a length of %zu (without"
" padding), which is invalid.\n",
@@ -164,7 +164,7 @@ grpc_slice grpc_chttp2_base64_decode(grpc_slice input) {
struct grpc_base64_decode_context ctx;
grpc_slice output;
- if (input_length % 4 != 0) {
+ if (GPR_UNLIKELY(input_length % 4 != 0)) {
gpr_log(GPR_ERROR,
"Base64 decoding failed, input of "
"grpc_chttp2_base64_decode has a length of %d, which is not a "
@@ -190,7 +190,7 @@ grpc_slice grpc_chttp2_base64_decode(grpc_slice input) {
ctx.output_end = GRPC_SLICE_END_PTR(output);
ctx.contains_tail = false;
- if (!grpc_base64_decode_partial(&ctx)) {
+ if (GPR_UNLIKELY(!grpc_base64_decode_partial(&ctx))) {
char* s = grpc_slice_to_c_string(input);
gpr_log(GPR_ERROR, "Base64 decoding failed, input string:\n%s\n", s);
gpr_free(s);
@@ -209,7 +209,7 @@ grpc_slice grpc_chttp2_base64_decode_with_length(grpc_slice input,
struct grpc_base64_decode_context ctx;
// The length of a base64 string cannot be 4 * n + 1
- if (input_length % 4 == 1) {
+ if (GPR_UNLIKELY(input_length % 4 == 1)) {
gpr_log(GPR_ERROR,
"Base64 decoding failed, input of "
"grpc_chttp2_base64_decode_with_length has a length of %d, which "
@@ -219,7 +219,8 @@ grpc_slice grpc_chttp2_base64_decode_with_length(grpc_slice input,
return grpc_empty_slice();
}
- if (output_length > input_length / 4 * 3 + tail_xtra[input_length % 4]) {
+ if (GPR_UNLIKELY(output_length >
+ input_length / 4 * 3 + tail_xtra[input_length % 4])) {
gpr_log(
GPR_ERROR,
"Base64 decoding failed, output_length %d is longer "
@@ -236,7 +237,7 @@ grpc_slice grpc_chttp2_base64_decode_with_length(grpc_slice input,
ctx.output_end = GRPC_SLICE_END_PTR(output);
ctx.contains_tail = true;
- if (!grpc_base64_decode_partial(&ctx)) {
+ if (GPR_UNLIKELY(!grpc_base64_decode_partial(&ctx))) {
char* s = grpc_slice_to_c_string(input);
gpr_log(GPR_ERROR, "Base64 decoding failed, input string:\n%s\n", s);
gpr_free(s);
diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc
index 0ef73961a5..ebd66d5256 100644
--- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc
+++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc
@@ -368,7 +368,7 @@ static void init_transport(grpc_chttp2_transport* t,
const int value =
grpc_channel_arg_get_integer(&channel_args->args[i], options);
if (value >= 0) {
- if ((t->next_stream_id & 1) != (value & 1)) {
+ if (GPR_UNLIKELY((t->next_stream_id & 1) != (value & 1))) {
gpr_log(GPR_ERROR, "%s: low bit must be %d on %s",
GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER,
t->next_stream_id & 1, is_client ? "client" : "server");
@@ -447,7 +447,7 @@ static void init_transport(grpc_chttp2_transport* t,
grpc_channel_arg_get_integer(&channel_args->args[i], {0, 0, 1}));
} else if (0 == strcmp(channel_args->args[i].key,
GRPC_ARG_OPTIMIZATION_TARGET)) {
- if (channel_args->args[i].type != GRPC_ARG_STRING) {
+ if (GPR_UNLIKELY(channel_args->args[i].type != GRPC_ARG_STRING)) {
gpr_log(GPR_ERROR, "%s should be a string",
GRPC_ARG_OPTIMIZATION_TARGET);
} else if (0 == strcmp(channel_args->args[i].value.string, "blend")) {
@@ -718,7 +718,7 @@ static void destroy_stream_locked(void* sp, grpc_error* error) {
grpc_chttp2_list_remove_stalled_by_stream(t, s);
for (int i = 0; i < STREAM_LIST_COUNT; i++) {
- if (s->included[i]) {
+ if (GPR_UNLIKELY(s->included[i])) {
gpr_log(GPR_ERROR, "%s stream %d still included in list %d",
t->is_client ? "client" : "server", s->id, i);
abort();
@@ -1088,8 +1088,9 @@ void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t,
* data equal to "too_many_pings", it should log the occurrence at a log level
* that is enabled by default and double the configured KEEPALIVE_TIME used
* for new connections on that channel. */
- if (t->is_client && goaway_error == GRPC_HTTP2_ENHANCE_YOUR_CALM &&
- grpc_slice_str_cmp(goaway_text, "too_many_pings") == 0) {
+ if (GPR_UNLIKELY(t->is_client &&
+ goaway_error == GRPC_HTTP2_ENHANCE_YOUR_CALM &&
+ grpc_slice_str_cmp(goaway_text, "too_many_pings") == 0)) {
gpr_log(GPR_ERROR,
"Received a GOAWAY with error code ENHANCE_YOUR_CALM and debug "
"data equal to \"too_many_pings\"");
@@ -2701,7 +2702,7 @@ static void keepalive_watchdog_fired_locked(void* arg, grpc_error* error) {
} else {
/* The watchdog timer should have been cancelled by
* finish_keepalive_ping_locked. */
- if (error != GRPC_ERROR_CANCELLED) {
+ if (GPR_UNLIKELY(error != GRPC_ERROR_CANCELLED)) {
gpr_log(GPR_ERROR, "keepalive_ping_end state error: %d (expect: %d)",
t->keepalive_state, GRPC_CHTTP2_KEEPALIVE_STATE_PINGING);
}
diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc
index a10c9ada46..1e491d2ef8 100644
--- a/src/core/ext/transport/chttp2/transport/parsing.cc
+++ b/src/core/ext/transport/chttp2/transport/parsing.cc
@@ -422,7 +422,8 @@ static void on_initial_header(void* tp, grpc_mdelem md) {
if (cached_timeout != nullptr) {
timeout = *cached_timeout;
} else {
- if (!grpc_http2_decode_timeout(GRPC_MDVALUE(md), &timeout)) {
+ if (GPR_UNLIKELY(
+ !grpc_http2_decode_timeout(GRPC_MDVALUE(md), &timeout))) {
char* val = grpc_slice_to_c_string(GRPC_MDVALUE(md));
gpr_log(GPR_ERROR, "Ignoring bad timeout value '%s'", val);
gpr_free(val);
@@ -550,15 +551,15 @@ static grpc_error* init_header_frame_parser(grpc_chttp2_transport* t,
/* could be a new grpc_chttp2_stream or an existing grpc_chttp2_stream */
s = grpc_chttp2_parsing_lookup_stream(t, t->incoming_stream_id);
if (s == nullptr) {
- if (is_continuation) {
+ if (GPR_UNLIKELY(is_continuation)) {
GRPC_CHTTP2_IF_TRACING(
gpr_log(GPR_ERROR,
"grpc_chttp2_stream disbanded before CONTINUATION received"));
return init_skip_frame_parser(t, 1);
}
if (t->is_client) {
- if ((t->incoming_stream_id & 1) &&
- t->incoming_stream_id < t->next_stream_id) {
+ if (GPR_LIKELY((t->incoming_stream_id & 1) &&
+ t->incoming_stream_id < t->next_stream_id)) {
/* this is an old (probably cancelled) grpc_chttp2_stream */
} else {
GRPC_CHTTP2_IF_TRACING(gpr_log(
@@ -569,7 +570,7 @@ static grpc_error* init_header_frame_parser(grpc_chttp2_transport* t,
grpc_chttp2_hpack_parser_set_has_priority(&t->hpack_parser);
}
return err;
- } else if (t->last_new_stream_id >= t->incoming_stream_id) {
+ } else if (GPR_UNLIKELY(t->last_new_stream_id >= t->incoming_stream_id)) {
GRPC_CHTTP2_IF_TRACING(gpr_log(
GPR_ERROR,
"ignoring out of order new grpc_chttp2_stream request on server; "
@@ -577,21 +578,22 @@ static grpc_error* init_header_frame_parser(grpc_chttp2_transport* t,
"id=%d, new grpc_chttp2_stream id=%d",
t->last_new_stream_id, t->incoming_stream_id));
return init_skip_frame_parser(t, 1);
- } else if ((t->incoming_stream_id & 1) == 0) {
+ } else if (GPR_UNLIKELY((t->incoming_stream_id & 1) == 0)) {
GRPC_CHTTP2_IF_TRACING(gpr_log(
GPR_ERROR,
"ignoring grpc_chttp2_stream with non-client generated index %d",
t->incoming_stream_id));
return init_skip_frame_parser(t, 1);
- } else if (grpc_chttp2_stream_map_size(&t->stream_map) >=
- t->settings[GRPC_ACKED_SETTINGS]
- [GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS]) {
+ } else if (GPR_UNLIKELY(
+ grpc_chttp2_stream_map_size(&t->stream_map) >=
+ t->settings[GRPC_ACKED_SETTINGS]
+ [GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS])) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Max stream count exceeded");
}
t->last_new_stream_id = t->incoming_stream_id;
s = t->incoming_stream =
grpc_chttp2_parsing_accept_stream(t, t->incoming_stream_id);
- if (s == nullptr) {
+ if (GPR_UNLIKELY(s == nullptr)) {
GRPC_CHTTP2_IF_TRACING(
gpr_log(GPR_ERROR, "grpc_chttp2_stream not accepted"));
return init_skip_frame_parser(t, 1);
@@ -601,7 +603,7 @@ static grpc_error* init_header_frame_parser(grpc_chttp2_transport* t,
}
GPR_ASSERT(s != nullptr);
s->stats.incoming.framing_bytes += 9;
- if (s->read_closed) {
+ if (GPR_UNLIKELY(s->read_closed)) {
GRPC_CHTTP2_IF_TRACING(gpr_log(
GPR_ERROR, "skipping already closed grpc_chttp2_stream header"));
t->incoming_stream = nullptr;
@@ -723,7 +725,7 @@ static grpc_error* parse_frame_slice(grpc_chttp2_transport* t, grpc_slice slice,
int is_last) {
grpc_chttp2_stream* s = t->incoming_stream;
grpc_error* err = t->parser(t->parser_data, t, s, slice, is_last);
- if (err == GRPC_ERROR_NONE) {
+ if (GPR_LIKELY(err == GRPC_ERROR_NONE)) {
return err;
} else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, nullptr)) {
if (grpc_http_trace.enabled()) {
diff --git a/src/core/ext/transport/chttp2/transport/writing.cc b/src/core/ext/transport/chttp2/transport/writing.cc
index 85efe27080..34d5e6e218 100644
--- a/src/core/ext/transport/chttp2/transport/writing.cc
+++ b/src/core/ext/transport/chttp2/transport/writing.cc
@@ -337,10 +337,10 @@ class DataSendContext {
s_->fetching_send_message == nullptr);
if (is_last_data_frame && s_->send_trailing_metadata != nullptr &&
s_->stream_compression_ctx != nullptr) {
- if (!grpc_stream_compress(
+ if (GPR_UNLIKELY(!grpc_stream_compress(
s_->stream_compression_ctx, &s_->flow_controlled_buffer,
&s_->compressed_data_buffer, nullptr, MAX_SIZE_T,
- GRPC_STREAM_COMPRESSION_FLUSH_FINISH)) {
+ GRPC_STREAM_COMPRESSION_FLUSH_FINISH))) {
gpr_log(GPR_ERROR, "Stream compression failed.");
}
grpc_stream_compression_context_destroy(s_->stream_compression_ctx);
@@ -368,10 +368,10 @@ class DataSendContext {
grpc_stream_compression_context_create(s_->stream_compression_method);
}
s_->uncompressed_data_size = s_->flow_controlled_buffer.length;
- if (!grpc_stream_compress(s_->stream_compression_ctx,
- &s_->flow_controlled_buffer,
- &s_->compressed_data_buffer, nullptr, MAX_SIZE_T,
- GRPC_STREAM_COMPRESSION_FLUSH_SYNC)) {
+ if (GPR_UNLIKELY(!grpc_stream_compress(
+ s_->stream_compression_ctx, &s_->flow_controlled_buffer,
+ &s_->compressed_data_buffer, nullptr, MAX_SIZE_T,
+ GRPC_STREAM_COMPRESSION_FLUSH_SYNC))) {
gpr_log(GPR_ERROR, "Stream compression failed.");
}
}
diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.cc b/src/core/ext/transport/cronet/transport/cronet_transport.cc
index 8e3ea05706..0b88ff7afe 100644
--- a/src/core/ext/transport/cronet/transport/cronet_transport.cc
+++ b/src/core/ext/transport/cronet/transport/cronet_transport.cc
@@ -360,7 +360,7 @@ static void remove_from_storage(struct stream_obj* s,
s->storage.num_pending_ops);
gpr_free(oas);
break;
- } else if (curr->next == nullptr) {
+ } else if (GPR_UNLIKELY(curr->next == nullptr)) {
CRONET_LOG(GPR_ERROR, "Reached end of LL and did not find op to free");
}
}
@@ -1054,7 +1054,7 @@ static enum e_op_result execute_stream_op(struct op_and_state* oas) {
GPR_ASSERT(false);
}
grpc_slice_buffer_add(&write_slice_buffer, slice);
- if (write_slice_buffer.count != 1) {
+ if (GPR_UNLIKELY(write_slice_buffer.count != 1)) {
/* Empty request not handled yet */
gpr_log(GPR_ERROR, "Empty request is not supported");
GPR_ASSERT(write_slice_buffer.count == 1);
@@ -1455,7 +1455,7 @@ grpc_transport* grpc_create_cronet_transport(void* engine, const char* target,
for (size_t i = 0; i < args->num_args; i++) {
if (0 ==
strcmp(args->args[i].key, GRPC_ARG_USE_CRONET_PACKET_COALESCING)) {
- if (args->args[i].type != GRPC_ARG_INTEGER) {
+ if (GPR_UNLIKELY(args->args[i].type != GRPC_ARG_INTEGER)) {
gpr_log(GPR_ERROR, "%s ignored: it must be an integer",
GRPC_ARG_USE_CRONET_PACKET_COALESCING);
} else {