quic: extract transport logic from Application to Session#64127
quic: extract transport logic from Application to Session#64127pimterry wants to merge 1 commit into
Conversation
|
Review requested:
|
Two small fixes notably included: - Fixed a SendPendingData but where datagrams would stall on an idle connection in the nwrite == 0 branch. - Check is_destroyed() after StreamCommit, since it calls JS callbacks which could destroy the session. Signed-off-by: Tim Perry <pimterry@gmail.com>
19197f6 to
5fdb7e8
Compare
| // A block of pending outbound stream data, passed between the application | ||
| // layer (which fills it via GetStreamData) and the send pump (which hands | ||
| // it to ngtcp2_conn_writev_stream and commits the accepted length). | ||
| struct StreamData final { |
There was a problem hiding this comment.
If at all possible, I think this should likely be moved into class Session (e.g. Session::StreamData). It makes more sense as a child class than it's own top-level.
| // The stream identifier. If this is a negative value then no stream is | ||
| // identified. | ||
| stream_id id = -1; | ||
| int fin = 0; |
There was a problem hiding this comment.
If we're changing things anyway, making this a bool would probably make sense.
| stream_id id = -1; | ||
| int fin = 0; | ||
| ngtcp2_vec data[kMaxVectorCount]{}; | ||
| BaseObjectPtr<Stream> stream; |
There was a problem hiding this comment.
I wonder if we can drop id and just rely on stream.
| // If < 0 is returned, either NGTCP2_ERR_WRITE_MORE or a fatal error is | ||
| // returned; the caller must check. If > 0 is returned, the packet is done |
There was a problem hiding this comment.
| // If < 0 is returned, either NGTCP2_ERR_WRITE_MORE or a fatal error is | |
| // returned; the caller must check. If > 0 is returned, the packet is done | |
| // If a negative value is returned, it is either NGTCP2_ERR_WRITE_MORE or | |
| // fatal error; the caller must check. If > 0 is returned, the packet is done |
| // the session, encapsulating ngtcp2 transport details here. | ||
|
|
||
| // Open a unidirectional stream, setting *id on success, or returning false | ||
| bool OpenUni(stream_id* id); |
There was a problem hiding this comment.
Prefer to avoid abbreviating. s/OpenUni/OpenUnidirectionalStream
|
|
||
| void ExtendMaxStreams(Direction direction, uint64_t max); | ||
|
|
||
| // Signal that we've consumed $len bytes on stream $id to update flow control |
There was a problem hiding this comment.
| // Signal that we've consumed $len bytes on stream $id to update flow control | |
| // Signal that we've consumed `len` bytes on stream $id to update flow control |
| PopPendingDatagram(); | ||
| } else { | ||
| Debug(this, "Datagram %" PRIu64 " not accepted into packet", dg.id); | ||
| } |
There was a problem hiding this comment.
Hmm... I think this has a bug. If dg_nwrite is positive, it appears to fall-through to the default: case below?
There was a problem hiding this comment.
(To be fair, I don't think it's a new bug ;-) ...)
Extracting out some standalone refactoring from #63995 for easier review while we keep debating the API. I think this is a helpful refactoring generally, but especially in a world where we're restructuring
Application.This shrinks the application layer by moving generic QUIC logic that will be used by all implementations into the Session itself, and makes the Session act as a clean interface over ngtcp2 - so that the Application exclusively uses Session methods for all connection manipulation, instead of managing ngtcp2 directly. This gives a cleaner split between the low-level QUIC behaviour and the per-application-protocol layer.
There's two small fixes notably included in the migration, contained within the moved code: