Skip to content

Commit faa071d

Browse files
author
Scott Hutton
committed
Support specififying non-default batch size
Provide new interfaces to allow calling `sendmmsg` and `recvmmsg` with a non-default batch size, specified by API clients as a generic constant during compile time. This is presently 1024 on Linux and FreeBSD. The default batch size is increased to 128 on these platforms. Also update to minimally support FreeBSD. Not all Linux features are supported yet.
1 parent d059417 commit faa071d

File tree

2 files changed

+174
-26
lines changed

2 files changed

+174
-26
lines changed

src/lib.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,17 @@ mod imp;
1616
pub use imp::{sync, UdpSocket};
1717
pub mod framed;
1818

19-
/// Number of UDP packets to send/receive at a time
20-
pub const BATCH_SIZE: usize = imp::BATCH_SIZE;
19+
/// Maximum number of UDP packets that can be sent by the `sendmmsg`/`recvmmsg`
20+
/// wrappers. Note that, for supported platforms, the OS caps the batch size at
21+
/// this value, but will not return an error, so this is just a suggested
22+
/// maximum.
23+
///
24+
/// Presently, this is 1024 on Linux an FreeBS, and 1 on platforms that don't
25+
/// support `sendmmsg`/`recvmmsg`
26+
pub const BATCH_SIZE_CAP: usize = imp::BATCH_SIZE_CAP;
27+
28+
/// Default number of UDP packets to send/receive at a time.
29+
pub const DEFAULT_BATCH_SIZE: usize = imp::DEFAULT_BATCH_SIZE;
2130

2231
/// The capabilities a UDP socket suppports on a certain platform
2332
#[derive(Debug)]

0 commit comments

Comments
 (0)