You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CP: Allow the app to react when app-provided buffer is insufficient (#5347)
* Allow the app to react when app-provided buffer is insufficient (#5313)
* Notify the app when not enough receive buffer is present
* Remove constrains on flow control
* Add test
* Update documentation
Copy file name to clipboardExpand all lines: docs/Streams.md
+9-2Lines changed: 9 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -170,9 +170,16 @@ The application regains full ownership of a buffer after it get a receive notifi
170
170
If the application accepts all the buffer's bytes **inline** from the receive notification, by returning `QUIC_STATUS_SUCCESS` and setting `TotalBufferLength` appropriately,
171
171
it can free or reuse the buffer while in the notification handler.
172
172
173
+
If more data is received on the stream than buffer space was provided by the application, MsQuic will emit a `QUIC_STREAM_EVENT_RECEIVE_BUFFER_NEEDED` notification.
174
+
When receiving this notification, the app can:
175
+
- provide a sufficient amount of buffer space **inline** from the callback using [`StreamProvideReceiveBuffers`](./api/StreamProvideReceiveBuffers.md)
176
+
- shutdown the stream receive direction of the stream **inline** by calling [`StreamShutdown`](api/StreamShutdown.md) with the `QUIC_STREAM_SHUTDOWN_FLAG_INLINE` flag
177
+
178
+
When the callback returns, if the stream has not been shutdown and a sufficient amount of memory is not available, the connection is closed abortively.
179
+
Providing memory in reaction to `QUIC_STREAM_EVENT_RECEIVE_BUFFER_NEEDED` can impact performances negatively.
180
+
173
181
For an application, providing receive buffers can improve performances by saving a copy: MsQuic places data directly in its final destination.
174
-
However, it comes with a large complexity overhead for the application, both in term of memory management and in term of flow control:
175
-
an application providing too much or too little buffer space could negatively impact performances.
182
+
However, it comes with a large complexity overhead for the application, both in term of memory management and in term of flow control: an application providing too much or too little buffer space could negatively impact performances.
176
183
Because of this, app-owned mode should be considered an advanced feature and used with caution.
177
184
178
185
> **Note**: As of now, app-owned buffer mode is not compatible with multi-receive mode. If multi-receive mode is enabled for the connection and app-owned mode is enabled on a stream, that specific stream will behave as if multi-receive mode was disabled. This may change in the future.
@@ -261,6 +269,23 @@ The application can supply an error code in this struct to be sent to the peer.
261
269
262
270
The application can set this 62 bit error code to communicate to the peer about the stream shutdown, which is received by the peer as a `QUIC_STREAM_EVENT_PEER_SEND_ABORTED` event on its stream object.
263
271
272
+
## QUIC_STREAM_EVENT_RECEIVE_BUFFER_NEEDED
273
+
274
+
This event is raised when a stream using app-provided receive buffers runs out of receive buffer space.
275
+
276
+
`BufferLengthNeeded`
277
+
278
+
The number of bytes MsQuic needs to be able to store the received data.
279
+
280
+
When receiving this notification, the app can:
281
+
- provide a sufficient amount of buffer space **inline** from the callback using [`StreamProvideReceiveBuffers`](./StreamProvideReceiveBuffers.md)
282
+
- shutdown the stream receive direction of the stream **inline** by calling [`StreamShutdown`](./StreamShutdown.md)
283
+
with the `QUIC_STREAM_SHUTDOWN_FLAG_INLINE` flag
284
+
285
+
Otherwise, the connection will be closed abortively.
286
+
287
+
See [App-Owned Buffer Mode](../Streams.md#App-Owned_Buffer_Mode) for further details.
0 commit comments