Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: smoltcp-rs/smoltcp
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: eff0e0b90e73
Choose a base ref
...
head repository: smoltcp-rs/smoltcp
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 51b2f18d1165
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Sep 22, 2017

  1. Fix a warning.

    whitequark committed Sep 22, 2017
    Copy the full SHA
    c879b39 View commit details
  2. Keep dispatching packets from a socket as long as there are any.

    Typically, the poll function is used as a part of a larger RTOS.
    If we only dispatch one packet per socket per poll() call,
    then we have to wait for a complete scheduler roundtrip,
    which is potentially a lot of time, and as a result we are
    not filling the peer's window efficiently.
    whitequark committed Sep 22, 2017
    Copy the full SHA
    51b2f18 View commit details
Showing with 35 additions and 34 deletions.
  1. +31 −29 src/iface/ethernet.rs
  2. +4 −5 src/socket/tcp.rs
60 changes: 31 additions & 29 deletions src/iface/ethernet.rs
Original file line number Diff line number Diff line change
@@ -165,36 +165,38 @@ impl<'a, 'b, 'c, DeviceT: Device + 'a> Interface<'a, 'b, 'c, DeviceT> {
let mut limits = self.device.limits();
limits.max_transmission_unit -= EthernetFrame::<&[u8]>::header_len();

for socket in sockets.iter_mut() {
let mut device_result = Ok(());
let socket_result =
match socket {
&mut Socket::Raw(ref mut socket) =>
socket.dispatch(|response| {
device_result = self.dispatch(timestamp, Packet::Raw(response));
device_result
}),
&mut Socket::Udp(ref mut socket) =>
socket.dispatch(|response| {
device_result = self.dispatch(timestamp, Packet::Udp(response));
device_result
}),
&mut Socket::Tcp(ref mut socket) =>
socket.dispatch(timestamp, &limits, |response| {
device_result = self.dispatch(timestamp, Packet::Tcp(response));
device_result
}),
&mut Socket::__Nonexhaustive => unreachable!()
};
match (device_result, socket_result) {
(Err(Error::Unaddressable), _) => break, // no one to transmit to
(Err(Error::Exhausted), _) => break, // nowhere to transmit
(Ok(()), Err(Error::Exhausted)) => (), // nothing to transmit
(Err(err), _) | (_, Err(err)) => {
net_debug!("cannot dispatch egress packet: {}", err);
return Err(err)
'iface: for socket in sockets.iter_mut() {
'socket: loop {
let mut device_result = Ok(());
let socket_result =
match socket {
&mut Socket::Raw(ref mut socket) =>
socket.dispatch(|response| {
device_result = self.dispatch(timestamp, Packet::Raw(response));
device_result
}),
&mut Socket::Udp(ref mut socket) =>
socket.dispatch(|response| {
device_result = self.dispatch(timestamp, Packet::Udp(response));
device_result
}),
&mut Socket::Tcp(ref mut socket) =>
socket.dispatch(timestamp, &limits, |response| {
device_result = self.dispatch(timestamp, Packet::Tcp(response));
device_result
}),
&mut Socket::__Nonexhaustive => unreachable!()
};
match (device_result, socket_result) {
(Err(Error::Exhausted), _) => break 'iface, // nowhere to transmit
(Err(Error::Unaddressable), _) => break 'socket, // no one to transmit to
(Ok(()), Err(Error::Exhausted)) => break 'socket, // nothing to transmit
(_, Err(err)) => {
net_debug!("cannot dispatch egress packet: {}", err);
return Err(err)
}
(_, Ok(())) => ()
}
(Ok(()), Ok(())) => ()
}
}

9 changes: 4 additions & 5 deletions src/socket/tcp.rs
Original file line number Diff line number Diff line change
@@ -627,15 +627,14 @@ impl<'a> TcpSocket<'a> {
// another (stale) SYN.
if !self.may_recv() { return Err(Error::Illegal) }

#[cfg(any(test, feature = "verbose"))]
let old_length = self.rx_buffer.len();
let _old_length = self.rx_buffer.len();
let buffer = self.rx_buffer.dequeue_many(size);
self.remote_seq_no += buffer.len();
if buffer.len() > 0 {
#[cfg(any(test, feature = "verbose"))]
net_trace!("[{}]{}:{}: rx buffer: dequeueing {} octets (now {})",
self.debug_id, self.local_endpoint, self.remote_endpoint,
buffer.len(), old_length - buffer.len());
buffer.len(), _old_length - buffer.len());
}
Ok(buffer)
}
@@ -650,14 +649,14 @@ impl<'a> TcpSocket<'a> {
// See recv() above.
if !self.may_recv() { return Err(Error::Illegal) }

let old_length = self.rx_buffer.len();
let _old_length = self.rx_buffer.len();
let dequeued = self.rx_buffer.dequeue_slice(data);
self.remote_seq_no += dequeued;
if dequeued > 0 {
#[cfg(any(test, feature = "verbose"))]
net_trace!("[{}]{}:{}: rx buffer: dequeueing {} octets (now {})",
self.debug_id, self.local_endpoint, self.remote_endpoint,
dequeued, old_length - dequeued);
dequeued, _old_length - dequeued);
}
Ok(dequeued)
}