Skip to content

Requeue a datagram when it can't be sent - #161

Open
holleman wants to merge 2 commits into
apple:mainfrom
holleman:datagram-requeue
Open

holleman wants to merge 2 commits into
apple:mainfrom
holleman:datagram-requeue

Conversation

@holleman

Copy link
Copy Markdown
Contributor

Make sure to requeue a datagram and let the caller know that it could not be sent. An example of this is when a pending ack has consumed space before the datagram.

Make sure to requeue a datagram and let the caller know that it
could not be sent.  An example of this is when a pending ack has
consumed space before the datagram.
@holleman holleman added the 🔨 semver/patch No public API change. label Sep 18, 2026
connection.log.datapath(
"datagram for flow \(firstFlowID.debugDescription) does not fit \(roomBeforeWriting) free bytes; requeueing"
)
datagrams.prepend(frame: datagramFrame)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Okay, so here we just add the frame back in and frame array and that way pending items knows to build a packet here for that flow again, correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, redo it. If it was a pending ack it would have gone out and then when we return we can pick up an empty packet and then send the datagram.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In general, this seems like a good idea to not drop locally -- but does this cause a case where not being able to send a particular datagram to be at the front of the list forever and if it is too big to fit, no other datagrams can send?

@agnosticdev agnosticdev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you!

connection.log.error("Unable to write datagram for flow \(firstFlowID)")
// Requeue rather than finalize and pass up the error so a retry is possible
connection.log.datapath(
"datagram for flow \(firstFlowID.debugDescription) does not fit \(roomBeforeWriting) free bytes; requeueing"

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
"datagram for flow \(firstFlowID.debugDescription) does not fit \(roomBeforeWriting) free bytes; requeueing"
"Datagram for flow \(firstFlowID.debugDescription) does not fit \(roomBeforeWriting) free bytes; requeueing"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done!

A datagram too big for the flow should be dropped and prevent any
head-of-line blocking.  That works, but add a test to ensure that
as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants