aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/ext/filters
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/ext/filters')
-rw-r--r--src/core/ext/filters/client_channel/backup_poller.cc2
-rw-r--r--src/core/ext/filters/client_channel/channel_connectivity.cc2
-rw-r--r--src/core/ext/filters/client_channel/client_channel.cc4
-rw-r--r--src/core/ext/filters/client_channel/http_connect_handshaker.cc2
-rw-r--r--src/core/ext/filters/client_channel/http_proxy.cc6
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc14
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc11
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc2
-rw-r--r--src/core/ext/filters/client_channel/parse_address.cc32
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc5
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc2
-rw-r--r--src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc2
-rw-r--r--src/core/ext/filters/client_channel/resolver_registry.cc2
-rw-r--r--src/core/ext/filters/client_channel/subchannel.cc4
-rw-r--r--src/core/ext/filters/http/client/http_client_filter.cc6
-rw-r--r--src/core/ext/filters/http/message_compress/message_compress_filter.cc8
16 files changed, 55 insertions, 49 deletions
diff --git a/src/core/ext/filters/client_channel/backup_poller.cc b/src/core/ext/filters/client_channel/backup_poller.cc
index 3e2faa57bc..895e255c06 100644
--- a/src/core/ext/filters/client_channel/backup_poller.cc
+++ b/src/core/ext/filters/client_channel/backup_poller.cc
@@ -61,7 +61,7 @@ static void init_globals() {
char* env = gpr_getenv("GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS");
if (env != nullptr) {
int poll_interval_ms = gpr_parse_nonnegative_int(env);
- if (poll_interval_ms == -1) {
+ if (GPR_UNLIKELY(poll_interval_ms == -1)) {
gpr_log(GPR_ERROR,
"Invalid GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS: %s, "
"default value %d will be used.",
diff --git a/src/core/ext/filters/client_channel/channel_connectivity.cc b/src/core/ext/filters/client_channel/channel_connectivity.cc
index 37860e82e3..c71d10274a 100644
--- a/src/core/ext/filters/client_channel/channel_connectivity.cc
+++ b/src/core/ext/filters/client_channel/channel_connectivity.cc
@@ -40,7 +40,7 @@ grpc_connectivity_state grpc_channel_check_connectivity_state(
GRPC_API_TRACE(
"grpc_channel_check_connectivity_state(channel=%p, try_to_connect=%d)", 2,
(channel, try_to_connect));
- if (client_channel_elem->filter == &grpc_client_channel_filter) {
+ if (GPR_LIKELY(client_channel_elem->filter == &grpc_client_channel_filter)) {
state = grpc_client_channel_check_connectivity_state(client_channel_elem,
try_to_connect);
diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc
index 80a647fa94..3813190794 100644
--- a/src/core/ext/filters/client_channel/client_channel.cc
+++ b/src/core/ext/filters/client_channel/client_channel.cc
@@ -379,7 +379,7 @@ static void on_resolver_result_changed_locked(void* arg, grpc_error* error) {
new_lb_policy =
grpc_core::LoadBalancingPolicyRegistry::CreateLoadBalancingPolicy(
lb_policy_name, lb_policy_args);
- if (new_lb_policy == nullptr) {
+ if (GPR_UNLIKELY(new_lb_policy == nullptr)) {
gpr_log(GPR_ERROR, "could not create LB policy \"%s\"",
lb_policy_name);
} else {
@@ -2200,7 +2200,7 @@ static void add_retriable_send_initial_metadata_op(
&batch_data->send_initial_metadata_storage[calld->send_initial_metadata
.list.count],
retry_md);
- if (error != GRPC_ERROR_NONE) {
+ if (GPR_UNLIKELY(error != GRPC_ERROR_NONE)) {
gpr_log(GPR_ERROR, "error adding retry metadata: %s",
grpc_error_string(error));
GPR_ASSERT(false);
diff --git a/src/core/ext/filters/client_channel/http_connect_handshaker.cc b/src/core/ext/filters/client_channel/http_connect_handshaker.cc
index 4e8b8b71db..2106860d8e 100644
--- a/src/core/ext/filters/client_channel/http_connect_handshaker.cc
+++ b/src/core/ext/filters/client_channel/http_connect_handshaker.cc
@@ -280,7 +280,7 @@ static void http_connect_handshaker_do_handshake(
gpr_malloc(sizeof(grpc_http_header) * num_header_strings));
for (size_t i = 0; i < num_header_strings; ++i) {
char* sep = strchr(header_strings[i], ':');
- if (sep == nullptr) {
+ if (GPR_UNLIKELY(sep == nullptr)) {
gpr_log(GPR_ERROR, "skipping unparseable HTTP CONNECT header: %s",
header_strings[i]);
continue;
diff --git a/src/core/ext/filters/client_channel/http_proxy.cc b/src/core/ext/filters/client_channel/http_proxy.cc
index 29a6c0e367..95c0c85498 100644
--- a/src/core/ext/filters/client_channel/http_proxy.cc
+++ b/src/core/ext/filters/client_channel/http_proxy.cc
@@ -50,11 +50,11 @@ static char* get_http_proxy_server(char** user_cred) {
size_t authority_nstrs;
if (uri_str == nullptr) return nullptr;
grpc_uri* uri = grpc_uri_parse(uri_str, false /* suppress_errors */);
- if (uri == nullptr || uri->authority == nullptr) {
+ if (GPR_UNLIKELY(uri == nullptr || uri->authority == nullptr)) {
gpr_log(GPR_ERROR, "cannot parse value of 'http_proxy' env var");
goto done;
}
- if (strcmp(uri->scheme, "http") != 0) {
+ if (GPR_UNLIKELY(strcmp(uri->scheme, "http") != 0)) {
gpr_log(GPR_ERROR, "'%s' scheme not supported in proxy URI", uri->scheme);
goto done;
}
@@ -93,7 +93,7 @@ static bool proxy_mapper_map_name(grpc_proxy_mapper* mapper,
if (*name_to_resolve == nullptr) return false;
char* no_proxy_str = nullptr;
grpc_uri* uri = grpc_uri_parse(server_uri, false /* suppress_errors */);
- if (uri == nullptr || uri->path[0] == '\0') {
+ if (GPR_UNLIKELY(uri == nullptr || uri->path[0] == '\0')) {
gpr_log(GPR_ERROR,
"'http_proxy' environment variable set, but cannot "
"parse server URI '%s' -- not using proxy",
diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
index 1a675476f0..ec338fbeac 100644
--- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
+++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
@@ -398,7 +398,7 @@ grpc_lb_addresses* ExtractBackendAddresses(const grpc_lb_addresses* addresses) {
bool IsServerValid(const grpc_grpclb_server* server, size_t idx, bool log) {
if (server->drop) return false;
const grpc_grpclb_ip_address* ip = &server->ip_address;
- if (server->port >> 16 != 0) {
+ if (GPR_UNLIKELY(server->port >> 16 != 0)) {
if (log) {
gpr_log(GPR_ERROR,
"Invalid port '%d' at index %lu of serverlist. Ignoring.",
@@ -406,7 +406,7 @@ bool IsServerValid(const grpc_grpclb_server* server, size_t idx, bool log) {
}
return false;
}
- if (ip->size != 4 && ip->size != 16) {
+ if (GPR_UNLIKELY(ip->size != 4 && ip->size != 16)) {
if (log) {
gpr_log(GPR_ERROR,
"Expected IP to be 4 or 16 bytes, got %d at index %lu of "
@@ -714,7 +714,7 @@ void GrpcLb::BalancerCallState::SendClientLoadReportLocked() {
this, grpc_combiner_scheduler(grpclb_policy()->combiner()));
grpc_call_error call_error = grpc_call_start_batch_and_execute(
lb_call_, &op, 1, &client_load_report_closure_);
- if (call_error != GRPC_CALL_OK) {
+ if (GPR_UNLIKELY(call_error != GRPC_CALL_OK)) {
gpr_log(GPR_ERROR, "[grpclb %p] call_error=%d", grpclb_policy_.get(),
call_error);
GPR_ASSERT(GRPC_CALL_OK == call_error);
@@ -936,7 +936,7 @@ grpc_lb_addresses* ExtractBalancerAddresses(
size_t lb_addresses_idx = 0;
for (size_t i = 0; i < addresses->num_addresses; ++i) {
if (!addresses->addresses[i].is_balancer) continue;
- if (addresses->addresses[i].user_data != nullptr) {
+ if (GPR_UNLIKELY(addresses->addresses[i].user_data != nullptr)) {
gpr_log(GPR_ERROR,
"This LB policy doesn't support user data. It will be ignored");
}
@@ -1284,7 +1284,7 @@ void GrpcLb::NotifyOnStateChangeLocked(grpc_connectivity_state* current,
void GrpcLb::ProcessChannelArgsLocked(const grpc_channel_args& args) {
const grpc_arg* arg = grpc_channel_args_find(&args, GRPC_ARG_LB_ADDRESSES);
- if (arg == nullptr || arg->type != GRPC_ARG_POINTER) {
+ if (GPR_UNLIKELY(arg == nullptr || arg->type != GRPC_ARG_POINTER)) {
// Ignore this update.
gpr_log(
GPR_ERROR,
@@ -1520,7 +1520,7 @@ void GrpcLb::PendingPickSetMetadataAndContext(PendingPick* pp) {
* policy (e.g., all addresses failed to connect). There won't be any
* user_data/token available */
if (pp->pick->connected_subchannel != nullptr) {
- if (!GRPC_MDISNULL(pp->lb_token)) {
+ if (GPR_LIKELY(!GRPC_MDISNULL(pp->lb_token))) {
AddLbTokenToInitialMetadata(GRPC_MDELEM_REF(pp->lb_token),
&pp->pick->lb_token_mdelem_storage,
pp->pick->initial_metadata);
@@ -1645,7 +1645,7 @@ void GrpcLb::CreateRoundRobinPolicyLocked(const Args& args) {
GPR_ASSERT(rr_policy_ == nullptr);
rr_policy_ = LoadBalancingPolicyRegistry::CreateLoadBalancingPolicy(
"round_robin", args);
- if (rr_policy_ == nullptr) {
+ if (GPR_UNLIKELY(rr_policy_ == nullptr)) {
gpr_log(GPR_ERROR, "[grpclb %p] Failure creating a RoundRobin policy",
this);
return;
diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc
index 7ef3bcf24f..0e80dd5521 100644
--- a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc
+++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc
@@ -29,7 +29,7 @@ static bool count_serverlist(pb_istream_t* stream, const pb_field_t* field,
void** arg) {
grpc_grpclb_serverlist* sl = static_cast<grpc_grpclb_serverlist*>(*arg);
grpc_grpclb_server server;
- if (!pb_decode(stream, grpc_lb_v1_Server_fields, &server)) {
+ if (GPR_UNLIKELY(!pb_decode(stream, grpc_lb_v1_Server_fields, &server))) {
gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(stream));
return false;
}
@@ -52,7 +52,7 @@ static bool decode_serverlist(pb_istream_t* stream, const pb_field_t* field,
GPR_ASSERT(dec_arg->serverlist->num_servers >= dec_arg->decoding_idx);
grpc_grpclb_server* server =
static_cast<grpc_grpclb_server*>(gpr_zalloc(sizeof(grpc_grpclb_server)));
- if (!pb_decode(stream, grpc_lb_v1_Server_fields, server)) {
+ if (GPR_UNLIKELY(!pb_decode(stream, grpc_lb_v1_Server_fields, server))) {
gpr_free(server);
gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(stream));
return false;
@@ -165,7 +165,8 @@ grpc_grpclb_initial_response* grpc_grpclb_initial_response_parse(
GRPC_SLICE_LENGTH(encoded_grpc_grpclb_response));
grpc_grpclb_response res;
memset(&res, 0, sizeof(grpc_grpclb_response));
- if (!pb_decode(&stream, grpc_lb_v1_LoadBalanceResponse_fields, &res)) {
+ if (GPR_UNLIKELY(
+ !pb_decode(&stream, grpc_lb_v1_LoadBalanceResponse_fields, &res))) {
gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&stream));
return nullptr;
}
@@ -195,7 +196,7 @@ grpc_grpclb_serverlist* grpc_grpclb_response_parse_serverlist(
res.server_list.servers.funcs.decode = count_serverlist;
res.server_list.servers.arg = sl;
bool status = pb_decode(&stream, grpc_lb_v1_LoadBalanceResponse_fields, &res);
- if (!status) {
+ if (GPR_UNLIKELY(!status)) {
gpr_free(sl);
gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&stream));
return nullptr;
@@ -211,7 +212,7 @@ grpc_grpclb_serverlist* grpc_grpclb_response_parse_serverlist(
res.server_list.servers.arg = &decode_arg;
status = pb_decode(&stream_at_start, grpc_lb_v1_LoadBalanceResponse_fields,
&res);
- if (!status) {
+ if (GPR_UNLIKELY(!status)) {
grpc_grpclb_destroy_serverlist(sl);
gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&stream));
return nullptr;
diff --git a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc
index 79e8ad5663..b177385065 100644
--- a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc
+++ b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc
@@ -608,7 +608,7 @@ void RoundRobin::PingOneLocked(grpc_closure* on_initiate,
void RoundRobin::UpdateLocked(const grpc_channel_args& args) {
const grpc_arg* arg = grpc_channel_args_find(&args, GRPC_ARG_LB_ADDRESSES);
- if (arg == nullptr || arg->type != GRPC_ARG_POINTER) {
+ if (GPR_UNLIKELY(arg == nullptr || arg->type != GRPC_ARG_POINTER)) {
gpr_log(GPR_ERROR, "[RR %p] update provided no addresses; ignoring", this);
// If we don't have a current subchannel list, go into TRANSIENT_FAILURE.
// Otherwise, keep using the current subchannel list (ignore this update).
diff --git a/src/core/ext/filters/client_channel/parse_address.cc b/src/core/ext/filters/client_channel/parse_address.cc
index b3900114ad..f3d6889f4d 100644
--- a/src/core/ext/filters/client_channel/parse_address.cc
+++ b/src/core/ext/filters/client_channel/parse_address.cc
@@ -39,7 +39,7 @@
bool grpc_parse_unix(const grpc_uri* uri,
grpc_resolved_address* resolved_addr) {
- if (strcmp("unix", uri->scheme) != 0) {
+ if (GPR_UNLIKELY(strcmp("unix", uri->scheme) != 0)) {
gpr_log(GPR_ERROR, "Expected 'unix' scheme, got '%s'", uri->scheme);
return false;
}
@@ -75,17 +75,18 @@ bool grpc_parse_ipv4_hostport(const char* hostport, grpc_resolved_address* addr,
addr->len = static_cast<socklen_t>(sizeof(grpc_sockaddr_in));
grpc_sockaddr_in* in = reinterpret_cast<grpc_sockaddr_in*>(addr->addr);
in->sin_family = GRPC_AF_INET;
- if (grpc_inet_pton(GRPC_AF_INET, host, &in->sin_addr) == 0) {
+ if (GPR_UNLIKELY(grpc_inet_pton(GRPC_AF_INET, host, &in->sin_addr) == 0)) {
if (log_errors) gpr_log(GPR_ERROR, "invalid ipv4 address: '%s'", host);
goto done;
}
// Parse port.
- if (port == nullptr) {
+ if (GPR_UNLIKELY(port == nullptr)) {
if (log_errors) gpr_log(GPR_ERROR, "no port given for ipv4 scheme");
goto done;
}
int port_num;
- if (sscanf(port, "%d", &port_num) != 1 || port_num < 0 || port_num > 65535) {
+ if (GPR_UNLIKELY(sscanf(port, "%d", &port_num) != 1 || port_num < 0 ||
+ port_num > 65535)) {
if (log_errors) gpr_log(GPR_ERROR, "invalid ipv4 port: '%s'", port);
goto done;
}
@@ -99,7 +100,7 @@ done:
bool grpc_parse_ipv4(const grpc_uri* uri,
grpc_resolved_address* resolved_addr) {
- if (strcmp("ipv4", uri->scheme) != 0) {
+ if (GPR_UNLIKELY(strcmp("ipv4", uri->scheme) != 0)) {
gpr_log(GPR_ERROR, "Expected 'ipv4' scheme, got '%s'", uri->scheme);
return false;
}
@@ -130,32 +131,35 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr,
uint32_t sin6_scope_id = 0;
strncpy(host_without_scope, host, host_without_scope_len);
host_without_scope[host_without_scope_len] = '\0';
- if (grpc_inet_pton(GRPC_AF_INET6, host_without_scope, &in6->sin6_addr) ==
- 0) {
+ if (GPR_UNLIKELY(grpc_inet_pton(GRPC_AF_INET6, host_without_scope,
+ &in6->sin6_addr)) == 0) {
gpr_log(GPR_ERROR, "invalid ipv6 address: '%s'", host_without_scope);
goto done;
}
- if (gpr_parse_bytes_to_uint32(host_end + 1,
- strlen(host) - host_without_scope_len - 1,
- &sin6_scope_id) == 0) {
+ if (GPR_UNLIKELY(
+ gpr_parse_bytes_to_uint32(host_end + 1,
+ strlen(host) - host_without_scope_len - 1,
+ &sin6_scope_id) == 0)) {
gpr_log(GPR_ERROR, "invalid ipv6 scope id: '%s'", host_end + 1);
goto done;
}
// Handle "sin6_scope_id" being type "u_long". See grpc issue #10027.
in6->sin6_scope_id = sin6_scope_id;
} else {
- if (grpc_inet_pton(GRPC_AF_INET6, host, &in6->sin6_addr) == 0) {
+ if (GPR_UNLIKELY(grpc_inet_pton(GRPC_AF_INET6, host, &in6->sin6_addr) ==
+ 0)) {
gpr_log(GPR_ERROR, "invalid ipv6 address: '%s'", host);
goto done;
}
}
// Parse port.
- if (port == nullptr) {
+ if (GPR_UNLIKELY(port == nullptr)) {
if (log_errors) gpr_log(GPR_ERROR, "no port given for ipv6 scheme");
goto done;
}
int port_num;
- if (sscanf(port, "%d", &port_num) != 1 || port_num < 0 || port_num > 65535) {
+ if (GPR_UNLIKELY(sscanf(port, "%d", &port_num) != 1 || port_num < 0 ||
+ port_num > 65535)) {
if (log_errors) gpr_log(GPR_ERROR, "invalid ipv6 port: '%s'", port);
goto done;
}
@@ -169,7 +173,7 @@ done:
bool grpc_parse_ipv6(const grpc_uri* uri,
grpc_resolved_address* resolved_addr) {
- if (strcmp("ipv6", uri->scheme) != 0) {
+ if (GPR_UNLIKELY(strcmp("ipv6", uri->scheme) != 0)) {
gpr_log(GPR_ERROR, "Expected 'ipv6' scheme, got '%s'", uri->scheme);
return false;
}
diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc
index c3c62b60bf..1b4767b47f 100644
--- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc
+++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc
@@ -225,14 +225,15 @@ bool ValueInJsonArray(grpc_json* array, const char* value) {
char* ChooseServiceConfig(char* service_config_choice_json) {
grpc_json* choices_json = grpc_json_parse_string(service_config_choice_json);
- if (choices_json == nullptr || choices_json->type != GRPC_JSON_ARRAY) {
+ if (GPR_UNLIKELY(choices_json == nullptr ||
+ choices_json->type != GRPC_JSON_ARRAY)) {
gpr_log(GPR_ERROR, "cannot parse service config JSON string");
return nullptr;
}
char* service_config = nullptr;
for (grpc_json* choice = choices_json->child; choice != nullptr;
choice = choice->next) {
- if (choice->type != GRPC_JSON_OBJECT) {
+ if (GPR_UNLIKELY(choice->type != GRPC_JSON_OBJECT)) {
gpr_log(GPR_ERROR, "cannot parse service config JSON string");
break;
}
diff --git a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc
index e7842a7951..920a492fdb 100644
--- a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc
+++ b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc
@@ -310,7 +310,7 @@ class NativeDnsResolverFactory : public ResolverFactory {
public:
OrphanablePtr<Resolver> CreateResolver(
const ResolverArgs& args) const override {
- if (0 != strcmp(args.uri->authority, "")) {
+ if (GPR_UNLIKELY(0 != strcmp(args.uri->authority, ""))) {
gpr_log(GPR_ERROR, "authority based dns uri's not supported");
return OrphanablePtr<Resolver>(nullptr);
}
diff --git a/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc b/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc
index f74ac5aebe..8f6132a726 100644
--- a/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc
+++ b/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc
@@ -123,7 +123,7 @@ void DoNothing(void* ignored) {}
OrphanablePtr<Resolver> CreateSockaddrResolver(
const ResolverArgs& args,
bool parse(const grpc_uri* uri, grpc_resolved_address* dst)) {
- if (0 != strcmp(args.uri->authority, "")) {
+ if (GPR_UNLIKELY(0 != strcmp(args.uri->authority, ""))) {
gpr_log(GPR_ERROR, "authority-based URIs not supported by the %s scheme",
args.uri->scheme);
return OrphanablePtr<Resolver>(nullptr);
diff --git a/src/core/ext/filters/client_channel/resolver_registry.cc b/src/core/ext/filters/client_channel/resolver_registry.cc
index 91c0267f95..7dfa57e11a 100644
--- a/src/core/ext/filters/client_channel/resolver_registry.cc
+++ b/src/core/ext/filters/client_channel/resolver_registry.cc
@@ -74,7 +74,7 @@ class RegistryState {
*uri = grpc_uri_parse(*canonical_target, 1);
factory =
*uri == nullptr ? nullptr : LookupResolverFactory((*uri)->scheme);
- if (factory == nullptr) {
+ if (GPR_UNLIKELY(factory == nullptr)) {
grpc_uri_destroy(grpc_uri_parse(target, 0));
grpc_uri_destroy(grpc_uri_parse(*canonical_target, 0));
gpr_log(GPR_ERROR, "don't know how to resolve '%s' or '%s'", target,
diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc
index d7815fb7e1..234ae49838 100644
--- a/src/core/ext/filters/client_channel/subchannel.cc
+++ b/src/core/ext/filters/client_channel/subchannel.cc
@@ -577,7 +577,7 @@ static bool publish_transport_locked(grpc_subchannel* c) {
grpc_error* error = grpc_channel_stack_builder_finish(
builder, 0, 1, connection_destroy, nullptr,
reinterpret_cast<void**>(&stk));
- if (error != GRPC_ERROR_NONE) {
+ if (GPR_UNLIKELY(error != GRPC_ERROR_NONE)) {
grpc_transport_destroy(c->connecting_result.transport);
gpr_log(GPR_ERROR, "error initializing subchannel stack: %s",
grpc_error_string(error));
@@ -803,7 +803,7 @@ grpc_error* ConnectedSubchannel::CreateCall(const CallArgs& args,
};
grpc_error* error = grpc_call_stack_init(
channel_stack_, 1, subchannel_call_destroy, *call, &call_args);
- if (error != GRPC_ERROR_NONE) {
+ if (GPR_UNLIKELY(error != GRPC_ERROR_NONE)) {
const char* error_string = grpc_error_string(error);
gpr_log(GPR_ERROR, "error: %s", error_string);
return error;
diff --git a/src/core/ext/filters/http/client/http_client_filter.cc b/src/core/ext/filters/http/client/http_client_filter.cc
index ae94ce47b9..8f27f2fea2 100644
--- a/src/core/ext/filters/http/client/http_client_filter.cc
+++ b/src/core/ext/filters/http/client/http_client_filter.cc
@@ -460,7 +460,7 @@ static size_t max_payload_size_from_args(const grpc_channel_args* args) {
if (args != nullptr) {
for (size_t i = 0; i < args->num_args; ++i) {
if (0 == strcmp(args->args[i].key, GRPC_ARG_MAX_PAYLOAD_SIZE_FOR_GET)) {
- if (args->args[i].type != GRPC_ARG_INTEGER) {
+ if (GPR_UNLIKELY(args->args[i].type != GRPC_ARG_INTEGER)) {
gpr_log(GPR_ERROR, "%s: must be an integer",
GRPC_ARG_MAX_PAYLOAD_SIZE_FOR_GET);
} else {
@@ -484,7 +484,7 @@ static grpc_slice user_agent_from_args(const grpc_channel_args* args,
for (i = 0; args && i < args->num_args; i++) {
if (0 == strcmp(args->args[i].key, GRPC_ARG_PRIMARY_USER_AGENT_STRING)) {
- if (args->args[i].type != GRPC_ARG_STRING) {
+ if (GPR_UNLIKELY(args->args[i].type != GRPC_ARG_STRING)) {
gpr_log(GPR_ERROR, "Channel argument '%s' should be a string",
GRPC_ARG_PRIMARY_USER_AGENT_STRING);
} else {
@@ -503,7 +503,7 @@ static grpc_slice user_agent_from_args(const grpc_channel_args* args,
for (i = 0; args && i < args->num_args; i++) {
if (0 == strcmp(args->args[i].key, GRPC_ARG_SECONDARY_USER_AGENT_STRING)) {
- if (args->args[i].type != GRPC_ARG_STRING) {
+ if (GPR_UNLIKELY(args->args[i].type != GRPC_ARG_STRING)) {
gpr_log(GPR_ERROR, "Channel argument '%s' should be a string",
GRPC_ARG_SECONDARY_USER_AGENT_STRING);
} else {
diff --git a/src/core/ext/filters/http/message_compress/message_compress_filter.cc b/src/core/ext/filters/http/message_compress/message_compress_filter.cc
index f8f478b6c0..933fe3c77b 100644
--- a/src/core/ext/filters/http/message_compress/message_compress_filter.cc
+++ b/src/core/ext/filters/http/message_compress/message_compress_filter.cc
@@ -116,8 +116,8 @@ static grpc_error* process_send_initial_metadata(
if (initial_metadata->idx.named.grpc_internal_encoding_request != nullptr) {
grpc_mdelem md =
initial_metadata->idx.named.grpc_internal_encoding_request->md;
- if (!grpc_compression_algorithm_parse(GRPC_MDVALUE(md),
- &compression_algorithm)) {
+ if (GPR_UNLIKELY(!grpc_compression_algorithm_parse(
+ GRPC_MDVALUE(md), &compression_algorithm))) {
char* val = grpc_slice_to_c_string(GRPC_MDVALUE(md));
gpr_log(GPR_ERROR,
"Invalid compression algorithm: '%s' (unknown). Ignoring.", val);
@@ -125,8 +125,8 @@ static grpc_error* process_send_initial_metadata(
calld->message_compression_algorithm = GRPC_MESSAGE_COMPRESS_NONE;
stream_compression_algorithm = GRPC_STREAM_COMPRESS_NONE;
}
- if (!GPR_BITGET(channeld->enabled_algorithms_bitset,
- compression_algorithm)) {
+ if (GPR_UNLIKELY(!GPR_BITGET(channeld->enabled_algorithms_bitset,
+ compression_algorithm))) {
char* val = grpc_slice_to_c_string(GRPC_MDVALUE(md));
gpr_log(GPR_ERROR,
"Invalid compression algorithm: '%s' (previously disabled). "