Skip to content

Commit

Permalink
[Chttp2Server] Add debug only trace flag for refcounting in chttp2 se…
Browse files Browse the repository at this point in the history
…rver
  • Loading branch information
yashykt committed Jan 22, 2025
1 parent c1bcb5d commit 47c35bb
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions doc/trace_flags.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 14 additions & 3 deletions src/core/ext/transport/chttp2/server/chttp2_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,11 @@ NewChttp2ServerListener::ActiveConnection::HandshakingState::HandshakingState(
RefCountedPtr<ActiveConnection> connection_ref, grpc_tcp_server* tcp_server,
grpc_pollset* accepting_pollset, AcceptorPtr acceptor,
const ChannelArgs& args, OrphanablePtr<grpc_endpoint> endpoint)
: connection_(std::move(connection_ref)),
: InternallyRefCounted(
GRPC_TRACE_FLAG_ENABLED(chttp2_server_refcount)
? "NewChttp2ServerListener::ActiveConnection::HandshakingState"
: nullptr),
connection_(std::move(connection_ref)),
tcp_server_(tcp_server),
accepting_pollset_(accepting_pollset),
acceptor_(std::move(acceptor)),
Expand Down Expand Up @@ -1128,7 +1132,10 @@ NewChttp2ServerListener::ActiveConnection::ActiveConnection(
grpc_tcp_server* tcp_server, grpc_pollset* accepting_pollset,
AcceptorPtr acceptor, const ChannelArgs& args, MemoryOwner memory_owner,
OrphanablePtr<grpc_endpoint> endpoint)
: listener_state_(std::move(listener_state)),
: LogicalConnection(GRPC_TRACE_FLAG_ENABLED(chttp2_server_refcount)
? "NewChttp2ServerListener::ActiveConnection"
: nullptr),
listener_state_(std::move(listener_state)),
work_serializer_(
args.GetObjectRef<grpc_event_engine::experimental::EventEngine>()),
state_(memory_owner.MakeOrphanable<HandshakingState>(
Expand Down Expand Up @@ -1317,7 +1324,11 @@ NewChttp2ServerListener* NewChttp2ServerListener::CreateForPassiveListener(
NewChttp2ServerListener::NewChttp2ServerListener(
const ChannelArgs& args,
std::shared_ptr<experimental::PassiveListenerImpl> passive_listener)
: args_(args), passive_listener_(std::move(passive_listener)) {
: ListenerInterface(GRPC_TRACE_FLAG_ENABLED(chttp2_server_refcount)
? "NewChttp2ServerListener"
: nullptr),
args_(args),
passive_listener_(std::move(passive_listener)) {
GRPC_CLOSURE_INIT(&tcp_server_shutdown_complete_, TcpServerShutdownComplete,
this, grpc_schedule_on_exec_ctx);
}
Expand Down
3 changes: 3 additions & 0 deletions src/core/lib/debug/trace_flags.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/core/lib/debug/trace_flags.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/core/lib/debug/trace_flags.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ chttp2_hpack_parser:
chttp2_new_stream:
default: false
description: HTTP/2 incoming stream creation.
chttp2_server_refcount:
debug_only: true
default: false
description: Refcounting in Chttp2 Server.
client_channel:
default: false
description: Client channel control plane activity, including resolver and load balancing policy interaction.
Expand Down
4 changes: 4 additions & 0 deletions src/core/server/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ class Server : public ServerInterface,
// tracking systems, without increasing memory utilization.
class LogicalConnection : public InternallyRefCounted<LogicalConnection> {
public:
explicit LogicalConnection(const char* trace = nullptr)
: InternallyRefCounted(trace) {}
~LogicalConnection() override = default;

// The following two methods are called in the context of a server config
Expand All @@ -189,6 +191,8 @@ class Server : public ServerInterface,
virtual void DisconnectImmediately() = 0;
};

explicit ListenerInterface(const char* trace = nullptr)
: InternallyRefCounted(trace) {}
~ListenerInterface() override = default;

/// Starts listening.
Expand Down

0 comments on commit 47c35bb

Please sign in to comment.