diff options
-rw-r--r-- | src/core/ext/transport/chttp2/server/chttp2_server.cc | 8 | ||||
-rw-r--r-- | src/core/lib/channel/channelz.cc | 8 | ||||
-rw-r--r-- | src/core/lib/channel/channelz.h | 4 | ||||
-rw-r--r-- | src/core/lib/surface/server.cc | 1 |
4 files changed, 15 insertions, 6 deletions
diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.cc b/src/core/ext/transport/chttp2/server/chttp2_server.cc index 05aeede07a..0b0adb9786 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.cc +++ b/src/core/ext/transport/chttp2/server/chttp2_server.cc @@ -37,6 +37,7 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/handshaker.h" #include "src/core/lib/channel/handshaker_registry.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/resource_quota.h" @@ -362,9 +363,14 @@ 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>( - *port_num); + host, *port_num); + gpr_free(port); socket_uuid = state->channelz_listen_socket->uuid(); } diff --git a/src/core/lib/channel/channelz.cc b/src/core/lib/channel/channelz.cc index 393abcef98..4a32b1f39a 100644 --- a/src/core/lib/channel/channelz.cc +++ b/src/core/lib/channel/channelz.cc @@ -374,8 +374,10 @@ grpc_json* SocketNode::RenderJson() { return top_level_json; } -ListenSocketNode::ListenSocketNode(int port) - : BaseNode(EntityType::kSocket), port_(port) {} +ListenSocketNode::ListenSocketNode(char* host, int port) + : BaseNode(EntityType::kSocket), + host_(UniquePtr<char>(host)), + port_(port) {} grpc_json* ListenSocketNode::RenderJson() { // We need to track these three json objects to build our object @@ -402,7 +404,7 @@ grpc_json* ListenSocketNode::RenderJson() { json_iterator = grpc_json_add_number_string_child(json, json_iterator, "port", port_); json_iterator = grpc_json_create_child(json_iterator, json, "ip_address", - "127.0 0.1", GRPC_JSON_STRING, false); + host_.get(), GRPC_JSON_STRING, false); return top_level_json; } diff --git a/src/core/lib/channel/channelz.h b/src/core/lib/channel/channelz.h index 9ee7dfa91f..2c6fd01006 100644 --- a/src/core/lib/channel/channelz.h +++ b/src/core/lib/channel/channelz.h @@ -268,12 +268,14 @@ class SocketNode : public BaseNode { // Handles channelz bookkeeping for listen sockets class ListenSocketNode : public BaseNode { public: - ListenSocketNode(int port); + // ListenSocketNode takes ownership of host. + ListenSocketNode(char* host, int port); ~ListenSocketNode() override {} grpc_json* RenderJson() override; private: + UniquePtr<char> host_; int port_; }; diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index f9d467e732..72391ca697 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -1248,7 +1248,6 @@ void grpc_server_populate_listen_sockets( grpc_server* server, grpc_core::channelz::ChildRefsList* listen_sockets) { gpr_mu_lock(&server->mu_global); for (listener* l = server->listeners; l != nullptr; l = l->next) { - gpr_log(GPR_ERROR, "here"); listen_sockets->push_back(l->socket_uuid); } gpr_mu_unlock(&server->mu_global); |