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

Apple Network Framework Socket Changes #662

Open
wants to merge 88 commits into
base: grand_dispatch_queue
Choose a base branch
from

Conversation

sbSteveK
Copy link
Contributor

Apple Network Framework socket integration

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link
Contributor

@bretambrose bretambrose left a comment

Choose a reason for hiding this comment

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

I haven't looked at nw_socket.c yet. I'm concerned about larger issues implied by the changes outside that file first.


Upon a connection being established, the new socket (either as the result of a `connect()` or `start_accept()` call)
will not be attached to any event loops. It is your responsibility to register it with an event loop to begin receiving
notifications.


#### V-Table
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this documentation necessary in the public readme? A giant list of functions feels like a distraction

Copy link
Contributor

Choose a reason for hiding this comment

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

It would help with anybody who would like to extend the socket implementation. Also, we listed the vtable for other classes as well.

README.md Outdated Show resolved Hide resolved

For LOCAL (Unix Domain Sockets or Named Pipes), the socket will be immediately ready for use upon a successful return.

int aws_socket_bind(struct aws_socket *socket, struct aws_socket_endpoint *local_endpoint);

Binds the socket to a local address. In UDP mode, the socket is ready for `aws_socket_read()` operations. In connection oriented
modes, you still must call `aws_socket_listen()` and `aws_socket_start_accept()` before using the socket.
Binds the socket to a local address. In UDP mode, the socket is ready for `aws_socket_read()` operations. In connection oriented
Copy link
Contributor

Choose a reason for hiding this comment

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

This if-else conditional behavior bothers me. What happens if you call aws_socket_listen on a bound UDP socket?

Copy link
Contributor

Choose a reason for hiding this comment

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

aws_socket_listen would fail with AWS_IO_SOCKET_ILLEGAL_OPERATION_FOR_STATE on a bounded UDP socket.

return aws_event_loop_thread_is_callers_thread(channel->loop);
// As aws_event_loop is not ref-counted, it is possible that the socket read/write callback get triggered after
// the event loop is released, ignore the function call here.
if (channel && channel->loop) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is alarming. I would like to know a lot more about how this is possible: how can you have a channel still alive while its event loop is not?

@@ -200,6 +200,9 @@ static int s_tls_common_tester_clean_up(struct tls_common_tester *tester) {

aws_condition_variable_clean_up(&tester->condition_variable);
aws_mutex_clean_up(&tester->mutex);
// wait for socket ref count drop and released
aws_thread_current_sleep(1000000000);
Copy link
Contributor

Choose a reason for hiding this comment

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

Doing this (presumably to prevent memory-still-in-use test failures) is the sign of a much larger problem that could easily make life terrible for us: we don't understand, can't reason about, and/or can't tightly control an async cleanup/shutdown process. We should talk about this with Mike.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants