mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
hoist net thread exhaustion check to before we check the poll interval
This commit is contained in:
parent
fd2aa438c0
commit
2a4dd67564
1 changed files with 20 additions and 13 deletions
|
|
@ -1580,17 +1580,17 @@ fn xmain() -> ! {
|
||||||
}
|
}
|
||||||
|
|
||||||
// establish our next check-up interval
|
// establish our next check-up interval
|
||||||
let timestamp = Instant::from_millis(timer.elapsed_ms() as i64);
|
if delay_threads.load(Ordering::SeqCst) < MAX_DELAY_THREADS {
|
||||||
if let Some(delay) = iface.poll_delay(&sockets, timestamp) {
|
let timestamp = Instant::from_millis(timer.elapsed_ms() as i64);
|
||||||
let delay_ms = delay.total_millis();
|
if let Some(delay) = iface.poll_delay(&sockets, timestamp) {
|
||||||
if delay_ms < 2 {
|
let delay_ms = delay.total_millis();
|
||||||
xous::try_send_message(
|
if delay_ms < 2 {
|
||||||
net_conn,
|
xous::try_send_message(
|
||||||
Message::new_scalar(Opcode::NetPump.to_usize().unwrap(), 0, 0, 0, 0),
|
net_conn,
|
||||||
)
|
Message::new_scalar(Opcode::NetPump.to_usize().unwrap(), 0, 0, 0, 0),
|
||||||
.ok();
|
)
|
||||||
} else {
|
.ok();
|
||||||
if delay_threads.load(Ordering::SeqCst) < MAX_DELAY_THREADS {
|
} else {
|
||||||
let prev_count = delay_threads.fetch_add(1, Ordering::SeqCst);
|
let prev_count = delay_threads.fetch_add(1, Ordering::SeqCst);
|
||||||
log::trace!(
|
log::trace!(
|
||||||
"spawning checkup thread for {}ms. New total threads: {}",
|
"spawning checkup thread for {}ms. New total threads: {}",
|
||||||
|
|
@ -1621,10 +1621,17 @@ fn xmain() -> ! {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
log::warn!("Could not queue delay of {}ms in net stack due to thread exhaustion.", delay_ms);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
log::warn!("Thread pool exhausted; deferring creation of new poll helpers");
|
||||||
|
// fire off another pump message. This will cause the network server to effectively
|
||||||
|
// busy-wait until the thread pool starts to clear out.
|
||||||
|
xous::try_send_message(
|
||||||
|
net_conn,
|
||||||
|
Message::new_scalar(Opcode::NetPump.to_usize().unwrap(), 0, 0, 0, 0),
|
||||||
|
)
|
||||||
|
.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(Opcode::GetIpv4Config) => {
|
Some(Opcode::GetIpv4Config) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue