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

Provide access to connection Waker to datagram Endpoint #1598

Merged
merged 2 commits into from
Jan 6, 2023

Conversation

Mark-Simulacrum
Copy link
Collaborator

Description of changes:

This waker allows datagram receiver/senders to wake up the connection,
which will re-poll the connection for interest in sending. When
implementing a custom datagram Receiver which wants to schedule a reply
datagram, this Waker or something like it is necessary to indirect the
wakeup of the connection and subsequent call to the Sender's
on_transmit.

This is a waker and not a connection handle for two reasons:

  • The Waker does not directly extend the lifetime of the connection,
    which avoids keeping the connection data indefinitely alive for cases
    where the Waker is stored within the Sender or Receiver.
  • s2n-quic calling datagram Endpoint::new_connection doesn't have easy
    access to an application handle to the connection.

Note that applications still must retain the Connection or a Handle to
it: when the last application handle closes, the connection is also
closed, even if there are Wakers for that connection still around.

In practice this seems useful as it allows bounding the number of active
connections with an Endpoint and the extra waste of connection handles
is unlikely to be significant.

Call-outs:

  • The choice to expose a Waker might not have any precedent in s2n-quic -- not sure if there's other APIs that do that.
  • The first commit removes Default impls for ConnectionInfo and PreConnectionInfo. This is intended to avoid needing to provide a default for the Waker field, which doesn't seem like it has an obvious default (a no-op waker, perhaps?). I believe these impls exist for construction outside of s2n-quic-owned crates as a way to construct despite the non_exhaustive annotations, but I'm not sure they are actually a good idea. Open to alternatives here.

This is sort of further iterating on options around #1565 -- it's not really directly related but provides another way of bypassing the normal structure.

Testing:

No dedicated tests are added. I'm not sure if there are tests related to connection wakeup & polling today -- it seems like the functionality added here would need to build essentially a full Endpoint to test it well. Happy to add that if pointed to some existing framework for it.

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

It doesn't make much sense for there to be default values for these, and
as more fields are added a Default may become awkward or impossible.

This removes the ability to construct these outside of s2n-quic, but
doing so is awkward if there's no reasonable default value for some of
the fields. (The next commit adds such a value for ConnectionInfo).
This waker allows datagram receiver/senders to wake up the connection,
which will re-poll the connection for interest in sending. When
implementing a custom datagram Receiver which wants to schedule a reply
datagram, this Waker or something like it is necessary to indirect the
wakeup of the connection and subsequent call to the Sender's
on_transmit.

This is a waker and not a connection handle for two reasons:

* The Waker does not directly extend the lifetime of the connection,
  which avoids keeping the connection data indefinitely alive for cases
  where the Waker is stored within the Sender or Receiver.
* s2n-quic calling datagram Endpoint::new_connection doesn't have easy
  access to an application handle to the connection.

Note that applications still must retain the Connection or a Handle to
it: when the last application handle closes, the connection is also
closed, even if there are Wakers for that connection still around.

In practice this seems useful as it allows bounding the number of active
connections with an Endpoint and the extra waste of connection handles
is unlikely to be significant.
@camshaft camshaft merged commit 37ad090 into aws:main Jan 6, 2023
@Mark-Simulacrum Mark-Simulacrum deleted the datagram-waker branch January 6, 2023 20:08
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.

2 participants