};
loop {
- if let Some(ret) = {
+ if let Some(req) = {
if ! downbound.is_empty() {
outstanding.pop_front()
} else if let Some((i,_)) = outstanding.iter().enumerate().find({
None
}
} {
+ let mut build: FrameQueueBuf = default();
+
+ loop {
+ let next = if let Some(n) = downbound.peek_front() { n }
+ else { break };
+ // Don't add 1 for the ESC since we will strip one
+ if build.len() + next.len() >= ic.max_batch_down.sat() { break }
+ build.esc_push(downbound.pop_front().unwrap());
+ }
+ if ! build.is_empty() {
+ // skip leading ESC
+ build.advance(1);
+ }
+
let response = WebResponse {
- data: Ok(default()),
+ data: Ok(build),
warnings: default(),
};
- try_send_response(ret.reply_to, response);
+ try_send_response(req.reply_to, response);
+ }
+
+ let max = usize::saturating_mul(
+ ic.max_requests_outstanding.sat(),
+ ic.max_batch_down.sat(),
+ ).saturating_add(1 /* one boundary SLIP_ESC which we'll trim */);
+
+ while downbound.total_len() > max {
+ let _ = downbound.pop_front();
}
select!{
biased;
-
- // xxx something something routed something
+ data = routed.recv() =>
+ {
+ let data = data.ok_or_else(|| anyhow!("routers shut down!"))?;
+ downbound.push_back(data.data);
+ },
req = web.recv() =>
{