Commit Graph

87 Commits

Author SHA1 Message Date
Marten Seemann
3cb5f3e104 optimize packing of STREAM_DATA_BLOCKED frames (#4801)
* refactor the framer to pack both control and STREAM frames

* refactor framer STREAM frame packing logic

* pack STREAM_DATA_BLOCKED in the same packet as the STREAM frame

This makes debugging easier (and is slightly more efficient). In the
pathological case where there is not enough space remaning in the packet
to pack the STREAM_DATA_BLOCKED frame, it is queued for the next packet.

* add an integration test
2025-01-07 12:06:00 +08:00
Marten Seemann
0b9bd3c4de remove redundant bool return value from sendStream.popStreamFrame (#4828) 2024-12-31 13:51:14 +08:00
Marten Seemann
1ccf2c3bff fix accounting for lost RESET_STREAM frames in the send stream (#4804) 2024-12-28 17:09:14 +08:00
Marten Seemann
72a934f375 don't enqueue send stream for sending on duplicate Close calls (#4815) 2024-12-28 16:43:16 +08:00
Marten Seemann
810ef27db5 don't generate empty STREAM frames in the send stream (#4812) 2024-12-28 16:21:48 +08:00
Marten Seemann
40a768e77b flowcontrol: avoid calling time.Now(), pass time as a function parameter (#4731) 2024-11-28 17:46:22 +08:00
sukun
d22d579733 don't cancel streams after shutdown (#4673)
This ensures that `stream.Write` and `stream.Read` return the error code
from connection close, if the stream was closed as a result of
connection close.
2024-09-13 21:47:48 -07:00
Marten Seemann
46fc42d0da only declare send stream completed when RESET_STREAM is acknowledged (#4613) 2024-08-06 16:55:36 -07:00
Marten Seemann
af9fa7a555 queue stream-related control frames in the respective stream (#4610)
* use a separate method for queueing control frames from the streams map

* queue stream-related control frames in the respective stream
2024-08-04 15:42:56 -07:00
Marten Seemann
b8ea5c7981 simplify generation of STREAM_DATA_BLOCKED frames (#4608)
The stream always gets blocked at the current write offset. There's no
need to return this offset from the flow controller.
2024-08-01 13:08:09 -07:00
sukun
8d821f4bc8 mark stream completed when CancelWrite is called after receiving STOP_SENDING (#4605)
* garbage collect stream when CancelWrite is called after receiving STOP_SENDING

* review comments

* Hold lock while checking isNewlyCompleted

---------

Co-authored-by: Marco Munizaga <git@marcopolo.io>
2024-08-01 13:07:06 -07:00
Marten Seemann
42f04d4e02 refactor frame packing to logic to not access the streams map (#4596)
* avoid accessing the streams map when packing stream data

* avoid accessing the streams map when packing flow control frames

* remove streamGetter interface
2024-07-28 12:32:54 -07:00
Marten Seemann
723a188dde remove unneeded stream context cancellation on shutdown (#4535)
The connection already cancels the base context, so we don't need to manually
cancel the stream context (which is derived from the connection context).
2024-05-27 21:43:27 -07:00
Marten Seemann
bff131e546 delay completion of the send stream until the reset error was delivered (#4445)
* delay completion of the send stream until the reset error was delivered

* mark the send stream completed on Close after receiving a STOP_SENDING

* fix handling of STOP_SENDING after Close
2024-04-26 08:31:00 -07:00
Marten Seemann
e310b80cf3 expose the connection tracing ID on the stream context (#4414)
This is especially interesting for HTTP servers: They can now learn
which connection a request was received on.
2024-04-06 07:41:25 -07:00
Marten Seemann
198de32ef6 don't enqueue stream for sending on reordered MAX_STREAM_DATA frames (#4269) 2024-02-02 22:02:13 -08:00
Marten Seemann
fbaa941ea1 protocol: rename VersionNumber to Version (#4295) 2024-01-31 21:57:33 -08:00
Marten Seemann
22411e16d5 utils: switch to standard library min and max functions (#4218)
These functions were added in Go 1.21.
2023-12-27 21:19:13 -08:00
Ferdinand Holzer
27301f791f surface stream error as stream context cancelation cause (#3970)
* send stream: surface error as stream context cancellation cause

* Update send_stream_test.go

Co-authored-by: Marten Seemann <martenseemann@gmail.com>

---------

Co-authored-by: Marten Seemann <martenseemann@gmail.com>
2023-07-19 10:12:01 -07:00
Marten Seemann
e1bcedc78c ackhandler: use a frame handler interface for OnAcked / OnLost of all frame types (#3888) 2023-06-04 13:04:28 -07:00
Marten Seemann
f8d24ef1e9 don't use closures for passing OnLost and OnAcked STREAM frame callbacks (#3833) 2023-06-02 04:14:04 -07:00
Marten Seemann
aa091fe672 remove unneeded tracking variables from streams, optimize memory layout (#3699)
* remove the closedForShutdown boolean in the send stream

* remove the canceledWrite boolean in the send stream

* remove the closedForShutdown boolean in the receive stream

* remove the canceledRead boolean in the receive stream

* remove the resetRemotely boolean in the receive stream

* optimize memory layout of the receiveStream

This brings it down from 200 to 192 bytes.
2023-02-13 13:57:00 -08:00
Marten Seemann
3f9d8feab2 return StreamErrors for all kinds of stream cancelations (#3681)
* fix: return typed errors when after cancelling actions

This is errors.Is'ed by libp2p and the fmt.Errorf messages didn't passed that test:
82315917f7/p2p/transport/quic/stream.go (L23)

* replace StreamErrorAction with a local / remote flag

Co-authored-by: Jorropo <jorropo.pgm@gmail.com>
2023-01-26 12:58:06 -08:00
Marten Seemann
58cedf7a4f rename module, adjust import paths to quic-go/quic-go (#3680) 2023-01-21 19:53:57 -08:00
Marten Seemann
1646fd545e refactor send stream to remove version from constructor 2023-01-18 20:51:59 +13:00
Marten Seemann
2aa71ff76b use a sync.Pool for ackhandler.Frames (#3656) 2023-01-17 23:15:02 -08:00
Toby
5fe9f9bd89 chore: fix multiple typos in comments (#3612)
* chore: fix multiple typos I run into

* Update conn_id_generator_test.go

Co-authored-by: Marten Seemann <martenseemann@gmail.com>

* Update internal/ackhandler/sent_packet_handler_test.go

Co-authored-by: Marten Seemann <martenseemann@gmail.com>

Co-authored-by: Marten Seemann <martenseemann@gmail.com>
2022-11-06 10:59:16 -08:00
Marten Seemann
43bde14cf7 implement generic Min and Max functions 2022-08-10 14:59:05 +02:00
Marten Seemann
8bcb6337d1 protect against concurrent use of Stream.Write (#3381) 2022-04-25 03:58:24 -07:00
Marten Seemann
90727cb41a introduce a quic.StreamError type and use it for stream cancelations 2021-05-01 09:39:52 +07:00
Marten Seemann
f5238bf7b1 move the ApplicationErrorCdoe to the qerr package 2021-05-01 09:38:49 +07:00
Marten Seemann
c27f5a55b3 rename sendStream.handleMaxStreamDataFrame to updateSendWindow 2021-03-12 13:36:23 +08:00
Marten Seemann
82ac6dcf6d rename MaxReceivePacketSize to MaxPacketBufferSize
We use the same buffer size for sending and receiving packets.
2021-03-03 12:00:14 +08:00
Marten Seemann
b5615db612 complete a stream that has frames in flight if it is canceled 2021-01-17 15:54:33 +08:00
Marten Seemann
8752576f26 run gofumpt, enable the gofumpt linter 2020-10-26 09:33:35 +07:00
Marten Seemann
838dd6e81a rename StreamFrame.FinBit to Fin 2020-07-02 16:41:43 +07:00
Marten Seemann
865332015c rename ResetStreamFrame.ByteOffset to FinalSize 2020-07-02 16:41:43 +07:00
Marten Seemann
cc340b2887 rename StreamDataBlockedFrame.DataLimit to MaximumStreamData 2020-07-02 16:41:43 +07:00
Marten Seemann
5466de6565 rename MaxStreamDataFrame.ByteOffset to MaximumStreamData 2020-07-02 16:41:43 +07:00
Marten Seemann
4ff3af3305 gracefully handle concurrent stream writes and cancellations
If the complete slice passed to Stream.Write() is sent out, and the
stream is canceled concurrently (either by calling Stream.CancelWrite()
or by receiving a STOP_SENDING frame), we don't need to return an error
for the Write() call.
2020-06-23 13:07:28 +07:00
Marten Seemann
84f7a9dfdd bundle small writes on streams 2020-05-12 12:36:32 +07:00
Marten Seemann
93cee1e07b stop the deadline timer in Stream.Read and Write 2020-05-03 11:22:58 +07:00
Marten Seemann
9905774c40 make it more likely that a STREAM frame is bundled with the FIN 2020-05-01 10:07:31 +07:00
Marten Seemann
7b1c4e7d80 don't dequeue retransmitted STREAM frames after the stream was canceled 2020-04-17 10:06:42 +07:00
Marten Seemann
599d937966 make Stream.Close() a no-op after the stream was closed for shutdown 2020-03-25 16:48:32 +07:00
Marten Seemann
d93afcac53 cancel the stream context as early as possible 2019-10-30 12:21:38 +07:00
Marten Seemann
6b22f36d82 add the stylecheck linter 2019-09-17 13:50:19 +07:00
Marten Seemann
4cb8bf3101 put STREAM frames back into the pool when they are acknowledged 2019-09-07 16:31:52 +07:00
Marten Seemann
4cfbb2f134 use STREAM frames from the buffer for sending data 2019-09-07 16:31:52 +07:00
Marten Seemann
94ab4e8d24 cancel retransmissions for streams that were reset 2019-08-31 17:37:20 +07:00