Skip to content

Convert chttp2 server connection-handling code to C++.#23104

Merged
markdroth merged 1 commit intogrpc:masterfrom
markdroth:chttp2_server_c++
Jun 22, 2020
Merged

Convert chttp2 server connection-handling code to C++.#23104
markdroth merged 1 commit intogrpc:masterfrom
markdroth:chttp2_server_c++

Conversation

@markdroth
Copy link
Copy Markdown
Member

No description provided.

@markdroth markdroth added the release notes: no Indicates if PR should not be in release notes label Jun 1, 2020
@markdroth markdroth requested a review from vjpai June 1, 2020 19:25
@markdroth markdroth mentioned this pull request Jun 2, 2020
#include "test/core/util/test_config.h"

void test_unparsable_target(void) {
gpr_log(GPR_INFO, "test_unparsable_target()");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were the log additions in this file intentional?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It helps figure out where the problem is when a test hangs.

That having been said, a better approach here is to just use gtest instead, since the framework handles this logging for you. So I've made that change.

Copy link
Copy Markdown
Contributor

@vjpai vjpai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great overall! It was quite easy to follow in Github split view because the code movement tended to be in big blocks. My comments are minor for the time being.

if (server->channelz_server != nullptr && l->socket_uuid != 0) {
server->channelz_server->RemoveChildListenSocket(l->socket_uuid);
for (auto& listener : server->listeners) {
auto* channelz_listen_socket_node =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we avoid auto since this isn't just being used as a pointer but is also being dereff'ed below?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

server->listeners = l;
grpc_server* server,
grpc_core::OrphanablePtr<grpc_core::ServerListenerInterface> listener) {
auto* listen_socket_node = listener->channelz_listen_socket_node();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise about avoiding auto here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

static grpc_error* CreateWithAcceptor(grpc_server* server, const char* name,
grpc_channel_args* args);

// Do not instantiate directly. Use one of the factory methods above.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider privatizing then?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They need to be public for MakeOrphanable<> and OrphanablePtr<>::reset(). Internally, see go/totw/134 for recommendations on this.

Comment on lines +94 to +96
Chttp2ServerListener* listener_;
grpc_pollset* accepting_pollset_;
grpc_tcp_server_acceptor* acceptor_;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Chttp2ServerListener* listener_;
grpc_pollset* accepting_pollset_;
grpc_tcp_server_acceptor* acceptor_;
Chttp2ServerListener* const listener_;
grpc_pollset* const accepting_pollset_;
grpc_tcp_server_acceptor* const acceptor_;

to emphasize a lack of change in these and that they don't need a default initializer

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

grpc_timer timer_;
grpc_closure on_timeout_;
grpc_closure on_receive_settings_;
grpc_pollset_set* interested_parties_;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
grpc_pollset_set* interested_parties_;
grpc_pollset_set* const interested_parties_;

I think on this also since the PSS is created in the constructor and just gets things add/del over time

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

static void DestroyListener(grpc_server* /*server*/, void* arg,
grpc_closure* destroy_done);

grpc_server* server_;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
grpc_server* server_;
grpc_server* const server_;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


grpc_server* server_;
grpc_tcp_server* tcp_server_;
grpc_channel_args* args_;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
grpc_channel_args* args_;
grpc_channel_args* const args_;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

&self->on_receive_settings_);
grpc_channel_args_destroy(args->args);
self->Ref().release(); // Held by OnTimeout().
GRPC_CHTTP2_REF_TRANSPORT((grpc_chttp2_transport*)transport,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a C-style cast here for a reinterpret_cast above?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was pre-existing code, but I've changed it to use reinterpret_cast<>.

@markdroth markdroth force-pushed the chttp2_server_c++ branch from f39c2d4 to 492889f Compare June 19, 2020 18:32
@markdroth
Copy link
Copy Markdown
Member Author

Green!

@markdroth markdroth merged commit 728d02f into grpc:master Jun 22, 2020
@markdroth markdroth deleted the chttp2_server_c++ branch June 22, 2020 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release notes: no Indicates if PR should not be in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants