diff options
author | 2018-10-31 18:48:22 -0700 | |
---|---|---|
committer | 2018-10-31 18:48:22 -0700 | |
commit | fa4894e110c7a70837d366d9f50066a06b01f848 (patch) | |
tree | cc69299f75e10e01053d0d58087a1b13519af7da /src/core/ext/transport | |
parent | 1a3c2d3e3ae3e7ab242c486db7e6405c9b7f8999 (diff) |
Handle uri parsing in channelz module
Diffstat (limited to 'src/core/ext/transport')
-rw-r--r-- | src/core/ext/transport/chttp2/server/chttp2_server.cc | 7 | ||||
-rw-r--r-- | src/core/ext/transport/chttp2/transport/chttp2_transport.cc | 34 |
2 files changed, 3 insertions, 38 deletions
diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.cc b/src/core/ext/transport/chttp2/server/chttp2_server.cc index 287bc0454e..cad71daf6e 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.cc +++ b/src/core/ext/transport/chttp2/server/chttp2_server.cc @@ -367,14 +367,9 @@ grpc_error* grpc_chttp2_server_add_port(grpc_server* server, const char* addr, arg = grpc_channel_args_find(args, GRPC_ARG_ENABLE_CHANNELZ); if (grpc_channel_arg_get_bool(arg, false)) { - char* host; - char* port; - gpr_split_host_port(addr, &host, &port); - // allocated host's ownership is passed to ListenSocketNode. state->channelz_listen_socket = grpc_core::MakeRefCounted<grpc_core::channelz::ListenSocketNode>( - grpc_core::UniquePtr<char>(host), *port_num); - gpr_free(port); + grpc_core::UniquePtr<char>(gpr_strdup(addr))); socket_uuid = state->channelz_listen_socket->uuid(); } diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 4fb121135c..6effa082a8 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -38,7 +38,6 @@ #include "src/core/lib/compression/stream_compression.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/gpr/env.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/http/parser.h" @@ -397,39 +396,10 @@ static bool read_channel_args(grpc_chttp2_transport* t, } } if (channelz_enabled) { - grpc_core::channelz::SocketAddress remote; - grpc_core::channelz::SocketAddress local; - char* host = nullptr; - int port_num = -1; - // try to pick out just the host port (maybe trims off scheme prefix). - grpc_uri* uri = grpc_uri_parse(t->peer_string, true); - // if peer string was a valid URI, we can use our lib to do the trimming. - // TODO(ncteisen): handle UDS address. - if (uri != nullptr) { - const char* host_port = uri->path; - if (*host_port == '/') ++host_port; - char* port; - GPR_ASSERT(gpr_split_host_port(host_port, &host, &port)); - if (port != nullptr) { - port_num = atoi(port); - } - remote.set_blob(gpr_string_base64_encode(host)); - remote.set_port(port_num); - remote.set_type( - grpc_core::channelz::SocketAddress::AddressType::kTcpAddress); - gpr_free(host); - gpr_free(port); - } else { - // if peer string is not a valid URI, just use the entire string to - // surface that info. - remote.set_blob(gpr_strdup(t->peer_string)); - remote.set_type(grpc_core::channelz::SocketAddress::AddressType:: - kDirectChannelAddress); - } t->channelz_socket = grpc_core::MakeRefCounted<grpc_core::channelz::SocketNode>( - std::move(local), std::move(remote)); - grpc_uri_destroy(uri); + grpc_core::UniquePtr<char>(), + grpc_core::UniquePtr<char>(gpr_strdup(t->peer_string))); } return enable_bdp; } |