Revert "Keep dispatching packets from a socket as long as there are any."
This reverts commit 51b2f18d1165bf7257de8894df101299cc93b094. There's no throughput difference so far as I could measure, but this greatly increases worst-case latency. At some later point we could perhaps pass a deadline to the poll function, but for now reverting this is simple enough.v0.7.x
parent
05a480575c
commit
a1b2605af7
|
@ -165,38 +165,36 @@ 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();
|
||||
|
||||
'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(())) => ()
|
||||
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)
|
||||
}
|
||||
(Ok(()), Ok(())) => ()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue