Skip to content

Commit 87b8d2c

Browse files
authored
Merge pull request #2444 from cagatay-y/fix-idle-poll
fix(idle-poll): wake the network task unconditionally
2 parents 28c7089 + 79d8b7a commit 87b8d2c

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

src/executor/network.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -246,19 +246,16 @@ async fn network_run() {
246246

247247
let now = now();
248248

249-
match nic.poll_common(now) {
250-
PollResult::SocketStateChanged => {
251-
// Progress was made
252-
cx.waker().wake_by_ref();
253-
}
254-
PollResult::None => {
255-
// Very likely no progress can be made, so set up a timer interrupt to wake the waker
256-
NETWORK_WAKER.lock().register(cx.waker());
257-
nic.set_polling_mode(false);
258-
if let Some(wakeup_time) = nic.poll_delay(now).map(|d| d.total_micros()) {
259-
create_timer(Source::Network, wakeup_time);
260-
trace!("Configured an interrupt for {wakeup_time:?}");
261-
}
249+
if nic.poll_common(now) == PollResult::SocketStateChanged || cfg!(feature = "idle-poll") {
250+
// Progress was made or we want to poll when idle.
251+
cx.waker().wake_by_ref();
252+
} else {
253+
// Very likely no progress can be made, so set up a timer interrupt to wake the waker
254+
NETWORK_WAKER.lock().register(cx.waker());
255+
nic.set_polling_mode(false);
256+
if let Some(wakeup_time) = nic.poll_delay(now).map(|d| d.total_micros()) {
257+
create_timer(Source::Network, wakeup_time);
258+
trace!("Configured an interrupt for {wakeup_time:?}");
262259
}
263260
}
264261

0 commit comments

Comments
 (0)