Skip to content

Commit 9a74ce7

Browse files
committed
Change net sleeping logic
1 parent 4f88dcd commit 9a74ce7

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

pixie-uefi/src/os/net/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,21 +126,22 @@ pub(super) fn init() {
126126

127127
Executor::spawn("[net_poll]", async {
128128
loop {
129+
const MIN_WAIT_US: u64 = 1000;
129130
let wait = poll();
130131
match wait {
131132
None => {
132133
Executor::wait_for_interrupt().await;
133134
}
134-
Some(wait) if wait < 200 => {
135+
Some(wait) if wait < MIN_WAIT_US => {
135136
// Immediately wake if we want call poll() again in a very short time.
136137
Executor::sched_yield().await;
137138
}
138139
Some(wait) => {
139140
futures::future::select(
140141
Executor::wait_for_interrupt(),
141-
// Halve the waiting time, to try to ensure that we don't exceed the suggested
142-
// waiting time.
143-
Executor::sleep(Duration::from_micros(wait / 2)),
142+
// Reduce the waiting time, to try to ensure that we don't exceed the
143+
// suggested waiting time.
144+
Executor::sleep(Duration::from_micros(wait - MIN_WAIT_US)),
144145
)
145146
.await;
146147
}

0 commit comments

Comments
 (0)