1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-11-22 16:02:34 +03:00
Commit Graph

7 Commits

Author SHA1 Message Date
Matt Joras
d3e8fe246a Convert IntervalSet from throwing exceptions to using CHECKs with Expected error handling
Summary:
This commit converts IntervalSet to use CHECKs instead of throwing exceptions and provides safe tryInsert methods that return quic::Expected for error handling.

**Core Problem Solved:**
IntervalSet was throwing `std::invalid_argument` exceptions in two scenarios:
1. When constructing an Interval with `start > end`
2. When interval bounds exceed the maximum allowed value

This change eliminates exceptions in favor of CHECKs (for internal validation) and Expected-based error handling (for caller validation).

**Implementation Details:**

**1. IntervalSet Core Changes:**
- Replaced `throw std::invalid_argument` with `CHECK_LE` in Interval constructor
- Replaced `throw std::invalid_argument` with `CHECK_LE` in `insert(start, end)`
- Added `IntervalSetError` enum for error classification
- Added `folly::Expected` include

**2. Safe API Layer:**
- Added `tryInsert(interval)` method returning `Expected<Unit, IntervalSetError>`
- Added `tryInsert(start, end)` method with pre-validation
- Added `tryInsert(point)` method
- Added static `Interval::tryCreate()` method for safe interval construction

**3. Updated  Code:**
- **QuicWriteCodec.cpp**: Updated `fillFrameWithPacketReceiveTimestamps` to use `tryInsert`
  - Returns `QuicError` if interval validation fails
  - Maintains existing error handling patterns
- **QuicTransportFunctions.cpp**: Updated `implicitAckCryptoStream` to use `tryInsert`
  - Logs errors and continues processing other packets
  - Robust error handling for crypto stream implicit acks

Reviewed By: kvtsoy

Differential Revision: D76792362

fbshipit-source-id: 5bd7c22e69a91d60cc41c603a1f2380893f4c8a0
2025-08-19 10:47:24 -07:00
Aman Sharma
41667ff7c5 Change Buf -> BufPtr and RawBuf -> Buf
Summary:
Previously,
* `RawBuf` was a typealias for `std::unique_ptr<folly::IOBuf>`
* `Buf` was a typealias for `folly::IOBuf`

In this diff,
* `Buf` is a typealias for `folly::IOBuf`
* `BufPtr` is a typealias for `std::unique_ptr<folly::IOBuf>`

Reviewed By: hanidamlaj

Differential Revision: D73206576

fbshipit-source-id: 454bf6ccfce3d6571e5e931889263ed98cc24af3
2025-04-21 20:14:02 -07:00
Aman Sharma
4de0df68c7 Functionality to remove data in readBuffer starting at offset
Summary: With reliable resets, we don't want to drop the entire `readBuffer`. Rather, we want to discard data that doesn't have to be reliably delivered.

Reviewed By: jbeshay

Differential Revision: D67766227

fbshipit-source-id: f8b0d1a51db3b84ad549c09021a0c1490f2b1c23
2025-01-07 13:33:37 -08:00
Aman Sharma
132a6b821c Make an allBytesAckedTill function
Summary: With reliable resets, we can only safely close a stream once all bytes until the reliable size have been ACKed by the peer. We're going to use this helper function to aid us in that.

Reviewed By: mjoras

Differential Revision: D66781309

fbshipit-source-id: 66094929b53c9eab3185e05b8a033b112577b60b
2024-12-10 16:39:37 -08:00
Aman Sharma
c59b3bf651 Change removeAfter offset to removeStartingAt
Summary: Some of the logic in subsequent diffs becomes a little easier if we change the "remove after" to "remove starting at", because we don't have to subtract 1 off of the reliable reset offset before passing it into these functions.

Reviewed By: jbeshay

Differential Revision: D66275065

fbshipit-source-id: 54a92dde7b23d09a1f8f59bfeabbec4fb149518a
2024-11-27 13:03:27 -08:00
Aman Sharma
f72ceb80ca Functionality for removals after specified offset [part 2]
Summary: When we send a reliable reset, we don't want to reset the entire `writeBufMeta`, `retransmissionBufMetas`, and `lossBufMetas`. We only want to reset them up to the `reliableSize`. I'm making helper functions to do this.

Reviewed By: jbeshay

Differential Revision: D66120070

fbshipit-source-id: 588db71b846247a9a2316f46ca6c6caef9246ba9
2024-11-20 17:17:46 -08:00
Aman Sharma
fb2c43078d Functionality for removals after specified offset [part 1]
Summary: When we send a reliable reset, we don't want to reset the entire `writeBuffer`, `retransmissionBuffer`, `lossBuffer`, and `pendingWrites`. We only want to reset them up to the `reliableSize`. I'm making helper functions to do this.

Reviewed By: jbeshay

Differential Revision: D64907982

fbshipit-source-id: ad9256638f5e0cb5f7c038e2c9d12253a7776b2d
2024-11-20 11:29:38 -08:00