Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make grpc_tcp_listener private. #4680

Merged
merged 14 commits into from
Jan 25, 2016
Merged

Conversation

daniel-j-born
Copy link
Contributor

grpc_tcp_listener is now completely private to the implementation. It seems its
only use was to return the port, so add_port() now returns this instead.

Made the port_index stable: adding more ports doesn't affect the indices of
existing ports. (Previously, every add_port() would should shift them all by
one.)

grpc_tcp_server is now refcounted.

grpc_tcp_server_cb passes a pointer to the server and gives the callee a ref. It
also gives the indices of the accepting server fd.

I wasn't able to test (or even compile) any of the windows code. It looks like
some combination of docker, run_tests.py, and Jenkins would do this, but I was
wondering if there is a recommended way for a Linux user.

Based on discussion in #4555

@grpc-kokoro
Copy link

Can one of the admins verify this patch?

1 similar comment
@grpc-kokoro
Copy link

Can one of the admins verify this patch?

@ctiller
Copy link
Member

ctiller commented Jan 12, 2016

The Windows code needs a Windows machine, unfortunately (as does some of the Mac code).

Build results are here:
https://grpc-testing.appspot.com/job/gRPC_pull_requests/5080/config=dbg,language=c,platform=windows/console


Review status: 0 of 9 files reviewed at latest revision, 6 unresolved discussions, some commit checks failed.


src/core/iomgr/tcp_server.h, line 44 [r1] (raw file):
If you have six arguments you probably missed one.

Let's bundle from_server, port_index, fd_index into a struct perhaps?


src/core/iomgr/tcp_server.h, line 73 [r1] (raw file):
grpc_tcp_server_port_fd_count


src/core/iomgr/tcp_server.h, line 79 [r1] (raw file):
grpc_tcp_server_port_fd


src/core/iomgr/tcp_server.h, line 86 [r1] (raw file):
I'd prefer to see the shutdown complete closure be a set-once thing.

Either it's always passed into the construction function, or it's always passed into the shutdown function.

The previous API would work if grpc_tcp_server_destroy were renamed grpc_tcp_server_shutdown and released an implicit ref to the server.


src/core/iomgr/tcp_server_posix.c, line 215 [r1] (raw file):
Style guide: static functions are not prefixed with grpc_

https://github.com/grpc/grpc/blob/master/doc/c-style-guide.md


src/core/iomgr/tcp_server_posix.c, line 366 [r1] (raw file):
Prefer passing a borrowed reference here and letting receivers ref if they need to keep the pointer.


Comments from the review on Reviewable.io

@daniel-j-born
Copy link
Contributor Author

It looks like my best option to is check those Jenkins logs after I push.


Review status: 0 of 9 files reviewed at latest revision, 6 unresolved discussions, some commit checks failed.


src/core/iomgr/tcp_server.h, line 44 [r1] (raw file):
Done.


src/core/iomgr/tcp_server.h, line 73 [r1] (raw file):
Done.


src/core/iomgr/tcp_server.h, line 79 [r1] (raw file):
Done.


src/core/iomgr/tcp_server.h, line 86 [r1] (raw file):
The problem with a grpc_tcp_server_shutdown(shutdown_cb) is that the caller never knows which shutdown call drops the refcount to zero, so every call must pass the shutdown_cb. Basically, every call to unref (or anything that effectively unrefs) would have to pass the shutdown_cb. I want to avoid this.

I made it so it can only be passed to create().


src/core/iomgr/tcp_server_posix.c, line 215 [r1] (raw file):
Done.


src/core/iomgr/tcp_server_posix.c, line 366 [r1] (raw file):
This is fine as long as on_accept_cb is called synchronously. It currently is, so I made this change.


Comments from the review on Reviewable.io

@daniel-j-born
Copy link
Contributor Author

The only thing left that might be a test failure is tests.bins/asan/generic_async_streaming_ping_pong_test, but this is unlikely to be related to my code. It looks like a pre-existing test failure.

tcp_server_posix_test illustrates how this can be used to implement a
weak referencing mechanism.
@daniel-j-born
Copy link
Contributor Author

There were some conflicts with master, so I did the merge. Craig, want to take a look at this and #4745 ?

@daniel-j-born
Copy link
Contributor Author

I merged #4745 into this. It was just one extra commit (9c12bc2) to add the shutdown_starting callbacks.

@jboeuf
Copy link
Contributor

jboeuf commented Jan 25, 2016

@ctiller, is there something this PR or should we merge it? Thanks!

@ctiller
Copy link
Member

ctiller commented Jan 25, 2016

Hey - we've had some testing infrastructure madness the past week. Let me
take a peek this morning.

On Mon, Jan 25, 2016 at 10:00 AM jboeuf notifications@github.com wrote:

@ctiller https://github.com/ctiller, is there something this PR or
should we merge it? Thanks!


Reply to this email directly or view it on GitHub
#4680 (comment).

@jboeuf
Copy link
Contributor

jboeuf commented Jan 25, 2016

Awesome. thanks!

ctiller added a commit that referenced this pull request Jan 25, 2016
@ctiller ctiller merged commit 15c8ec3 into grpc:master Jan 25, 2016
@daniel-j-born daniel-j-born deleted the tcp_listener branch January 25, 2016 20:35
@lock lock bot locked as resolved and limited conversation to collaborators Jan 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants