Skip to content

Commit

Permalink
Platform flags
Browse files Browse the repository at this point in the history
  • Loading branch information
evanrittenhouse committed Jul 2, 2024
1 parent 07d3266 commit 258e57e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
18 changes: 9 additions & 9 deletions apps/src/bin/quiche-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ fn main() {
let enable_gro = if args.disable_gro {
false
} else {
detect_gro(&socket)
detect_gro(&socket, 1)
};

let max_datagram_size = MAX_DATAGRAM_SIZE;
Expand Down Expand Up @@ -277,8 +277,8 @@ fn main() {

// Lookup a connection based on the packet's connection ID. If there
// is no connection matching, create a new one.
let client = if !clients_ids.contains_key(&hdr.dcid) &&
!clients_ids.contains_key(&conn_id)
let client = if !clients_ids.contains_key(&hdr.dcid)
&& !clients_ids.contains_key(&conn_id)
{
if hdr.ty != quiche::Type::Initial {
error!("Packet is not Initial");
Expand Down Expand Up @@ -447,9 +447,9 @@ fn main() {

// Create a new application protocol session as soon as the QUIC
// connection is established.
if !client.app_proto_selected &&
(client.conn.is_in_early_data() ||
client.conn.is_established())
if !client.app_proto_selected
&& (client.conn.is_in_early_data()
|| client.conn.is_established())
{
// At this stage the ALPN negotiation succeeded and selected a
// single application protocol name. We'll use this to construct
Expand Down Expand Up @@ -561,9 +561,9 @@ fn main() {
}

let max_send_burst =
client.conn.send_quantum().min(client.max_send_burst) /
client.max_datagram_size *
client.max_datagram_size;
client.conn.send_quantum().min(client.max_send_burst)
/ client.max_datagram_size
* client.max_datagram_size;
let mut total_write = 0;
let mut dst_info = None;

Expand Down
6 changes: 2 additions & 4 deletions apps/src/recvfrom.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use dgram::RecvData;

use std::io;

/// For Linux, try to detect if GRO is available. If it is, the
/// [`UdpGroSegment`] socket option will be set on the passed socket.
///
Expand All @@ -28,7 +26,7 @@ pub fn detect_gro(socket: &mio::net::UdpSocket) -> bool {
}

#[cfg(not(target_os = "linux"))]
pub fn detect_gro(socket: &mio::net::UdpSocket, _segment_size: usize) -> bool {
pub fn detect_gro(_socket: &mio::net::UdpSocket, _segment_size: usize) -> bool {
false
}

Expand All @@ -52,7 +50,7 @@ pub fn recv_from(
}

#[cfg(not(target_os = "linux"))]
fn recv_from(
pub fn recv_from(
socket: &mio::net::UdpSocket, buf: &mut [u8],
) -> std::io::Result<RecvData> {
match socket.recv_from(buf) {
Expand Down
4 changes: 3 additions & 1 deletion dgram/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
pub mod socket_setup;
#[cfg(target_os = "linux")]
pub mod sync;
mod syscalls;
#[cfg(feature = "async")]
pub mod tokio;

use std::net::SocketAddr;
#[cfg(target_os = "linux")]
use std::time::Instant;
use std::time::SystemTime;

Expand All @@ -13,7 +15,6 @@ use libc::in_pktinfo;
use libc::sockaddr_in;
use libc::sockaddr_in6;
use nix::sys::socket::ControlMessageOwned;
use nix::sys::socket::MsgFlags;

/// Settings for handling control messages when sending data.
#[cfg(target_os = "linux")]
Expand Down Expand Up @@ -45,6 +46,7 @@ pub struct RecvMsgSettings<'c> {
pub cmsg_space: &'c mut Vec<u8>,
}

#[cfg(target_os = "linux")]
impl<'c> RecvMsgSettings<'c> {
// Convenience to avoid forcing a specific version of nix
pub fn new(store_cmsgs: bool, cmsg_space: &'c mut Vec<u8>) -> Self {
Expand Down
4 changes: 1 addition & 3 deletions dgram/src/syscalls.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use std::time::SystemTime;

#[cfg(target_os = "linux")]
mod linux {
pub(super) use super::super::linux_imports::*;
pub(super) use std::os::fd::AsFd;
pub(super) use std::time::Instant;

pub(crate) type SyscallResult<T> = std::result::Result<T, Errno>;
Expand All @@ -17,6 +14,7 @@ mod linux {
#[cfg(target_os = "linux")]
use linux::*;

#[cfg(target_os = "linux")]
fn raw_send_to(
fd: &impl AsFd, send_buf: &[u8], cmsgs: &[ControlMessage],
msg_flags: MsgFlags, client_addr: Option<SockaddrStorage>,
Expand Down

0 comments on commit 258e57e

Please sign in to comment.