|
|
|
@ -415,26 +415,33 @@ grpc_call* grpc_channel_create_pollset_set_call( |
|
|
|
|
|
|
|
|
|
namespace grpc_core { |
|
|
|
|
|
|
|
|
|
RegisteredCall::RegisteredCall(const char* method, const char* host) { |
|
|
|
|
path = grpc_mdelem_from_slices(GRPC_MDSTR_PATH, |
|
|
|
|
grpc_core::ExternallyManagedSlice(method)); |
|
|
|
|
authority = |
|
|
|
|
host ? grpc_mdelem_from_slices(GRPC_MDSTR_AUTHORITY, |
|
|
|
|
grpc_core::ExternallyManagedSlice(host)) |
|
|
|
|
: GRPC_MDNULL; |
|
|
|
|
} |
|
|
|
|
RegisteredCall::RegisteredCall(const char* method_arg, const char* host_arg) |
|
|
|
|
: method(method_arg != nullptr ? method_arg : ""), |
|
|
|
|
host(host_arg != nullptr ? host_arg : ""), |
|
|
|
|
path(grpc_mdelem_from_slices( |
|
|
|
|
GRPC_MDSTR_PATH, grpc_core::ExternallyManagedSlice(method.c_str()))), |
|
|
|
|
authority(!host.empty() |
|
|
|
|
? grpc_mdelem_from_slices( |
|
|
|
|
GRPC_MDSTR_AUTHORITY, |
|
|
|
|
grpc_core::ExternallyManagedSlice(host.c_str())) |
|
|
|
|
: GRPC_MDNULL) {} |
|
|
|
|
|
|
|
|
|
// TODO(vjpai): Delete copy-constructor when allowed by all supported compilers.
|
|
|
|
|
RegisteredCall::RegisteredCall(const RegisteredCall& other) { |
|
|
|
|
path = other.path; |
|
|
|
|
authority = other.authority; |
|
|
|
|
GRPC_MDELEM_REF(path); |
|
|
|
|
GRPC_MDELEM_REF(authority); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
RegisteredCall::RegisteredCall(RegisteredCall&& other) noexcept { |
|
|
|
|
path = other.path; |
|
|
|
|
authority = other.authority; |
|
|
|
|
RegisteredCall::RegisteredCall(const RegisteredCall& other) |
|
|
|
|
: RegisteredCall(other.method.c_str(), other.host.c_str()) {} |
|
|
|
|
|
|
|
|
|
RegisteredCall::RegisteredCall(RegisteredCall&& other) noexcept |
|
|
|
|
: method(std::move(other.method)), |
|
|
|
|
host(std::move(other.host)), |
|
|
|
|
path(grpc_mdelem_from_slices( |
|
|
|
|
GRPC_MDSTR_PATH, grpc_core::ExternallyManagedSlice(method.c_str()))), |
|
|
|
|
authority(!host.empty() |
|
|
|
|
? grpc_mdelem_from_slices( |
|
|
|
|
GRPC_MDSTR_AUTHORITY, |
|
|
|
|
grpc_core::ExternallyManagedSlice(host.c_str())) |
|
|
|
|
: GRPC_MDNULL) { |
|
|
|
|
GRPC_MDELEM_UNREF(other.path); |
|
|
|
|
GRPC_MDELEM_UNREF(other.authority); |
|
|
|
|
other.path = GRPC_MDNULL; |
|
|
|
|
other.authority = GRPC_MDNULL; |
|
|
|
|
} |
|
|
|
@ -457,13 +464,14 @@ void* grpc_channel_register_call(grpc_channel* channel, const char* method, |
|
|
|
|
|
|
|
|
|
grpc_core::MutexLock lock(&channel->registration_table->mu); |
|
|
|
|
channel->registration_table->method_registration_attempts++; |
|
|
|
|
auto key = std::make_pair(host, method); |
|
|
|
|
auto key = std::make_pair(std::string(host != nullptr ? host : ""), |
|
|
|
|
std::string(method != nullptr ? method : "")); |
|
|
|
|
auto rc_posn = channel->registration_table->map.find(key); |
|
|
|
|
if (rc_posn != channel->registration_table->map.end()) { |
|
|
|
|
return &rc_posn->second; |
|
|
|
|
} |
|
|
|
|
auto insertion_result = channel->registration_table->map.insert( |
|
|
|
|
{key, grpc_core::RegisteredCall(method, host)}); |
|
|
|
|
{std::move(key), grpc_core::RegisteredCall(method, host)}); |
|
|
|
|
return &insertion_result.first->second; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|