Skip to content

Commit

Permalink
net: wake all sockets on restart.
Browse files Browse the repository at this point in the history
This avoids a potential liveness issue described in #1844, wherein a
task waiting for tx queue space would not notice net restarting.

Fixes #1844.
  • Loading branch information
cbiffle committed Aug 14, 2024
1 parent d165a64 commit 3bad23c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions task/net/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,14 @@ fn main() -> ! {
);
}

// Ensure that sockets are woken at least once at startup, so that anyone
// who was waiting to hear back on their TX queue becoming non-full will
// snap out of it.
//
// This only works because we've set waiting_to_send to true for all sockets
// above.
server.wake_sockets();

// Go!
loop {
count!(Event::Iter);
Expand Down
4 changes: 3 additions & 1 deletion task/net/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,9 @@ where

Self {
eth,
client_waiting_to_send: [false; SOCKET_COUNT],
// The 'true' here is load-bearing: it ensures that sockets receive
// a notification on stack restart.
client_waiting_to_send: [true; SOCKET_COUNT],
vlan_state: enum_map::EnumMap::from_array(
vlan_state.into_array().unwrap_lite(),
),
Expand Down

0 comments on commit 3bad23c

Please sign in to comment.