File tree Expand file tree Collapse file tree 3 files changed +48
-1
lines changed
Expand file tree Collapse file tree 3 files changed +48
-1
lines changed Original file line number Diff line number Diff line change 11[package ]
22name = " quinn-udp"
3- version = " 0.6.0 "
3+ version = " 0.5.13 " # FIXME: Temporary Firefox vendoring hack. Revert.
44edition.workspace = true
55rust-version.workspace = true
66license.workspace = true
@@ -19,6 +19,7 @@ tracing-log = ["tracing/log"]
1919log = [" dep:log" ]
2020# Use private Apple APIs to send multiple packets in a single syscall.
2121fast-apple-datapath = []
22+ direct-log = [] # FIXME: Temporary Firefox vendoring hack. Revert.
2223
2324[dependencies ]
2425libc = " 0.2.175"
Original file line number Diff line number Diff line change @@ -258,6 +258,31 @@ impl EcnCodepoint {
258258 }
259259}
260260
261+ /// Pre-sets Apple fast path availability from external code.
262+ ///
263+ /// This allows embedders (e.g., Firefox) to perform the `sendmsg_x`/`recvmsg_x`
264+ /// probe in C++ and pass the result to quinn-udp, avoiding socket creation and
265+ /// forking in Rust code.
266+ ///
267+ /// Must be called before any socket operations that would trigger the internal
268+ /// probe. Returns the effective value after the set attempt: if already
269+ /// initialized, returns the existing value; otherwise returns the newly set value.
270+ ///
271+ /// # Example
272+ ///
273+ /// ```c
274+ /// // In C++ code:
275+ /// extern "C" bool quinn_udp_set_apple_fast_path_available(bool available);
276+ ///
277+ /// bool probeResult = PerformAppleFastDatapathProbe();
278+ /// bool effective = quinn_udp_set_apple_fast_path_available(probeResult);
279+ /// ```
280+ #[ cfg( apple_fast) ]
281+ #[ no_mangle]
282+ pub extern "C" fn quinn_udp_set_apple_fast_path_available ( available : bool ) -> bool {
283+ imp:: set_apple_fast_path_available ( available)
284+ }
285+
261286#[ cfg( test) ]
262287mod tests {
263288 use std:: net:: Ipv4Addr ;
Original file line number Diff line number Diff line change @@ -1228,6 +1228,19 @@ mod probe {
12281228 * FAST_PATH_AVAILABLE . get_or_init ( run_probe)
12291229 }
12301230
1231+ /// Pre-sets the fast path availability from external code.
1232+ ///
1233+ /// This allows embedders to perform the probe externally (e.g., in C++ code)
1234+ /// and pass the result to quinn-udp. Useful when the Rust code is not allowed
1235+ /// to create sockets or fork processes.
1236+ ///
1237+ /// Returns the effective value after the set attempt. If the value was already
1238+ /// initialized, returns the existing value; otherwise returns the newly set value.
1239+ pub ( super ) fn set_fast_path_available ( available : bool ) -> bool {
1240+ let _ = FAST_PATH_AVAILABLE . set ( available) ;
1241+ is_fast_path_available ( )
1242+ }
1243+
12311244 /// Runs the probe by forking a child process to test the private APIs.
12321245 fn run_probe ( ) -> bool {
12331246 match probe ( fast_path_available) {
@@ -1371,3 +1384,11 @@ mod probe {
13711384 }
13721385 }
13731386}
1387+
1388+ /// Pre-sets Apple fast path availability from external code.
1389+ ///
1390+ /// See [`probe::set_fast_path_available`] for details.
1391+ #[ cfg( apple_fast) ]
1392+ pub ( crate ) fn set_apple_fast_path_available ( available : bool ) -> bool {
1393+ probe:: set_fast_path_available ( available)
1394+ }
You can’t perform that action at this time.
0 commit comments