diff options
author | ncteisen <ncteisen@gmail.com> | 2018-10-29 08:38:35 -0700 |
---|---|---|
committer | ncteisen <ncteisen@gmail.com> | 2018-10-29 08:38:35 -0700 |
commit | 08519d44729c95b2f62a661ec846aa40448a5ef4 (patch) | |
tree | e1a528df6a6c680b53d051c09b92d1305fa3f5e5 /src | |
parent | 5cf95f0b52c21e6ebd0a7917d619da7b545d86c7 (diff) |
Listen sockets track their port
Diffstat (limited to 'src')
-rw-r--r-- | src/core/ext/transport/chttp2/server/chttp2_server.cc | 3 | ||||
-rw-r--r-- | src/core/lib/channel/channelz.cc | 18 | ||||
-rw-r--r-- | src/core/lib/channel/channelz.h | 5 | ||||
-rw-r--r-- | src/core/lib/surface/server.cc | 1 |
4 files changed, 24 insertions, 3 deletions
diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.cc b/src/core/ext/transport/chttp2/server/chttp2_server.cc index bdb2339e40..05aeede07a 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.cc +++ b/src/core/ext/transport/chttp2/server/chttp2_server.cc @@ -363,7 +363,8 @@ 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)) { state->channelz_listen_socket = - grpc_core::MakeRefCounted<grpc_core::channelz::ListenSocketNode>(); + grpc_core::MakeRefCounted<grpc_core::channelz::ListenSocketNode>( + *port_num); socket_uuid = state->channelz_listen_socket->uuid(); } diff --git a/src/core/lib/channel/channelz.cc b/src/core/lib/channel/channelz.cc index 33577d890a..393abcef98 100644 --- a/src/core/lib/channel/channelz.cc +++ b/src/core/lib/channel/channelz.cc @@ -374,7 +374,8 @@ grpc_json* SocketNode::RenderJson() { return top_level_json; } -ListenSocketNode::ListenSocketNode() : BaseNode(EntityType::kSocket) {} +ListenSocketNode::ListenSocketNode(int port) + : BaseNode(EntityType::kSocket), port_(port) {} grpc_json* ListenSocketNode::RenderJson() { // We need to track these three json objects to build our object @@ -388,6 +389,21 @@ grpc_json* ListenSocketNode::RenderJson() { json_iterator = nullptr; json_iterator = grpc_json_add_number_string_child(json, json_iterator, "socketId", uuid()); + json = top_level_json; + json_iterator = nullptr; + json_iterator = grpc_json_create_child(json_iterator, json, "local", nullptr, + GRPC_JSON_OBJECT, false); + json = json_iterator; + json_iterator = nullptr; + json_iterator = grpc_json_create_child(json_iterator, json, "tcpip_address", + nullptr, GRPC_JSON_OBJECT, false); + json = json_iterator; + json_iterator = nullptr; + 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); + return top_level_json; } diff --git a/src/core/lib/channel/channelz.h b/src/core/lib/channel/channelz.h index 88551befc8..9ee7dfa91f 100644 --- a/src/core/lib/channel/channelz.h +++ b/src/core/lib/channel/channelz.h @@ -268,10 +268,13 @@ class SocketNode : public BaseNode { // Handles channelz bookkeeping for listen sockets class ListenSocketNode : public BaseNode { public: - ListenSocketNode(); + ListenSocketNode(int port); ~ListenSocketNode() override {} grpc_json* RenderJson() override; + + private: + int port_; }; // Creation functions diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index 72391ca697..f9d467e732 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -1248,6 +1248,7 @@ 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); |